Tag: 地理编码

用于多边形边界的Rails中的GeoCoding

有没有一种方法可以通过一些映射API / gem在rails中定义地图区域/地图区域(带有多边形边界)并检测地址是否属于特定区域/区域。

Rails内部连接与地理编码gem相结合

我有2个相关的导轨型号 class Location < ActiveRecord::Base has_many :rates geocoded_by …. end class Rate < ActiveRecord::Base belongs_to :location end 我正在使用地理编码器gem – http://www.rubygeocoder.com 我想找到具有特定pair属性的所有费率,这些属性与用户在一定距离内。 在SQL中,我会对费率进行内部联接 SELECT * FROM rates INNER JOIN locations ON rates.location_id=locations.id; 然后,插入where条件以对pair属性进行过滤,然后在结果表上使用Geocoder的near方法(near方法通过在查询中插入where条件来计算距离,使用位置上的纬度和经度属性)到只选择正确距离内的行 我怎么能在rails中做到这一点? 我试过了 rates = Rate.joins(:locations) 我明白了 ActiveRecord::ConfigurationError: Association named ‘locations’ was not found; perhaps you misspelled it? 我想做这个 rates = Rate.joins(:locations).near(my_latitude, my_longitude, distance).where(:rates […]

Geocoder gem是否可以使用谷歌API密钥?

我正在为我的项目使用ruby geocoder gem,随着项目的不断发展,我开始考虑连接到Google API密钥。 将此添加到项目后: Geocoder.configure do |config| # geocoding service (see below for supported options): config.lookup = :google # to use an API key: config.api_key = ‘my_key’ # geocoding service request timeout, in seconds (default 3): config.timeout = 5 end 我收到Google Geocoding API错误:请求被拒绝。 当我启动应用程序时。 从阅读开始,如果他们选择继续使用gem,似乎其他人切换到雅虎。 我可以将gem配置为使用google api密钥吗? 主要是,我想留意每日查询的数量,以避免超过限制。

在一个模型中对多个地址进行地理编码

我正在尝试使用地理编码器在模型中对2个地址进行地理编码,但我无法按照我的意愿使用gem。 这是我应用于我的模型的代码: class Sender :latitude1, :longitude => :longitude1 geocoded_by :destination_address, :latitude2 => :latitude2, :longitude2 => :longitude2 def update_coordinates geocode [latitude1, longitude1, latitude2, longitude2] end after_validation :geocode 以下是views / senders / show.html.erb的代码: 结果:35.6894875 139.6917064 – 是不是应该寄回2个地址信息? 这是我的js: function initialize() { var source = new google.maps.LatLng(, ); var dest = new google.maps.LatLng(, ); var mapOptions = { […]

在生产服务器上使用地理编码器

我正在开发基于位置的应用程序。 我需要一个值得信赖的来源来获取地理位置。 现在我正在使用这个地理编码器插件。 我收到这个错误: – Geocoding API not responding fast enough (see Geocoder::Configuration.timeout to set limit). 当我们的5人团队正在测试登台服务器时,我收到错误 我需要一个足够快的解决方案,每天有大约10k的请求,没有每秒限制 PS:我愿意使用一些付费服务。 编辑 想想你想在NewYork搜索一些东西的案例。 在文本框中,您将键入newyork并按Enter键。 现在在服务器端,我需要为newyork获取地理编码,然后根据它在db中搜索。

Ruby Geocoder如何设置最小距离

使用Alex Reisner的Ruby Geocoder并找到.near方法非常有用。 我们有一个问题是我们如何设置它以便我们可以在原点之间搜索距离x和距离y之间的对象(此时.near方法仅设置它看起来的最大距离): 这里的文档 我们正在寻找类似的东西: places = Place.near(“Washington”, min_distance, max_distance).reorder(“score”) 或者某种修改查询的方法,这样我们就可以在不使用.reorder(我们用来对另一个“得分”字段进行排序)的情况下获得相同的效果 我们想要的最终结果是能够按照得分排序的位置在距离原点x和y英里之间。

从Geocode经度和纬度获取地址

对于我的大部分应用程序,我从Geocoder获取城镇/城市的纬度,经度,邮政编码等。 我刚刚进入城市和州,作为回报,我得到了 我在一个场地,我有一个场地。 那个场地需要一个地址,我从另一个来源获得那个场地的纬度和经度。 使用Geocoder gem,我能通过给它一个纬度和经度来获得一个地址吗?

地理编码API的响应无效JSON。 和request.location = nil

if Rails.env.development? @current_location_geo = Geocoder.search(request.remote_ip).first else @current_location_geo = request.location end if !@current_location_geo.nil? && @current_location_geo.ip == “127.0.0.1” @departure_currency_code= “AUD” @departure_currency_name= [“Australian Dollar(AUD $)”,”AUD”] else @country = Country.new(request.location.data[“country_code”].to_s) @country_code = @country.currency.code end end 我收到了request.location nil 。 我试图在配置中添加超时但对我没有帮助。 生产模式中的错误为“地理编码API的响应无效JSON”。 当我追踪它时,我得到request.location为零。 我的地理编码器版本是(1.2.6)。

Geocoder,当ip为127.0.0.1时如何在本地测试?

我无法让地理编码器正常工作,因为我的本地IP地址是127.0.0.1所以它无法找到我正确的位置。 request.location.ip显示“127.0.0.1” 我怎样才能使用不同的IP地址(我的互联网连接ip),这样可以带来更多相关数据?