Class: GeoRuby::SimpleFeatures::Point::Endpointer

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(origin, heading, distance, options = {}) ⇒ Endpointer

Returns a new instance of Endpointer.



52
53
54
# File 'lib/georuby-ext/georuby/point.rb', line 52

def initialize(origin, heading, distance, options = {})
  @origin, @heading, @distance = origin, heading.deg2rad, distance
end

Instance Attribute Details

#distanceObject

Returns the value of attribute distance.



50
51
52
# File 'lib/georuby-ext/georuby/point.rb', line 50

def distance
  @distance
end

#headingObject

Returns the value of attribute heading.



50
51
52
# File 'lib/georuby-ext/georuby/point.rb', line 50

def heading
  @heading
end

#originObject

Returns the value of attribute origin.



50
51
52
# File 'lib/georuby-ext/georuby/point.rb', line 50

def origin
  @origin
end

#unitObject

Returns the value of attribute unit.



50
51
52
# File 'lib/georuby-ext/georuby/point.rb', line 50

def unit
  @unit
end

Instance Method Details

#arrivalObject



98
99
# File 'lib/georuby-ext/georuby/point.rb', line 98

def arrival
origin.change :x => arrival_longitude.rad2deg, :y => arrival_latitude.rad2deg    end

#arrival_latitudeObject



88
89
90
91
# File 'lib/georuby-ext/georuby/point.rb', line 88

def arrival_latitude
  Math.asin(sin_latitude * cos_distance_per_radius +
            cos_latitude * sin_distance_per_radius * Math.cos(heading))
end

#arrival_longitudeObject



93
94
95
96
# File 'lib/georuby-ext/georuby/point.rb', line 93

def arrival_longitude
  longitude + Math.atan2(Math.sin(heading) * sin_distance_per_radius * cos_latitude,
                         cos_distance_per_radius - sin_latitude * Math.sin(arrival_latitude))
end

#cos_distance_per_radiusObject



64
65
66
# File 'lib/georuby-ext/georuby/point.rb', line 64

def cos_distance_per_radius
  @cos_distance_per_radius ||= Math.cos(distance_per_radius)
end

#cos_latitudeObject



76
77
78
# File 'lib/georuby-ext/georuby/point.rb', line 76

def cos_latitude
  @cos_latitude ||= Math.cos(latitude)
end

#distance_per_radiusObject



60
61
62
# File 'lib/georuby-ext/georuby/point.rb', line 60

def distance_per_radius
  @distance_per_radius ||= distance / radius
end

#latitudeObject



72
73
74
# File 'lib/georuby-ext/georuby/point.rb', line 72

def latitude
  @latitude ||= origin.lat.deg2rad
end

#longitudeObject



84
85
86
# File 'lib/georuby-ext/georuby/point.rb', line 84

def longitude
  @longitude ||= origin.lng.deg2rad
end

#radiusObject



56
57
58
# File 'lib/georuby-ext/georuby/point.rb', line 56

def radius
  GeoRuby::SimpleFeatures::Point.earth_radius
end

#sin_distance_per_radiusObject



68
69
70
# File 'lib/georuby-ext/georuby/point.rb', line 68

def sin_distance_per_radius
  @sin_distance_per_radius ||= Math.sin(distance_per_radius)
end

#sin_latitudeObject



80
81
82
# File 'lib/georuby-ext/georuby/point.rb', line 80

def sin_latitude
  @sin_latitude ||= Math.sin(latitude)
end