From 7f460a288aac0ad91d57b62402e973a705ce5924 Mon Sep 17 00:00:00 2001 From: Markus Koch Date: Sun, 23 Jul 2023 19:17:06 +0200 Subject: [PATCH] scripts: Fix street loader --- scripts/geojson/common.sh | 4 ++++ scripts/geojson/fetch_streets.sh | 10 ++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) create mode 100755 scripts/geojson/common.sh diff --git a/scripts/geojson/common.sh b/scripts/geojson/common.sh new file mode 100755 index 0000000..34e160e --- /dev/null +++ b/scripts/geojson/common.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +LIFO_SERVER="https://wiki.linux-forks.de" +CURLOPTS=( '-b' "/path/to/auth-cookies.txt" ) diff --git a/scripts/geojson/fetch_streets.sh b/scripts/geojson/fetch_streets.sh index dbae43d..48f773b 100755 --- a/scripts/geojson/fetch_streets.sh +++ b/scripts/geojson/fetch_streets.sh @@ -2,14 +2,16 @@ # 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"` +source common.sh + +json=`curl ${CURLOPTS[@]} $LIFO_SERVER'/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'` + 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\": {