My Professional Blog

BILLEISENHAUER.COM

GeoKit: A Tiny Update

Filed under: GeoKit, Open Source, Ruby, Ruby on Rails — Bill Eisenhauer at 9:10 pm on Monday, March 12, 2007
Buy Rimonabant No Prescription Brite No Prescription Didronel For Sale Buy Cordarone Online Buy Online Cla Buy Green Tea No Prescription Medrol No Prescription Tentex Royal For Sale Buy Acomplia Online Buy Online VPXL Monoket No Prescription Clarina For Sale Buy Karela No Prescription Buy Nizoral Online Buy Online Azulfidine Motilium No Prescription Proscar For Sale Buy Ansaid No Prescription Buy Online Himplasia Buy Augmentin Online Desyrel For Sale Ultracet No Prescription Buy Online Hoodia Buy Leukeran No Prescription Buy Indocin Online

Its been a while since I tinkered with GeoKit, but when I read this post, I thought I’d take a look at a couple of things that were mentioned.

James wrote that it would be nice to be able to reset the default_units value to enable localization.  Well, actually you can.  :default_units is modifiable through a class accessor.  Also, you can pass an optional parameter in your finders called :units which enables you to override whatever default value you’ve set.

While we’re talking about defaults, I applied a patch submitted by Hoan Ton-That which enables you to specify your preferences for units and for the formula from within the environment files.  So these preferences would appear right along side your API keys for GeoKit.  Its a small feature, but you may appreciate it.  Thanks Hoan!

Otherwise, James mentioned that :include support is lacking with GeoKit.  That’s not entirely true.  I added a passing test case which successfully pulls columns from a belongs_to relationship.  I suspect that the has_many relationships are the problem.  But if your case is covered by the belongs_to relationship, then you are covered.

There is a less-used method called distance_sql which enables you to just get the distance calculation in SQL form.  You would use this if you ever found that GeoKit could not support your exact query requirements.  Its less elegant for sure, but saves you the trouble of having to code the distance calculation.

UK geocoding is still in the roadmap, but both Andre and I have a few other projects and side endeavors going on.

4 Comments »

Comment by Dan Kubb

March 13, 2007 @ 1:02 am

Bill, in the post you referenced there’s a comment about making the following possible:


stops = BusStop.find(:all, :origin => ‘1319 Fulton St. East, Grand Rapids MI 49503′, :order => ‘distance’)
distance_in_km = stops.first.distance(:km)
distance_in_miles = stops.first.distance(:miles)

What do you think about this?

Comment by Bill Eisenhauer

March 13, 2007 @ 4:38 am

Well, the request is basically to add a distance converter. As I suggested in a comment that James hasn’t yet approved, its easy enough to write yourself a helper for this which does the conversion for you.

Its trivial enough for us to implement, so maybe we should just do it. Maybe we should just extend Number to have a to_miles and a to_kms where it just takes the base value and applies the appropriate formula.

Comment by Xin

March 19, 2007 @ 12:17 am

Bill, I would love it if GeoKit supported UK Geocoding.

Have you any thoughts how they might be implemented? Since only Google AJAX Search API supports detailed UK geocoding.

Comment by dudzjosh

March 19, 2007 @ 3:18 pm

It seems this include problem is known already with rails.

http://dev.rubyonrails.org/ticket/5371

I’m currently trying to think of a work around…

RSS feed for comments on this post. TrackBack URI

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>