English 中文(简体)
Http Geocoder (Google) Accuracy level
原标题:

I am geocoding a large amount of user entered addresses and interested in the accuracy levels returned. My GOAL is to get the BEST POSSIBLE ACCURACY score for a given address.

I call the geocder api following way http://maps.google.com/maps/geo?q={address}&output=csv&sensor=false&key=xx

now the accuracy levels returned for same address with/without premise name

  1. q = Key Arena, 305 Harrison Street, Seattle, WA 98109 (Accuracy is 5)
  2. q = 305 Harrison Street Seattle, WA 98109 (Accuracy is 8)
  3. q = Key Arena, Seattle, WA 98109 (Accuracy is 9.)

Its obvious from the above that the google servers does not return the best accuracy when street name is appended with premise/venue.

the question is :) is there a way to pass the complete address ( with premise name / i.e case 1 ) and get the Max Accuracy. ( or how can tell the google server that the address is passed with premise/building name and street name)

( if you are thinking why not just use case 3, the answer is these are user entered addresses, they could enter "my moms s house" for premise, with accurate street address. in which case i want the accuracy to be 8 not 5)

最佳回答

Well today when i checked the address "Key Arena, 305 Harrison Street, Seattle, WA 98109" does return the accuracy as 9. So i assume either there was some glitch with geocoding service or google changed their algo..

问题回答

It s pretty easy, just do an if statement to check and see what the accuracy is. If it is too low, try and goecode without your premise name. In my case below, I m trying addr_2 and then addr_3 to account for the situations where the user entered a name on addr_1.

$addr_1 = urlencode($row["addr_line1"]);
$addr_2 = urlencode($row["addr_line2"]);
$addr_3 = urlencode($row["addr_line3"]);
$city = urlencode($row[ addr_city ]);
$state = urlencode($row[ addr_state ]);
$postal = urlencode($row[ addr_postalcode ]);
$country = urlencode($row[ addr_country ]);

$address = format_address($addr_1, $city, $state, $postal, $country);
$base_url = "http://" . MAPS_HOST . "/maps/geo?output=json&key=" . KEY;

$request_url = $base_url . "&q=" . $address;
$geocode = geocode_address($request_url);

// check geocode accuracy and try again with different data if needed
if ($geocode[ accuracy ] < 6) {
      // bad geocode, try addr_2
      $address2 = format_address($addr_2, $city, $state, $postal, $country);
      $request_url2 = $base_url . "&q=" . $address2;
      $geocode = geocode_address($request_url2);

      if ($geocode[ accuracy ] < 6) {
        // bad geocode, try addr_3
        $address3 = format_address($addr_3, $city, $state, $postal, $country);
        $request_url3 = $base_url . "&q=" . $address3;
        $geocode = geocode_address($request_url3);
      }
}
// process results in $geocode below

See Geocoding Addresses with PHP/MySQL for more details on what I m doing in format_address() and geocode_address().





相关问题
avoiding geocode range collisions

I am in the process of extracting location entities ( Madison Square Garden , San Diego Zoo , etc.) from a large table of non-uniform location. I m trying to avoid multiple entities in my new table. ...

Using Dell GPS in FireFox 3.5, not Google/Skyhookwireless

I want to make sure FireFox is using my local GPS on my machine (Dell Mini-10) for Location Aware browsing, not Google wi-fi triangulation services. How would one make sure FireFox is using the GPS?...

How to find State location from iphone GPS?

I m trying to add to my program that locates the person in GPS but sets a value to the State that person is in so example: GPS Locates person from his/her iphone then returns the state they are in so ...

Location based information

I would like to show information on my website based on user s geography. In my current design would not want the user to enter their location/zip code. Using IP I can find user s location but how ...

Geocoding town names to their coordinates in a loop

I ve read similar posts, but still didn t find a solution for myself. Basically I have an array with countries+towns in PHP and I need to show them on the map with markers. Here is my code: function ...

热门标签