#!/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 ecoversities "$i"; done if [ $# -eq 0 ] then echo "Missing parameters. Use: ./bin/reevotech/CompletaGeoPorDireccion.sh deployment Endorser:XXX Endorser" exit fi DEPLOY="$1" EXP="$2" TEMPLATE="$3" DATA=`php PropiedadObtener.php -d="$DEPLOY" -t="$EXP" -p="$TEMPLATE:place-street" -p="$TEMPLATE:place-city" -p="$TEMPLATE:place-state" -p="$DEPLOY: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="$TEMPLATE: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