From 215e607cb71627f613fc8de3db5276390b421cec Mon Sep 17 00:00:00 2001 From: Markus Koch Date: Mon, 22 Mar 2021 18:30:50 +0100 Subject: [PATCH] scripts: Fix geotype for bodies of water --- scripts/geojson/maps/fetch_bodiesofwater.sh | 60 ++++++++++++++------- 1 file changed, 40 insertions(+), 20 deletions(-) diff --git a/scripts/geojson/maps/fetch_bodiesofwater.sh b/scripts/geojson/maps/fetch_bodiesofwater.sh index 0a2f589..8cd4a29 100755 --- a/scripts/geojson/maps/fetch_bodiesofwater.sh +++ b/scripts/geojson/maps/fetch_bodiesofwater.sh @@ -16,26 +16,46 @@ for entry in $data; do 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 + 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 "{}"