Class: GeoRuby::SimpleFeatures::MultiLineString
- Inherits:
-
Object
- Object
- GeoRuby::SimpleFeatures::MultiLineString
- Defined in:
- lib/georuby-ext/georuby/locators.rb
Defined Under Namespace
Classes: PointLocator
Instance Method Summary collapse
- #interpolate_point(location) ⇒ Object
- #locate_point(target) ⇒ Object
- #locators(point) ⇒ Object
- #nearest_locator(target) ⇒ Object
Instance Method Details
#interpolate_point(location) ⇒ Object
13 14 15 16 |
# File 'lib/georuby-ext/georuby/locators.rb', line 13 def interpolate_point(location) line_index, line_location = location.to_i, location % 1 lines[line_index].interpolate_point(line_location) end |
#locate_point(target) ⇒ Object
8 9 10 11 |
# File 'lib/georuby-ext/georuby/locators.rb', line 8 def locate_point(target) nearest_locator = nearest_locator(target) nearest_locator.location + nearest_locator.index end |
#locators(point) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/georuby-ext/georuby/locators.rb', line 22 def locators(point) [].tap do |locators| lines.each_with_index do |line, index| locators << PointLocator.new(point, line, index) end end end |
#nearest_locator(target) ⇒ Object
18 19 20 |
# File 'lib/georuby-ext/georuby/locators.rb', line 18 def nearest_locator(target) locators(target).min_by(&:distance_from_line) end |