Class: MarsGeo::Point

Inherits:
Object
  • Object
show all
Defined in:
lib/mars_geo/point.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(lat, lng) ⇒ Point

Returns a new instance of Point.



6
7
8
# File 'lib/mars_geo/point.rb', line 6

def initialize(lat,lng)
  self.lat, self.lng = lat, lng
end

Instance Attribute Details

#latObject

Returns the value of attribute lat.



3
4
5
# File 'lib/mars_geo/point.rb', line 3

def lat
  @lat
end

#lngObject

Returns the value of attribute lng.



3
4
5
# File 'lib/mars_geo/point.rb', line 3

def lng
  @lng
end

Instance Method Details

#offsetObject



12
13
14
15
16
17
18
19
20
# File 'lib/mars_geo/point.rb', line 12

def offset
    temp_lat = self.lat * 3686400
    temp_lng = self.lng * 3686400
    converter = Converter.new
    hash_point = converter.wgtochina_lb(1,temp_lat.to_i,temp_lng.to_i,0,0,0)
    temp_lat = hash_point[:lat] / 3686400.0
    temp_lng = hash_point[:lng] / 3686400.0
    Point.new(temp_lat,temp_lng)
end