Module: RGeo::Feature::Geometry
- Extended by:
- Type
- Included in:
- Curve, GeometryCollection, Point, Surface
- Defined in:
- lib/rgeo/feature/geometry.rb
Overview
SFS 1.1 Description
Geometry is the root class of the hierarchy. Geometry is an abstract (non-instantiable) class.
The instantiable subclasses of Geometry defined in this International Standard are restricted to 0, 1 and 2-dimensional geometric objects that exist in 2-dimensional coordinate space (R2).
All instantiable Geometry classes described in this part of ISO 19125 are defined so that valid instances of a Geometry class are topologically closed, i.e. all defined geometries include their boundary.
Notes
Geometry is defined as a module and is provided primarily for the sake of documentation. Implementations need not necessarily include this module itself. Therefore, you should not depend on the kind_of? method to check type. Instead, use the provided check_type class method (or === operator) defined in the Type module.
Some implementations may support higher dimensional objects or coordinate systems, despite the limits of the SFS.
Forms of equivalence
The Geometry model defines three forms of equivalence.
-
Spatial equivalence is the weakest form of equivalence, indicating that the objects represent the same region of space, but may be different representations of that region. For example, POINT(0 0) and a MULTIPOINT(0 0) are spatially equivalent, as are LINESTRING(0 0, 10 10) and GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0, 10 10, 0 0)). As a general rule, objects must have factories that are Factory#eql? in order to be spatially equivalent.
-
Objective equivalence is a stronger form of equivalence, indicating that the objects are the same representation, but may be different objects. All objectively equivalent objects are spatially equivalent, but not all spatially equivalent objects are objectively equivalent. For example, none of the examples in the spatial equivalence section above are objectively equivalent. However, two separate objects that both represent POINT(1 2) are objectively equivalent as well as spatially equivalent.
-
Objective identity is the strongest form, indicating that the references refer to the same object. Of course, all pairs of references with the same objective identity are both objectively equivalent and spatially equivalent.
Different methods test for different types of equivalence:
-
equals?
and==
test for spatial equivalence. -
eql?
tests for objective equivalence. -
equal?
tests for objective identity.
Constant Summary
Constants included from Type
Instance Method Summary collapse
-
#*(rhs_) ⇒ Object
Alias of the intersection method.
-
#+(rhs_) ⇒ Object
Alias of the union method.
-
#-(rhs_) ⇒ Object
Alias of the difference method.
-
#==(rhs_) ⇒ Object
Alias of the equals? method.
-
#as_binary ⇒ Object
SFS 1.1 Description.
-
#as_text ⇒ Object
SFS 1.1 Description.
-
#boundary ⇒ Object
SFS 1.1 Description.
-
#buffer(distance_) ⇒ Object
SFS 1.1 Description.
-
#contains?(another_geometry_) ⇒ Boolean
SFS 1.1 Description.
-
#convex_hull ⇒ Object
SFS 1.1 Description.
-
#crosses?(another_geometry_) ⇒ Boolean
SFS 1.1 Description.
-
#difference(another_geometry_) ⇒ Object
SFS 1.1 Description.
-
#dimension ⇒ Object
SFS 1.1 Description.
-
#disjoint?(another_geometry_) ⇒ Boolean
SFS 1.1 Description.
-
#distance(another_geometry_) ⇒ Object
SFS 1.1 Description.
-
#envelope ⇒ Object
SFS 1.1 Description.
-
#eql?(another_geometry_) ⇒ Boolean
Returns true if this geometric object is objectively equivalent to the given object.
-
#equals?(another_geometry_) ⇒ Boolean
SFS 1.1 Description.
-
#factory ⇒ Object
Returns a factory for creating features related to this one.
-
#geometry_type ⇒ Object
SFS 1.1 Description.
-
#intersection(another_geometry_) ⇒ Object
SFS 1.1 Description.
-
#intersects?(another_geometry_) ⇒ Boolean
SFS 1.1 Description.
-
#is_empty? ⇒ Boolean
SFS 1.1 Description.
-
#is_simple? ⇒ Boolean
SFS 1.1 Description.
-
#overlaps?(another_geometry_) ⇒ Boolean
SFS 1.1 Description.
-
#relate(another_geometry_, intersection_pattern_matrix_) ⇒ Object
SFS 1.1 Description.
-
#srid ⇒ Object
SFS 1.1 Description.
-
#sym_difference(another_geometry_) ⇒ Object
SFS 1.1 Description.
-
#touches?(another_geometry_) ⇒ Boolean
SFS 1.1 Description.
-
#union(another_geometry_) ⇒ Object
SFS 1.1 Description.
-
#within?(another_geometry_) ⇒ Boolean
SFS 1.1 Description.
Methods included from Type
check_type, subtype_of?, type_name
Instance Method Details
#*(rhs_) ⇒ Object
Alias of the intersection method.
604 605 606 |
# File 'lib/rgeo/feature/geometry.rb', line 604 def *(rhs_) intersection(rhs_) end |
#+(rhs_) ⇒ Object
Alias of the union method.
597 598 599 |
# File 'lib/rgeo/feature/geometry.rb', line 597 def +(rhs_) union(rhs_) end |
#-(rhs_) ⇒ Object
Alias of the difference method.
590 591 592 |
# File 'lib/rgeo/feature/geometry.rb', line 590 def -(rhs_) difference(rhs_) end |
#==(rhs_) ⇒ Object
Alias of the equals? method.
583 584 585 |
# File 'lib/rgeo/feature/geometry.rb', line 583 def ==(rhs_) equals?(rhs_) end |
#as_binary ⇒ Object
SFS 1.1 Description
Exports this geometric object to a specific Well-known Binary Representation of Geometry.
Notes
Returns a binary string.
213 214 215 |
# File 'lib/rgeo/feature/geometry.rb', line 213 def as_binary raise Error::UnsupportedOperation, "Method Geometry#as_binary not defined." end |
#as_text ⇒ Object
SFS 1.1 Description
Exports this geometric object to a specific Well-known Text Representation of Geometry.
Notes
Returns an ASCII string.
199 200 201 |
# File 'lib/rgeo/feature/geometry.rb', line 199 def as_text raise Error::UnsupportedOperation, "Method Geometry#as_text not defined." end |
#boundary ⇒ Object
SFS 1.1 Description
Returns the closure of the combinatorial boundary of this geometric object. Because the result of this function is a closure, and hence topologically closed, the resulting boundary can be represented using representational Geometry primitives.
Notes
Returns an object that supports the Geometry interface.
263 264 265 |
# File 'lib/rgeo/feature/geometry.rb', line 263 def boundary raise Error::UnsupportedOperation, "Method Geometry#boundary not defined." end |
#buffer(distance_) ⇒ Object
SFS 1.1 Description
Returns a geometric object that represents all Points whose distance from this geometric object is less than or equal to distance. Calculations are in the spatial reference system of this geometric object.
Notes
Returns an object that supports the Geometry interface.
486 487 488 |
# File 'lib/rgeo/feature/geometry.rb', line 486 def buffer(distance_) raise Error::UnsupportedOperation, "Method Geometry#buffer not defined." end |
#contains?(another_geometry_) ⇒ Boolean
SFS 1.1 Description
Returns true if this geometric object “spatially contains” another_geometry.
Notes
Returns a boolean value. Note that this is different from the SFS specification, which stipulates an integer return value.
Although implementations are free to attempt to handle another_geometry values that do not share the same factory as this geometry, strictly speaking, the result of comparing objects of different factories is undefined.
403 404 405 |
# File 'lib/rgeo/feature/geometry.rb', line 403 def contains?(another_geometry_) raise Error::UnsupportedOperation, "Method Geometry#contains? not defined." end |
#convex_hull ⇒ Object
SFS 1.1 Description
Returns a geometric object that represents the convex hull of this geometric object.
Notes
Returns an object that supports the Geometry interface.
500 501 502 |
# File 'lib/rgeo/feature/geometry.rb', line 500 def convex_hull raise Error::UnsupportedOperation, "Method Geometry#convex_hull not defined." end |
#crosses?(another_geometry_) ⇒ Boolean
SFS 1.1 Description
Returns true if this geometric object “spatially crosses” another_geometry.
Notes
Returns a boolean value. Note that this is different from the SFS specification, which stipulates an integer return value.
Although implementations are free to attempt to handle another_geometry values that do not share the same factory as this geometry, strictly speaking, the result of comparing objects of different factories is undefined.
363 364 365 |
# File 'lib/rgeo/feature/geometry.rb', line 363 def crosses?(another_geometry_) raise Error::UnsupportedOperation, "Method Geometry#crosses? not defined." end |
#difference(another_geometry_) ⇒ Object
SFS 1.1 Description
Returns a geometric object that represents the Point set difference of this geometric object with another_geometry.
Notes
Returns an object that supports the Geometry interface.
Although implementations are free to attempt to handle another_geometry values that do not share the same factory as this geometry, strictly speaking, the result of performing operations on objects of different factories is undefined.
557 558 559 |
# File 'lib/rgeo/feature/geometry.rb', line 557 def difference(another_geometry_) raise Error::UnsupportedOperation, "Method Geometry#difference not defined." end |
#dimension ⇒ Object
SFS 1.1 Description
The inherent dimension of this geometric object, which must be less than or equal to the coordinate dimension. This specification is restricted to geometries in 2-dimensional coordinate space.
Notes
Returns an integer. This value is -1 for an empty geometry, 0 for point geometries, 1 for curves, and 2 for surfaces.
136 137 138 |
# File 'lib/rgeo/feature/geometry.rb', line 136 def dimension raise Error::UnsupportedOperation, "Method Geometry#dimension not defined." end |
#disjoint?(another_geometry_) ⇒ Boolean
SFS 1.1 Description
Returns true if this geometric object is “spatially disjoint” from another_geometry.
Notes
Returns a boolean value. Note that this is different from the SFS specification, which stipulates an integer return value.
Although implementations are free to attempt to handle another_geometry values that do not share the same factory as this geometry, strictly speaking, the result of comparing objects of different factories is undefined.
303 304 305 |
# File 'lib/rgeo/feature/geometry.rb', line 303 def disjoint?(another_geometry_) raise Error::UnsupportedOperation, "Method Geometry#disjoint? not defined." end |
#distance(another_geometry_) ⇒ Object
SFS 1.1 Description
Returns the shortest distance between any two Points in the two geometric objects as calculated in the spatial reference system of this geometric object.
Notes
Returns a floating-point scalar value.
Although implementations are free to attempt to handle another_geometry values that do not share the same factory as this geometry, strictly speaking, the result of measuring the distance between objects of different factories is undefined.
470 471 472 |
# File 'lib/rgeo/feature/geometry.rb', line 470 def distance(another_geometry_) raise Error::UnsupportedOperation, "Method Geometry#distance not defined." end |
#envelope ⇒ Object
SFS 1.1 Description
The minimum bounding box for this Geometry, returned as a Geometry. The polygon is defined by the corner points of the bounding box [(MINX, MINY), (MAXX, MINY), (MAXX, MAXY), (MINX, MAXY), (MINX, MINY)].
Notes
Returns an object that supports the Geometry interface.
185 186 187 |
# File 'lib/rgeo/feature/geometry.rb', line 185 def envelope raise Error::UnsupportedOperation, "Method Geometry#envelope not defined." end |
#eql?(another_geometry_) ⇒ Boolean
Returns true if this geometric object is objectively equivalent to the given object.
120 121 122 |
# File 'lib/rgeo/feature/geometry.rb', line 120 def eql?(another_geometry_) raise Error::UnsupportedOperation, "Method Geometry#eql? not defined." end |
#equals?(another_geometry_) ⇒ Boolean
SFS 1.1 Description
Returns true if this geometric object is “spatially equal” to another_geometry.
Notes
Returns a boolean value. Note that this is different from the SFS specification, which stipulates an integer return value.
Although implementations are free to attempt to handle another_geometry values that do not share the same factory as this geometry, strictly speaking, the result of comparing objects of different factories is undefined.
283 284 285 |
# File 'lib/rgeo/feature/geometry.rb', line 283 def equals?(another_geometry_) raise Error::UnsupportedOperation, "Method Geometry#equals? not defined." end |
#factory ⇒ Object
Returns a factory for creating features related to this one. This does not necessarily need to be the same factory that created this object, but it should create objects that are “compatible” with this one. (i.e. they should be in the same spatial reference system by default, and it should be possible to perform relational operations on them.)
112 113 114 |
# File 'lib/rgeo/feature/geometry.rb', line 112 def factory raise Error::UnsupportedOperation, "Method Geometry#factory not defined." end |
#geometry_type ⇒ Object
SFS 1.1 Description
Returns the instantiable subtype of Geometry of which this geometric object is an instantiable member.
Notes
Returns one of the type modules in RGeo::Feature. e.g. a point object would return RGeo::Feature::Point. Note that this is different from the SFS specification, which stipulates that the string name of the type is returned. To obtain the name string, call the type_name
method of the returned module.
154 155 156 |
# File 'lib/rgeo/feature/geometry.rb', line 154 def geometry_type raise Error::UnsupportedOperation, "Method Geometry#geometry_type not defined." end |
#intersection(another_geometry_) ⇒ Object
SFS 1.1 Description
Returns a geometric object that represents the Point set intersection of this geometric object with another_geometry.
Notes
Returns an object that supports the Geometry interface.
Although implementations are free to attempt to handle another_geometry values that do not share the same factory as this geometry, strictly speaking, the result of performing operations on objects of different factories is undefined.
519 520 521 |
# File 'lib/rgeo/feature/geometry.rb', line 519 def intersection(another_geometry_) raise Error::UnsupportedOperation, "Method Geometry#intersection not defined." end |
#intersects?(another_geometry_) ⇒ Boolean
SFS 1.1 Description
Returns true if this geometric object “spatially intersects” another_geometry.
Notes
Returns a boolean value. Note that this is different from the SFS specification, which stipulates an integer return value.
Although implementations are free to attempt to handle another_geometry values that do not share the same factory as this geometry, strictly speaking, the result of comparing objects of different factories is undefined.
323 324 325 |
# File 'lib/rgeo/feature/geometry.rb', line 323 def intersects?(another_geometry_) raise Error::UnsupportedOperation, "Method Geometry#intersects? not defined." end |
#is_empty? ⇒ Boolean
SFS 1.1 Description
Returns true if this geometric object is the empty Geometry. If true, then this geometric object represents the empty point set for the coordinate space.
Notes
Returns a boolean value. Note that this is different from the SFS specification, which stipulates an integer return value.
229 230 231 |
# File 'lib/rgeo/feature/geometry.rb', line 229 def is_empty? raise Error::UnsupportedOperation, "Method Geometry#is_empty? not defined." end |
#is_simple? ⇒ Boolean
SFS 1.1 Description
Returns true if this geometric object has no anomalous geometric points, such as self intersection or self tangency. The description of each instantiable geometric class will include the specific conditions that cause an instance of that class to be classified as not simple.
Notes
Returns a boolean value. Note that this is different from the SFS specification, which stipulates an integer return value.
247 248 249 |
# File 'lib/rgeo/feature/geometry.rb', line 247 def is_simple? raise Error::UnsupportedOperation, "Method Geometry#is_simple? not defined." end |
#overlaps?(another_geometry_) ⇒ Boolean
SFS 1.1 Description
Returns true if this geometric object “spatially overlaps” another_geometry.
Notes
Returns a boolean value. Note that this is different from the SFS specification, which stipulates an integer return value.
Although implementations are free to attempt to handle another_geometry values that do not share the same factory as this geometry, strictly speaking, the result of comparing objects of different factories is undefined.
423 424 425 |
# File 'lib/rgeo/feature/geometry.rb', line 423 def overlaps?(another_geometry_) raise Error::UnsupportedOperation, "Method Geometry#overlaps? not defined." end |
#relate(another_geometry_, intersection_pattern_matrix_) ⇒ Object
SFS 1.1 Description
Returns true if this geometric object is spatially related to another_geometry by testing for intersections between the interior, boundary and exterior of the two geometric objects as specified by the values in the intersection_pattern_matrix.
Notes
The intersection_pattern_matrix is provided as a nine-character string in row-major order, representing the dimensionalities of the different intersections in the DE-9IM. Supported characters include T, F, *, 0, 1, and 2.
Returns a boolean value. Note that this is different from the SFS specification, which stipulates an integer return value.
Although implementations are free to attempt to handle another_geometry values that do not share the same factory as this geometry, strictly speaking, the result of comparing objects of different factories is undefined.
450 451 452 |
# File 'lib/rgeo/feature/geometry.rb', line 450 def relate(another_geometry_, intersection_pattern_matrix_) raise Error::UnsupportedOperation, "Method Geometry#relate not defined." end |
#srid ⇒ Object
SFS 1.1 Description
Returns the Spatial Reference System ID for this geometric object.
Notes
Returns an integer.
This will normally be a foreign key to an index of reference systems stored in either the same or some other datastore.
170 171 172 |
# File 'lib/rgeo/feature/geometry.rb', line 170 def srid raise Error::UnsupportedOperation, "Method Geometry#srid not defined." end |
#sym_difference(another_geometry_) ⇒ Object
SFS 1.1 Description
Returns a geometric object that represents the Point set symmetric difference of this geometric object with another_geometry.
Notes
Returns an object that supports the Geometry interface.
Although implementations are free to attempt to handle another_geometry values that do not share the same factory as this geometry, strictly speaking, the result of performing operations on objects of different factories is undefined.
576 577 578 |
# File 'lib/rgeo/feature/geometry.rb', line 576 def sym_difference(another_geometry_) raise Error::UnsupportedOperation, "Method Geometry#sym_difference not defined." end |
#touches?(another_geometry_) ⇒ Boolean
SFS 1.1 Description
Returns true if this geometric object “spatially touches” another_geometry.
Notes
Returns a boolean value. Note that this is different from the SFS specification, which stipulates an integer return value.
Although implementations are free to attempt to handle another_geometry values that do not share the same factory as this geometry, strictly speaking, the result of comparing objects of different factories is undefined.
343 344 345 |
# File 'lib/rgeo/feature/geometry.rb', line 343 def touches?(another_geometry_) raise Error::UnsupportedOperation, "Method Geometry#touches? not defined." end |
#union(another_geometry_) ⇒ Object
SFS 1.1 Description
Returns a geometric object that represents the Point set union of this geometric object with another_geometry.
Notes
Returns an object that supports the Geometry interface.
Although implementations are free to attempt to handle another_geometry values that do not share the same factory as this geometry, strictly speaking, the result of performing operations on objects of different factories is undefined.
538 539 540 |
# File 'lib/rgeo/feature/geometry.rb', line 538 def union(another_geometry_) raise Error::UnsupportedOperation, "Method Geometry#union not defined." end |
#within?(another_geometry_) ⇒ Boolean
SFS 1.1 Description
Returns true if this geometric object is “spatially within” another_geometry.
Notes
Returns a boolean value. Note that this is different from the SFS specification, which stipulates an integer return value.
Although implementations are free to attempt to handle another_geometry values that do not share the same factory as this geometry, strictly speaking, the result of comparing objects of different factories is undefined.
383 384 385 |
# File 'lib/rgeo/feature/geometry.rb', line 383 def within?(another_geometry_) raise Error::UnsupportedOperation, "Method Geometry#within? not defined." end |