public
Description: A plugin for maps-based apps with 1) ActiveRecord extensions for geo-based finders (find within X miles); 2) geocoding through multiple providers with failover; 3) geo distance calculations; 4) IP-based location lookup; 5) before_filter for IP geocoder.; forked from official SVN repo to fix bugs
Homepage: http://geokit.rubyforge.org/
Clone URL: git://github.com/ptb/geokit.git
Further fix of distance calculation, this time in SQL. Now uses least() 
function, which is available in MySQL version 3.22.5+ and postgres 
versions 8.1+

Made it version 1.0.1

git-svn-id: http://geokit.rubyforge.org/svn/trunk@46 
9265c765-0211-4c68-b2df-6d1bd6e20c4d
lewisac (author)
Sun Jan 20 19:32:57 -0800 2008
commit  e65a8ed1e7f7d72a6e075cc425defcca1e233c23
tree    c7f3bf1e42294a9d7841d0640d67a50f09ea6a5b
parent  c4ec6089f095a36583720d8b4f8f0611841800b7
0
...
409
410
411
 
 
 
 
 
 
412
413
414
...
409
410
411
412
413
414
415
416
417
418
419
420
0
@@ -409,6 +409,12 @@ If you need to sort things post-query, you can do so:
0
 Obviously, each of the items in the array must have a latitude/longitude so
0
 they can be sorted by distance.
0
 
0
+Database Compatability
0
+=================================================================================
0
+GeoKit does *not* work with SQLite, as it lacks the necessary geometry functions.
0
+GeoKit works with MySQL (tested with version 5.0.41) or PostgreSQL (tested with version 8.2.6)
0
+GeoKit is known to *not* work with Postgres <8.1 -- it uses the least() funciton.
0
+
0
 
0
 HIGH-LEVEL NOTES ON WHAT'S WHERE
0
 =================================================================================
...
4
5
6
7
 
8
9
10
...
4
5
6
 
7
8
9
10
0
@@ -4,6 +4,6 @@ author:
0
   name_2: Andre Lewis
0
   homepage_2: http://www.earthcode.com
0
 summary: Geo distance calculations, distance calculation query support, geocoding for physical and ip addresses.
0
-version: 1.0
0
+version: 1.0.1
0
 rails_version: 1.0+
0
 license: MIT
0
\ No newline at end of file
...
380
381
382
383
 
384
385
 
386
387
388
389
 
390
391
 
392
393
394
...
380
381
382
 
383
384
 
385
386
387
388
 
389
390
 
391
392
393
394
0
@@ -380,15 +380,15 @@ module GeoKit
0
           case connection.adapter_name.downcase
0
           when "mysql"
0
             sql=<<-SQL_END
0
- (ACOS(COS(#{lat})*COS(#{lng})*COS(RADIANS(#{qualified_lat_column_name}))*COS(RADIANS(#{qualified_lng_column_name}))+
0
+ (ACOS(least(1,COS(#{lat})*COS(#{lng})*COS(RADIANS(#{qualified_lat_column_name}))*COS(RADIANS(#{qualified_lng_column_name}))+
0
                   COS(#{lat})*SIN(#{lng})*COS(RADIANS(#{qualified_lat_column_name}))*SIN(RADIANS(#{qualified_lng_column_name}))+
0
- SIN(#{lat})*SIN(RADIANS(#{qualified_lat_column_name})))*#{multiplier})
0
+ SIN(#{lat})*SIN(RADIANS(#{qualified_lat_column_name}))))*#{multiplier})
0
                   SQL_END
0
           when "postgresql"
0
             sql=<<-SQL_END
0
- (ACOS(COS(#{lat})*COS(#{lng})*COS(RADIANS(#{qualified_lat_column_name}))*COS(RADIANS(#{qualified_lng_column_name}))+
0
+ (ACOS(least(1,COS(#{lat})*COS(#{lng})*COS(RADIANS(#{qualified_lat_column_name}))*COS(RADIANS(#{qualified_lng_column_name}))+
0
                   COS(#{lat})*SIN(#{lng})*COS(RADIANS(#{qualified_lat_column_name}))*SIN(RADIANS(#{qualified_lng_column_name}))+
0
- SIN(#{lat})*SIN(RADIANS(#{qualified_lat_column_name})))*#{multiplier})
0
+ SIN(#{lat})*SIN(RADIANS(#{qualified_lat_column_name}))))*#{multiplier})
0
                   SQL_END
0
           else
0
             sql = "unhandled #{connection.adapter_name.downcase} adapter"
...
176
177
178
179
 
 
180
181
182
...
176
177
178
 
179
180
181
182
183
0
@@ -176,7 +176,8 @@ module GeoKit
0
           res.street_address = doc.elements['//ThoroughfareName'].text if doc.elements['//ThoroughfareName']
0
           # Translate accuracy into Yahoo-style token address, street, zip, zip+4, city, state, country
0
           # For Google, 1=low accuracy, 8=high accuracy
0
- address_details=doc.elements['//AddressDetails','urn:oasis:names:tc:ciq:xsdschema:xAL:2.0']
0
+ # old way -- address_details=doc.elements['//AddressDetails','urn:oasis:names:tc:ciq:xsdschema:xAL:2.0']
0
+ address_details=doc.elements['//*[local-name() = "AddressDetails"]']
0
           accuracy = address_details ? address_details.attributes['Accuracy'].to_i : 0
0
           res.precision=%w{unknown country state state city zip zip+4 street address}[accuracy]
0
           res.success=true

Comments

    No one has commented yet.