Sha256: d21bcaa45a442be106c7c8d58896e09dcedfc73e772cb2e7b202e9a867f5caa0

Contents?: true

Size: 590 Bytes

Versions: 1

Compression:

Stored size: 590 Bytes

Contents

module GeoKit
  class LatLng

    def valid?
      self.lat and self.lng
    end

    def wgs84_to_google
      self.class.from_pro4j Proj4::Projection.wgs84.transform Proj4::Projection.google, self.proj4_point(Math::PI / 180)
    end

    def google_to_wgs84
      self.class.from_pro4j Proj4::Projection.google.transform(Proj4::Projection.wgs84, self.proj4_point), 180 / Math::PI  
    end

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

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

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
georuby-ext-0.0.1 lib/georuby-ext/geokit.rb