summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Koch <markus@notsyncing.net>2021-03-22 18:01:05 +0100
committerMarkus Koch <markus@notsyncing.net>2021-03-22 18:01:05 +0100
commitb888dbe3f4d01ee01ebe5517814f29bc5e770671 (patch)
treec497e6d19a150a239f8a9ff1a3d363870fa21413
parent6cc5cb8b4b600a6262f1d51e08ea40c6124efc72 (diff)
downloadlifomapserver-b888dbe3f4d01ee01ebe5517814f29bc5e770671.tar.gz
lifomapserver-b888dbe3f4d01ee01ebe5517814f29bc5e770671.tar.bz2
lifomapserver-b888dbe3f4d01ee01ebe5517814f29bc5e770671.zip
scripts: Add fetch_bodiesofwater.sh
-rwxr-xr-xscripts/geojson/maps/fetch_bodiesofwater.sh42
1 files changed, 42 insertions, 0 deletions
diff --git a/scripts/geojson/maps/fetch_bodiesofwater.sh b/scripts/geojson/maps/fetch_bodiesofwater.sh
new file mode 100755
index 0000000..0a2f589
--- /dev/null
+++ b/scripts/geojson/maps/fetch_bodiesofwater.sh
@@ -0,0 +1,42 @@
+ #!/bin/bash
+
+json=`curl 'https://wiki.linux-forks.de/mediawiki/api.php?action=query&prop=revisions&rvprop=content&format=json&titles=Maps:BodiesOfWater'`
+data=`echo "$json" | json_reformat | sed -e 's/\\\\n//g' -n -e 's/begin:mapdata\([^}]\+\)/\1/gp' | sed -e "s/|-|/}/g"`
+
+section=""
+echo "["
+export IFS="}"
+for entry in $data; do
+ this_section=`echo $entry | sed -n 's/.*== \([^=]\+\) ==.*/\1/p'`
+ if [[ "$this_section" != "" ]]; then
+ section=$this_section
+ fi
+
+ if [[ "$section" != "$1" ]]; then
+ continue
+ fi
+
+ 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 [[ "$type" == "district" ]]; then
+ continue;
+ fi
+ if [[ "$name" != "" && "$coord" != "" ]]; then
+ echo "{ \"type\": \"Feature\",
+ \"geometry\": {
+ \"type\": \"Polygon\",
+ \"coordinates\": [[
+ $coord
+ ]]
+ },
+ \"properties\": {
+ \"name\": \"$name\",
+ \"type\": \"$type\"
+ }
+},"
+ fi
+done
+export IFS=" "
+echo "{}"
+echo "]"