From 3a32cbd1891d2782c51d1b99706c4471bb8bc23c Mon Sep 17 00:00:00 2001 From: Stephen Repetski Date: Sat, 8 Jul 2023 00:33:14 -0400 Subject: [PATCH 1/2] Add SQL update for insertion of Potomac Yard --- .editorconfig | 21 +++++++++++++++++++++ README.md | 26 ++++++++++++++++++++++++++ sql/01_insert_c11.sql | 17 +++++++++++++++++ src/main/resources/stations.csv | 3 ++- 4 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 .editorconfig create mode 100644 sql/01_insert_c11.sql diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..c2cdfb8 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,21 @@ +# EditorConfig helps developers define and maintain consistent +# coding styles between different editors and IDEs +# editorconfig.org + +root = true + + +[*] + +# Change these settings to your own preference +indent_style = space +indent_size = 2 + +# We recommend you to keep these unchanged +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.md] +trim_trailing_whitespace = false diff --git a/README.md b/README.md index e317625..9eb4133 100644 --- a/README.md +++ b/README.md @@ -82,3 +82,29 @@ Note, that LetsEncrypt certificates are valid for 90 days and require fairly-fre 5. If you're using IntelliJ or another fully-featured IDE, you can use the autoconfigured Spring configuration (targeting the `Application` Java class) to start the server for development purposes, otherwise you can use `sudo mvn spring-boot:run -Dspring-boot.run.jvmArguments="-Xmx16g"`, e.g. in a production environment. 6. If you're running the server locally, navigate to https://localhost:9443/ to start using the webapp with it connected to your server. 7. If the logs are a little too noisy for your use case, e.g. in production, consider setting the `logging.level.com.jamespizzurro.metrorailserver` property in src/main/resources/application.properties to WARN instead of INFO, or set it to DEBUG to get even more log output for debugging purposes. + +## Adding a new infill station +When adding a new infill Metrorail station, such as Potomac Yard, there are a number of files that need to be updated. + +Beginning with the Webapp frontend: +* Use [Rail Station Information](https://api.wmata.com/Rail.svc/json/jStationInfo?StationCode=C11) API endpoint in order to grab the info block about the new station(s). This will include Lat/Long, address, and other information needed for MetroHero. +* `src/{blue,yellow,silver,red,green,orange}_stations.json` + * Edit the relevant file(s). If a station is used by multiple lines, all files should be updated + * Use the Rail Station Information endpoint to populate this +* src/components/Line.js + * For an infill station, the station links on either side may need to be updated; for instance, links from C10 to C12 need to be split and modified so C10-C11 and C11-C12, rather than C10-C12, for a C11 infill station + +Server repo: +* src/main/resources/stations.csv + * Add the new station to the list, along with names that the station is referenced as + +## Station location track circuits +(Look for the track circuits of 600' length) + +* C10-C1: 1010 +* C11-C1: 3493 +* C12-C1: 976 + +* C10-C2: 1204 +* C11-C2: 3512 +* C12-C2: 1170 diff --git a/sql/01_insert_c11.sql b/sql/01_insert_c11.sql new file mode 100644 index 0000000..b73280e --- /dev/null +++ b/sql/01_insert_c11.sql @@ -0,0 +1,17 @@ +\c metrohero + +--Original database additions: +--INSERT INTO public.station_to_station_travel_time (station_codes_key, distance, from_station_code, last_updated, to_station_code) VALUES ('C10_C12', 15483, 'C10', '2017-06-16 19:28:41.066000', 'C12') ON CONFLICT (station_codes_key) DO UPDATE SET distance = EXCLUDED.distance; +--INSERT INTO public.station_to_station_travel_time (station_codes_key, distance, from_station_code, last_updated, to_station_code) VALUES ('C12_C10', 15483, 'C12', '2017-09-16 10:07:13.434000', 'C10') ON CONFLICT (station_codes_key) DO UPDATE SET distance = EXCLUDED.distance; + +-- Drop the old data +DELETE FROM public.station_to_station_travel_time WHERE station_codes_key = 'C10_C12'; +DELETE FROM public.station_to_station_travel_time WHERE station_codes_key = 'C12_C10'; + +-- C1 +INSERT INTO public.station_to_station_travel_time (station_codes_key, distance, from_station_code, last_updated, to_station_code) VALUES ('C12_C11', 6814, 'C11', '2023-07-09 16:49:00.000000', 'C11') ON CONFLICT (station_codes_key) DO UPDATE SET distance = EXCLUDED.distance; +INSERT INTO public.station_to_station_travel_time (station_codes_key, distance, from_station_code, last_updated, to_station_code) VALUES ('C11_C10', 8703, 'C11', '2023-07-09 16:49:00.000000', 'C10') ON CONFLICT (station_codes_key) DO UPDATE SET distance = EXCLUDED.distance; + +-- C2 +INSERT INTO public.station_to_station_travel_time (station_codes_key, distance, from_station_code, last_updated, to_station_code) VALUES ('C10_C11', 9137, 'C10', '2023-07-09 16:49:00.000000', 'C11') ON CONFLICT (station_codes_key) DO UPDATE SET distance = EXCLUDED.distance; +INSERT INTO public.station_to_station_travel_time (station_codes_key, distance, from_station_code, last_updated, to_station_code) VALUES ('C11_C12', 6814, 'C11', '2023-07-09 16:49:00.000000', 'C12') ON CONFLICT (station_codes_key) DO UPDATE SET distance = EXCLUDED.distance; diff --git a/src/main/resources/stations.csv b/src/main/resources/stations.csv index d157e24..bd0fac7 100644 --- a/src/main/resources/stations.csv +++ b/src/main/resources/stations.csv @@ -69,6 +69,7 @@ N07,Rest,Reston Town Center B04,Rhod,Rhode Island Avenue-Brentwood|Rhode Island Ave|Rhode Island|R.I. Ave|Brentwood|RIA A14,Rock,Rockville C10,DCA,Ronald Reagan Washington National Airport|DCA|National Airport|Reagan|Airport +C11,PoYd,Potomac Yard C05,Ross,Rosslyn A15,ShGr,Shady Grove E02,Shaw,Shaw-Howard University|Shaw|Howard University|Howard @@ -94,4 +95,4 @@ E07,WstH,West Hyattsville|Hyattsville|W Hyattsville B10,Whtn,Wheaton A12,NoBe,North Bethesda|White Flint N06,WRE,Wiehle-Reston East|Wiehle-Reston|Wiehle|Reston -A04,WdPk,Woodley Park \ No newline at end of file +A04,WdPk,Woodley Park From 03b037d60c2e0ef1297b4c0cbb14b6c9bb671adc Mon Sep 17 00:00:00 2001 From: Stephen Repetski Date: Wed, 19 Jul 2023 09:50:13 -0400 Subject: [PATCH 2/2] Add additional documentation and changes for C11 addition --- README.md | 21 ++++++++++++++++----- sql/01_insert_c11.sql | 4 ++-- src/main/resources/StandardRoutes.json | 10 +++++----- src/main/resources/logback.xml | 8 +++++--- src/main/resources/station_durations.csv | 5 +++-- 5 files changed, 31 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 9eb4133..334f33d 100644 --- a/README.md +++ b/README.md @@ -58,17 +58,19 @@ The setup instructions below are for Ubuntu 16.04. They may work for newer versi $ psql -f sql/station_to_station_travel_time.sql ``` -9. Follow step 1 of the Usage section to populate your WMATA API keys +9. Run any additional numbered scripts in the `sql` directory, in the order they are numbered. -10. Get an SSL certificate for your installation. MetroHero will require a P12-format file with the private key and the public certificate available to the Java Spring application. This developer prefers LetsEncrypt, doing something like: +10. Follow step 1 of the Usage section to populate your WMATA API keys + +11. Get an SSL certificate for your installation. MetroHero will require a P12-format file with the private key and the public certificate available to the Java Spring application. This developer prefers LetsEncrypt, doing something like: `certbot certonly -d dcmetrohero.net --preferred-challenges dns --manual` Note, that LetsEncrypt certificates are valid for 90 days and require fairly-frequent renewal. -11. Generate your combined P12 file: `pkcs12 -in /etc/letsencrypt/live/dcmetrohero.net/fullchain.pem -inkey /etc/letsencrypt/live/dcmetrohero.net/privkey.pem -export -out keystore.p12` +12. Generate your combined P12 file: `pkcs12 -in /etc/letsencrypt/live/dcmetrohero.net/fullchain.pem -inkey /etc/letsencrypt/live/dcmetrohero.net/privkey.pem -export -out keystore.p12` -12. Launch the server inside `screen` so you can attach to it after-the-fact: +13. Launch the server inside `screen` so you can attach to it after-the-fact: ```screen -U mvn spring-boot:run -Dspring-boot.run.jvmArguments="-Xmx8g" ``` @@ -90,13 +92,19 @@ Beginning with the Webapp frontend: * Use [Rail Station Information](https://api.wmata.com/Rail.svc/json/jStationInfo?StationCode=C11) API endpoint in order to grab the info block about the new station(s). This will include Lat/Long, address, and other information needed for MetroHero. * `src/{blue,yellow,silver,red,green,orange}_stations.json` * Edit the relevant file(s). If a station is used by multiple lines, all files should be updated - * Use the Rail Station Information endpoint to populate this + * Use the WMATA Rail Station Information API endpoint to populate this * src/components/Line.js * For an infill station, the station links on either side may need to be updated; for instance, links from C10 to C12 need to be split and modified so C10-C11 and C11-C12, rather than C10-C12, for a C11 infill station +* src/stores/LineStore.js +* src/stores/MareyDiagramStore.js Server repo: * src/main/resources/stations.csv * Add the new station to the list, along with names that the station is referenced as +* src/main/resources/StandardRoutes.json + * For each station platform track circuit, set the station code (i.e. "C11") to associate the two +* src/main/resources/station_durations.csv + * Use [WMATA Trip Planner](https://wmata.com) to determine the time in minutes between the new station and its left and right pairs. Insert this, using the station codes as columns 1 and 2, as the 3rd column ## Station location track circuits (Look for the track circuits of 600' length) @@ -108,3 +116,6 @@ Server repo: * C10-C2: 1204 * C11-C2: 3512 * C12-C2: 1170 + +## Configure length of train tracking history +By default, MetroHero will attmept to store up to 24 months of historical train location data. This configuration can be found in `src/main/java/com/jamespizzurro/metrorailserver/repository/TrainStatusRepository.java`, and adjusted up or down as appropriate for your environment. A lower history setting is likely more appropriate for a dev, rather than a production, environment. diff --git a/sql/01_insert_c11.sql b/sql/01_insert_c11.sql index b73280e..7d5d523 100644 --- a/sql/01_insert_c11.sql +++ b/sql/01_insert_c11.sql @@ -9,9 +9,9 @@ DELETE FROM public.station_to_station_travel_time WHERE station_codes_key = 'C10 DELETE FROM public.station_to_station_travel_time WHERE station_codes_key = 'C12_C10'; -- C1 -INSERT INTO public.station_to_station_travel_time (station_codes_key, distance, from_station_code, last_updated, to_station_code) VALUES ('C12_C11', 6814, 'C11', '2023-07-09 16:49:00.000000', 'C11') ON CONFLICT (station_codes_key) DO UPDATE SET distance = EXCLUDED.distance; +INSERT INTO public.station_to_station_travel_time (station_codes_key, distance, from_station_code, last_updated, to_station_code) VALUES ('C12_C11', 6814, 'C12', '2023-07-09 16:49:00.000000', 'C11') ON CONFLICT (station_codes_key) DO UPDATE SET distance = EXCLUDED.distance; INSERT INTO public.station_to_station_travel_time (station_codes_key, distance, from_station_code, last_updated, to_station_code) VALUES ('C11_C10', 8703, 'C11', '2023-07-09 16:49:00.000000', 'C10') ON CONFLICT (station_codes_key) DO UPDATE SET distance = EXCLUDED.distance; -- C2 INSERT INTO public.station_to_station_travel_time (station_codes_key, distance, from_station_code, last_updated, to_station_code) VALUES ('C10_C11', 9137, 'C10', '2023-07-09 16:49:00.000000', 'C11') ON CONFLICT (station_codes_key) DO UPDATE SET distance = EXCLUDED.distance; -INSERT INTO public.station_to_station_travel_time (station_codes_key, distance, from_station_code, last_updated, to_station_code) VALUES ('C11_C12', 6814, 'C11', '2023-07-09 16:49:00.000000', 'C12') ON CONFLICT (station_codes_key) DO UPDATE SET distance = EXCLUDED.distance; +INSERT INTO public.station_to_station_travel_time (station_codes_key, distance, from_station_code, last_updated, to_station_code) VALUES ('C11_C12', 7579, 'C11', '2023-07-09 16:49:00.000000', 'C12') ON CONFLICT (station_codes_key) DO UPDATE SET distance = EXCLUDED.distance; diff --git a/src/main/resources/StandardRoutes.json b/src/main/resources/StandardRoutes.json index 7f9c5f3..722b6dd 100644 --- a/src/main/resources/StandardRoutes.json +++ b/src/main/resources/StandardRoutes.json @@ -497,7 +497,7 @@ { "SeqNum": 100, "CircuitId": 3493, - "StationCode": null + "StationCode": "C11" }, { "SeqNum": 101, @@ -2588,7 +2588,7 @@ { "SeqNum": 103, "CircuitId": 3512, - "StationCode": null + "StationCode": "C11" }, { "SeqNum": 104, @@ -20422,7 +20422,7 @@ { "SeqNum": 52, "CircuitId": 3493, - "StationCode": null + "StationCode": "C11" }, { "SeqNum": 53, @@ -21548,7 +21548,7 @@ { "SeqNum": 51, "CircuitId": 3512, - "StationCode": null + "StationCode": "C11" }, { "SeqNum": 52, @@ -22463,4 +22463,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml index d7b641b..da31d9a 100644 --- a/src/main/resources/logback.xml +++ b/src/main/resources/logback.xml @@ -1,5 +1,7 @@ - - - \ No newline at end of file + + + + + diff --git a/src/main/resources/station_durations.csv b/src/main/resources/station_durations.csv index b419d5b..6c60c65 100644 --- a/src/main/resources/station_durations.csv +++ b/src/main/resources/station_durations.csv @@ -68,7 +68,8 @@ G04,G05,3 J03,J02,6 J02,C13,5 C13,C12,2 -C12,C10,5 +C12,C11,3 +C11,C10,3 C10,C09,2 C09,C08,2 C08,C07,1 @@ -96,4 +97,4 @@ F08,F07,2 F07,F06,3 F06,F05,2 F05,F04,2 -F04,F03,2 \ No newline at end of file +F04,F03,2