Class: Geodesics::Strategies::Lambert
- Inherits:
-
Object
- Object
- Geodesics::Strategies::Lambert
- Defined in:
- lib/geodesics/strategies/lambert.rb
Constant Summary collapse
- INVERSE_FLATTENING =
WGS 84
298.257223563
- FLATTENING =
1.0 / INVERSE_FLATTENING
- EQUATORIAL_RADIUS =
6_378_137
- CENTRAL_ANGLE =
CentralAngles::Haversine.new
Instance Method Summary collapse
- #distance(point1, point2) ⇒ Object
-
#initialize(equatorial_radius: EQUATORIAL_RADIUS, flattening: FLATTENING, central_angle: CENTRAL_ANGLE) ⇒ Lambert
constructor
A new instance of Lambert.
Constructor Details
#initialize(equatorial_radius: EQUATORIAL_RADIUS, flattening: FLATTENING, central_angle: CENTRAL_ANGLE) ⇒ Lambert
Returns a new instance of Lambert.
13 14 15 16 17 18 19 20 21 |
# File 'lib/geodesics/strategies/lambert.rb', line 13 def initialize( equatorial_radius: EQUATORIAL_RADIUS, flattening: FLATTENING, central_angle: CENTRAL_ANGLE ) @equatorial_radius = equatorial_radius @flattening = flattening @central_angle = central_angle end |
Instance Method Details
#distance(point1, point2) ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/geodesics/strategies/lambert.rb', line 23 def distance(point1, point2) sigma = @central_angle.call(point1, point2) beta1 = parametric_latitude(point1.latitude) beta2 = parametric_latitude(point2.latitude) p = (beta1 + beta2) / 2 q = (beta2 - beta1) / 2 x = (sigma - sin(sigma)) * sin(p)**2 * cos(q)**2 / cos(sigma / 2)**2 y = (sigma + sin(sigma)) * cos(p)**2 * sin(q)**2 / sin(sigma / 2)**2 @equatorial_radius * (sigma - @flattening * (x + y) / 2) end |