Class: RGeo::Geos::ZMFactory
- Inherits:
-
Object
- Object
- RGeo::Geos::ZMFactory
- Includes:
- Feature::Factory::Instance
- Defined in:
- lib/rgeo/geos/zm_factory.rb
Overview
A factory for Geos that handles both Z and M.
Class Method Summary collapse
-
.create(opts_ = {}) ⇒ Object
Create a new factory.
Instance Method Summary collapse
-
#buffer_resolution ⇒ Object
Returns the resolution used by buffer calculations on geometries created by this factory.
-
#collection(elems_) ⇒ Object
See ::RGeo::Feature::Factory#collection.
-
#coord_sys ⇒ Object
See ::RGeo::Feature::Factory#coord_sys.
-
#eql?(rhs_) ⇒ Boolean
(also: #==)
Factory equivalence test.
-
#initialize(opts_ = {}) ⇒ ZMFactory
constructor
:nodoc:.
-
#lenient_multi_polygon_assertions? ⇒ Boolean
Returns true if this factory is lenient with MultiPolygon assertions.
-
#line(start_, end_) ⇒ Object
See ::RGeo::Feature::Factory#line.
-
#line_string(points_) ⇒ Object
See ::RGeo::Feature::Factory#line_string.
-
#linear_ring(points_) ⇒ Object
See ::RGeo::Feature::Factory#linear_ring.
-
#m_factory ⇒ Object
Returns the m-only factory corresponding to this factory.
-
#multi_line_string(elems_) ⇒ Object
See ::RGeo::Feature::Factory#multi_line_string.
-
#multi_point(elems_) ⇒ Object
See ::RGeo::Feature::Factory#multi_point.
-
#multi_polygon(elems_) ⇒ Object
See ::RGeo::Feature::Factory#multi_polygon.
-
#override_cast(original_, ntype_, flags_) ⇒ Object
See ::RGeo::Feature::Factory#override_cast.
-
#parse_wkb(str_) ⇒ Object
See ::RGeo::Feature::Factory#parse_wkb.
-
#parse_wkt(str_) ⇒ Object
See ::RGeo::Feature::Factory#parse_wkt.
-
#point(x_, y_, z_ = 0, m_ = 0) ⇒ Object
See ::RGeo::Feature::Factory#point.
-
#polygon(outer_ring_, inner_rings_ = nil) ⇒ Object
See ::RGeo::Feature::Factory#polygon.
-
#proj4 ⇒ Object
See ::RGeo::Feature::Factory#proj4.
-
#property(name_) ⇒ Object
See ::RGeo::Feature::Factory#property.
-
#srid ⇒ Object
Returns the SRID of geometries created by this factory.
-
#z_factory ⇒ Object
Returns the z-only factory corresponding to this factory.
Constructor Details
#initialize(opts_ = {}) ⇒ ZMFactory
:nodoc:
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/rgeo/geos/zm_factory.rb', line 64 def initialize(opts_={}) # :nodoc: proj4_ = opts_[:proj4] coord_sys_ = opts_[:coord_sys] srid_ = opts_[:srid] if (!proj4_ || !coord_sys_) && srid_ && (db_ = opts_[:srs_database]) entry_ = db_.get(srid_.to_i) if entry_ proj4_ ||= entry_.proj4 coord_sys_ ||= entry_.coord_sys end end srid_ ||= coord_sys_. if coord_sys_ config_ = { :lenient_multi_polygon_assertions => opts_[:lenient_multi_polygon_assertions], :buffer_resolution => opts_[:buffer_resolution], :srid => srid_.to_i, :proj4 => proj4_, :coord_sys => coord_sys_, } @zfactory = Factory.create(config_.merge(:has_z_coordinate => true)) @mfactory = Factory.create(config_.merge(:has_m_coordinate => true)) end |
Class Method Details
.create(opts_ = {}) ⇒ Object
Create a new factory. Returns nil if the GEOS implementation is not supported.
55 56 57 58 |
# File 'lib/rgeo/geos/zm_factory.rb', line 55 def create(opts_={}) return nil unless Geos.supported? new(opts_) end |
Instance Method Details
#buffer_resolution ⇒ Object
Returns the resolution used by buffer calculations on geometries created by this factory
96 97 98 |
# File 'lib/rgeo/geos/zm_factory.rb', line 96 def buffer_resolution @zfactory._buffer_resolution end |
#collection(elems_) ⇒ Object
See ::RGeo::Feature::Factory#collection
193 194 195 |
# File 'lib/rgeo/geos/zm_factory.rb', line 193 def collection(elems_) ZMGeometryCollectionImpl.create(self, @zfactory.collection(elems_), @mfactory.collection(elems_)) end |
#coord_sys ⇒ Object
See ::RGeo::Feature::Factory#coord_sys
228 229 230 |
# File 'lib/rgeo/geos/zm_factory.rb', line 228 def coord_sys @zfactory.coord_sys end |
#eql?(rhs_) ⇒ Boolean Also known as: ==
Factory equivalence test.
124 125 126 |
# File 'lib/rgeo/geos/zm_factory.rb', line 124 def eql?(rhs_) rhs_.is_a?(ZMFactory) && rhs_.z_factory == @zfactory end |
#lenient_multi_polygon_assertions? ⇒ Boolean
Returns true if this factory is lenient with MultiPolygon assertions
103 104 105 |
# File 'lib/rgeo/geos/zm_factory.rb', line 103 def lenient_multi_polygon_assertions? @zfactory.lenient_multi_polygon_assertions? end |
#line(start_, end_) ⇒ Object
See ::RGeo::Feature::Factory#line
172 173 174 |
# File 'lib/rgeo/geos/zm_factory.rb', line 172 def line(start_, end_) ZMLineStringImpl.create(self, @zfactory.line(start_, end_), @mfactory.line(start_, end_)) end |
#line_string(points_) ⇒ Object
See ::RGeo::Feature::Factory#line_string
165 166 167 |
# File 'lib/rgeo/geos/zm_factory.rb', line 165 def line_string(points_) ZMLineStringImpl.create(self, @zfactory.line_string(points_), @mfactory.line_string(points_)) end |
#linear_ring(points_) ⇒ Object
See ::RGeo::Feature::Factory#linear_ring
179 180 181 |
# File 'lib/rgeo/geos/zm_factory.rb', line 179 def linear_ring(points_) ZMLineStringImpl.create(self, @zfactory.linear_ring(points_), @mfactory.linear_ring(points_)) end |
#m_factory ⇒ Object
Returns the m-only factory corresponding to this factory.
117 118 119 |
# File 'lib/rgeo/geos/zm_factory.rb', line 117 def m_factory @mfactory end |
#multi_line_string(elems_) ⇒ Object
See ::RGeo::Feature::Factory#multi_line_string
207 208 209 |
# File 'lib/rgeo/geos/zm_factory.rb', line 207 def multi_line_string(elems_) ZMMultiLineStringImpl.create(self, @zfactory.multi_line_string(elems_), @mfactory.multi_line_string(elems_)) end |
#multi_point(elems_) ⇒ Object
See ::RGeo::Feature::Factory#multi_point
200 201 202 |
# File 'lib/rgeo/geos/zm_factory.rb', line 200 def multi_point(elems_) ZMGeometryCollectionImpl.create(self, @zfactory.multi_point(elems_), @mfactory.multi_point(elems_)) end |
#multi_polygon(elems_) ⇒ Object
See ::RGeo::Feature::Factory#multi_polygon
214 215 216 |
# File 'lib/rgeo/geos/zm_factory.rb', line 214 def multi_polygon(elems_) ZMMultiPolygonImpl.create(self, @zfactory.multi_polygon(elems_), @mfactory.multi_polygon(elems_)) end |
#override_cast(original_, ntype_, flags_) ⇒ Object
See ::RGeo::Feature::Factory#override_cast
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 |
# File 'lib/rgeo/geos/zm_factory.rb', line 235 def override_cast(original_, ntype_, flags_) return nil unless Geos.supported? keep_subtype_ = flags_[:keep_subtype] force_new_ = flags_[:force_new] project_ = flags_[:project] type_ = original_.geometry_type ntype_ = type_ if keep_subtype_ && type_.include?(ntype_) case original_ when ZMGeometryImpl # Optimization if we're just changing factories, but to # another ZM factory. if original_.factory != self && ntype_ == type_ && (!project_ || original_.factory.proj4 == @proj4) then zresult_ = original_.z_geometry.dup zresult_._set_factory(@zfactory) mresult_ = original_.m_geometry.dup mresult_._set_factory(@mfactory) return original_.class.create(self, zresult_, mresult_) end # LineString conversion optimization. if (original_.factory != self || ntype_ != type_) && (!project_ || original_.factory.proj4 == @proj4) && type_.subtype_of?(Feature::LineString) && ntype_.subtype_of?(Feature::LineString) then klass_ = Factory::IMPL_CLASSES[ntype_] zresult_ = klass_._copy_from(@zfactory, original_.z_geometry) mresult_ = klass_._copy_from(@mfactory, original_.m_geometry) return ZMLineStringImpl.create(self, zresult_, mresult_) end end false end |
#parse_wkb(str_) ⇒ Object
See ::RGeo::Feature::Factory#parse_wkb
151 152 153 |
# File 'lib/rgeo/geos/zm_factory.rb', line 151 def parse_wkb(str_) WKRep::WKBParser.new(self).parse(str_) end |
#parse_wkt(str_) ⇒ Object
See ::RGeo::Feature::Factory#parse_wkt
144 145 146 |
# File 'lib/rgeo/geos/zm_factory.rb', line 144 def parse_wkt(str_) WKRep::WKTParser.new(self).parse(str_) end |
#point(x_, y_, z_ = 0, m_ = 0) ⇒ Object
See ::RGeo::Feature::Factory#point
158 159 160 |
# File 'lib/rgeo/geos/zm_factory.rb', line 158 def point(x_, y_, z_=0, m_=0) ZMPointImpl.create(self, @zfactory.point(x_, y_, z_), @mfactory.point(x_, y_, m_)) end |
#polygon(outer_ring_, inner_rings_ = nil) ⇒ Object
See ::RGeo::Feature::Factory#polygon
186 187 188 |
# File 'lib/rgeo/geos/zm_factory.rb', line 186 def polygon(outer_ring_, inner_rings_=nil) ZMPolygonImpl.create(self, @zfactory.polygon(outer_ring_, inner_rings_), @mfactory.polygon(outer_ring_, inner_rings_)) end |
#proj4 ⇒ Object
See ::RGeo::Feature::Factory#proj4
221 222 223 |
# File 'lib/rgeo/geos/zm_factory.rb', line 221 def proj4 @zfactory.proj4 end |
#property(name_) ⇒ Object
See ::RGeo::Feature::Factory#property
132 133 134 135 136 137 138 139 |
# File 'lib/rgeo/geos/zm_factory.rb', line 132 def property(name_) case name_ when :has_z_coordinate, :has_m_coordinate, :is_cartesian true else nil end end |
#srid ⇒ Object
Returns the SRID of geometries created by this factory.
88 89 90 |
# File 'lib/rgeo/geos/zm_factory.rb', line 88 def srid @zfactory._srid end |
#z_factory ⇒ Object
Returns the z-only factory corresponding to this factory.
110 111 112 |
# File 'lib/rgeo/geos/zm_factory.rb', line 110 def z_factory @zfactory end |