diff options
Diffstat (limited to 'scripts/geojson/fetch_city_outlines.sh')
-rwxr-xr-x | scripts/geojson/fetch_city_outlines.sh | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/scripts/geojson/fetch_city_outlines.sh b/scripts/geojson/fetch_city_outlines.sh index 3f65b22..c9c2b58 100755 --- a/scripts/geojson/fetch_city_outlines.sh +++ b/scripts/geojson/fetch_city_outlines.sh @@ -1,14 +1,14 @@ #!/bin/bash json=`curl 'https://wiki.linux-forks.de/mediawiki/api.php?action=query&prop=revisions&rvprop=content&format=json&titles=Maps:Cities'` -data=`echo $json | json_reformat | sed -e 's/\\\\n//g' -n -e 's/begin:mapdata\([^}]\+\)/\1/gp' | sed -e "s/|-|/}/g"` +data=`echo "$json" | json_reformat | sed -e 's/\\\\n//g' -n -e 's/begin:mapdata\([^}]\+\)/\1/gp' | sed -e "s/|-|/}/g"` echo "[" export IFS="}" for entry in $data; do - name=`echo $entry | sed -n 's/\s*\([^|]\+\).*/\1/p' | sed 's/ $//'` - type=`echo $entry | sed -n 's/\s*\([^|]\+\)||\s*\([^|]\+\).*/\2/p' | sed 's/ $//'` - coord=`echo $entry | sed -n 's/.*||\s*\([^|]\+\).*/\1/p'` + name=`echo "$entry" | sed -n 's/\s*\([^|]\+\).*/\1/p' | sed 's/ $//'` + type=`echo "$entry" | sed -n 's/\s*\([^|]\+\)||\s*\([^|]\+\).*/\2/p' | sed 's/ $//'` + coord=`echo "$entry" | sed -n 's/.*||\s*\([^|]\+\).*/\1/p'` if [[ "$name" != "" && "$coord" != "" ]]; then echo "{ \"type\": \"Feature\", \"geometry\": { |