Skip to content

Commit

Permalink
update route geometries and add points for stop locations
Browse files Browse the repository at this point in the history
see make_routes.sh for source of route/stop info
  • Loading branch information
naf419 committed Apr 24, 2024
1 parent 6a2564a commit 54645c9
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 53 deletions.
4 changes: 2 additions & 2 deletions app/main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ import './main.css';
const animatedComponents = makeAnimated();
const ROUTES = NortaGeoJson
.features
.filter(f => f.geometry.type === "MultiLineString" && f.properties.route_id)
.filter(f => f.geometry.type === "GeometryCollection" && f.properties.route_id)
.reduce((acc, f) => {
return {
...acc,
[f.properties.route_id]: <GeoJSON key={f.properties.route_id} data={f} pathOptions={{ color: f.properties.route_color }} />
[f.properties.route_id]: <GeoJSON key={f.properties.route_id} data={f} pathOptions={{ color: f.properties.route_color }} pointToLayer={function (feature, latlng) { return L.circleMarker(latlng, {radius: 3, fillColor: f.properties.route_color}); }} />
}
}, {})

Expand Down
43 changes: 43 additions & 0 deletions data/make_routes.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/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 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
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

Loading

0 comments on commit 54645c9

Please sign in to comment.