Skip to content

Commit

Permalink
Merge pull request #179 from bcgov/qa
Browse files Browse the repository at this point in the history
Migrate Sept 4 temp-road-closures/extents to Prod
  • Loading branch information
NicoledeGreef authored Sep 8, 2020
2 parents 9e06bc1 + 80fe530 commit 7ae7de1
Show file tree
Hide file tree
Showing 49 changed files with 5,116 additions and 4,012 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
config/key
etc
temp
46 changes: 46 additions & 0 deletions build/cache/GM_DangerousGoodsRoutes.geojson

Large diffs are not rendered by default.

1,112 changes: 1,112 additions & 0 deletions build/cache/GM_OverheadStructures.geojson

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions build/cache/GM_TermPermitPoints.geojson
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"type": "FeatureCollection",
"name": "GM_TermPermitPoints",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
"features": [
{ "type": "Feature", "properties": { "Location": "232 St \/ 72 Ave", "Note": "Note this existing roundabout may change as the Interchange is being replaced by MoTI as part of the Highway 1, 216 Street to 264 Street widening project.", "Status": "Existing", "Description": "TOL Roundabout", "Municipality": "Langley Township" }, "geometry": { "type": "Point", "coordinates": [ -122.58132, 49.13825, 0.0 ] } },
{ "type": "Feature", "properties": { "Location": "232 St \/ 64 Ave", "Note": null, "Status": "Under Construction", "Description": "TOL Roundabout", "Municipality": "Langley Township" }, "geometry": { "type": "Point", "coordinates": [ -122.58166, 49.11893, 0.0 ] } },
{ "type": "Feature", "properties": { "Location": "232 St \/ 56 Ave", "Note": null, "Status": "Existing", "Description": "TOL Roundabout", "Municipality": "Langley Township" }, "geometry": { "type": "Point", "coordinates": [ -122.58115, 49.10396, 0.0 ] } },
{ "type": "Feature", "properties": { "Location": "216 St \/ 50 Ave", "Note": "only the north\/south through movements accommodate a heavy truck", "Status": "Existing", "Description": "TOL Roundabout", "Municipality": "Langley Township" }, "geometry": { "type": "Point", "coordinates": [ -122.62463, 49.09305, 0.0 ] } },
{ "type": "Feature", "properties": { "Location": "216 St \/ 48 Ave \/ Old Yale Road", "Note": null, "Status": "Existing", "Description": "TOL Roundabout", "Municipality": "Langley Township" }, "geometry": { "type": "Point", "coordinates": [ -122.62474, 49.08942, 0.0 ] } },
{ "type": "Feature", "properties": { "Location": "Glover Road \/ University Drive", "Note": null, "Status": "Existing", "Description": "TOL Roundabout", "Municipality": "Langley Township" }, "geometry": { "type": "Point", "coordinates": [ -122.60289, 49.14265, 0.0 ] } },
{ "type": "Feature", "properties": { "Location": "201 St \/ 100A Ave", "Note": "Technically not a truck route, but the main access point into the Northwest Langley industrial area", "Status": null, "Description": "TOL Roundabout", "Municipality": "Langley Township" }, "geometry": { "type": "Point", "coordinates": [ -122.66431, 49.18459, 0.0 ] } }
]
}
87 changes: 87 additions & 0 deletions build/cache/GM_TermPermitRoutes.geojson

Large diffs are not rendered by default.

42 changes: 42 additions & 0 deletions build/download-geojson.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/sh

download () {
# mkdir -p "layers/$3"
local out="temp/geojson/$1.geojson"
local url="https://trp.regionalroads.com/api/?data=$1&format=geojson&download=true"

echo
echo "downloading $url"
curl "$url" --progress-bar > $out
# jq -c ".features |= [ .[] | if .properties | $2 then . else empty end ] | .name = \"$3\" $4" $1 | ogr2ogr "$out" /vsistdin/
echo "wrote $out ( $( jq ".features|length" "$out" ) features )"
}

mkdir -p temp/geojson

echo
echo "Cleanup"
rm -v temp/geojson/*

echo
echo "Copying cached datasets"
cp -v cache/* temp/geojson

download GM_Cardlock
download GM_Covid19Relief
download GM_DangerousGoodsRestrictions
# download GM_DangerousGoodsRoutes
download GM_DowntownVancouver
download GM_IndustrialAreas
download GM_InspectionStation
download GM_MetroVancouverBoundary
download GM_MRN
download GM_OSOWRoutes
# download GM_OverheadStructures
download GM_PortofVancouverFacilities
download GM_TemporaryRoadClosures
download GM_TemporaryRoadClosuresExtent
# download GM_TermPermitPoints
# download GM_TermPermitRoutes
download GM_TruckParking
download GM_TruckRoutes
76 changes: 76 additions & 0 deletions build/extract-layers.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#!/bin/sh

filter () {
echo
mkdir -p "temp/layers/$3"
local out="temp/layers/$3/$3.geojson"
jq -c ".features |= [ .[] | if .properties | $2 then del( .id, .geometry_name, .properties.Shape_Length, .properties.Shape_Area ) else empty end ] | .name = \"$3\" | .features |= sort_by( .geometry.coordinates ) | del( .totalFeatures, .numberMatched, .numberReturned, .timeStamp ) $4" $1 | ogr2ogr "$out" /vsistdin/ -lco COORDINATE_PRECISION=5
echo "$1 ( $( jq ".features|length" "$1" ) ) -> $out ( $( jq ".features|length" "$out" ) )"
}

mkdir -p temp/layers

echo
echo "Cleanup"
rm -vfr temp/layers/*

filter temp/geojson/GM_MetroVancouverBoundary.geojson '.' metro-vancouver-boundary

filter temp/geojson/GM_IndustrialAreas.geojson '.' industrial-area

filter temp/geojson/GM_DowntownVancouver.geojson '.' downtown-vancouver

filter temp/geojson/GM_MRN.geojson '.' major-road-network

filter temp/geojson/GM_TruckRoutes.geojson '.ProvincialJurisdiction == 1' provincial-highway

filter temp/geojson/GM_TruckRoutes.geojson '.RouteType != "Designated Municipal Truck Route with Restrictions" and .AdvisoryType == "Restriction"' truck-advisories-restrictions
filter temp/geojson/GM_TruckRoutes.geojson '.RouteType != "Designated Municipal Truck Route with Restrictions" and .AdvisoryType == "Truck Travel Warning"' truck-advisories-warning

filter temp/geojson/GM_TruckRoutes.geojson '.RouteType == "Designated Municipal Truck Route"' truck-routes-designated-municipal-truck-route
filter temp/geojson/GM_TruckRoutes.geojson '.RouteType == "Designated Municipal Truck Route with Restrictions"' truck-routes-designated-municipal-truck-route-with-restrictions
filter temp/geojson/GM_TruckRoutes.geojson '.RouteType == "Municipal Road with No Truck Travel Restriction" and .AdvisoryType == null' truck-routes-municipal-road-with-no-truck-travel-restriction
filter temp/geojson/GM_TruckRoutes.geojson '.RouteType == "Federal Road with No Truck Travel Restrictions"' truck-routes-federal-road-with-no-truck-travel-restrictions

filter temp/geojson/GM_TruckParking.geojson '.' truck-parking

filter temp/geojson/GM_PortofVancouverFacilities.geojson '.' port-of-vancouver-facilities-terminals

filter temp/geojson/GM_OverheadStructures.geojson '.Posted_Limit != "Y" and ( .Structure_Type == "Advertisement Sign" or .Structure_Type == "Overhead Sign/Signal" or .Structure_Type == "Scale Sign" )' overhead-directional-signs
filter temp/geojson/GM_OverheadStructures.geojson '.Posted_Limit != "Y" and .Structure_Type != "Advertisement Sign" and .Structure_Type != "Overhead Sign/Signal" and .Structure_Type != "Scale Sign"' overhead-structure-without-height-marker
filter temp/geojson/GM_OverheadStructures.geojson '.Posted_Limit == "Y"' overhead-structure-with-height-marker

filter temp/geojson/GM_Cardlock.geojson '.' cardlock

filter temp/geojson/GM_InspectionStation.geojson '.' inspection-station

filter temp/geojson/GM_DangerousGoodsRoutes.geojson '.' dangerous-goods-routes

filter temp/geojson/GM_DangerousGoodsRestrictions.geojson '.' dangerous-goods-restrictions

filter temp/geojson/GM_OSOWRoutes.geojson '.HeightRestriction == "4.88"' oversize-overweight-truck-routes-oah-up-to-4-88-m
filter temp/geojson/GM_OSOWRoutes.geojson '.WidthRestriction == "5.0"' oversize-overweight-truck-routes-oaw-up-to-5-m
filter temp/geojson/GM_OSOWRoutes.geojson '.WeightRestriction == "80000"' oversize-overweight-truck-routes-gvw-up-to-80000-kg
filter temp/geojson/GM_OSOWRoutes.geojson '.WeightRestriction == "85000"' oversize-overweight-truck-routes-gvw-up-to-85000-kg
filter temp/geojson/GM_OSOWRoutes.geojson '.WeightRestriction == "125000"' oversize-overweight-truck-routes-gvw-up-to-125000-kg

# filter temp/geojson/GM_TermPermit_Points.geojson '.Description == "OAW > 3.2m restricted"' term-permit-oaw-over-3-2-m
# filter temp/geojson/GM_TermPermit_Points.geojson '.Description == "OAW > 3.8m restricted"' term-permit-oaw-over-3-8-m
# filter temp/geojson/GM_TermPermit_Points.geojson '.Description == "OS/OW Truck Restriction"' term-permit-os-ow-truck-restriction
filter temp/geojson/GM_TermPermitPoints.geojson '.Description == "TOL Roundabout"' term-permit-roundabout

filter temp/geojson/GM_TermPermitRoutes.geojson '.TermPermitType == "Restricted Term Permit Route"' term-permit-restricted-route
filter temp/geojson/GM_TermPermitRoutes.geojson '.TermPermitType == "Restriction"' term-permit-restriction
filter temp/geojson/GM_TermPermitRoutes.geojson '.TermPermitType == "Term Permit Route"' term-permit-route

filter temp/geojson/GM_TemporaryRoadClosuresExtent.geojson '.Status == "Active"' temporary-road-closure-extent
filter temp/geojson/GM_TemporaryRoadClosures.geojson '.Status == "Active"' temporary-road-closure

filter temp/geojson/GM_Covid19Relief.geojson '.Active and .AmenityType == "Cardlock"' covid19-relief-cardlock
filter temp/geojson/GM_Covid19Relief.geojson '.Active and .AmenityType == "Food Truck"' covid19-relief-food-truck
filter temp/geojson/GM_Covid19Relief.geojson '.Active and .AmenityType == "Hotel"' covid19-relief-hotel
filter temp/geojson/GM_Covid19Relief.geojson '.Active and .AmenityType == "Inspection Station"' covid19-relief-inspection-station
filter temp/geojson/GM_Covid19Relief.geojson '.Active and .AmenityType == "Portable Toilet"' covid19-relief-portable-toilet
filter temp/geojson/GM_Covid19Relief.geojson '.Active and .AmenityType == "Rest Area"' covid19-relief-rest-area
filter temp/geojson/GM_Covid19Relief.geojson '.Active and .AmenityType == "Temporary Truck Parking"' covid19-relief-temporary-truck-parking
filter temp/geojson/GM_Covid19Relief.geojson '.Active and .AmenityType == "Tourist Centre"' covid19-relief-tourist-centre
39 changes: 39 additions & 0 deletions build/normalize-layers.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
./normalize.sh ../layers/cardlock/cardlock.geojson
./normalize.sh ../layers/covid19-relief-cardlock/covid19-relief-cardlock.geojson
./normalize.sh ../layers/covid19-relief-food-truck/covid19-relief-food-truck.geojson
./normalize.sh ../layers/covid19-relief-hotel/covid19-relief-hotel.geojson
./normalize.sh ../layers/covid19-relief-inspection-station/covid19-relief-inspection-station.geojson
./normalize.sh ../layers/covid19-relief-portable-toilet/covid19-relief-portable-toilet.geojson
./normalize.sh ../layers/covid19-relief-rest-area/covid19-relief-rest-area.geojson
./normalize.sh ../layers/covid19-relief-temporary-truck-parking/covid19-relief-temporary-truck-parking.geojson
./normalize.sh ../layers/covid19-relief-tourist-centre/covid19-relief-tourist-centre.geojson
./normalize.sh ../layers/dangerous-goods-restrictions/dangerous-goods-restrictions.geojson
./normalize.sh ../layers/dangerous-goods-routes/dangerous-goods-routes.geojson
./normalize.sh ../layers/downtown-vancouver/downtown-vancouver.geojson
./normalize.sh ../layers/industrial-area/industrial-area.geojson
./normalize.sh ../layers/inspection-station/inspection-station.geojson
./normalize.sh ../layers/major-road-network/major-road-network.geojson
./normalize.sh ../layers/metro-vancouver-boundary/metro-vancouver-boundary.geojson
./normalize.sh ../layers/overhead-directional-signs/overhead-directional-signs.geojson
./normalize.sh ../layers/overhead-structure-with-height-marker/overhead-structure-with-height-marker.geojson
./normalize.sh ../layers/overhead-structure-without-height-marker/overhead-structure-without-height-marker.geojson
./normalize.sh ../layers/oversize-overweight-truck-routes-gvw-up-to-80000-kg/oversize-overweight-truck-routes-gvw-up-to-80000-kg.geojson
./normalize.sh ../layers/oversize-overweight-truck-routes-gvw-up-to-85000-kg/oversize-overweight-truck-routes-gvw-up-to-85000-kg.geojson
./normalize.sh ../layers/oversize-overweight-truck-routes-gvw-up-to-125000-kg/oversize-overweight-truck-routes-gvw-up-to-125000-kg.geojson
./normalize.sh ../layers/oversize-overweight-truck-routes-oah-up-to-4-88-m/oversize-overweight-truck-routes-oah-up-to-4-88-m.geojson
./normalize.sh ../layers/oversize-overweight-truck-routes-oaw-up-to-5-m/oversize-overweight-truck-routes-oaw-up-to-5-m.geojson
./normalize.sh ../layers/port-of-vancouver-facilities-terminals/port-of-vancouver-facilities-terminals.geojson
./normalize.sh ../layers/provincial-highway/provincial-highway.geojson
./normalize.sh ../layers/temporary-road-closure/temporary-road-closure.geojson
./normalize.sh ../layers/temporary-road-closure-extent/temporary-road-closure-extent.geojson
./normalize.sh ../layers/term-permit-restricted-route/term-permit-restricted-route.geojson
./normalize.sh ../layers/term-permit-restriction/term-permit-restriction.geojson
./normalize.sh ../layers/term-permit-roundabout/term-permit-roundabout.geojson
./normalize.sh ../layers/term-permit-route/term-permit-route.geojson
./normalize.sh ../layers/truck-advisories-restrictions/truck-advisories-restrictions.geojson
./normalize.sh ../layers/truck-advisories-warning/truck-advisories-warning.geojson
./normalize.sh ../layers/truck-parking/truck-parking.geojson
./normalize.sh ../layers/truck-routes-designated-municipal-truck-route/truck-routes-designated-municipal-truck-route.geojson
./normalize.sh ../layers/truck-routes-designated-municipal-truck-route-with-restrictions/truck-routes-designated-municipal-truck-route-with-restrictions.geojson
./normalize.sh ../layers/truck-routes-federal-road-with-no-truck-travel-restrictions/truck-routes-federal-road-with-no-truck-travel-restrictions.geojson
./normalize.sh ../layers/truck-routes-municipal-road-with-no-truck-travel-restriction/truck-routes-municipal-road-with-no-truck-travel-restriction.geojson
9 changes: 9 additions & 0 deletions build/normalize.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
echo
rm "$1.old"
mv -v $1 "$1.old"
echo "$1.old ( $( jq ".features|length" "$1.old" ) features )"

jq -c ".features |= [ .[] | del( .id, .geometry_name, .properties.Shape_Length, .properties.Shape_Area ) ] | .features |= sort_by( .geometry.coordinates ) | del( .totalFeatures, .numberMatched, .numberReturned, .timeStamp )" "$1.old" | ogr2ogr "$1" /vsistdin/ -lco COORDINATE_PRECISION=5

echo "normalized $1 ( $( jq ".features|length" "$1" ) features )"
rm "$1.old"
40 changes: 40 additions & 0 deletions build/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Instructions for updating the layer geo-data

## Prerequisites

The scripts are written in Bash, so will need a Unix-like system to run.
Mac OS will work fine.
Windows Subsystem for Linux (WSL) will also work.

To use these scripts, some additional tools are needed. All of these tools can be installed with homebrew (Mac), or apt (WSL):

- [cUrl](https://curl.haxx.se/)

- [jq](https://stedolan.github.io/jq/)

- [gdal](https://gdal.org/)

## Updating layers

Change to the `build` directory (directory where this readme is located):

> cd build

Download the latest versions of the source data:

> ./download-geojson.sh

Extract the layer files from the source data:

> ./extract-layers.sh

If everything looks ok, and no errors are reported, then update the layer files for the app:

> ./update-layers.sh

Now, look at the changes to the `layers` directory in your git client.
Ensure that the changes are what you are expecting to be changed.
Commit only changes that you are sure are actually necessary.

The directories `build/temp` and `build/etc` should be ignored by git, so don't commit any changes in those directories.

4 changes: 4 additions & 0 deletions build/update-layers.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

cd temp/layers
find . -name '*geojson' -exec cp -v {} ../../../layers/{} \;
Loading

0 comments on commit 7ae7de1

Please sign in to comment.