Class: GeoRuby::SimpleFeatures::LinearRing
- Inherits:
-
LineString
- Object
- Geometry
- LineString
- GeoRuby::SimpleFeatures::LinearRing
- 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.
Instance Attribute Summary
Attributes inherited from LineString
Attributes inherited from Geometry
Instance Method Summary collapse
-
#contains_point?(point) ⇒ Boolean
Does this linear string contain the given point? We use the algorithm described here:.
-
#initialize(srid = DEFAULT_SRID, with_z = false, with_m = false) ⇒ LinearRing
constructor
A new instance of LinearRing.
- #kml_representation(options = {}) ⇒ Object
-
#orig_kml_representation ⇒ Object
fix kml export.
Methods inherited from LineString
#==, #as_json, #binary_geometry_type, #binary_representation, #bounding_box, #clockwise?, #do_simplify, #euclidian_distance, from_coordinates, from_points, #georss_gml_representation, #georss_poslist, #georss_simple_representation, #georss_w3cgeo_representation, #intersects?, #is_closed, #kml_poslist, #m_range, #method_missing, #simplify, #spherical_distance, #text_geometry_type, #text_representation, #to_coordinates, #to_json
Methods inherited from Geometry
#as_ewkb, #as_ewkt, #as_georss, #as_hex_ewkb, #as_hex_wkb, #as_kml, #as_wkb, #as_wkt, #bounding_box, #envelope, from_ewkb, from_ewkt, from_geojson, from_georss, from_georss_with_tags, from_hex_ewkb, from_kml, #m_range
Constructor Details
#initialize(srid = DEFAULT_SRID, with_z = false, with_m = false) ⇒ LinearRing
Returns a new instance of LinearRing.
11 12 13 |
# File 'lib/geo_ruby/simple_features/linear_ring.rb', line 11 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
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/geo_ruby/simple_features/linear_ring.rb', line 25 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
17 18 19 |
# File 'lib/geo_ruby/simple_features/linear_ring.rb', line 17 def kml_representation( = {}) orig_kml_representation().gsub('LineString', 'LinearRing') end |
#orig_kml_representation ⇒ Object
fix kml export
16 |
# File 'lib/geo_ruby/simple_features/linear_ring.rb', line 16 alias_method :orig_kml_representation, :kml_representation |