Yahoo BOSS Placefinder 结果不准确
Posted
技术标签:
【中文标题】Yahoo BOSS Placefinder 结果不准确【英文标题】:Yahoo BOSS Placefinder inaccurate results 【发布时间】:2013-10-22 20:44:48 【问题描述】:我的公司正在使用我的前任开发的功能来定位地址列表。然而,从上周开始,返回的结果不是几米,而是几十甚至几百公里。
决定将 Yahoo BOSS API 与 PlaceFinder 一起使用。函数如下:
function geocode_yahoo($address,$city,$state,$country)
$url = "http://yboss.yahooapis.com/geo/placefinder";
$cc_key = "***masked for security reason ***";
$cc_secret = "***masked for security reason ***";
$consumer = new OAuthConsumer($cc_key, $cc_secret);
$address = array($address, $city, $state, $country);
$address = array_filter($address);
$args = array();
$args["q"] = rawurlencode(implode(' ', $address));
$args["flags"] = "CJ";
$request = OAuthRequest::from_consumer_and_token($consumer, NULL,"GET", $url,$args);
$request->sign_request(new OAuthSignatureMethod_HMAC_SHA1(), $consumer, NULL);
$url = sprintf("%s?%s", $url, OAuthUtil::build_http_query($args));
$ch = curl_init($url);
$headers = array($request->to_header());
curl_setopt($ch,CURLOPT_ENCODING , "gzip");
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$rsp = curl_exec($ch);
if ($rsp != '')
$data = json_decode($rsp);
if ($data && $data->bos-s-response->responsecode == '200' && intval($data->bos-s-response->placefinder->count)>0)
return (object) array('lat'=>$data->bos-s-response->placefinder->results[0]->latitude, 'lng'=>$data->bos-s-response->placefinder->results[0]->longitude);
return false;
所有使用的地址都是加拿大人,我们正确地使用了 Oauth 类。从上周开始,返回的结果没有任何意义。
例如,如果我输入地址:5275 Griffith Road, Vanderhoof, BC, Canada,我从 Yahoo BOSS 收到以下返回:
5275 Griffith Road, Vanderhoof, BC, CANADA
"bos-s-response":"responsecode":"200","placefinder":"start":"0","count":"8","request":"flags=CJ&locale=CA&q=5275%2520Griffith%2520Road%252C%2520Vanderhoof%252C%2520BC%252C%2520CANADA","results":
["quality":"59","latitude":"-36.71462","longitude":"139.989586","offsetlat":"-36.714619","offsetlon":"139.989578","radius":"64700",
"quality":"59","latitude":"47.5714","longitude":"8.115335","offsetlat":"47.5714","offsetlon":"8.11533","radius":"2100",
"quality":"59","latitude":"51.667509","longitude":"5.375125","offsetlat":"51.667511","offsetlon":"5.37512","radius":"3900",
"quality":"59","latitude":"-30.832686","longitude":"-66.089954","offsetlat":"-30.832689","offsetlon":"-66.089951","radius":"30000",
"quality":"59","latitude":"45.965999","longitude":"14.02893","offsetlat":"45.966","offsetlon":"14.11538","radius":"13000",
"quality":"59","latitude":"-32.82341","longitude":"28.05365","offsetlat":"-32.82341","offsetlon":"28.05365","radius":"11200",
"quality":"59","latitude":"33.824049","longitude":"35.677601","offsetlat":"33.824051","offsetlon":"35.677601","radius":"1000",
"quality":"39","latitude":"54.014011","longitude":"-124.012894","offsetlat":"54.014011","offsetlon":"-124.012894","radius":"9600"]
如您所见,Yahoo BOSS 发现了一些东西(代码 200)质量结果很低,59 和更少。事实上他们都错了:地址在不列颠哥伦比亚省,但有些结果是从墨西哥得到的结果。最接近的结果是最后一个,得到的结果是 39。它得到了正确的城市,但不够精确。这不是唯一的无效结果,它们还有几十个其他地址具有相同的结果。
我尝试输入邮政编码,将搜索限制为 locale=CA,更改了地址格式,但没有任何改进。我尝试将变量从 $args["q"] 更改为 $args["location"],结果没有区别。我已经仔细检查了我们的钥匙,一切似乎都很正常。我在Yahoo BOSS网站上查询了最近API是否发生了任何变化,什么都没有。我已经向雅虎集团询问了与BOSS相关的问题,没有答案。我有点绝望,所以欢迎任何帮助!
【问题讨论】:
我会去对雅虎人大喊大叫。除非他们的输入要求发生了巨大变化,否则您的代码中没有任何内容可以告诉雅虎您想要墨西哥 B.C.地址。 是的,我已经写信给他们了,没有回音。一位同事向我建议删除 rawurlencode,它大大改善了结果。但是,我仍然有大约 10% 的结果的地理定位质量为 60% 或更低。 【参考方案1】:好的,看来问题出在 rawurlencode 上,现在 Yahoo BOSS API 不需要它了。他们从来没有回答我们,但我怀疑他们的 API 中的一些变化会使这种编码变得无用。
【讨论】:
以上是关于Yahoo BOSS Placefinder 结果不准确的主要内容,如果未能解决你的问题,请参考以下文章
由于跨域功能,无法从我的网站的 yahoo Finance api 获取结果