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

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

问题描述

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

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

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

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.

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

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

我希望能够使用 Google API 来支持初始地理编码过程 - 即,当对象被地理编码时,我希望 Google API 处理这个过程,因为它比 Bing 产品可靠得多.

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.

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

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?

推荐答案

比较晚,但如果有人在寻找答案,您可以将服务作为 :lookup 值传递,例如.

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天全站免登陆