2021-03-22 18:01:05 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2022-05-12 19:11:17 +02:00
|
|
|
source common.sh
|
|
|
|
|
|
|
|
json=`curl ${CURLOPTS[@]} 'https://wiki.linux-forks.de/mediawiki/api.php?action=query&prop=revisions&rvprop=content&format=json&titles=Maps:BodiesOfWater'`
|
2021-03-22 18:01:05 +01:00
|
|
|
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
|
|
|
|
|
2021-03-22 18:30:50 +01:00
|
|
|
case "$section" in
|
|
|
|
"Rivers")
|
|
|
|
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 [[ "$name" != "" && "$coord" != "" ]]; then
|
|
|
|
echo "{ \"type\": \"Feature\",
|
|
|
|
\"geometry\": {
|
|
|
|
\"type\": \"LineString\",
|
|
|
|
\"coordinates\": [
|
|
|
|
$coord
|
|
|
|
]
|
|
|
|
},
|
|
|
|
\"properties\": {
|
|
|
|
\"name\": \"$name\",
|
|
|
|
\"type\": \"$type\"
|
|
|
|
}
|
|
|
|
},"
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
"Oceans, Seas, and Lakes")
|
|
|
|
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 [[ "$name" != "" && "$coord" != "" ]]; then
|
|
|
|
echo "{ \"type\": \"Feature\",
|
|
|
|
\"geometry\": {
|
|
|
|
\"type\": \"Polygon\",
|
|
|
|
\"coordinates\": [[
|
|
|
|
$coord
|
|
|
|
]]
|
|
|
|
},
|
|
|
|
\"properties\": {
|
|
|
|
\"name\": \"$name\",
|
|
|
|
\"type\": \"$type\"
|
|
|
|
}
|
|
|
|
},"
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|
2021-03-22 18:01:05 +01:00
|
|
|
done
|
|
|
|
export IFS=" "
|
|
|
|
echo "{}"
|
|
|
|
echo "]"
|