--- a/maxious-canberra-transit-feed/04-locatebetweenpoints.reversegeocode.php +++ b/maxious-canberra-transit-feed/04-locatebetweenpoints.reversegeocode.php @@ -1,1 +1,38 @@ +\n"); + } + while ($stop = pg_fetch_assoc($result_stops)) { + echo "Processing ".$stop['geohash'] . " ... "; + $url = "http://geocoding.cloudmade.com/daa03470bb8740298d4b10e3f03d63e6/geocoding/v2/find.js?around=".($stop['lat']/10000000).",".($stop['lng']/10000000)."&distance=closest&object_type=road"; + $contents = json_decode(getPage($url)); + $name = $contents->features[0]->properties->name; + echo "Saving $name !
" ; + $result_save = pg_query($conn, "UPDATE stops set name = '".pg_escape_string($name)."' where geohash = '{$stop['geohash']}' "); + if (!$result_save) { + echo("Error in SQL query: " . pg_last_error() ."
\n"); + } + flush(); + } +?> + +