Tag: geokit

Rails Geokit太多查询错误

我试图做一个小应用来测试gem“geokit”,“〜> 1.8.4” 它在开始时工作,但随后开始引发此错误 Geokit ::地址解析器:: TooManyQueriesError 最多我用这行代码做了100次查询 suggested_bounds = Geokit :: Geocoders :: GoogleGeocoder.geocode(params [:location]) 谁能帮我 谢谢

Rails:从MySQL转换为PostGres打破了Geokit距离计算?

我最近将我的数据库从MySQL切换到PostGres。 我也使用GeoKit。 当我使用已经播种的新数据库启动我的应用程序时,我收到以下错误: PGError: ERROR: function radians(character varying) does not exist LINE 1: …COS(0.661045389762993)*COS(-2.12957994527573)*COS(RADIANS(ti… ^ HINT: No function matches the given name and argument types. You might need to add explicit type casts. 任何人都知道为什么现在这会破裂? 我知道GeoKit仍然有效,因为当数据库被播种时,它仍然在每张票的模型中执行地理编码,它只是不能正确地进行距离计算。

为什么Postgresql会像Geokit这样失败?

我刚刚开始使用Rails为我正在构建的应用程序玩geokit。 我的记录得到了地理编码,但是当我进入控制台看看我能用它做什么时它会爆炸以下:用户是一个用户对象,我的数据库中有lat和lng >> Restaurant.find(:all, :origin => user) Restaurant Load (0.0ms) PGError: ERROR: operator does not exist: numeric – character varying LINE 1: …*, SQRT(POW(111.1819*(-33.872517-restauran… ^ HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts. : SELECT *, SQRT(POW(111.1819*(-33.872517-restaurants.lat),2)+ POW(76.7136337302943*(151.205536-restaurants.lng),2)) AS distance FROM “restaurants” ActiveRecord::StatementInvalid: PGError: ERROR: […]

Ruby on Rails中的Geokit,acts_as_mappable的问题

我查看了相关问题列表,但我的问题似乎没有列出,因此它是: 基本上我正在尝试在Ruby on Rails环境中使用Geokit,我不确定我是否正确安装它,我已将它包含在environment.rb中(并完成了rake db:install)我现在正在尝试以下: require ‘active_record’ require ‘geokit’ class Store < ActiveRecord::Base acts_as_mappable end 不幸的是,当我尝试运行它并查看它是否正常时,我收到以下错误: c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/base.rb:1959:in `method_missing’: undefined local variable or method `acts_as_mappable’ for # (NameError) from C:/Users/Erika/Documents/Visual Studio 2008/Projects/StoreLocator/StoreLocator/app/models/store.rb:5 我正在为Visual Studio 2008运行Ruby in Steel,我不知道我做错了什么,因为我发现所有的在线教程都比较旧,并且适用于我。 任何帮助将不胜感激。 谢谢! 编辑:(根据Ben的请求添加)以下是我的environment.rb的样子 # Be sure to restart your server when you modify this file # Specifies gem version […]

在Rails中组合条件数组

我正在使用Rails3 beta,will_paginate gem和geokit gem&plugin。 作为geokit-rails插件,似乎不支持Rails3范围(包括:origin符号是问题),我需要使用.find语法。 代替范围,我需要以数组格式组合两组标准: 我有一个默认条件: conditions = [“invoices.cancelled = ? AND invoices.paid = ?”, false, false] 我可能需要将以下条件之一添加到默认条件,具体取决于UI选择: #aged 0 lambda {[“created_at IS NULL OR created_at = ? AND created_at 90 lamdba {[“created_at >= ?”, Date.today + 90.days]} 生成的查询类似于: @invoices = Invoice.find( :all, :conditions => conditions, :origin => ll #current_user’s lat/lng pair ).paginate(:per_page => […]

哪个邮政编码最接近Geokit?

我正在使用geokit给我两个邮政编码之间的距离。 我需要确定哪个邮政编码最近。 point_a = Geokit::Geocoders::GoogleGeocoder.geocode “se18 7hp” alpha = [“cr0 3rl”, “W2 1AA”] miles = alpha.map do |m| point_a.distance_to(m) end miles.min # => 11.005310790913377 我怎么做miles.min的反向来了解哪个邮政编码离point_a最近?

在Ruby on Rails中更改request.remote_ip的值

出于测试目的,我想更改request.remote_ip的返回值。 在我的开发机器上,它总是返回127.0.0.1,但我想给自己不同的假IP来测试我的应用程序的正确行为,而不首先将它部署到实时服务器! 谢谢。