Add script to fetch streets from Wiki
This commit is contained in:
parent
e0970aacb9
commit
11b8c7ede3
28
scripts/geojson/fetch_streets.sh
Executable file
28
scripts/geojson/fetch_streets.sh
Executable file
@ -0,0 +1,28 @@
|
|||||||
|
#!/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/p' | 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
|
||||||
|
echo "{}"
|
||||||
|
echo "]"
|
Loading…
Reference in New Issue
Block a user