# Class: GeoRuby::SimpleFeatures::LinearRing

Inherits:
LineString
show all
Defined in:
lib/geo_ruby/simple_features/linear_ring.rb

## Overview

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.

#points

## Instance Method Summary collapse

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

• constructor

A new instance of LinearRing.

• fix kml export.

## Constructor Details

### #initialize(srid = DEFAULT_SRID, with_z = false, with_m = false) ⇒ LinearRing

Returns a new instance of LinearRing.

 ``` 8 9 10``` ```# 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```

## Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class GeoRuby::SimpleFeatures::LineString

## Instance Method Details

### #contains_point?(point) ⇒ Boolean

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

Returns:

• (Boolean)
 ``` 22 23 24 25 26 27 28 29 30 31``` ```# 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 = {}) ⇒ Object

 ``` 14 15 16``` ```# File 'lib/geo_ruby/simple_features/linear_ring.rb', line 14 def kml_representation(options = {}) orig_kml_representation(options).gsub('LineString', 'LinearRing') end```

### #orig_kml_representation ⇒ Object

fix kml export

 ``` 13``` ```# File 'lib/geo_ruby/simple_features/linear_ring.rb', line 13 alias_method :orig_kml_representation, :kml_representation```