class GeoRuby::SimpleFeatures::LinearRing

Represents a linear ring, which is a closed line string (see LineString). Currently, no check is performed to verify if the linear ring is really closed.

Public Class Methods

new(srid = DEFAULT_SRID, with_z = false, with_m = false) click to toggle source
# File lib/geo_ruby/simple_features/linear_ring.rb, line 8
def initialize(srid = DEFAULT_SRID, with_z = false, with_m = false)
  super(srid, with_z, with_m)
end

Public Instance Methods

contains_point?(point) click to toggle source

Does this linear string contain the given point? We use the algorithm described here:

www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html

# File lib/geo_ruby/simple_features/linear_ring.rb, line 22
def contains_point?(point)
  x, y = point.x, point.y
  tuples = @points.zip(@points[1..-1] + [@points[0]])
  crossings =
    tuples.select do |a, b|
      (b.y > y != a.y > y) && (x < (a.x - b.x) * (y - b.y) / (a.y - b.y) + b.x)
    end

  crossings.size % 2 == 1
end
kml_representation(options = {}) click to toggle source
# File lib/geo_ruby/simple_features/linear_ring.rb, line 14
def kml_representation(options = {})
  orig_kml_representation(options).gsub('LineString', 'LinearRing')
end
Also aliased as: orig_kml_representation
orig_kml_representation(options = {})

fix kml export

Alias for: kml_representation