Http 地理编码器 (Google) 准确度级别

发布于 2024-09-04 11:37:14 字数 709 浏览 3 评论 0原文

我正在对大量用户输入的地址进行地理编码,并对返回的准确性级别感兴趣。我的目标是获得给定地址的最佳准确性分数。

我按照以下方式调用 geocder api http://maps.google.com/maps/geo?q={地址}&output=csv&sensor=false&key=xx

现在,针对带/不带前提名称的同一地址返回的准确度级别

  1. q = Key Arena, 305 Harrison Street, Seattle, WA 98109(准确度为 5)
  2. q = 305 Harrison Street Seattle, WA 98109(准确度为 8)
  3. q = Key Arena, Seattle, WA 98109(准确度为 9。)

从上面可以明显看出,当街道名称附加前提/地点时,Google 服务器不会返回最佳准确度。

问题是:) 有没有办法传递完整的地址(带有前提名称/即情况1) 并获得最大准确度。 (或者如何告诉谷歌服务器该地址是通过前提/建筑物名称和街道名称传递的)

(如果您在想为什么不只使用案例3,答案是这些是 用户输入地址,可以输入“我妈妈的房子”作为前提,并有准确的街道地址。在这种情况下,我希望准确度为 8 而不是 5)

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)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

长梦不多时 2024-09-11 11:37:14

很简单,只需做一个 if 语句来检查并看看准确性如何。如果它太低,请尝试在没有您的前提名称的情况下进行 goecode。在下面的例子中,我先尝试 addr_2,然后再尝试 addr_3,以考虑用户在 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

有关我的内容的更多详细信息,请参阅使用 PHP/MySQL 对地址进行地理编码我在 format_address() 和 geocode_address() 中执行操作。

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().

酒几许 2024-09-11 11:37:14

今天,当我检查地址“Key Arena, 305 Harrison Street, Seattle, WA 98109”时,返回的准确度确实为 9。所以我认为地理编码服务出现了一些故障,或者谷歌改变了他们的算法。

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..

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文