From be1dc049d63dccd22b60e64a2cf1f27a464b5ee4 Mon Sep 17 00:00:00 2001 From: Markus Koch Date: Tue, 14 Apr 2020 18:10:19 +0200 Subject: Initial commit --- scripts/geojson/fetch_single.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 scripts/geojson/fetch_single.sh (limited to 'scripts/geojson/fetch_single.sh') diff --git a/scripts/geojson/fetch_single.sh b/scripts/geojson/fetch_single.sh new file mode 100755 index 0000000..61ab79d --- /dev/null +++ b/scripts/geojson/fetch_single.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=$1&rvsection=0&rvslots=main" | sed -s "s/\\\\\\\\n//g"` + +title=`echo $json | sed -n 's/.*"title":\s*"\([^"]\+\).*/\1/p'` +image=`echo "$json" | sed -n "s/.*image = \([^|]*\).*/\1/p"` + +coords=`echo "$json" | sed -n "s/.*coordinates = {{Co|\([^}]*\).*/\1/p"` +coord_x=`echo "$coords" | sed -n "s/\([^|]\+\).*/\1/p"` +coord_y=`echo "$coords" | sed -n "s/.*|\([^|]\+\).*/\1/p"` + +description=`echo $json | sed -n "s/.*coordinates.*[^']*'''\([^']*\)'''\([^\.]*\).*/\1\2./p" +` + +if [[ "$coord_x" != "" && "$coord_y" != "" ]]; then + echo "{\ + \"type\": \"Feature\",\ + \"properties\": {\ + \"name\": \"$title\",\ + \"amenity\": \"City\",\ + \"description\": \"$description\",\ + \"image\": \"https://wiki.linux-forks.de/mediawiki/images/thumb/0/0e/$image/250px-$image\"\ + },\ + \"geometry\": {\ + \"type\": \"Point\",\ + \"coordinates\": [$coord_x, $coord_y]\ + }\ + }," +fi -- cgit v1.2.3