Module: RGeo::Geos::FFIGeometryMethods
- Includes:
- Feature::Instance
- Included in:
- FFIGeometryCollectionImpl, FFIGeometryImpl, FFILineImpl, FFILineStringImpl, FFILinearRingImpl, FFIMultiLineStringImpl, FFIMultiPointImpl, FFIMultiPolygonImpl, FFIPointImpl, FFIPolygonImpl
- Defined in:
- lib/rgeo/geos/ffi_feature_methods.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#_klasses ⇒ Object
readonly
:nodoc:.
-
#factory ⇒ Object
readonly
Returns the value of attribute factory.
-
#fg_geom ⇒ Object
readonly
Returns the value of attribute fg_geom.
Instance Method Summary collapse
-
#_detach_fg_geom ⇒ Object
:nodoc:.
-
#_request_prepared ⇒ Object
:nodoc:.
- #as_binary ⇒ Object
- #as_text ⇒ Object (also: #to_s)
- #boundary ⇒ Object
- #buffer(distance_) ⇒ Object
- #contains?(rhs_) ⇒ Boolean
- #convex_hull ⇒ Object
- #crosses?(rhs_) ⇒ Boolean
- #difference(rhs_) ⇒ Object (also: #-)
- #dimension ⇒ Object
- #disjoint?(rhs_) ⇒ Boolean
- #distance(rhs_) ⇒ Object
-
#encode_with(coder_) ⇒ Object
Psych support.
- #envelope ⇒ Object
- #eql?(rhs_) ⇒ Boolean
- #equals?(rhs_) ⇒ Boolean (also: #==)
- #geometry_type ⇒ Object
-
#init_with(coder_) ⇒ Object
:nodoc:.
- #initialize(factory_, fg_geom_, klasses_) ⇒ Object
- #initialize_copy(orig_) ⇒ Object
- #inspect ⇒ Object
- #intersection(rhs_) ⇒ Object (also: #*)
- #intersects?(rhs_) ⇒ Boolean
- #is_empty? ⇒ Boolean
- #is_simple? ⇒ Boolean
-
#marshal_dump ⇒ Object
Marshal support.
-
#marshal_load(data_) ⇒ Object
:nodoc:.
- #overlaps?(rhs_) ⇒ Boolean
- #prepare! ⇒ Object
- #prepared? ⇒ Boolean
- #relate?(rhs_, pattern_) ⇒ Boolean (also: #relate)
- #srid ⇒ Object
- #sym_difference(rhs_) ⇒ Object
- #touches?(rhs_) ⇒ Boolean
- #union(rhs_) ⇒ Object (also: #+)
- #within?(rhs_) ⇒ Boolean
Instance Attribute Details
#_klasses ⇒ Object (readonly)
:nodoc:
58 59 60 |
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 58 def _klasses @_klasses end |
#factory ⇒ Object (readonly)
Returns the value of attribute factory.
55 56 57 |
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 55 def factory @factory end |
#fg_geom ⇒ Object (readonly)
Returns the value of attribute fg_geom.
56 57 58 |
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 56 def fg_geom @fg_geom end |
Instance Method Details
#_detach_fg_geom ⇒ Object
:nodoc:
256 257 258 259 260 |
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 256 def _detach_fg_geom # :nodoc: fg_ = @fg_geom @fg_geom = nil fg_ end |
#_request_prepared ⇒ Object
:nodoc:
262 263 264 265 266 267 268 269 270 271 272 273 274 |
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 262 def _request_prepared # :nodoc: case @_fg_prep when 0 nil when 1 @_fg_prep = 2 nil when 2 @_fg_prep = ::Geos::PreparedGeometry.new(@fg_geom) else @_fg_prep end end |
#as_binary ⇒ Object
110 111 112 |
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 110 def as_binary @factory._generate_wkb(self) end |
#as_text ⇒ Object Also known as: to_s
103 104 105 106 107 |
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 103 def as_text str_ = @factory._generate_wkt(self) str_.force_encoding("US-ASCII") if str_.respond_to?(:force_encoding) str_ end |
#boundary ⇒ Object
95 96 97 98 99 100 101 |
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 95 def boundary if self.class == FFIGeometryCollectionImpl nil else @factory._wrap_fg_geom(@fg_geom.boundary, nil) end end |
#buffer(distance_) ⇒ Object
218 219 220 |
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 218 def buffer(distance_) @factory._wrap_fg_geom(@fg_geom.buffer(distance_, @factory.buffer_resolution), nil) end |
#contains?(rhs_) ⇒ Boolean
187 188 189 190 191 192 193 194 195 |
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 187 def contains?(rhs_) fg_ = factory._convert_to_fg_geometry(rhs_) if fg_ prep_ = _request_prepared if Utils.ffi_supports_prepared_level_1 prep_ ? prep_.contains?(fg_) : @fg_geom.contains?(fg_) else false end end |
#convex_hull ⇒ Object
222 223 224 |
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 222 def convex_hull @factory._wrap_fg_geom(@fg_geom.convex_hull, nil) end |
#crosses?(rhs_) ⇒ Boolean
167 168 169 170 171 172 173 174 175 |
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 167 def crosses?(rhs_) fg_ = factory._convert_to_fg_geometry(rhs_) if fg_ prep_ = _request_prepared if Utils.ffi_supports_prepared_level_2 prep_ ? prep_.crosses?(fg_) : @fg_geom.crosses?(fg_) else false end end |
#difference(rhs_) ⇒ Object Also known as: -
240 241 242 243 |
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 240 def difference(rhs_) fg_ = factory._convert_to_fg_geometry(rhs_) fg_ ? @factory._wrap_fg_geom(@fg_geom.difference(fg_), nil) : nil end |
#dimension ⇒ Object
72 73 74 |
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 72 def dimension Utils.ffi_compute_dimension(@fg_geom) end |
#disjoint?(rhs_) ⇒ Boolean
137 138 139 140 141 142 143 144 145 |
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 137 def disjoint?(rhs_) fg_ = factory._convert_to_fg_geometry(rhs_) if fg_ prep_ = _request_prepared if Utils.ffi_supports_prepared_level_2 prep_ ? prep_.disjoint?(fg_) : @fg_geom.disjoint?(fg_) else false end end |
#distance(rhs_) ⇒ Object
213 214 215 216 |
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 213 def distance(rhs_) fg_ = factory._convert_to_fg_geometry(rhs_) fg_ ? @fg_geom.distance(fg_) : nil end |
#encode_with(coder_) ⇒ Object
Psych support
40 41 42 43 44 45 |
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 40 def encode_with(coder_) # :nodoc: coder_["factory"] = @factory str_ = @factory._write_for_psych(self) str_ = str_.encode("US-ASCII") if str_.respond_to?(:encode) coder_["wkt"] = str_ end |
#envelope ⇒ Object
91 92 93 |
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 91 def envelope @factory._wrap_fg_geom(@fg_geom.envelope, nil) end |
#eql?(rhs_) ⇒ Boolean
252 253 254 |
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 252 def eql?(rhs_) rep_equals?(rhs_) end |
#equals?(rhs_) ⇒ Boolean Also known as: ==
122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 122 def equals?(rhs_) return false unless rhs_.is_a?(::RGeo::Feature::Instance) fg_ = factory._convert_to_fg_geometry(rhs_) if !fg_ false # GEOS has a bug where empty geometries are not spatially equal # to each other. Work around this case first. elsif fg_.empty? && @fg_geom.empty? true else @fg_geom.eql?(fg_) end end |
#geometry_type ⇒ Object
76 77 78 |
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 76 def geometry_type Feature::Geometry end |
#init_with(coder_) ⇒ Object
:nodoc:
47 48 49 50 51 52 53 |
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 47 def init_with(coder_) # :nodoc: @factory = coder_["factory"] @fg_geom = @factory._read_for_psych(coder_["wkt"]) @fg_geom.srid = @factory.srid @_fg_prep = @factory._auto_prepare ? 1 : 0 @_klasses = nil end |
#initialize(factory_, fg_geom_, klasses_) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 12 def initialize(factory_, fg_geom_, klasses_) @factory = factory_ @fg_geom = fg_geom_ @_fg_prep = factory_._auto_prepare ? 1 : 0 @_klasses = klasses_ fg_geom_.srid = factory_.srid end |
#initialize_copy(orig_) ⇒ Object
60 61 62 63 64 65 66 |
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 60 def initialize_copy(orig_) @factory = orig_.factory @fg_geom = orig_.fg_geom.clone @fg_geom.srid = orig_.fg_geom.srid @_fg_prep = @factory._auto_prepare ? 1 : 0 @_klasses = orig_._klasses end |
#inspect ⇒ Object
20 21 22 |
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 20 def inspect "#<#{self.class}:0x#{object_id.to_s(16)} #{as_text.inspect}>" end |
#intersection(rhs_) ⇒ Object Also known as: *
226 227 228 229 |
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 226 def intersection(rhs_) fg_ = factory._convert_to_fg_geometry(rhs_) fg_ ? @factory._wrap_fg_geom(@fg_geom.intersection(fg_), nil) : nil end |
#intersects?(rhs_) ⇒ Boolean
147 148 149 150 151 152 153 154 155 |
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 147 def intersects?(rhs_) fg_ = factory._convert_to_fg_geometry(rhs_) if fg_ prep_ = _request_prepared if Utils.ffi_supports_prepared_level_1 prep_ ? prep_.intersects?(fg_) : @fg_geom.intersects?(fg_) else false end end |
#is_empty? ⇒ Boolean
114 115 116 |
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 114 def is_empty? @fg_geom.empty? end |
#is_simple? ⇒ Boolean
118 119 120 |
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 118 def is_simple? @fg_geom.simple? end |
#marshal_dump ⇒ Object
Marshal support
26 27 28 |
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 26 def marshal_dump # :nodoc: [@factory, @factory._write_for_marshal(self)] end |
#marshal_load(data_) ⇒ Object
:nodoc:
30 31 32 33 34 35 36 |
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 30 def marshal_load(data_) # :nodoc: @factory = data_[0] @fg_geom = @factory._read_for_marshal(data_[1]) @fg_geom.srid = @factory.srid @_fg_prep = @factory._auto_prepare ? 1 : 0 @_klasses = nil end |
#overlaps?(rhs_) ⇒ Boolean
197 198 199 200 201 202 203 204 205 |
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 197 def overlaps?(rhs_) fg_ = factory._convert_to_fg_geometry(rhs_) if fg_ prep_ = _request_prepared if Utils.ffi_supports_prepared_level_2 prep_ ? prep_.overlaps?(fg_) : @fg_geom.overlaps?(fg_) else false end end |
#prepare! ⇒ Object
84 85 86 87 88 89 |
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 84 def prepare! if @_fg_prep.is_a?(::Integer) @_fg_prep = ::Geos::PreparedGeometry.new(@fg_geom) end self end |
#prepared? ⇒ Boolean
80 81 82 |
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 80 def prepared? !@_fg_prep.is_a?(::Integer) end |
#relate?(rhs_, pattern_) ⇒ Boolean Also known as: relate
207 208 209 210 |
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 207 def relate?(rhs_, pattern_) fg_ = factory._convert_to_fg_geometry(rhs_) fg_ ? @fg_geom.relate_pattern(fg_, pattern_) : nil end |
#srid ⇒ Object
68 69 70 |
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 68 def srid @fg_geom.srid end |
#sym_difference(rhs_) ⇒ Object
247 248 249 250 |
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 247 def sym_difference(rhs_) fg_ = factory._convert_to_fg_geometry(rhs_) fg_ ? @factory._wrap_fg_geom(@fg_geom.sym_difference(fg_), nil) : nil end |
#touches?(rhs_) ⇒ Boolean
157 158 159 160 161 162 163 164 165 |
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 157 def touches?(rhs_) fg_ = factory._convert_to_fg_geometry(rhs_) if fg_ prep_ = _request_prepared if Utils.ffi_supports_prepared_level_2 prep_ ? prep_.touches?(fg_) : @fg_geom.touches?(fg_) else false end end |
#union(rhs_) ⇒ Object Also known as: +
233 234 235 236 |
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 233 def union(rhs_) fg_ = factory._convert_to_fg_geometry(rhs_) fg_ ? @factory._wrap_fg_geom(@fg_geom.union(fg_), nil) : nil end |
#within?(rhs_) ⇒ Boolean
177 178 179 180 181 182 183 184 185 |
# File 'lib/rgeo/geos/ffi_feature_methods.rb', line 177 def within?(rhs_) fg_ = factory._convert_to_fg_geometry(rhs_) if fg_ prep_ = _request_prepared if Utils.ffi_supports_prepared_level_2 prep_ ? prep_.within?(fg_) : @fg_geom.within?(fg_) else false end end |