Compare commits

...

2 Commits

2 changed files with 54 additions and 3 deletions

View File

@ -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 "]"

View File

@ -1,10 +1,19 @@
#!/bin/bash
function fetch() {
"./fetch_$1.sh" | json_reformat -m > "$1.json.tmp"
rm -f "$1.json"
mv "$1.json.tmp" "$1.json"
if [[ "$3" != "" ]]; then
fn="$3"
else
fn="$1"
fi
"./fetch_$1.sh" "$2" | json_reformat -m > "$fn.json.tmp"
rm -f "$fn.json"
mv "$fn.json.tmp" "$fn.json"
}
fetch streets
fetch city_outlines
fetch trainlines "Train Lines"
fetch trainlines "Access Paths" trainlines_access
fetch bodiesofwater "Rivers" rivers
fetch bodiesofwater "Oceans, Seas, and Lakes" oceans