Update Mapbox Pistes Tileset #2
This file contains hidden or 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
| name: Update Mapbox Pistes Tileset | |
| on: | |
| workflow_dispatch: | |
| jobs: | |
| update-tileset: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.x' | |
| # Should be available on base image... | |
| # - name: Install jq | |
| # run: sudo apt-get update && sudo apt-get install -y jq | |
| - name: Install query-overpass globally | |
| run: npm install -g query-overpass | |
| - name: Install mapbox-tilesets | |
| run: pip3 install mapbox-tilesets | |
| - name: Query Overpass API for PNW pistes | |
| run: | | |
| echo '[out:json][timeout:25]; | |
| ( | |
| way["piste:type"](43.213183300738876,-125.37597656250001,49.56797785892715,-113.51074218750001); | |
| relation["piste:type"](43.213183300738876,-125.37597656250001,49.56797785892715,-113.51074218750001); | |
| ); | |
| out body; | |
| >; | |
| out skel qt;' | query-overpass --flat-properties > pnw-pistes.geojson | |
| - name: Convert GeoJSON for Mapbox | |
| run: | | |
| cat pnw-pistes.geojson | jq -c ".features[]" > nld_features.json | |
| - name: Create tileset recipe | |
| run: | | |
| cat > pistes_tile_recipe.json << 'EOF' | |
| { | |
| "version": 1, | |
| "layers": { | |
| "ski_trails": { | |
| "source": "mapbox://tileset-source/flyingtrolleycars/osm_pistes_pnw", | |
| "minzoom" : 0, | |
| "maxzoom" : 11, | |
| "features" : { | |
| "attributes" : { | |
| "allowed_output" : [ | |
| "name", | |
| "piste:difficulty", | |
| "piste:name", | |
| "trail_visibility", | |
| "piste:grooming", | |
| "piste:type", | |
| "piste:status" | |
| ], | |
| "set": { | |
| "description": [ "coalesce", [ "get", "description" ], "ski trail"] | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| EOF | |
| - name: Upload to Mapbox tileset source | |
| env: | |
| MAPBOX_ACCESS_TOKEN: ${{ secrets.MAPBOX_WRITE_TOKEN }} | |
| run: | | |
| tilesets upload-source --replace flyingtrolleycars osm_pistes_pnw pnw-pistes.geojson | |
| - name: Publish Mapbox tileset | |
| env: | |
| MAPBOX_ACCESS_TOKEN: ${{ secrets.MAPBOX_WRITE_TOKEN }} | |
| run: | | |
| tilesets publish flyingtrolleycars.osm_pistes_pnw |