Created
October 19, 2017 10:37
-
-
Save atomotic/1115cb16e8375a9d8f74b125c054e647 to your computer and use it in GitHub Desktop.
save into an sqlite database data of the first trackpoint of a gpx track using openstreetmap reverse nominatim
This file contains 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
#!/usr/local/Cellar/bash/4.4.12/bin/bash | |
# sqlite3 tracks.db "CREATE TABLE tracks ( id integer primary key, gpxfile varchar, osm json)" | |
GPX=$1 | |
echo "$GPX" | |
COORD=$(xml sel -N x=http://www.topografix.com/GPX/1/1 -t -v "//x:trkpt[1]/@*" "$GPX") | |
readarray -t y <<<"$COORD" | |
LAT=${y[0]} | |
LON=${y[1]} | |
OSM=$(curl -s "http://nominatim.openstreetmap.org/reverse?format=json&lat=$LAT&lon=$LON&zoom=18&addressdetails=1") | |
sqlite3 tracks.db "INSERT INTO tracks (gpxfile, osm) VALUES ('$GPX', '$OSM');" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment