Class: LongLat

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

Constant Summary collapse

RHO =

earth radius in meters

6378200

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(longitude, latitude) ⇒ LongLat

Returns a new instance of LongLat.



7
8
9
# File 'lib/long_lat.rb', line 7

def initialize(longitude, latitude)
  @longitude, @latitude = longitude, latitude
end

Instance Attribute Details

#latitudeObject

Returns the value of attribute latitude.



5
6
7
# File 'lib/long_lat.rb', line 5

def latitude
  @latitude
end

#longitudeObject

Returns the value of attribute longitude.



5
6
7
# File 'lib/long_lat.rb', line 5

def longitude
  @longitude
end

Class Method Details

.from_data(data) ⇒ Object



11
12
13
14
15
16
# File 'lib/long_lat.rb', line 11

def self.from_data(data)
  new(
    BinData::Int32le.read(data) / 3600000.0,
    BinData::Int32le.read(data) / 3600000.0
  )
end

Instance Method Details

#distance_to(other) ⇒ Object



18
19
20
# File 'lib/long_lat.rb', line 18

def distance_to(other)
  distance_point_to_point(point_matrix, other.point_matrix)
end

#point_matrixObject



22
23
24
25
26
# File 'lib/long_lat.rb', line 22

def point_matrix
  Matrix[[RHO * sin_phi * cos_theta],
         [RHO * sin_phi * sin_theta],
         [RHO * cos_phi]]
end