lib/rgeo/geos/zm_factory.rb in rgeo-3.0.0.pre.rc.3 vs lib/rgeo/geos/zm_factory.rb in rgeo-3.0.0
- old
+ new
@@ -7,11 +7,10 @@
# -----------------------------------------------------------------------------
module RGeo
module Geos
# A factory for Geos that handles both Z and M.
-
class ZMFactory
include Feature::Factory::Instance
include ImplHelper::Utils
# :stopdoc:
@@ -58,37 +57,41 @@
@zfactory = CAPIFactory.create(config.merge(has_z_coordinate: true))
@mfactory = CAPIFactory.create(config.merge(has_m_coordinate: true))
end
wkt_generator = opts[:wkt_generator]
- case wkt_generator
- when Hash
- @wkt_generator = WKRep::WKTGenerator.new(wkt_generator)
- else
- @wkt_generator = WKRep::WKTGenerator.new(convert_case: :upper)
- end
+ @wkt_generator =
+ case wkt_generator
+ when Hash
+ WKRep::WKTGenerator.new(wkt_generator)
+ else
+ WKRep::WKTGenerator.new(convert_case: :upper)
+ end
wkb_generator = opts[:wkb_generator]
- case wkb_generator
- when Hash
- @wkb_generator = WKRep::WKBGenerator.new(wkb_generator)
- else
- @wkb_generator = WKRep::WKBGenerator.new
- end
+ @wkb_generator =
+ case wkb_generator
+ when Hash
+ WKRep::WKBGenerator.new(wkb_generator)
+ else
+ WKRep::WKBGenerator.new
+ end
wkt_parser = opts[:wkt_parser]
- case wkt_parser
- when Hash
- @wkt_parser = WKRep::WKTParser.new(self, wkt_parser)
- else
- @wkt_parser = WKRep::WKTParser.new(self)
- end
+ @wkt_parser =
+ case wkt_parser
+ when Hash
+ WKRep::WKTParser.new(self, wkt_parser)
+ else
+ WKRep::WKTParser.new(self)
+ end
wkb_parser = opts[:wkb_parser]
- case wkb_parser
- when Hash
- @wkb_parser = WKRep::WKBParser.new(self, wkb_parser)
- else
- @wkb_parser = WKRep::WKBParser.new(self)
- end
+ @wkb_parser =
+ case wkb_parser
+ when Hash
+ WKRep::WKBParser.new(self, wkb_parser)
+ else
+ WKRep::WKBParser.new(self)
+ end
end
# Marshal support
def marshal_dump # :nodoc:
@@ -106,15 +109,13 @@
hash["cs"] = coord_sys.to_wkt if coord_sys
hash
end
def marshal_load(data) # :nodoc:
- if (coord_sys_data = data["cs"])
- coord_sys = CoordSys::CONFIG.default_coord_sys_class.create_from_wkt(coord_sys_data)
- else
- coord_sys = nil
- end
+ cs_class = CoordSys::CONFIG.default_coord_sys_class
+ coord_sys = data["cs"]&.then { |cs| cs_class.create_from_wkt(cs) }
+
initialize(
native_interface: (data["nffi"] ? :ffi : :capi),
has_z_coordinate: data["hasz"],
has_m_coordinate: data["hasm"],
srid: data["srid"],
@@ -137,21 +138,20 @@
coder["wkb_generator"] = @wkb_generator.properties
coder["wkt_parser"] = @wkt_parser.properties
coder["wkb_parser"] = @wkb_parser.properties
coder["auto_prepare"] = @zfactory.property(:auto_prepare).to_s
coder["native_interface"] = @zfactory.is_a?(FFIFactory) ? "ffi" : "capi"
- if (coord_sys = @zfactory.coord_sys)
- coder["coord_sys"] = coord_sys.to_wkt
- end
+
+ return unless (coord_sys = @zfactory.coord_sys)
+
+ coder["coord_sys"] = coord_sys.to_wkt
end
def init_with(coder) # :nodoc:
- if (coord_sys_data = coder["cs"])
- coord_sys = CoordSys::CONFIG.default_coord_sys_class.create_from_wkt(coord_sys_data.to_s)
- else
- coord_sys = nil
- end
+ cs_class = CoordSys::CONFIG.default_coord_sys_class
+ coord_sys = coder["cs"]&.then { |cs| cs_class.create_from_wkt(cs) }
+
initialize(
native_interface: coder["native_interface"] == "ffi" ? :ffi : :capi,
has_z_coordinate: coder["has_z_coordinate"],
has_m_coordinate: coder["has_m_coordinate"],
srid: coder["srid"],
@@ -190,12 +190,12 @@
@mfactory
end
# Factory equivalence test.
- def eql?(rhs)
- rhs.is_a?(ZMFactory) && rhs.z_factory == @zfactory
+ def eql?(other)
+ other.is_a?(ZMFactory) && other.z_factory == @zfactory
end
alias == eql?
# Standard hash code
@@ -225,11 +225,15 @@
end
# See RGeo::Feature::Factory#point
def point(x, y, z = 0, m = 0)
- create_feature(ZMPointImpl, @zfactory.point(x, y, z), @mfactory.point(x, y, m))
+ create_feature(
+ ZMPointImpl,
+ @zfactory.point(x, y, z),
+ @mfactory.point(x, y, m)
+ )
end
# See RGeo::Feature::Factory#line_string
def line_string(points)
@@ -249,10 +253,14 @@
end
# See RGeo::Feature::Factory#polygon
def polygon(outer_ring, inner_rings = nil)
- create_feature(ZMPolygonImpl, @zfactory.polygon(outer_ring, inner_rings), @mfactory.polygon(outer_ring, inner_rings))
+ create_feature(
+ ZMPolygonImpl,
+ @zfactory.polygon(outer_ring, inner_rings),
+ @mfactory.polygon(outer_ring, inner_rings)
+ )
end
# See RGeo::Feature::Factory#collection
def collection(elems)