diff options
author | Markus Koch <markus@notsyncing.net> | 2020-04-26 17:28:28 +0200 |
---|---|---|
committer | Markus Koch <markus@notsyncing.net> | 2020-04-26 17:28:37 +0200 |
commit | a1c50a3cfb61d4268518b08ec84b77c4dbca643b (patch) | |
tree | 228d389540b7905a0e79527eb8234c1264463f68 /scripts/geojson/maps | |
parent | 98cd0c8fe9fb1c3409fcac79af3f760b90a7dcd2 (diff) | |
download | lifomapserver-a1c50a3cfb61d4268518b08ec84b77c4dbca643b.tar.gz lifomapserver-a1c50a3cfb61d4268518b08ec84b77c4dbca643b.tar.bz2 lifomapserver-a1c50a3cfb61d4268518b08ec84b77c4dbca643b.zip |
Move Maps:-based scripts to separate directory
Diffstat (limited to 'scripts/geojson/maps')
-rwxr-xr-x | scripts/geojson/maps/fetch_city_outlines.sh | 29 | ||||
-rwxr-xr-x | scripts/geojson/maps/fetch_streets.sh | 29 |
2 files changed, 58 insertions, 0 deletions
diff --git a/scripts/geojson/maps/fetch_city_outlines.sh b/scripts/geojson/maps/fetch_city_outlines.sh new file mode 100755 index 0000000..c9c2b58 --- /dev/null +++ b/scripts/geojson/maps/fetch_city_outlines.sh @@ -0,0 +1,29 @@ +#!/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"` + +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'` + if [[ "$name" != "" && "$coord" != "" ]]; then + echo "{ \"type\": \"Feature\", + \"geometry\": { + \"type\": \"Polygon\", + \"coordinates\": [[ + $coord + ]] + }, + \"properties\": { + \"name\": \"$name\", + \"type\": \"$type\" + } +}," + fi +done +export IFS=" " +echo "{}" +echo "]" diff --git a/scripts/geojson/maps/fetch_streets.sh b/scripts/geojson/maps/fetch_streets.sh new file mode 100755 index 0000000..741f82a --- /dev/null +++ b/scripts/geojson/maps/fetch_streets.sh @@ -0,0 +1,29 @@ +#!/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/gp' | 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 +export IFS=" " +echo "{}" +echo "]" |