Add scripts to fetch bodies of water, city outlines, and trainlines
This commit is contained in:
parent
7f460a288a
commit
ce9199847c
64
scripts/geojson/fetch_bodiesofwater.sh
Executable file
64
scripts/geojson/fetch_bodiesofwater.sh
Executable file
@ -0,0 +1,64 @@
|
||||
#!/bin/bash
|
||||
|
||||
source common.sh
|
||||
|
||||
json=`curl ${CURLOPTS[@]} $LIFO_SERVER'/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
|
||||
|
||||
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
|
||||
done
|
||||
export IFS=" "
|
||||
echo "{}"
|
||||
echo "]"
|
34
scripts/geojson/fetch_city_outlines.sh
Executable file
34
scripts/geojson/fetch_city_outlines.sh
Executable file
@ -0,0 +1,34 @@
|
||||
#!/bin/bash
|
||||
|
||||
source common.sh
|
||||
|
||||
json=`curl ${CURLOPTS[@]} $LIFO_SERVER'/api.php?action=query&prop=revisions&rvprop=content&format=json&titles=Maps:Cities'`
|
||||
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/ $//'`
|
||||
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 "]"
|
68
scripts/geojson/fetch_trainlines.sh
Executable file
68
scripts/geojson/fetch_trainlines.sh
Executable file
@ -0,0 +1,68 @@
|
||||
#!/bin/bash
|
||||
|
||||
source common.sh
|
||||
|
||||
json=`curl ${CURLOPTS[@]} $LIFO_SERVER'/api.php?action=query&prop=revisions&rvprop=content&format=json&titles=Maps:Trainlines'`
|
||||
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
|
||||
|
||||
case "$section" in
|
||||
"Train Lines")
|
||||
name=`echo "$entry" | sed -n 's/\s*\([^|]\+\).*/\1/p' | sed 's/ $//'`
|
||||
start=`echo "$entry" | sed -n 's/\s*\([^|]\+\)||\s*\([^|]\+\).*/\2/p' | sed 's/ $//'`
|
||||
end=`echo "$entry" | sed -n 's/\s*\([^|]\+\)||\([^|]\+\)||\s*\([^|]\+\).*/\3/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\",
|
||||
\"start\": \"$start\",
|
||||
\"end\": \"$end\"
|
||||
}
|
||||
},"
|
||||
fi
|
||||
;;
|
||||
"Access Paths")
|
||||
name=`echo "$entry" | sed -n 's/\s*\([^|]\+\).*/\1/p' | sed 's/ $//'`
|
||||
lines=`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\": \"LineString\",
|
||||
\"coordinates\": [
|
||||
$coord
|
||||
]
|
||||
},
|
||||
\"properties\": {
|
||||
\"name\": \"$lines:$name\"
|
||||
}
|
||||
},"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
done
|
||||
export IFS=" "
|
||||
echo "{}"
|
||||
echo "]"
|
21
scripts/geojson/update_all.sh
Executable file
21
scripts/geojson/update_all.sh
Executable file
@ -0,0 +1,21 @@
|
||||
#!/bin/bash
|
||||
|
||||
source common.sh
|
||||
|
||||
function fetch() {
|
||||
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
|
Loading…
Reference in New Issue
Block a user