Class: RGeo::Cartesian::Factory
- Inherits:
-
Object
- Object
- RGeo::Cartesian::Factory
- Includes:
- Feature::Factory::Instance
- Defined in:
- lib/rgeo/cartesian/factory.rb
Overview
This class implements the factory for the simple cartesian implementation.
Instance Method Summary collapse
-
#collection(elems_) ⇒ Object
See ::RGeo::Feature::Factory#collection.
-
#coord_sys ⇒ Object
See ::RGeo::Feature::Factory#coord_sys.
-
#eql?(rhs_) ⇒ Boolean
(also: #==)
Equivalence test.
-
#initialize(opts_ = {}) ⇒ Factory
constructor
Create a new simple cartesian factory.
-
#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.
-
#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.
-
#parse_wkb(str_) ⇒ Object
See ::RGeo::Feature::Factory#parse_wkb.
-
#parse_wkt(str_) ⇒ Object
See ::RGeo::Feature::Factory#parse_wkt.
-
#point(x_, y_, *extra_) ⇒ 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.
Constructor Details
#initialize(opts_ = {}) ⇒ Factory
Create a new simple cartesian factory.
See ::RGeo::Cartesian::simple_factory for a list of supported options.
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/rgeo/cartesian/factory.rb', line 54 def initialize(opts_={}) @has_z = opts_[:has_z_coordinate] ? true : false @has_m = opts_[:has_m_coordinate] ? true : false @proj4 = opts_[:proj4] if CoordSys::Proj4.supported? if @proj4.kind_of?(::String) || @proj4.kind_of?(::Hash) @proj4 = CoordSys::Proj4.create(@proj4) end else @proj4 = nil end srid_ = opts_[:srid] @coord_sys = opts_[:coord_sys] if @coord_sys.kind_of?(::String) @coord_sys = CoordSys::CS.create_from_wkt(@coord_sys) rescue nil end 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 @srid = srid_.to_i end |
Instance Method Details
#collection(elems_) ⇒ Object
See ::RGeo::Feature::Factory#collection
164 165 166 |
# File 'lib/rgeo/cartesian/factory.rb', line 164 def collection(elems_) GeometryCollectionImpl.new(self, elems_) rescue nil end |
#coord_sys ⇒ Object
See ::RGeo::Feature::Factory#coord_sys
199 200 201 |
# File 'lib/rgeo/cartesian/factory.rb', line 199 def coord_sys @coord_sys end |
#eql?(rhs_) ⇒ Boolean Also known as: ==
Equivalence test.
84 85 86 |
# File 'lib/rgeo/cartesian/factory.rb', line 84 def eql?(rhs_) rhs_.is_a?(self.class) && @srid == rhs_.srid && @has_z == rhs_.property(:has_z_coordinate) && @has_m == rhs_.property(:has_m_coordinate) end |
#line(start_, end_) ⇒ Object
See ::RGeo::Feature::Factory#line
143 144 145 |
# File 'lib/rgeo/cartesian/factory.rb', line 143 def line(start_, end_) LineImpl.new(self, start_, end_) rescue nil end |
#line_string(points_) ⇒ Object
See ::RGeo::Feature::Factory#line_string
136 137 138 |
# File 'lib/rgeo/cartesian/factory.rb', line 136 def line_string(points_) LineStringImpl.new(self, points_) rescue nil end |
#linear_ring(points_) ⇒ Object
See ::RGeo::Feature::Factory#linear_ring
150 151 152 |
# File 'lib/rgeo/cartesian/factory.rb', line 150 def linear_ring(points_) LinearRingImpl.new(self, points_) rescue nil end |
#multi_line_string(elems_) ⇒ Object
See ::RGeo::Feature::Factory#multi_line_string
178 179 180 |
# File 'lib/rgeo/cartesian/factory.rb', line 178 def multi_line_string(elems_) MultiLineStringImpl.new(self, elems_) rescue nil end |
#multi_point(elems_) ⇒ Object
See ::RGeo::Feature::Factory#multi_point
171 172 173 |
# File 'lib/rgeo/cartesian/factory.rb', line 171 def multi_point(elems_) MultiPointImpl.new(self, elems_) rescue nil end |
#multi_polygon(elems_) ⇒ Object
See ::RGeo::Feature::Factory#multi_polygon
185 186 187 |
# File 'lib/rgeo/cartesian/factory.rb', line 185 def multi_polygon(elems_) MultiPolygonImpl.new(self, elems_) rescue nil end |
#parse_wkb(str_) ⇒ Object
See ::RGeo::Feature::Factory#parse_wkb
122 123 124 |
# File 'lib/rgeo/cartesian/factory.rb', line 122 def parse_wkb(str_) WKRep::WKBParser.new(self).parse(str_) end |
#parse_wkt(str_) ⇒ Object
See ::RGeo::Feature::Factory#parse_wkt
115 116 117 |
# File 'lib/rgeo/cartesian/factory.rb', line 115 def parse_wkt(str_) WKRep::WKTParser.new(self).parse(str_) end |
#point(x_, y_, *extra_) ⇒ Object
See ::RGeo::Feature::Factory#point
129 130 131 |
# File 'lib/rgeo/cartesian/factory.rb', line 129 def point(x_, y_, *extra_) PointImpl.new(self, x_, y_, *extra_) rescue nil end |
#polygon(outer_ring_, inner_rings_ = nil) ⇒ Object
See ::RGeo::Feature::Factory#polygon
157 158 159 |
# File 'lib/rgeo/cartesian/factory.rb', line 157 def polygon(outer_ring_, inner_rings_=nil) PolygonImpl.new(self, outer_ring_, inner_rings_) rescue nil end |
#proj4 ⇒ Object
See ::RGeo::Feature::Factory#proj4
192 193 194 |
# File 'lib/rgeo/cartesian/factory.rb', line 192 def proj4 @proj4 end |
#property(name_) ⇒ Object
See ::RGeo::Feature::Factory#property
99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/rgeo/cartesian/factory.rb', line 99 def property(name_) case name_ when :has_z_coordinate @has_z when :has_m_coordinate @has_m when :is_cartesian true else nil end end |
#srid ⇒ Object
Returns the SRID.
92 93 94 |
# File 'lib/rgeo/cartesian/factory.rb', line 92 def srid @srid end |