parent
00600cb28a
commit
5f601d2d6f
@ -0,0 +1,56 @@ |
|||||||
|
#!/bin/bash |
||||||
|
# SIOSE geojson to YAOM |
||||||
|
|
||||||
|
OUTFILENAME="landcover_SIOSE_MadMap.osm" |
||||||
|
|
||||||
|
set -e |
||||||
|
|
||||||
|
if [ $# -eq 0 ]; then |
||||||
|
echo "Uso: $0 SIOSE_Madrid_2014.osm" |
||||||
|
exit 1 |
||||||
|
fi |
||||||
|
|
||||||
|
perl -pe "s/'/\"/g" $1 > in.osm |
||||||
|
rm -f out.osm |
||||||
|
|
||||||
|
while IFS= read -r nametagscode |
||||||
|
do |
||||||
|
SIOSECODE=`echo "$nametagscode" | awk -F ',' '{print $3}'` |
||||||
|
NAME=`echo "$nametagscode" | awk -F ',' '{print $1}'` |
||||||
|
TAGVALUES=`echo "$nametagscode" | awk -F ',' '{print $2}'` |
||||||
|
echo "Processing $NAME..." |
||||||
|
if echo $TAGVALUES | grep "+" ; |
||||||
|
then |
||||||
|
echo $TAGVALUES | perl -pe 's/ \+ /\n/g' > /tmp/tagvalue |
||||||
|
while IFS= read -r tagvalue |
||||||
|
do |
||||||
|
TAG=`echo "$tagvalue" | awk -F '=' '{print $1}'` |
||||||
|
VALUE=`echo "$tagvalue" | awk -F '=' '{print $2}'` |
||||||
|
echo "Adding $TAG=$VALUE..." |
||||||
|
# perl -pe 's/<tag k="SIOSE_CODE" v="'$SIOSECODE'/<tag k="'$TAG'" v="'$VALUE'" \/> \n <tag k="description" v="'$NAME'" \/> \n <tag k="SIOSE_CODE" v="'$SIOSECODE'/g' in.osm > tmp ; mv tmp in.osm |
||||||
|
perl -pe 's/<tag k="SIOSE_CODE" v="'$SIOSECODE'/<tag k="'$TAG'" v="'$VALUE'" \/> \n <tag k="SIOSE_CODE" v="'$SIOSECODE'/g' in.osm > tmp ; mv tmp in.osm |
||||||
|
done < /tmp/tagvalue |
||||||
|
|
||||||
|
else |
||||||
|
TAG=`echo "$TAGVALUES" | awk -F '=' '{print $1}'` |
||||||
|
VALUE=`echo "$TAGVALUES" | awk -F '=' '{print $2}'` |
||||||
|
echo "Adding $TAG=$VALUE..." |
||||||
|
perl -pe 's/<tag k="SIOSE_CODE" v="'$SIOSECODE'/<tag k="'$TAG'" v="'$VALUE'" \/> \n <tag k="SIOSE_CODE" v="'$SIOSECODE'/g' in.osm > tmp ; mv tmp in.osm |
||||||
|
fi |
||||||
|
|
||||||
|
done < "SIOSE_tags.csv" |
||||||
|
|
||||||
|
grep -v CODBLQ in.osm | grep -v CODIIGE | grep -v FCC | grep -v HILUCS | grep -v ID_POLYGON | grep -v SELLADO | grep -v SIOSE_CODE | grep -v SIOSE_XML | grep -v SUPERF_HA | grep -v 'k="id"' > out.osm |
||||||
|
|
||||||
|
osmium renumber --start-id=100020000 out.osm -o tmp.osm |
||||||
|
|
||||||
|
perl -pe 's/id="/version="1" id="/g' tmp.osm > "$OUTFILENAME" && rm tmp.osm |
||||||
|
|
||||||
|
echo "OK. Abrir $OUTFILENAME en JOSM, pasar validación y borrar áreas y multipolígonos sin etiquetas" |
||||||
|
echo 'josm "'$OUTFILENAME'"' |
||||||
|
exit 0 |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in new issue