parent
03fa396ce6
commit
2febdec877
@ -0,0 +1,76 @@ |
||||
#!/bin/bash |
||||
# Descarga y procesa los aseos públicos operativos de Madrid |
||||
# Santiago Crespo 2022 |
||||
|
||||
INITIALDIR=`pwd` |
||||
TMPDIR=/tmp/aseos |
||||
|
||||
mkdir -p $TMPDIR |
||||
rm -f $TMPDIR/* |
||||
cd $TMPDIR |
||||
|
||||
wget -nv "https://datos.madrid.es/portal/site/egob/menuitem.ac61933d6ee3c31cae77ae7784f1a5a0/?vgnextoid=00149033f2201410VgnVCM100000171f5a0aRCRD&format=dcat&filename=300103-0-Aseos-Publicos-Operativos&file=0&mgmtid=edcaaa8cf6bda510VgnVCM1000001d4a900aRCRD&preview=full" -O aseos.rdf |
||||
|
||||
SOURCEDATE=`grep modified aseos.rdf | awk -F '>' '{print $2}' | awk -F 'T' '{print $1}'` |
||||
URLCSV=`grep csv aseos.rdf | grep http | awk -F '>' '{print $2}' | awk -F '<' '{print $1}'` |
||||
|
||||
wget -nv "$URLCSV" -O aseos_tmp.csv |
||||
|
||||
# Remove 1st line |
||||
grep -v "FECHA PUESTA" aseos_tmp.csv | grep -v "Binary file" > aseos.csv |
||||
|
||||
echo '<?xml version="1.0" encoding="UTF-8"?> |
||||
<osm version="0.6" upload="false" generator="'$0'">' > aseos.osm |
||||
|
||||
ID="79999595000" |
||||
|
||||
# Para el timestamp |
||||
DIA=`date +%Y-%m-%d` |
||||
HORA=`date +%H:%M:%S` |
||||
|
||||
echo "Procesando..." |
||||
|
||||
while IFS='' read -r line || [[ -n "$line" ]]; do |
||||
REF=`echo $line | awk -F ';' '{print $1}'` |
||||
FECHAPUESTAENSERVICIO=`echo $line | awk -F ';' '{print $10}' | awk -F '/' '{print $3"-"$2"-"$1}'` |
||||
LAT=`echo $line | awk -F ';' '{print $11}'` |
||||
LON=`echo $line | awk -F ';' '{print $12}'` |
||||
NAME=`echo $line | awk -F ';' '{print $13}'` |
||||
|
||||
if [ -z "$LON" ] |
||||
then |
||||
echo "LON is empty. Not adding this one." |
||||
else |
||||
echo '<node version="1" changeset="1" timestamp="'$DIA'T'$HORA'Z" id="'$ID'" lat="'$LAT'" lon="'$LON'" visible="true"> |
||||
<tag k="amenity" v="toilets"/> |
||||
<tag k="access" v="yes"/> |
||||
<tag k="fee" v="yes"/> |
||||
<tag k="charge" v="0.10 EUR"/> |
||||
<tag k="wheelchair" v="yes"/> |
||||
<tag k="opening_hours" v="24/7"/> |
||||
<tag k="changing_table" v="yes"/> |
||||
<tag k="unisex" v="yes"/> |
||||
<tag k="supervised" v="no"/> |
||||
<tag k="toilets:disposal" v="flush"/> |
||||
<tag k="toilets:position" v="seated"/> |
||||
<tag k="toilets:paper_supplied" v="yes"/> |
||||
<tag k="toilets:hands_drying" v="electric_hand_dryer"/> |
||||
<tag k="toilets:handwashing" v="yes"/> |
||||
<tag k="handwashing:soap" v="yes"/> |
||||
<tag k="source" v="Ayuntamiento de Madrid"/> |
||||
<tag k="source:date" v="'$SOURCEDATE'"/> |
||||
<tag k="operator" v="Ayuntamiento de Madrid"/> |
||||
<tag k="ref" v="'$REF'"/> |
||||
<tag k="name" v="'$NAME'"/> |
||||
<tag k="start_date" v="'$FECHAPUESTAENSERVICIO'"/> |
||||
</node> |
||||
' >> aseos.osm |
||||
|
||||
ID=$((ID + 1)) |
||||
|
||||
fi |
||||
|
||||
done < aseos.csv |
||||
|
||||
echo '</osm>' >> aseos.osm && cp aseos.osm "$INITIALDIR/aseos.osm" && cd "$INITIALDIR" && echo "aseos.osm creado!" && date && exit 0 |
||||
|
Loading…
Reference in new issue