Module: RGeo::Geos::FFIMultiLineStringMethods

Defined in:
lib/georuby-ext/rgeo/geos/ffi_feature_methods.rb

Defined Under Namespace

Classes: PointLocator

Instance Method Summary collapse

Instance Method Details

#interpolate_point(location) ⇒ Object



205
206
207
208
209
210
# File 'lib/georuby-ext/rgeo/geos/ffi_feature_methods.rb', line 205

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

#locate_point(target) ⇒ Object



200
201
202
203
# File 'lib/georuby-ext/rgeo/geos/ffi_feature_methods.rb', line 200

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

#locators(point) ⇒ Object



216
217
218
219
220
221
222
# File 'lib/georuby-ext/rgeo/geos/ffi_feature_methods.rb', line 216

def locators(point)
  [].tap do |locators|
    geometries.each_with_index do |line, index| 
      locators << PointLocator.new(point, line, index) 
    end
  end
end

#nearest_locator(target) ⇒ Object



212
213
214
# File 'lib/georuby-ext/rgeo/geos/ffi_feature_methods.rb', line 212

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