diff options
Diffstat (limited to 'bin/reevotech/CompletaGeoPorDireccion.sh')
-rwxr-xr-x | bin/reevotech/CompletaGeoPorDireccion.sh | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/bin/reevotech/CompletaGeoPorDireccion.sh b/bin/reevotech/CompletaGeoPorDireccion.sh new file mode 100755 index 00000000..6950e2dc --- /dev/null +++ b/bin/reevotech/CompletaGeoPorDireccion.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +# Este script lo usamos para actualizar los datos de geolocalizcion ubicacion de experiencia a partir de los campos que contienen la dirección postal... Usamos OSM nominatim: `https://nominatim.org/release-docs/develop/api/Search/` +# +# Se puede usar como: IFS=$(echo -en "\n\b") && for i in `php ../ListarPaginas.php Plantilla:Experiencia`; do ./CompletaGeoPorDireccion.sh "$i"; done +DEPLOY="$1" +EXP="$2" +DATA=`php PropiedadObtener.php -d="$DEPLOY" -t="$EXP" -p="ecoversity:place-street" -p="ecoversity:place-city" -p="ecoversity:place-state" -p="ecoversity:place-country" > /tmp/x && sed 's/ /+/g' /tmp/x | sed ':a;N;$!ba;s/\n/,/g'` +echo "https://nominatim.openstreetmap.org/search.php?format=json&addressdetails=1&q=$DATA" + +if [ -z "$DATA" ] +then + echo "\$DATA is empty, exiting...." + exit +else + echo "\$DATA is NOT empty" +fi + + + +curl -s "https://nominatim.openstreetmap.org/search.php?format=json&addressdetails=1&q=$DATA" > /tmp/json + +cat /tmp/json | jq '.[0]' + +LAT=`cat /tmp/json | jq '.[0] | .lat' | sed 's/"//g'` +LON=`cat /tmp/json | jq '.[0] | .lon' | sed 's/"//g'` + +echo "Lat: $LAT" +echo "Lon: $LON" + +if [ $LAT != "null" ]; then + php PropiedadActualizar.php -d="$DEPLOY" -t="$EXP" -f="true" -p="ecoversity:place|$LAT, $LON" + sed -i "/$EXP/d" todos.log + echo $EXP >> correctos.log +else + echo "I was unable to get a coordinate, logging to revisar.log" + sed -i "/$EXP/d" todos.log + echo $EXP >> revisar.log +fi |