diff options
author | Markus Koch <markus@notsyncing.net> | 2020-04-17 17:36:06 +0200 |
---|---|---|
committer | Markus Koch <markus@notsyncing.net> | 2020-04-17 17:36:06 +0200 |
commit | 11b8c7ede3b6b6b023fe243a5469169a4a4f9842 (patch) | |
tree | 9327ffeb6296c1281875cf2179f1150ec03ede44 | |
parent | e0970aacb9787b2fff3268d6cb1546861786730f (diff) | |
download | lifomapserver-11b8c7ede3b6b6b023fe243a5469169a4a4f9842.tar.gz lifomapserver-11b8c7ede3b6b6b023fe243a5469169a4a4f9842.tar.bz2 lifomapserver-11b8c7ede3b6b6b023fe243a5469169a4a4f9842.zip |
Add script to fetch streets from Wiki
-rwxr-xr-x | scripts/geojson/fetch_streets.sh | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/scripts/geojson/fetch_streets.sh b/scripts/geojson/fetch_streets.sh new file mode 100755 index 0000000..74a58aa --- /dev/null +++ b/scripts/geojson/fetch_streets.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +# WARNING: This script is not yet production ready. The slightest error in the wikipage can throw it off. Handle with care. + +json=`curl 'https://wiki.linux-forks.de/mediawiki/api.php?action=query&prop=revisions&rvprop=content&format=json&titles=Maps:Streets'` +data=`echo $json | json_reformat | sed -e 's/\\\\n//g' -n -e 's/.*begin:mapdata\([^}]\+\).*/\1/p' | sed -e "s/|-|/}/g"` + +echo "[" +export IFS="}" +for entry in $data; do + name=`echo $entry | sed -n 's/\s*\([^|]\+\).*/\1/p' | sed 's/ $//'` + coord=`echo $entry | sed -n 's/.*||\s*\([^|]\+\).*/\1/p'` + if [[ "$name" != "" && "$coord" != "" ]]; then + echo "{ \"type\": \"Feature\", + \"geometry\": { + \"type\": \"LineString\", + \"coordinates\": [ + $coord + ] + }, + \"properties\": { + \"name\": \"$name\" + } +}," + fi +done +echo "{}" +echo "]" |