Class: GeoRuby::SimpleFeatures::Point::Endpointer
- Inherits:
-
Object
- Object
- GeoRuby::SimpleFeatures::Point::Endpointer
- Defined in:
- lib/georuby-ext/georuby/point.rb
Instance Attribute Summary collapse
-
#distance ⇒ Object
Returns the value of attribute distance.
-
#heading ⇒ Object
Returns the value of attribute heading.
-
#origin ⇒ Object
Returns the value of attribute origin.
-
#unit ⇒ Object
Returns the value of attribute unit.
Instance Method Summary collapse
- #arrival ⇒ Object
- #arrival_latitude ⇒ Object
- #arrival_longitude ⇒ Object
- #cos_distance_per_radius ⇒ Object
- #cos_latitude ⇒ Object
- #distance_per_radius ⇒ Object
-
#initialize(origin, heading, distance, options = {}) ⇒ Endpointer
constructor
A new instance of Endpointer.
- #latitude ⇒ Object
- #longitude ⇒ Object
- #radius ⇒ Object
- #sin_distance_per_radius ⇒ Object
- #sin_latitude ⇒ Object
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, = {}) @origin, @heading, @distance = origin, heading.deg2rad, distance end |
Instance Attribute Details
#distance ⇒ Object
Returns the value of attribute distance.
50 51 52 |
# File 'lib/georuby-ext/georuby/point.rb', line 50 def distance @distance end |
#heading ⇒ Object
Returns the value of attribute heading.
50 51 52 |
# File 'lib/georuby-ext/georuby/point.rb', line 50 def heading @heading end |
#origin ⇒ Object
Returns the value of attribute origin.
50 51 52 |
# File 'lib/georuby-ext/georuby/point.rb', line 50 def origin @origin end |
#unit ⇒ Object
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
#arrival ⇒ Object
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_latitude ⇒ Object
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_longitude ⇒ Object
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_radius ⇒ Object
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_latitude ⇒ Object
76 77 78 |
# File 'lib/georuby-ext/georuby/point.rb', line 76 def cos_latitude @cos_latitude ||= Math.cos(latitude) end |
#distance_per_radius ⇒ Object
60 61 62 |
# File 'lib/georuby-ext/georuby/point.rb', line 60 def distance_per_radius @distance_per_radius ||= distance / radius end |
#latitude ⇒ Object
72 73 74 |
# File 'lib/georuby-ext/georuby/point.rb', line 72 def latitude @latitude ||= origin.lat.deg2rad end |
#longitude ⇒ Object
84 85 86 |
# File 'lib/georuby-ext/georuby/point.rb', line 84 def longitude @longitude ||= origin.lng.deg2rad end |
#radius ⇒ Object
56 57 58 |
# File 'lib/georuby-ext/georuby/point.rb', line 56 def radius GeoRuby::SimpleFeatures::Point.earth_radius end |
#sin_distance_per_radius ⇒ Object
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_latitude ⇒ Object
80 81 82 |
# File 'lib/georuby-ext/georuby/point.rb', line 80 def sin_latitude @sin_latitude ||= Math.sin(latitude) end |