Module: RGeo::Geos::Utils
- Defined in:
- lib/rgeo/geos/utils.rb
Overview
:nodoc:
Class Attribute Summary collapse
-
.ffi_supports_prepared_level_1 ⇒ Object
readonly
Returns the value of attribute ffi_supports_prepared_level_1.
-
.ffi_supports_prepared_level_2 ⇒ Object
readonly
Returns the value of attribute ffi_supports_prepared_level_2.
-
.ffi_supports_set_output_dimension ⇒ Object
readonly
Returns the value of attribute ffi_supports_set_output_dimension.
-
.marshal_wkb_generator ⇒ Object
readonly
Returns the value of attribute marshal_wkb_generator.
-
.psych_wkt_generator ⇒ Object
readonly
Returns the value of attribute psych_wkt_generator.
Class Method Summary collapse
- ._init ⇒ Object
- .ffi_compute_dimension(geom_) ⇒ Object
- .ffi_coord_seq_hash(cs_, hash_ = 0) ⇒ Object
- .ffi_coord_seqs_equal?(cs1_, cs2_, check_z_) ⇒ Boolean
Class Attribute Details
.ffi_supports_prepared_level_1 ⇒ Object (readonly)
Returns the value of attribute ffi_supports_prepared_level_1.
66 67 68 |
# File 'lib/rgeo/geos/utils.rb', line 66 def ffi_supports_prepared_level_1 @ffi_supports_prepared_level_1 end |
.ffi_supports_prepared_level_2 ⇒ Object (readonly)
Returns the value of attribute ffi_supports_prepared_level_2.
67 68 69 |
# File 'lib/rgeo/geos/utils.rb', line 67 def ffi_supports_prepared_level_2 @ffi_supports_prepared_level_2 end |
.ffi_supports_set_output_dimension ⇒ Object (readonly)
Returns the value of attribute ffi_supports_set_output_dimension.
68 69 70 |
# File 'lib/rgeo/geos/utils.rb', line 68 def ffi_supports_set_output_dimension @ffi_supports_set_output_dimension end |
.marshal_wkb_generator ⇒ Object (readonly)
Returns the value of attribute marshal_wkb_generator.
70 71 72 |
# File 'lib/rgeo/geos/utils.rb', line 70 def marshal_wkb_generator @marshal_wkb_generator end |
.psych_wkt_generator ⇒ Object (readonly)
Returns the value of attribute psych_wkt_generator.
69 70 71 |
# File 'lib/rgeo/geos/utils.rb', line 69 def psych_wkt_generator @psych_wkt_generator end |
Class Method Details
._init ⇒ Object
56 57 58 59 60 61 62 63 64 |
# File 'lib/rgeo/geos/utils.rb', line 56 def _init if FFI_SUPPORTED @ffi_supports_prepared_level_1 = ::Geos::FFIGeos.respond_to?(:GEOSPreparedContains_r) @ffi_supports_prepared_level_2 = ::Geos::FFIGeos.respond_to?(:GEOSPreparedDisjoint_r) @ffi_supports_set_output_dimension = ::Geos::FFIGeos.respond_to?(:GEOSWKTWriter_setOutputDimension_r) end @psych_wkt_generator = WKRep::WKTGenerator.new(convert_case: :upper) @marshal_wkb_generator = WKRep::WKBGenerator.new end |
.ffi_compute_dimension(geom_) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/rgeo/geos/utils.rb', line 26 def ffi_compute_dimension(geom_) result_ = -1 case geom_.type_id when ::Geos::GeomTypes::GEOS_POINT result_ = 0 when ::Geos::GeomTypes::GEOS_MULTIPOINT result_ = 0 unless geom_.empty? when ::Geos::GeomTypes::GEOS_LINESTRING, ::Geos::GeomTypes::GEOS_LINEARRING result_ = 1 when ::Geos::GeomTypes::GEOS_MULTILINESTRING result_ = 1 unless geom_.empty? when ::Geos::GeomTypes::GEOS_POLYGON result_ = 2 when ::Geos::GeomTypes::GEOS_MULTIPOLYGON result_ = 2 unless geom_.empty? when ::Geos::GeomTypes::GEOS_GEOMETRYCOLLECTION geom_.each do |g_| dim_ = ffi_compute_dimension(g_) result_ = dim_ if result_ < dim_ end end result_ end |
.ffi_coord_seq_hash(cs_, hash_ = 0) ⇒ Object
50 51 52 53 54 |
# File 'lib/rgeo/geos/utils.rb', line 50 def ffi_coord_seq_hash(cs_, hash_ = 0) (0...cs_.length).inject(hash_) do |_h_, i_| [hash_, cs_.get_x(i_), cs_.get_y(i_), cs_.get_z(i_)].hash end end |
.ffi_coord_seqs_equal?(cs1_, cs2_, check_z_) ⇒ Boolean
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/rgeo/geos/utils.rb', line 11 def ffi_coord_seqs_equal?(cs1_, cs2_, check_z_) len1_ = cs1_.length len2_ = cs2_.length if len1_ == len2_ (0...len1_).each do |i_| return false unless cs1_.get_x(i_) == cs2_.get_x(i_) && cs1_.get_y(i_) == cs2_.get_y(i_) && (!check_z_ || cs1_.get_z(i_) == cs2_.get_z(i_)) end true else false end end |