-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add script to update route geometries programatically and add points for stop locations #19
Open
naf419
wants to merge
2
commits into
codefornola:main
Choose a base branch
from
naf419:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,3 +22,6 @@ node_modules | |
nola-transit-map | ||
|
||
.DS_Store | ||
|
||
#generated temp route files | ||
data/route_* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/bin/sh | ||
|
||
#init list of routes | ||
jq . > routes.json << EOF | ||
{ | ||
"type": "FeatureCollection", | ||
"name": "routes", | ||
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } }, | ||
"features": [] | ||
} | ||
EOF | ||
|
||
for route in 12 46 47 48 49 1 4 3 8 9 11 27 31 32 45 51 52 53-O 55 57 61 62 62-O 66 67 68 80 84 86 91 103 105 114A 114B 201 202; do | ||
|
||
echo "ROUTE $route" | ||
|
||
#get stops and lines for each route direction | ||
for dir in 0 1; do | ||
wget -q -O route_${route}_dir${dir} "https://www.norta.com/RTAGetRoute?routeID=${route}&directionID=${dir}" | ||
cat route_${route}_dir${dir} | jq -c '{type: "MultiPoint", coordinates: .[0].stops | [.[] | [.stopLongitude, .stopLatitude]]}' > route_${route}_dir${dir}_stops | ||
cat route_${route}_dir${dir} | jq -c '{type: "MultiLineString", coordinates: [.[0].lines[0].latLongList | [.[] | [.shapeLog, .shapeLat]]]}' > route_${route}_dir${dir}_lines | ||
|
||
#fix bogus RTA datapoints | ||
if [ "$route" = "57" ] && [ "$dir" = "0" ]; then | ||
sed -i -e 's/\"-90.054342\",\"29.968979\"/\"-90.05486\",\"29.97270\"/g' route_${route}_dir${dir}_stops | ||
sed -i -e 's/\[\"-90.055450\",\"29.972701\"\].*\[\"-90.052978\",\"29.972807\"\]/\[\"-90.05486\",\"29.97270\"\]/g' route_${route}_dir${dir}_lines | ||
fi | ||
done | ||
|
||
#remove duplicate second direction info if identical to first | ||
if cmp --silent -- "route_${route}_dir0_lines" "route_${route}_dir1_lines"; then | ||
echo "" > route_${route}_dir1_lines | ||
fi | ||
if cmp --silent -- "route_${route}_dir0_stops" "route_${route}_dir1_stops"; then | ||
echo "" > route_${route}_dir1_stops | ||
fi | ||
|
||
#for header just use direction0 to get route name, etc | ||
cat route_${route}_dir0 | jq '.[0] | {type: "Feature", properties: { agency_name: "NORTA", route_id: .routeCode, agency_id: "1", route_short_name: .routeCode, route_long_name: .routeName, route_type: 3, route_color: ("#" + .routeColor), route_text_color: "#000000" }, geometry: {type: "GeometryCollection", geometries: []}}' > route_${route}_header | ||
|
||
#combine stops and lines into geometrycollection | ||
jq '.geometry.geometries += $stops0 + $stops1 + $lines0 + $lines1' route_${route}_header --slurpfile stops0 route_${route}_dir0_stops --slurpfile stops1 route_${route}_dir1_stops --slurpfile lines0 route_${route}_dir0_lines --slurpfile lines1 route_${route}_dir1_lines > route_${route}_feature | ||
|
||
#add to list of routes | ||
jq -c '.features += $feature' routes.json --slurpfile feature route_${route}_feature > routes.json.tmp | ||
mv routes.json.tmp routes.json | ||
|
||
done | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure where this runs- just double checking that we know we have
jq
available here.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
jq only required to generate routes.json offline.
would replace using QGIS and manual processing which previously generated the routes.json, at least according to https://github.com/codefornola/nola-transit-map/blob/main/data/README.md
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so i picture this would be used to refresh the routes when they change (yearly/whenever) on a single developers system (the only place jq would be required) with the outputs added back into git (so anyone cloning can get the site up easily, no jq required).
(This would be a similar scheme to gnu-style projects that commit the autoconf-generated configure script alongside the autoconf inputs)