#!/usr/bin/env nix-shell #! nix-shell -i bash --pure #! nix-shell -p bash curl cacert jq if [ $# -eq 2 ]; then OUTPUT=$1 else OUTPUT=data/raw.osm.pbf fi WAY_DATA=$(curl -s https://overpass-api.de/api/interpreter --data-urlencode 'data=[out:json];way["name"="Northern Arizona University"];out geom;') # Extract coordinates from the response COORDINATES=$(echo "$WAY_DATA" | jq '[.elements[] | select(.type == "way") | .geometry[] | [.lon, .lat]]') echo $COORDINATES # Ensure we have coordinates if [ -z "$COORDINATES" ]; then echo "Error: Could not find coordinates for NAU" exit 1 fi # Construct the GeoJSON payload PAYLOAD=$(jq -n --argjson coords "$COORDINATES" '{ "Name": "none", "RegionType": "geojson", "RegionData": { "type": "Polygon", "coordinates": [$coords] } }') # Send the request to the Slice API UUID=$(curl -X POST https://slice.openstreetmap.us/api/ -H "Content-Type: application/json" -d "$PAYLOAD") while ! [ $(curl https://slice.openstreetmap.us/api/$UUID | jq -r '.Complete') = 'true' ]; do sleep 1 done curl https://slice.openstreetmap.us/files/$UUID.osm.pbf -o $OUTPUT