Class: GeoRuby::SimpleFeatures::MultiLineString

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

Defined Under Namespace

Classes: PointLocator

Instance Method Summary collapse

Instance Method Details

#interpolate_point(location) ⇒ Object



10
11
12
13
14
15
# File 'lib/georuby-ext/georuby/locators.rb', line 10

def interpolate_point(location)
  line_index, line_location = location.to_i, location % 1
  if line = lines[line_index]
    line.interpolate_point(line_location)
  end
end

#locate_point(target) ⇒ Object



5
6
7
8
# File 'lib/georuby-ext/georuby/locators.rb', line 5

def locate_point(target)
  nearest_locator = nearest_locator(target)
  nearest_locator.location + nearest_locator.index
end

#locators(point) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/georuby-ext/georuby/locators.rb', line 21

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



17
18
19
# File 'lib/georuby-ext/georuby/locators.rb', line 17

def nearest_locator(target)
  locators(target).min_by(&:distance_from_line)
end