Module: RGeo::Geos
- Defined in:
- lib/rgeo/geos.rb,
lib/rgeo/geos/utils.rb,
lib/rgeo/geos/interface.rb,
lib/rgeo/geos/zm_factory.rb,
lib/rgeo/geos/ffi_factory.rb,
lib/rgeo/geos/capi_factory.rb,
lib/rgeo/geos/zm_feature_classes.rb,
lib/rgeo/geos/zm_feature_methods.rb,
lib/rgeo/geos/ffi_feature_classes.rb,
lib/rgeo/geos/ffi_feature_methods.rb,
lib/rgeo/geos/capi_feature_classes.rb,
ext/geos_c_impl/globals.c
Defined Under Namespace
Modules: Analysis, CAPIGeometryCollectionMethods, CAPIGeometryMethods, CAPILineMethods, CAPILineStringMethods, CAPILinearRingMethods, CAPIMultiLineStringMethods, CAPIMultiPointMethods, CAPIMultiPolygonMethods, CAPIPolygonMethods, FFIGeometryCollectionMethods, FFIGeometryMethods, FFILineMethods, FFILineStringMethods, FFILinearRingMethods, FFIMultiLineStringMethods, FFIMultiPointMethods, FFIMultiPolygonMethods, FFIPointMethods, FFIPolygonMethods, Utils, ZMGeometryCollectionMethods, ZMGeometryMethods, ZMLineStringMethods, ZMMultiLineStringMethods, ZMMultiPolygonMethods, ZMPointMethods, ZMPolygonMethods Classes: CAPIFactory, CAPIGeometryCollectionImpl, CAPIGeometryImpl, CAPILineImpl, CAPILineStringImpl, CAPILinearRingImpl, CAPIMultiLineStringImpl, CAPIMultiPointImpl, CAPIMultiPolygonImpl, CAPIPointImpl, CAPIPolygonImpl, FFIFactory, FFIGeometryCollectionImpl, FFIGeometryImpl, FFILineImpl, FFILineStringImpl, FFILinearRingImpl, FFIMultiLineStringImpl, FFIMultiPointImpl, FFIMultiPolygonImpl, FFIPointImpl, FFIPolygonImpl, ZMFactory, ZMGeometryCollectionImpl, ZMGeometryImpl, ZMLineImpl, ZMLineStringImpl, ZMLinearRingImpl, ZMMultiLineStringImpl, ZMMultiPointImpl, ZMMultiPolygonImpl, ZMPointImpl, ZMPolygonImpl
Constant Summary collapse
- CAPI_SUPPORTED =
continue
RGeo::Geos.const_defined?(:CAPIGeometryMethods)
- CAP_ROUND =
1
- CAP_FLAT =
2
- CAP_SQUARE =
3
- JOIN_ROUND =
1
- JOIN_MITRE =
2
- JOIN_BEVEL =
3
Class Attribute Summary collapse
-
.preferred_native_interface ⇒ Object
The preferred native interface.
Class Method Summary collapse
-
.capi_geos?(object) ⇒ Boolean
Returns true if the given feature is a CAPI GEOS feature, or if the given factory is a CAPI GEOS factory.
-
.capi_supported? ⇒ Boolean
Returns true if the CAPI GEOS implementation is supported.
-
.factory(opts = {}) ⇒ Object
Returns a factory for the GEOS implementation.
-
.ffi_geos?(object) ⇒ Boolean
Returns true if the given feature is an FFI GEOS feature, or if the given factory is an FFI GEOS factory.
-
.ffi_supported? ⇒ Boolean
Returns true if the FFI GEOS implementation is supported.
-
.geos?(object) ⇒ Boolean
Returns true if the given feature is a GEOS feature, or if the given factory is a GEOS factory.
-
.supported? ⇒ Boolean
Returns true if any GEOS implementation is supported.
-
.version ⇒ Object
Returns the GEOS library version as a string of the format “x.y.z”.
Class Attribute Details
.preferred_native_interface ⇒ Object
The preferred native interface. This is the native interface used by default when a factory is created. Supported values are :capi
and :ffi
.
This is set automatically when RGeo loads, to :capi
if the CAPI interface is available, otheriwse to :ffi
if FFI is available, otherwise to nil if no GEOS interface is available. You can override this setting if you want to prefer FFI over CAPI.
85 86 87 |
# File 'lib/rgeo/geos/interface.rb', line 85 def preferred_native_interface @preferred_native_interface end |
Class Method Details
.capi_geos?(object) ⇒ Boolean
Returns true if the given feature is a CAPI GEOS feature, or if the given factory is a CAPI GEOS factory.
34 35 36 37 38 39 |
# File 'lib/rgeo/geos/interface.rb', line 34 def capi_geos?(object) CAPI_SUPPORTED && (CAPIFactory === object || CAPIGeometryMethods === object || ZMFactory === object && CAPIFactory === object.z_factory || ZMGeometryMethods === object && CAPIGeometryMethods === object.z_geometry) end |
.capi_supported? ⇒ Boolean
Returns true if the CAPI GEOS implementation is supported.
14 15 16 |
# File 'lib/rgeo/geos/interface.rb', line 14 def capi_supported? CAPI_SUPPORTED end |
.factory(opts = {}) ⇒ Object
Returns a factory for the GEOS implementation. Returns nil if the GEOS implementation is not supported.
Note that GEOS does not natively support 4-dimensional data (i.e. both z and m values). However, RGeo’s GEOS wrapper does provide a 4-dimensional factory that utilizes an extra native GEOS object to handle the extra coordinate. Hence, a factory configured with both Z and M support will work, but will be slower than a 2-dimensional or 3-dimensional factory.
Options include:
:native_interface
-
Specifies which native interface to use. Possible values are
:capi
and:ffi
. The default is the value of the preferred_native_interface. :buffer_resolution
-
The resolution of buffers around geometries created by this factory. This controls the number of line segments used to approximate curves. The default is 1, which causes, for example, the buffer around a point to be approximated by a 4-sided polygon. A resolution of 2 would cause that buffer to be approximated by an 8-sided polygon. The exact behavior for different kinds of buffers is defined by GEOS.
:srid
-
Set the SRID returned by geometries created by this factory. Default is 0.
:coord_sys
-
The coordinate system in OGC form, either as a subclass of CoordSys::CS::CoordinateSystem, or as a string in WKT format. Optional. If not provided, but
:srid
is, a coord_sys will be created using the CS::CONFIG.default_coord_sys_class. :coord_sys_class
-
The coordinate system implementation to use if you do not want to use the CS::CONFIG.default_coord_sys_class. Optional.
:has_z_coordinate
-
Support
z_coordinate
. Default is false. :has_m_coordinate
-
Support
m_coordinate
. Default is false. :wkt_parser
-
Configure the parser for WKT. You may either pass a hash of configuration parameters for WKRep::WKTParser.new, or the special value
:geos
, indicating to use the native GEOS parser. Default is the empty hash, indicating the default configuration for WKRep::WKTParser. Note that the special:geos
value is not supported for ZM factories, since GEOS currently can’t handle ZM natively. :wkb_parser
-
Configure the parser for WKB. You may either pass a hash of configuration parameters for WKRep::WKBParser.new, or the special value
:geos
, indicating to use the native GEOS parser. Default is the empty hash, indicating the default configuration for WKRep::WKBParser. Note that the special:geos
value is not supported for ZM factories, since GEOS currently can’t handle ZM natively. :wkt_generator
-
Configure the generator for WKT. You may either pass a hash of configuration parameters for WKRep::WKTGenerator.new, or the special value
:geos
, indicating to use the native GEOS generator. Default is{:convert_case => :upper}
. Note that the special:geos
value is not supported for ZM factories, since GEOS currently can’t handle ZM natively. :wkb_generator
-
Configure the generator for WKB. You may either pass a hash of configuration parameters for WKRep::WKBGenerator.new, or the special value
:geos
, indicating to use the native GEOS generator. Default is the empty hash, indicating the default configuration for WKRep::WKBGenerator. Note that the special:geos
value is not supported for ZM factories, since GEOS currently can’t handle ZM natively. :auto_prepare
-
Request an auto-prepare strategy. Supported values are
:simple
and:disabled
. The former (which is the default) generates a prepared geometry the second time an operation that would benefit from it is called. The latter never automatically generates a prepared geometry (unless you generate one explicitly using theprepare!
method).
164 165 166 167 168 169 170 171 172 173 174 175 176 |
# File 'lib/rgeo/geos/interface.rb', line 164 def factory(opts = {}) return unless supported? native_interface = opts[:native_interface] || Geos.preferred_native_interface if opts[:has_z_coordinate] && opts[:has_m_coordinate] ZMFactory.new(opts) elsif native_interface == :ffi FFIFactory.new(opts) else CAPIFactory.create(opts) end end |
.ffi_geos?(object) ⇒ Boolean
Returns true if the given feature is an FFI GEOS feature, or if the given factory is an FFI GEOS factory.
44 45 46 47 48 49 |
# File 'lib/rgeo/geos/interface.rb', line 44 def ffi_geos?(object) FFI_SUPPORTED && (FFIFactory === object || FFIGeometryMethods === object || ZMFactory === object && FFIFactory === object.z_factory || ZMGeometryMethods === object && FFIGeometryMethods === object.z_geometry) end |
.ffi_supported? ⇒ Boolean
Returns true if the FFI GEOS implementation is supported.
20 21 22 |
# File 'lib/rgeo/geos/interface.rb', line 20 def ffi_supported? FFI_SUPPORTED end |
.geos?(object) ⇒ Boolean
Returns true if the given feature is a GEOS feature, or if the given factory is a GEOS factory. Does not distinguish between CAPI and FFI.
54 55 56 57 58 |
# File 'lib/rgeo/geos/interface.rb', line 54 def geos?(object) CAPI_SUPPORTED && (CAPIFactory === object || CAPIGeometryMethods === object) || FFI_SUPPORTED && (FFIFactory === object || FFIGeometryMethods === object) || ZMFactory === object || ZMGeometryMethods === object end |
.supported? ⇒ Boolean
Returns true if any GEOS implementation is supported. If this returns false, GEOS features are not available at all.
27 28 29 |
# File 'lib/rgeo/geos/interface.rb', line 27 def supported? FFI_SUPPORTED || CAPI_SUPPORTED end |
.version ⇒ Object
Returns the GEOS library version as a string of the format “x.y.z”. Returns nil if GEOS is not available.
63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/rgeo/geos/interface.rb', line 63 def version unless defined?(@version) @version = if RGeo::Geos::CAPI_SUPPORTED RGeo::Geos::CAPIFactory._geos_version.freeze elsif RGeo::Geos::FFI_SUPPORTED ::Geos::FFIGeos.GEOSversion.sub(/-CAPI-.*$/, "").freeze end end @version end |