scripts: Fix street loader

This commit is contained in:
Markus Koch 2023-07-23 19:17:06 +02:00
parent be16cf2f6e
commit 7f460a288a
2 changed files with 10 additions and 4 deletions

4
scripts/geojson/common.sh Executable file
View File

@ -0,0 +1,4 @@
#!/bin/bash
LIFO_SERVER="https://wiki.linux-forks.de"
CURLOPTS=( '-b' "/path/to/auth-cookies.txt" )

View File

@ -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\": {