Beispiel #1
0
 public function geocode()
 {
     global $app_config;
     static $sleep_delay;
     if (!$sleep_delay) {
         $sleep_delay = 90000;
     }
     $address = $this->getZip();
     $url = "http://maps.google.com/maps/geo?q=" . urlencode($address) . "&output=csv&key=" . $app_config['google_maps']['api_key'];
     $data = GroupPeer::remote_request($url);
     $addr_bits = split(",", $data);
     list($response_code, $precision, $lat, $lon) = $addr_bits;
     if ($response_code == "620") {
         $sleep_delay += 20000;
         print "waiting {$sleep_delay} ... \n";
         usleep($sleep_delay);
         return $this->geocode();
     }
     if ($response_code = "200" && $lat != '""') {
         $this->setLat($lat);
         $this->setLon($lon);
     }
     $this->setGeocodeAttemptedAt(time() - 4 * 3600);
     usleep($sleep_delay);
     print $url . "\n";
     print "{$response_code}: level {$precision}, LAT: {$lat}, LON: {$lon} \n\n";
 }