Class: Geos::Geometry
- Inherits:
-
Object
show all
- Includes:
- Tools
- Defined in:
- lib/ffi-geos/geometry.rb
Constant Summary
Constants included
from GeomTypes
Geos::GeomTypes::GEOS_GEOMETRYCOLLECTION, Geos::GeomTypes::GEOS_LINEARRING, Geos::GeomTypes::GEOS_LINESTRING, Geos::GeomTypes::GEOS_MULTILINESTRING, Geos::GeomTypes::GEOS_MULTIPOINT, Geos::GeomTypes::GEOS_MULTIPOLYGON, Geos::GeomTypes::GEOS_POINT, Geos::GeomTypes::GEOS_POLYGON
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
-
#area ⇒ Object
-
#boundary ⇒ Object
-
#buffer(width, options = nil) ⇒ Object
:call-seq: buffer(width) buffer(width, options) buffer(width, buffer_params) buffer(width, quad_segs).
-
#centroid ⇒ Object
(also: #center)
-
#contains?(geom) ⇒ Boolean
-
#convex_hull ⇒ Object
-
#coord_seq ⇒ Object
-
#covered_by?(geom) ⇒ Boolean
-
#covers?(geom) ⇒ Boolean
-
#crosses?(geom) ⇒ Boolean
-
#difference(geom) ⇒ Object
-
#dimensions ⇒ Object
-
#disjoint?(geom) ⇒ Boolean
-
#distance(geom) ⇒ Object
-
#empty? ⇒ Boolean
-
#end_point ⇒ Object
-
#envelope ⇒ Object
-
#eql?(geom) ⇒ Boolean
(also: #==, #equals?)
-
#eql_almost?(geom, decimal = 6) ⇒ Boolean
(also: #equals_almost?, #almost_equals?)
-
#eql_exact?(geom, tolerance) ⇒ Boolean
(also: #equals_exact?, #exactly_equals?)
-
#extract_unique_points ⇒ Object
(also: #unique_points)
-
#geom_type ⇒ Object
Returns the name of the Geometry type, i.e.
-
#has_z? ⇒ Boolean
-
#hausdorff_distance(geom, densify_frac = nil) ⇒ Object
-
#initialize(ptr, options = {}) ⇒ Geometry
constructor
-
#initialize_copy(source) ⇒ Object
-
#interpolate(d, normalized = false) ⇒ Object
-
#interpolate_normalized(d) ⇒ Object
-
#intersection(geom) ⇒ Object
-
#intersects?(geom) ⇒ Boolean
-
#length ⇒ Object
-
#line_merge ⇒ Object
-
#normalize! ⇒ Object
(also: #normalize)
-
#num_coordinates ⇒ Object
-
#num_geometries ⇒ Object
-
#overlaps?(geom) ⇒ Boolean
-
#point_on_surface ⇒ Object
(also: #representative_point)
-
#polygonize ⇒ Object
-
#polygonize_cut_edges ⇒ Object
-
#polygonize_full ⇒ Object
Returns a Hash with the following structure:.
-
#project(geom, normalized = false) ⇒ Object
-
#project_normalized(geom) ⇒ Object
-
#relate(geom) ⇒ Object
Returns the Dimensionally Extended Nine-Intersection Model (DE-9IM) matrix of the geometries as a String.
-
#relate_boundary_node_rule(geom, bnr = :mod2) ⇒ Object
-
#relate_pattern(geom, pattern) ⇒ Object
Checks the DE-9IM pattern against the geoms.
-
#ring? ⇒ Boolean
-
#shared_paths(geom) ⇒ Object
-
#simple? ⇒ Boolean
-
#simplify(tolerance) ⇒ Object
-
#snap(geom, tolerance) ⇒ Object
(also: #snap_to)
-
#srid ⇒ Object
-
#srid=(s) ⇒ Object
-
#start_point ⇒ Object
-
#sym_difference(geom) ⇒ Object
(also: #symmetric_difference)
-
#to_prepared ⇒ Object
-
#to_s ⇒ Object
-
#topology_preserve_simplify(tolerance) ⇒ Object
-
#touches?(geom) ⇒ Boolean
-
#type_id ⇒ Object
Returns one of the values from Geos::GeomTypes.
-
#unary_union ⇒ Object
-
#union(geom = nil) ⇒ Object
Calling without a geom argument is equivalent to calling unary_union when using GEOS 3.3+ and is equivalent to calling union_cascaded in older versions.
-
#union_cascaded ⇒ Object
-
#valid? ⇒ Boolean
-
#valid_detail(flags = 0) ⇒ Object
Returns a Hash containing the following structure on invalid geometries:.
-
#valid_reason ⇒ Object
Returns a String describing whether or not the Geometry is valid.
-
#within?(geom) ⇒ Boolean
Methods included from Tools
#bool_result, #cast_geometry_ptr, #check_enum_value, #check_geometry, #pick_srid_according_to_policy, #pick_srid_from_geoms, #symbol_for_enum
Constructor Details
#initialize(ptr, options = {}) ⇒ Geometry
For internal use. Geometry objects should be created via WkbReader, WktReader and the various Geos.create_* methods.
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/ffi-geos/geometry.rb', line 11
def initialize(ptr, options = {})
options = {
:auto_free => true
}.merge(options)
@ptr = FFI::AutoPointer.new(
ptr,
self.class.method(:release)
)
@ptr.autorelease = !!options[:auto_free]
@parent = options[:parent] if options[:parent]
end
|
Instance Attribute Details
#ptr ⇒ Object
Returns the value of attribute ptr.
7
8
9
|
# File 'lib/ffi-geos/geometry.rb', line 7
def ptr
@ptr
end
|
Class Method Details
.release(ptr) ⇒ Object
35
36
37
|
# File 'lib/ffi-geos/geometry.rb', line 35
def self.release(ptr) FFIGeos.GEOSGeom_destroy_r(Geos.current_handle, ptr)
end
|
Instance Method Details
#area ⇒ Object
435
436
437
438
439
440
441
442
443
|
# File 'lib/ffi-geos/geometry.rb', line 435
def area
if self.empty?
0
else
double_ptr = FFI::MemoryPointer.new(:double)
FFIGeos.GEOSArea_r(Geos.current_handle, self.ptr, double_ptr)
double_ptr.read_double
end
end
|
#boundary ⇒ Object
155
156
157
|
# File 'lib/ffi-geos/geometry.rb', line 155
def boundary
cast_geometry_ptr(FFIGeos.GEOSBoundary_r(Geos.current_handle, self.ptr), :srid_copy => self.srid)
end
|
#buffer(width, options = nil) ⇒ Object
:call-seq:
buffer(width)
buffer(width, options)
buffer(width, buffer_params)
buffer(width, quad_segs)
Calls buffer on the Geometry. Options can be passed as either a BufferParams object, as an equivalent Hash or as a quad_segs value. Default values can be found in Geos::Constants::BUFFER_PARAM_DEFAULTS.
Note that when using versions of GEOS prior to 3.3.0, only the quad_segs option is recognized when using Geometry#buffer and other options are ignored.
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
# File 'lib/ffi-geos/geometry.rb', line 103
def buffer(width, options = nil)
options ||= {}
params = case options
when Hash
Geos::BufferParams.new(options)
when Geos::BufferParams
options
when Numeric
Geos::BufferParams.new(:quad_segs => options)
else
raise ArgumentError.new("Expected Geos::BufferParams, a Hash or a Numeric")
end
cast_geometry_ptr(FFIGeos.GEOSBufferWithParams_r(Geos.current_handle, self.ptr, params.ptr, width), :srid_copy => self.srid)
end
|
#centroid ⇒ Object
Also known as:
center
197
198
199
|
# File 'lib/ffi-geos/geometry.rb', line 197
def centroid
cast_geometry_ptr(FFIGeos.GEOSGetCentroid_r(Geos.current_handle, self.ptr), :srid_copy => self.srid)
end
|
#contains?(geom) ⇒ Boolean
270
271
272
273
|
# File 'lib/ffi-geos/geometry.rb', line 270
def contains?(geom)
check_geometry(geom)
bool_result(FFIGeos.GEOSContains_r(Geos.current_handle, self.ptr, geom.ptr))
end
|
#convex_hull ⇒ Object
136
137
138
|
# File 'lib/ffi-geos/geometry.rb', line 136
def convex_hull
cast_geometry_ptr(FFIGeos.GEOSConvexHull_r(Geos.current_handle, self.ptr), :srid_copy => self.srid)
end
|
#covered_by?(geom) ⇒ Boolean
306
307
308
309
|
# File 'lib/ffi-geos/geometry.rb', line 306
def covered_by?(geom)
check_geometry(geom)
bool_result(FFIGeos.GEOSCoveredBy_r(Geos.current_handle, self.ptr, geom.ptr))
end
|
#covers?(geom) ⇒ Boolean
284
285
286
287
|
# File 'lib/ffi-geos/geometry.rb', line 284
def covers?(geom)
check_geometry(geom)
bool_result(FFIGeos.GEOSCovers_r(Geos.current_handle, self.ptr, geom.ptr))
end
|
#crosses?(geom) ⇒ Boolean
260
261
262
263
|
# File 'lib/ffi-geos/geometry.rb', line 260
def crosses?(geom)
check_geometry(geom)
bool_result(FFIGeos.GEOSCrosses_r(Geos.current_handle, self.ptr, geom.ptr))
end
|
#difference(geom) ⇒ Object
140
141
142
143
144
145
|
# File 'lib/ffi-geos/geometry.rb', line 140
def difference(geom)
check_geometry(geom)
cast_geometry_ptr(FFIGeos.GEOSDifference_r(Geos.current_handle, self.ptr, geom.ptr), {
:srid_copy => pick_srid_from_geoms(self.srid, geom.srid)
})
end
|
#dimensions ⇒ Object
66
67
68
|
# File 'lib/ffi-geos/geometry.rb', line 66
def dimensions
FFIGeos.GEOSGeom_getDimensions_r(Geos.current_handle, self.ptr)
end
|
#disjoint?(geom) ⇒ Boolean
245
246
247
248
|
# File 'lib/ffi-geos/geometry.rb', line 245
def disjoint?(geom)
check_geometry(geom)
bool_result(FFIGeos.GEOSDisjoint_r(Geos.current_handle, self.ptr, geom.ptr))
end
|
#distance(geom) ⇒ Object
455
456
457
458
459
460
|
# File 'lib/ffi-geos/geometry.rb', line 455
def distance(geom)
check_geometry(geom)
double_ptr = FFI::MemoryPointer.new(:double)
FFIGeos.GEOSDistance_r(Geos.current_handle, self.ptr, geom.ptr, double_ptr)
double_ptr.read_double
end
|
#empty? ⇒ Boolean
345
346
347
|
# File 'lib/ffi-geos/geometry.rb', line 345
def empty?
bool_result(FFIGeos.GEOSisEmpty_r(Geos.current_handle, self.ptr))
end
|
#end_point ⇒ Object
431
432
433
|
# File 'lib/ffi-geos/geometry.rb', line 431
def end_point
cast_geometry_ptr(FFIGeos.GEOSGeomGetEndPoint_r(Geos.current_handle, self.ptr), :srid_copy => self.srid)
end
|
#envelope ⇒ Object
202
203
204
|
# File 'lib/ffi-geos/geometry.rb', line 202
def envelope
cast_geometry_ptr(FFIGeos.GEOSEnvelope_r(Geos.current_handle, self.ptr), :srid_copy => self.srid)
end
|
#eql?(geom) ⇒ Boolean
Also known as:
==, equals?
324
325
326
327
|
# File 'lib/ffi-geos/geometry.rb', line 324
def eql?(geom)
check_geometry(geom)
bool_result(FFIGeos.GEOSEquals_r(Geos.current_handle, self.ptr, geom.ptr))
end
|
#eql_almost?(geom, decimal = 6) ⇒ Boolean
Also known as:
equals_almost?, almost_equals?
338
339
340
341
|
# File 'lib/ffi-geos/geometry.rb', line 338
def eql_almost?(geom, decimal = 6)
check_geometry(geom)
bool_result(FFIGeos.GEOSEqualsExact_r(Geos.current_handle, self.ptr, geom.ptr, 0.5 * 10 ** (-decimal)))
end
|
#eql_exact?(geom, tolerance) ⇒ Boolean
Also known as:
equals_exact?, exactly_equals?
331
332
333
334
|
# File 'lib/ffi-geos/geometry.rb', line 331
def eql_exact?(geom, tolerance)
check_geometry(geom)
bool_result(FFIGeos.GEOSEqualsExact_r(Geos.current_handle, self.ptr, geom.ptr, tolerance))
end
|
240
241
242
|
# File 'lib/ffi-geos/geometry.rb', line 240
def
cast_geometry_ptr(FFIGeos.GEOSGeom_extractUniquePoints_r(Geos.current_handle, self.ptr), :srid_copy => self.srid)
end
|
#geom_type ⇒ Object
Returns the name of the Geometry type, i.e. “Point”, “Polygon”, etc.
#has_z? ⇒ Boolean
391
392
393
|
# File 'lib/ffi-geos/geometry.rb', line 391
def has_z?
bool_result(FFIGeos.GEOSHasZ_r(Geos.current_handle, self.ptr))
end
|
#hausdorff_distance(geom, densify_frac = nil) ⇒ Object
462
463
464
465
466
467
468
469
470
471
472
473
474
|
# File 'lib/ffi-geos/geometry.rb', line 462
def hausdorff_distance(geom, densify_frac = nil)
check_geometry(geom)
double_ptr = FFI::MemoryPointer.new(:double)
if densify_frac
FFIGeos.GEOSHausdorffDistanceDensify_r(Geos.current_handle, self.ptr, geom.ptr, densify_frac, double_ptr)
else
FFIGeos.GEOSHausdorffDistance_r(Geos.current_handle, self.ptr, geom.ptr, double_ptr)
end
double_ptr.read_double
end
|
#initialize_copy(source) ⇒ Object
25
26
27
28
29
30
31
32
33
|
# File 'lib/ffi-geos/geometry.rb', line 25
def initialize_copy(source)
@ptr = FFI::AutoPointer.new(
FFIGeos.GEOSGeom_clone_r(Geos.current_handle, source.ptr),
self.class.method(:release)
)
self.srid = source.srid
end
|
#interpolate(d, normalized = false) ⇒ Object
413
414
415
416
417
418
419
420
421
|
# File 'lib/ffi-geos/geometry.rb', line 413
def interpolate(d, normalized = false)
ret = if normalized
FFIGeos.GEOSInterpolateNormalized_r(Geos.current_handle, self.ptr, d)
else
FFIGeos.GEOSInterpolate_r(Geos.current_handle, self.ptr, d)
end
cast_geometry_ptr(ret, :srid_copy => self.srid)
end
|
#interpolate_normalized(d) ⇒ Object
423
424
425
|
# File 'lib/ffi-geos/geometry.rb', line 423
def interpolate_normalized(d)
self.interpolate(d, true)
end
|
#intersection(geom) ⇒ Object
82
83
84
85
86
87
|
# File 'lib/ffi-geos/geometry.rb', line 82
def intersection(geom)
check_geometry(geom)
cast_geometry_ptr(FFIGeos.GEOSIntersection_r(Geos.current_handle, self.ptr, geom.ptr), {
:srid_copy => pick_srid_from_geoms(self.srid, geom.srid)
})
end
|
#intersects?(geom) ⇒ Boolean
255
256
257
258
|
# File 'lib/ffi-geos/geometry.rb', line 255
def intersects?(geom)
check_geometry(geom)
bool_result(FFIGeos.GEOSIntersects_r(Geos.current_handle, self.ptr, geom.ptr))
end
|
#length ⇒ Object
445
446
447
448
449
450
451
452
453
|
# File 'lib/ffi-geos/geometry.rb', line 445
def length
if self.empty?
0
else
double_ptr = FFI::MemoryPointer.new(:double)
FFIGeos.GEOSLength_r(Geos.current_handle, self.ptr, double_ptr)
double_ptr.read_double
end
end
|
#line_merge ⇒ Object
228
229
230
|
# File 'lib/ffi-geos/geometry.rb', line 228
def line_merge
cast_geometry_ptr(FFIGeos.GEOSLineMerge_r(Geos.current_handle, self.ptr), :srid_copy => self.srid)
end
|
#normalize! ⇒ Object
Also known as:
normalize
49
50
51
52
53
54
55
|
# File 'lib/ffi-geos/geometry.rb', line 49
def normalize!
if FFIGeos.GEOSNormalize_r(Geos.current_handle, self.ptr) == -1
raise RuntimeError.new("Couldn't normalize #{self.class}")
end
self
end
|
#num_coordinates ⇒ Object
74
75
76
|
# File 'lib/ffi-geos/geometry.rb', line 74
def num_coordinates
FFIGeos.GEOSGetNumCoordinates_r(Geos.current_handle, self.ptr)
end
|
#num_geometries ⇒ Object
70
71
72
|
# File 'lib/ffi-geos/geometry.rb', line 70
def num_geometries
FFIGeos.GEOSGetNumGeometries_r(Geos.current_handle, self.ptr)
end
|
#overlaps?(geom) ⇒ Boolean
275
276
277
278
|
# File 'lib/ffi-geos/geometry.rb', line 275
def overlaps?(geom)
check_geometry(geom)
bool_result(FFIGeos.GEOSOverlaps_r(Geos.current_handle, self.ptr, geom.ptr))
end
|
#point_on_surface ⇒ Object
Also known as:
representative_point
192
193
194
|
# File 'lib/ffi-geos/geometry.rb', line 192
def point_on_surface
cast_geometry_ptr(FFIGeos.GEOSPointOnSurface_r(Geos.current_handle, self.ptr), :srid_copy => self.srid)
end
|
#polygonize ⇒ Object
522
523
524
525
526
527
|
# File 'lib/ffi-geos/geometry.rb', line 522
def polygonize
ary = FFI::MemoryPointer.new(:pointer)
ary.write_array_of_pointer([ self.ptr ])
cast_geometry_ptr(FFIGeos.GEOSPolygonize_r(Geos.current_handle, ary, 1), :srid_copy => self.srid).to_a
end
|
#polygonize_cut_edges ⇒ Object
529
530
531
532
533
534
|
# File 'lib/ffi-geos/geometry.rb', line 529
def polygonize_cut_edges
ary = FFI::MemoryPointer.new(:pointer)
ary.write_array_of_pointer([ self.ptr ])
cast_geometry_ptr(FFIGeos.GEOSPolygonizer_getCutEdges_r(Geos.current_handle, ary, 1), :srid_copy => self.srid).to_a
end
|
#polygonize_full ⇒ Object
Returns a Hash with the following structure:
{
:rings => [ ... ],
:cuts => [ ... ],
:dangles => [ ... ],
:invalid_rings => [ ... ]
}
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
|
# File 'lib/ffi-geos/geometry.rb', line 499
def polygonize_full
cuts = FFI::MemoryPointer.new(:pointer)
dangles = FFI::MemoryPointer.new(:pointer)
invalid_rings = FFI::MemoryPointer.new(:pointer)
rings = cast_geometry_ptr(
FFIGeos.GEOSPolygonize_full_r(Geos.current_handle, self.ptr, cuts, dangles, invalid_rings), {
:srid_copy => self.srid
}
)
cuts = cast_geometry_ptr(cuts.read_pointer, :srid_copy => self.srid)
dangles = cast_geometry_ptr(dangles.read_pointer, :srid_copy => self.srid)
invalid_rings = cast_geometry_ptr(invalid_rings.read_pointer, :srid_copy => self.srid)
{
:rings => rings.to_a,
:cuts => cuts.to_a,
:dangles => dangles.to_a,
:invalid_rings => invalid_rings.to_a
}
end
|
#project(geom, normalized = false) ⇒ Object
398
399
400
401
402
403
404
405
406
|
# File 'lib/ffi-geos/geometry.rb', line 398
def project(geom, normalized = false)
raise TypeError.new("Expected Geos::Point type") if !geom.is_a?(Geos::Point)
if normalized
FFIGeos.GEOSProjectNormalized_r(Geos.current_handle, self.ptr, geom.ptr)
else
FFIGeos.GEOSProject_r(Geos.current_handle, self.ptr, geom.ptr)
end
end
|
#project_normalized(geom) ⇒ Object
408
409
410
|
# File 'lib/ffi-geos/geometry.rb', line 408
def project_normalized(geom)
self.project(geom, true)
end
|
#relate(geom) ⇒ Object
Returns the Dimensionally Extended Nine-Intersection Model (DE-9IM) matrix of the geometries as a String.
208
209
210
211
|
# File 'lib/ffi-geos/geometry.rb', line 208
def relate(geom)
check_geometry(geom)
FFIGeos.GEOSRelate_r(Geos.current_handle, self.ptr, geom.ptr)
end
|
#relate_boundary_node_rule(geom, bnr = :mod2) ⇒ Object
221
222
223
224
225
|
# File 'lib/ffi-geos/geometry.rb', line 221
def relate_boundary_node_rule(geom, bnr = :mod2)
check_geometry(geom)
check_enum_value(Geos::RelateBoundaryNodeRules, bnr)
FFIGeos.GEOSRelateBoundaryNodeRule_r(Geos.current_handle, self.ptr, geom.ptr, bnr)
end
|
#relate_pattern(geom, pattern) ⇒ Object
Checks the DE-9IM pattern against the geoms.
214
215
216
217
|
# File 'lib/ffi-geos/geometry.rb', line 214
def relate_pattern(geom, pattern)
check_geometry(geom)
bool_result(FFIGeos.GEOSRelatePattern_r(Geos.current_handle, self.ptr, geom.ptr, pattern))
end
|
#ring? ⇒ Boolean
387
388
389
|
# File 'lib/ffi-geos/geometry.rb', line 387
def ring?
bool_result(FFIGeos.GEOSisRing_r(Geos.current_handle, self.ptr))
end
|
#shared_paths(geom) ⇒ Object
484
485
486
487
488
489
|
# File 'lib/ffi-geos/geometry.rb', line 484
def shared_paths(geom)
check_geometry(geom)
cast_geometry_ptr(FFIGeos.GEOSSharedPaths_r(Geos.current_handle, self.ptr, geom.ptr), {
:srid_copy => pick_srid_from_geoms(self.srid, geom.srid)
}).to_a
end
|
#simple? ⇒ Boolean
383
384
385
|
# File 'lib/ffi-geos/geometry.rb', line 383
def simple?
bool_result(FFIGeos.GEOSisSimple_r(Geos.current_handle, self.ptr))
end
|
#simplify(tolerance) ⇒ Object
232
233
234
|
# File 'lib/ffi-geos/geometry.rb', line 232
def simplify(tolerance)
cast_geometry_ptr(FFIGeos.GEOSSimplify_r(Geos.current_handle, self.ptr, tolerance), :srid_copy => self.srid)
end
|
#snap(geom, tolerance) ⇒ Object
Also known as:
snap_to
476
477
478
479
480
481
|
# File 'lib/ffi-geos/geometry.rb', line 476
def snap(geom, tolerance)
check_geometry(geom)
cast_geometry_ptr(FFIGeos.GEOSSnap_r(Geos.current_handle, self.ptr, geom.ptr, tolerance), {
:srid_copy => pick_srid_from_geoms(self.srid, geom.srid)
})
end
|
#start_point ⇒ Object
427
428
429
|
# File 'lib/ffi-geos/geometry.rb', line 427
def start_point
cast_geometry_ptr(FFIGeos.GEOSGeomGetStartPoint_r(Geos.current_handle, self.ptr), :srid_copy => self.srid)
end
|
#sym_difference(geom) ⇒ Object
Also known as:
symmetric_difference
147
148
149
150
151
152
|
# File 'lib/ffi-geos/geometry.rb', line 147
def sym_difference(geom)
check_geometry(geom)
cast_geometry_ptr(FFIGeos.GEOSSymDifference_r(Geos.current_handle, self.ptr, geom.ptr), {
:srid_copy => pick_srid_from_geoms(self.srid, geom.srid)
})
end
|
#to_s ⇒ Object
540
541
542
543
544
545
546
547
548
|
# File 'lib/ffi-geos/geometry.rb', line 540
def to_s
writer = WktWriter.new
wkt = writer.write(self)
if wkt.length > 120
wkt = "#{wkt[0...120]} ... "
end
"#<Geos::#{self.geom_type}: #{wkt}>"
end
|
#topology_preserve_simplify(tolerance) ⇒ Object
236
237
238
|
# File 'lib/ffi-geos/geometry.rb', line 236
def topology_preserve_simplify(tolerance)
cast_geometry_ptr(FFIGeos.GEOSTopologyPreserveSimplify_r(Geos.current_handle, self.ptr, tolerance), :srid_copy => self.srid)
end
|
#touches?(geom) ⇒ Boolean
250
251
252
253
|
# File 'lib/ffi-geos/geometry.rb', line 250
def touches?(geom)
check_geometry(geom)
bool_result(FFIGeos.GEOSTouches_r(Geos.current_handle, self.ptr, geom.ptr))
end
|
#type_id ⇒ Object
Returns one of the values from Geos::GeomTypes.
#unary_union ⇒ Object
185
186
187
188
189
|
# File 'lib/ffi-geos/geometry.rb', line 185
def unary_union
cast_geometry_ptr(FFIGeos.GEOSUnaryUnion_r(Geos.current_handle, self.ptr), {
:srid_copy => self.srid
})
end
|
#union(geom = nil) ⇒ Object
Calling without a geom argument is equivalent to calling unary_union when using GEOS 3.3+ and is equivalent to calling union_cascaded in older versions.
162
163
164
165
166
167
168
169
170
171
172
173
174
175
|
# File 'lib/ffi-geos/geometry.rb', line 162
def union(geom = nil)
if geom
check_geometry(geom)
cast_geometry_ptr(FFIGeos.GEOSUnion_r(Geos.current_handle, self.ptr, geom.ptr), {
:srid_copy => pick_srid_from_geoms(self.srid, geom.srid)
})
else
if self.respond_to?(:unary_union)
self.unary_union
else
self.union_cascaded
end
end
end
|
#union_cascaded ⇒ Object
177
178
179
180
181
|
# File 'lib/ffi-geos/geometry.rb', line 177
def union_cascaded
cast_geometry_ptr(FFIGeos.GEOSUnionCascaded_r(Geos.current_handle, self.ptr), {
:srid_copy => self.srid
})
end
|
#valid? ⇒ Boolean
349
350
351
|
# File 'lib/ffi-geos/geometry.rb', line 349
def valid?
bool_result(FFIGeos.GEOSisValid_r(Geos.current_handle, self.ptr))
end
|
#valid_detail(flags = 0) ⇒ Object
Returns a Hash containing the following structure on invalid geometries:
{
:detail => "String explaining the problem",
:location => Geos::Point }
If the Geometry is valid, returns nil.
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
|
# File 'lib/ffi-geos/geometry.rb', line 366
def valid_detail(flags = 0)
detail = FFI::MemoryPointer.new(:pointer)
location = FFI::MemoryPointer.new(:pointer)
valid = bool_result(
FFIGeos.GEOSisValidDetail_r(Geos.current_handle, self.ptr, flags, detail, location)
)
if !valid
{
:detail => detail.read_pointer.read_string,
:location => cast_geometry_ptr(location.read_pointer, {
:srid_copy => self.srid
})
}
end
end
|
#valid_reason ⇒ Object
Returns a String describing whether or not the Geometry is valid.
354
355
356
|
# File 'lib/ffi-geos/geometry.rb', line 354
def valid_reason
FFIGeos.GEOSisValidReason_r(Geos.current_handle, self.ptr)
end
|
#within?(geom) ⇒ Boolean
265
266
267
268
|
# File 'lib/ffi-geos/geometry.rb', line 265
def within?(geom)
check_geometry(geom)
bool_result(FFIGeos.GEOSWithin_r(Geos.current_handle, self.ptr, geom.ptr))
end
|