Module: GeoFoo
- Defined in:
- lib/geo_foo.rb,
lib/geo_foo/core.rb,
lib/geo_foo/scope.rb,
lib/geo_foo/active_record.rb
Defined Under Namespace
Modules: ActiveRecord, ClassMethods, Core, InstanceMethods, Scope
Constant Summary collapse
- SRID =
WGS-84
4326
- EarthRadius =
meters (as used by postgis’ ST_Distance_Sphere())
6370986.0
Class Method Summary collapse
-
.as_point(lat, lon) ⇒ Object
return a postgis string representation of the given coordinates.
Class Method Details
.as_point(lat, lon) ⇒ Object
return a postgis string representation of the given coordinates
7 8 9 10 11 12 |
# File 'lib/geo_foo/core.rb', line 7 def self.as_point lat, lon # Intentionally use (lat,lon) and not (lon,lat), because latitude is the # 'horizontal' coordinate. # See: http://archives.postgresql.org/pgsql-general/2008-02/msg01393.php "ST_GeomFromText('POINT(#{lon} #{lat})', #{SRID})" end |