Class: RGeo::Geos::FFILineStringMethods::Segment
- Inherits:
-
Object
- Object
- RGeo::Geos::FFILineStringMethods::Segment
- Defined in:
- lib/georuby-ext/rgeo/geos/ffi_feature_methods.rb
Instance Attribute Summary collapse
-
#arrival ⇒ Object
readonly
Returns the value of attribute arrival.
-
#departure ⇒ Object
readonly
Returns the value of attribute departure.
-
#line ⇒ Object
Returns the value of attribute line.
-
#line_distance_at_departure ⇒ Object
Returns the value of attribute line_distance_at_departure.
Instance Method Summary collapse
- #distance ⇒ Object
-
#initialize(departure, arrival) ⇒ Segment
constructor
A new instance of Segment.
- #interpolate_point(location) ⇒ Object
- #line_distance_at_arrival ⇒ Object
- #location_in_line ⇒ Object
- #locator(target) ⇒ Object
- #square_of_distance ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(departure, arrival) ⇒ Segment
Returns a new instance of Segment.
120 121 122 |
# File 'lib/georuby-ext/rgeo/geos/ffi_feature_methods.rb', line 120 def initialize(departure, arrival) @departure, @arrival = departure, arrival end |
Instance Attribute Details
#arrival ⇒ Object (readonly)
Returns the value of attribute arrival.
118 119 120 |
# File 'lib/georuby-ext/rgeo/geos/ffi_feature_methods.rb', line 118 def arrival @arrival end |
#departure ⇒ Object (readonly)
Returns the value of attribute departure.
118 119 120 |
# File 'lib/georuby-ext/rgeo/geos/ffi_feature_methods.rb', line 118 def departure @departure end |
#line ⇒ Object
Returns the value of attribute line.
124 125 126 |
# File 'lib/georuby-ext/rgeo/geos/ffi_feature_methods.rb', line 124 def line @line end |
#line_distance_at_departure ⇒ Object
Returns the value of attribute line_distance_at_departure.
124 125 126 |
# File 'lib/georuby-ext/rgeo/geos/ffi_feature_methods.rb', line 124 def line_distance_at_departure @line_distance_at_departure end |
Instance Method Details
#distance ⇒ Object
144 145 146 |
# File 'lib/georuby-ext/rgeo/geos/ffi_feature_methods.rb', line 144 def distance @distance ||= departure.distance(arrival) end |
#interpolate_point(location) ⇒ Object
152 153 154 155 |
# File 'lib/georuby-ext/rgeo/geos/ffi_feature_methods.rb', line 152 def interpolate_point(location) dx, dy = (arrival.x - departure.x) * location, (arrival.y - departure.y) * location RGeo::Geos::FFIPoint.from_x_y departure.x + dx, departure.y + dy, line.srid end |
#line_distance_at_arrival ⇒ Object
126 127 128 |
# File 'lib/georuby-ext/rgeo/geos/ffi_feature_methods.rb', line 126 def line_distance_at_arrival line_distance_at_departure + distance end |
#location_in_line ⇒ Object
134 135 136 137 138 |
# File 'lib/georuby-ext/rgeo/geos/ffi_feature_methods.rb', line 134 def location_in_line if line and line_distance_at_departure line_distance_at_departure / line.length end end |
#locator(target) ⇒ Object
130 131 132 |
# File 'lib/georuby-ext/rgeo/geos/ffi_feature_methods.rb', line 130 def locator(target) PointLocator.new target, self end |
#square_of_distance ⇒ Object
140 141 142 |
# File 'lib/georuby-ext/rgeo/geos/ffi_feature_methods.rb', line 140 def square_of_distance distance**2 end |
#to_s ⇒ Object
148 149 150 |
# File 'lib/georuby-ext/rgeo/geos/ffi_feature_methods.rb', line 148 def to_s "#{departure.x},#{departure.y}..#{arrival.x},#{arrival.y}" end |