Module: RGeo::Feature::Type
- Included in:
- Curve, Geometry, GeometryCollection, Line, LineString, LinearRing, MultiCurve, MultiLineString, MultiPoint, MultiPolygon, MultiSurface, Point, Polygon, Surface
- Defined in:
- lib/rgeo/feature/types.rb
Overview
These methods are available as module methods (not instance methods) of the various feature types. For example, you may determine whether a feature object is a point by calling:
::RGeo::Feature::Point.check_type(object)
A corresponding === operator is provided so you can use the type modules in a case-when clause.
You may also use the presence of this module to determine whether a particular object is a feature type:
object.kind_of?(::RGeo::Feature::Type)
Constant Summary collapse
Instance Method Summary collapse
-
#check_type(rhs_) ⇒ Object
(also: #===)
Returns true if the given object is this type or a subtype thereof, or if it is a feature object whose geometry_type is this type or a subtype thereof.
-
#subtype_of?(type_) ⇒ Boolean
Returns true if this type is the same type or a subtype of the given type.
-
#type_name ⇒ Object
Returns the OpenGIS type name of this type.
Instance Method Details
#check_type(rhs_) ⇒ Object Also known as: ===
Returns true if the given object is this type or a subtype thereof, or if it is a feature object whose geometry_type is this type or a subtype thereof.
Note that feature objects need not actually include this module.
78 79 80 81 |
# File 'lib/rgeo/feature/types.rb', line 78 def check_type(rhs_) rhs_ = rhs_.geometry_type if rhs_.kind_of?(Feature::Instance) rhs_.kind_of?(Type) && (rhs_ == self || rhs_.include?(self)) end |
#subtype_of?(type_) ⇒ Boolean
Returns true if this type is the same type or a subtype of the given type.
88 89 90 |
# File 'lib/rgeo/feature/types.rb', line 88 def subtype_of?(type_) self == type_ || self.include?(type_) end |
#type_name ⇒ Object
Returns the OpenGIS type name of this type.
95 96 97 |
# File 'lib/rgeo/feature/types.rb', line 95 def type_name self.name.sub('RGeo::Feature::', '') end |