From 4e2851fb1d9fc831324ea3a816e523ac3a429931 Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Thu, 28 Jan 2021 18:15:47 +1100 Subject: [PATCH 1/3] add GitHub action Processes geojson to topojson on a change to the geojson file. --- .github/scripts/minify-map-json.sh | 4 ++++ .github/workflows/minify-map-json.yml | 23 +++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 .github/scripts/minify-map-json.sh create mode 100644 .github/workflows/minify-map-json.yml diff --git a/.github/scripts/minify-map-json.sh b/.github/scripts/minify-map-json.sh new file mode 100644 index 0000000..d512cc6 --- /dev/null +++ b/.github/scripts/minify-map-json.sh @@ -0,0 +1,4 @@ +npm install -g mapshaper +mapshaper ./boundaries.geo.json snap -clean -o force precision=0.0001 format=geojson ./boundaries.geo.json +npm install -g topojson-server +geo2topo ./boundaries.geo.json -q 50000 > ./website/data/boundaries.topo.json \ No newline at end of file diff --git a/.github/workflows/minify-map-json.yml b/.github/workflows/minify-map-json.yml new file mode 100644 index 0000000..b3886ee --- /dev/null +++ b/.github/workflows/minify-map-json.yml @@ -0,0 +1,23 @@ +name: Minify Map JSON +on: + push: + branches: + - master + paths: + - boundaries.geo.json +jobs: + mergeData: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Update TopoJSON boundaries + run: ./.github/scripts/minify-map-json.sh + - name: Create Pull Request + uses: peter-evans/create-pull-request@v3 + with: + commit-message: Update TopoJSON boundaries + title: Update TopoJSON boundaries + body: Clean and minify GeoJSON and process to TopoJSON + branch: geo-to-topo \ No newline at end of file From 12997c2eb4b04c7adc9fe91dccdc473f859f4cd1 Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Thu, 28 Jan 2021 18:25:11 +1100 Subject: [PATCH 2/3] add csv-to-topo to geo-t-topo We need to merge the csv data into the new topojson file! --- .github/workflows/minify-map-json.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/minify-map-json.yml b/.github/workflows/minify-map-json.yml index b3886ee..83724ee 100644 --- a/.github/workflows/minify-map-json.yml +++ b/.github/workflows/minify-map-json.yml @@ -6,7 +6,7 @@ on: paths: - boundaries.geo.json jobs: - mergeData: + prepare: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -14,6 +14,13 @@ jobs: fetch-depth: 0 - name: Update TopoJSON boundaries run: ./.github/scripts/minify-map-json.sh + merge: + needs: prepare + runs-on: ubuntu-latest + steps: + - name: Merge CSV to TopoJSON + run: | + python3 ./.github/scripts/merge_csv_to_topojson.py - name: Create Pull Request uses: peter-evans/create-pull-request@v3 with: From f55bcd97f9a6b4c1508284db2af62dde3cffbb43 Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Thu, 28 Jan 2021 18:26:31 +1100 Subject: [PATCH 3/3] clarify path for GH Action --- .github/workflows/minify-map-json.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/minify-map-json.yml b/.github/workflows/minify-map-json.yml index 83724ee..1bad029 100644 --- a/.github/workflows/minify-map-json.yml +++ b/.github/workflows/minify-map-json.yml @@ -4,7 +4,7 @@ on: branches: - master paths: - - boundaries.geo.json + - ./boundaries.geo.json jobs: prepare: runs-on: ubuntu-latest