fix Action workflows

- fix incorrect key name in merge file (json_data['objects']['boundaries.geo'] rather than json_data['objects']['boundaries'])
- don't merge csv and topo.json when topo.json changes, as this will create an infinite loop
- run merge as part of geo-to-topo Action, after new topo file is created
- remove redundant shell file
This commit is contained in:
Hugh Rundle 2021-01-29 08:28:40 +11:00
parent f22901f869
commit 92ad548b92
4 changed files with 2 additions and 7 deletions

View file

@ -10,7 +10,7 @@ geo = open(topojson_file, 'r') # open the topo.json file
json_data = json.loads(geo.read()) # read the file and load into a dict json_data = json.loads(geo.read()) # read the file and load into a dict
# for each feature, if the name in the json matches the name in the csv, add new properties to the json # for each feature, if the name in the json matches the name in the csv, add new properties to the json
for feature in json_data['objects']['boundaries']['geometries']: for feature in json_data['objects']['boundaries.geo']['geometries']:
with open(csv_file, newline='') as f: with open(csv_file, newline='') as f:
# use DictReader so we can use the header names # use DictReader so we can use the header names
reader = csv.DictReader(f) reader = csv.DictReader(f)

View file

@ -1,5 +0,0 @@
#!/usr/bin/env bash
sudo npm install -g mapshaper
mapshaper ./boundaries.geo.json snap -clean -o force precision=0.0001 format=geojson ./boundaries.geo.json
sudo npm install -g topojson-server
geo2topo ./boundaries.geo.json -q 50000 > ./website/data/boundaries.topo.json

View file

@ -5,7 +5,6 @@ on:
- master - master
paths: paths:
- website/data/library_services_information.csv - website/data/library_services_information.csv
- website/data/boundaries.topo.json
jobs: jobs:
mergeData: mergeData:
runs-on: ubuntu-latest runs-on: ubuntu-latest

View file

@ -19,6 +19,7 @@ jobs:
mapshaper boundaries.geo.json snap -clean -o force precision=0.0001 format=geojson boundaries.geo.json mapshaper boundaries.geo.json snap -clean -o force precision=0.0001 format=geojson boundaries.geo.json
sudo npm install -g topojson-server sudo npm install -g topojson-server
geo2topo boundaries.geo.json -q 50000 > website/data/boundaries.topo.json geo2topo boundaries.geo.json -q 50000 > website/data/boundaries.topo.json
python3 ./.github/scripts/merge_csv_to_topojson.py
- name: Create Pull Request - name: Create Pull Request
uses: peter-evans/create-pull-request@v3 uses: peter-evans/create-pull-request@v3
with: with: