geokit

Make GeoKit play nicely with my Address class

My Address class has a geocode class method that returns an array of address objects derived from geocoding the method's parameter (if the geocoding results in an exact match, the array will have one element). One annoying part about writing this method is translating the GeoKit address objects to my address objects (e.g., "street_addre...

Geokit and Authlogic, geocoding the users ip address when they create a user

Has anyone done this? I'm confused at how I can make this work, first off I have my user model Geocoding with it works fine in IRB, just can't figure out how to get it to work in my project. Trying to use some examples from the readme here: http://github.com/andre/geokit-rails/tree/master. Anyhow here is what I have: class User < Act...

Floating point calculations with latitudes and longitudes of varying precisions

Background: I receive a long and lat as parameters to a web service. They are typically up to 6 decimal places. When a new request is received, I calculate the distance between the last recorded loc and the long/lat in the params of the request. If the distance is greater than a certain threshold of miles apart, I update the current loc....

Is mysql using my index or not, and can the performance of geokit be improved?

I'm using geokit (acts_as_mappable) in a rails application, and the performance of radial or bounds searches degrades considerably when there is a large number of models (I've tried with 1-2million but the problem no doubt kicks in earlier than this). Geokit does all its calculations based on lat and lng columns in the table (latitude ...

Why does Postgresql fail with Geokit like this??

I've just started playing with geokit with Rails for an app I am building. I have got my recorda getting geocoded, but then when I go into the console to have a look at what I can do it with and it blew up with the following: user is a user object with lat and lng from my database >> Restaurant.find(:all, :origin => user) Restau...

Rails ActiveRecord Problem With Complex Join - Select Does Not Work

Hello, I have two model objects: Event Venue Events have Venues. Venues can have 1..* events. Venues have a location, a lat and long, which I use with the Geokit Rails plugin. Here's what these models look like in Rails: class Event < ActiveRecord::Base belongs_to :venue acts_as_mappable :through => :venue end and class Ven...

Geokit in Ruby on Rails, problem with acts_as_mappable

Hi, i have looked through the list of related questions however my problem does not seem to be listed and hence here it is: Basically I'm trying to use Geokit within the Ruby on Rails environment, im not sure if i installed it properly, I have included it within the environment.rb (and done rake db:install) and i'm now trying to do the ...

Multiple Markers on Google Map (Fails to display over 10 markers) - Ruby on Rails Environment YM4R Plugin

Hi, I have the following issue. I have a google map (using YM4r + Geokit) within Ruby on Rails, anyhow, i basically have an array of markers which are populated in the following manner @shops.each do |sto| markers << GMarker.new (....) end They are definitely being stored fine as under 10 markers they are displayed just fine. Th...

Geokit error - "uninitialized constant"

I followed the install steps to the letter to get Geokit working on my site. I can do a distance calculation just fine, but when I try to render a Google map using: @map = GMap.new("map") It throws me this error: NameError in TechsController#home uninitialized constant TechsController::GMap Anyone know why? I have a feeling it h...

Problems with installing plugins using command line on windows?

I've been trying to get GeoKit installed on my computer and for the life of me I couldn't understand why acts as mappable was showing up as an unknown variable. I followed the instructions (I'm using Windows): ruby script/plugin install git://github.com/andre/geokit-rails.git I added to the environment.rb config.gem "geokit" and I...

Change value of request.remote_ip in Ruby on Rails

For test purposes I want to change the return value of request.remote_ip. While being on my development machine it returns always 127.0.0.1 as it should but I would like to give myself different fake IPs to test the correct behavior of my app without deploying it to an live server first! Thank you. ...

RoR - Geokit plugin: why Location.find is giving me back an empty array? (Location is a model that "acts_as_mappable")

Hi, I have installed both geokit gem and geokit-rails plugin. I configured the plugin as shown here: http://github.com/andre/geokit-rails . Then I generated a new model - Location, which looks like this: class Location < ActiveRecord::Base acts_as_mappable :default_units => :kms end and a controller: class TestController < Applicat...

Rails geokit caching

How would you cache GeoKit requests? This does not work for me... Geokit::Geocoders::query_cache = true Geokit::Geocoders::query_cache_max_age = 86400 # 1 day in seconds URL: http://github.com/seebq/geokit-gem ...

Rails: Converting from MySQL to PostGres breaks Geokit Distance Calculations???

I recently switched my database from MySQL to PostGres. I also use GeoKit. When I started my app up with the new database already seeded, I get the following error: PGError: ERROR: function radians(character varying) does not exist LINE 1: ...COS(0.661045389762993)*COS(-2.12957994527573)*COS(RADIANS(ti... ...

Geokit distance calculation oddity

I'm using the Geokit plugin to calculate the distance between the current_user and other users (geocoding actually stored in Profile model). For testing purpose, I created two Users, one in Minneapolis, MN and one in St. Paul, MN. I used the Geokit gem to geocode the Profiles' lat/lng pair in an IRB session. I changed the Index view t...

Will_paginate and geokit misbehavior (double query)

Hi all, I'm using will_paginate to paginate my geokit search results. The code works, however, when looking at the log it does double the geokit query when using the following will_paginate call: @posts = Post.paginate :page => params[:page], :per_page => 1, :origin => @search, :within => @miles, :include => :u...

Database layout for an application with geocoding features using geokit

I'm developing a real estate web catalogue and want to geocode every ad using geokit gem. My question is what would be the best database layout from the performance point if i want to make search by country, city of the selected country, administrative area or nearest metro station of the selected city. Available countries, cities, admin...

geokit acts as mappable through polymorphic

I have two models Store (with lat, lng columns) and Coupon. Store has many coupons, as => couponables Coupon belongs to couponable, :polymorphic => true (it's necessary for coupons association to be polymorphic for other use cases). Is it possible to do geo queries for coupons around a zipcode through the Store model by declaring the ...

Show nearby cities in a geo location search

I'm developing an app where a user can search by address and get all results within a certain mile radius. I have that part working with the geokit gem and plugin in Rails. But, I'm trying to figure out the best way to to show a list of nearby cities and the number of matches per city. I could iterate over the result set and take out th...

Setup a testdirectory for a Rails Plugin

Hi. I started to create a rails plugin which includes some class and instance methods of Controller and Model. I fist tried to setup the tests for the Model. Add a models directory in my test dir. But i noticed - i need the geokit-rails plugin for my model to be able to "acts_as_mappable" How to get the plugin into the test dir? I try...