Class: GeoKit::LatLng

Inherits:
Object
  • Object
show all
Defined in:
lib/georuby-ext/geokit.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_pro4j(point, ratio = 1) ⇒ Object



27
28
29
# File 'lib/georuby-ext/geokit.rb', line 27

def self.from_pro4j(point, ratio = 1)
  new point.lat * ratio, point.lon * ratio
end

Instance Method Details

#google_to_wgs84Object



18
19
20
21
# File 'lib/georuby-ext/geokit.rb', line 18

def google_to_wgs84
  ActiveSupport::Deprecation.warn "use Point geometry which supports srid"
  self.class.from_pro4j Proj4::Projection.google.transform(Proj4::Projection.wgs84, self.proj4_point.x, self.proj4_point.y), 180 / Math::PI 
end

#proj4_point(ratio = 1) ⇒ Object



23
24
25
# File 'lib/georuby-ext/geokit.rb', line 23

def proj4_point(ratio = 1)
  Proj4::Point.new(lng * ratio, lat * ratio)
end

#valid?Boolean

Returns:

  • (Boolean)


4
5
6
7
8
# File 'lib/georuby-ext/geokit.rb', line 4

def valid?
  self.lat and self.lng and
    self.lat >= -90 and self.lat <= 90 and
    self.lng >= -180 and self.lng <= 180
end

#wgs84_to_googleObject

DEPRECATED Use Point geometry which supports srid



13
14
15
16
# File 'lib/georuby-ext/geokit.rb', line 13

def wgs84_to_google
  ActiveSupport::Deprecation.warn "use Point geometry which supports srid"
  self.class.from_pro4j Proj4::Projection.wgs84.transform Proj4::Projection.google, self.proj4_point(Math::PI / 180).x, self.proj4_point(Math::PI / 180).y
end