Geocoder Rails:针对不同任务使用多个API [英] Geocoder Rails: Using multiple APIs for different tasks

查看:52
本文介绍了Geocoder Rails:针对不同任务使用多个API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Geocoder gem for Rails,它非常简单且易于实现.

我在一个网站上使用gem,用户在该网站上搜索某个位置附近的工作,为此,我在后台使用Bing API来处理地理编码请求.

我发现使用Bing API的结果质量很差.我得到的结果非常零散,这给我留下了一堆没有任何地理编码数据的条目.

所以,我有一个解决方案的主意,但是我不确定我可以实现此精度的程度...

我希望能够使用Google API来支持初始地理编码过程-即,当对对象进行地理编码时,我希望Google API能够处理此过程,因为它比Bing产品更可靠./p>

然后,我希望能够继续使用Bing API进行任何与搜索相关的地理编码查询:例如 Object.near(无论如何).

我知道我可以使用地址解析器配置多种服务,但是我不确定如何明确地将一种服务用于特定目的.其他人是否有使用Geocoder进行此操作的经验?

解决方案

虽然来得很晚,但是如果有人在寻找答案,您可以将服务作为:lookup值来传递,例如.

Geocoder.search(英国诺丁汉市地面",:lookup =>:谷歌)

I am using the Geocoder gem for Rails, which is brilliantly simple and easy to implement.

I am using the gem on a website where users search for jobs near a location, and for this I am using the Bing API in the background to process the geocoding requests.

I am finding that the quality of the results from using the Bing API are very poor. I get very patchy results and this leaves me with a bunch of entries without any geocoding data whatsoever.

So, I have an idea for a solution, but I am unsure how precisely I can implement this...

I want to be able to use the Google API to power the initial geocoding process - i.e, when an object is geocoded, I want the Google API to handle this process, as it is far more reliable than the Bing offering.

I then want to be able to continue using the Bing API for any search related geocoding queries: Object.near(whatever) for example.

I know that I can configure multiple services with geocoder, however I am unsure how I explicitly use one service for a specific purpose. Has anybody else got any experience of doing this with geocoder?

解决方案

Rather late, but if anybody is looking for the answer, you pass the service as a :lookup value, eg.

Geocoder.search("City Ground, Nottingham, UK", :lookup => :google)

这篇关于Geocoder Rails:针对不同任务使用多个API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆