Skip to content

Instantly share code, notes, and snippets.

@arbakker
Created June 7, 2022 14:48
Show Gist options
  • Save arbakker/c2f893cff4d59d7427b8cec6e5e7cae5 to your computer and use it in GitHub Desktop.
Save arbakker/c2f893cff4d59d7427b8cec6e5e7cae5 to your computer and use it in GitHub Desktop.
Retrieve geojson course layout udisc #discgolf #geojson #jq
#!/usr/bin/env bash
set -e
COURSE_ID=immerloo-park-6pMm
curl -s "https://udisc.com/courses/${COURSE_ID}/map" |
pup "body script:first-of-type text{}" | cut -d= -f2 |
jq '[.courseDirectory.course.holes | to_entries[] | (.value.pathConfigurations[0] as $path | ({type: "Feature","geometry": {"type": "LineString","coordinates": [[($path.teePosition.longitude,$path.teePosition.latitude)], ($path.doglegs[] | [.longitude,.latitude]),[($path.targetPosition.longitude,$path.targetPosition.latitude)]]},"properties": {"holenr": [.key | tonumber ,1] | add}}))]' |
xargs -0 -I {} echo "{\"type\": \"FeatureCollection\",\"features\": {}}" |
jq
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment