Class: Geos::WkbWriter
- Inherits:
-
Object
show all
- Includes:
- Tools
- Defined in:
- lib/ffi-geos/wkb_writer.rb
Constant Summary
Constants included
from GeomTypes
GeomTypes::GEOS_GEOMETRYCOLLECTION, GeomTypes::GEOS_LINEARRING, GeomTypes::GEOS_LINESTRING, GeomTypes::GEOS_MULTILINESTRING, GeomTypes::GEOS_MULTIPOINT, GeomTypes::GEOS_MULTIPOLYGON, GeomTypes::GEOS_POINT, GeomTypes::GEOS_POLYGON
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Tools
#bool_result, #bool_to_int, #cast_geometry_ptr, #check_enum_value, #check_geometry, #extract_options!, #pick_srid_according_to_policy, #pick_srid_from_geoms, #symbol_for_enum
Constructor Details
#initialize(options = {}) ⇒ WkbWriter
Returns a new instance of WkbWriter.
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/ffi-geos/wkb_writer.rb', line 9
def initialize(options = {})
options = {
include_srid: false
}.merge(options)
ptr = FFIGeos.GEOSWKBWriter_create_r(Geos.current_handle_pointer)
@ptr = FFI::AutoPointer.new(
ptr,
self.class.method(:release)
)
set_options(options)
end
|
Instance Attribute Details
#ptr ⇒ Object
Returns the value of attribute ptr.
7
8
9
|
# File 'lib/ffi-geos/wkb_writer.rb', line 7
def ptr
@ptr
end
|
Instance Method Details
#byte_order=(val) ⇒ Object
#include_srid=(val) ⇒ Object
#output_dimensions ⇒ Object
#output_dimensions=(dim) ⇒ Object
59
60
61
62
63
|
# File 'lib/ffi-geos/wkb_writer.rb', line 59
def output_dimensions=(dim)
raise ArgumentError, 'Output dimensions must be either 2 or 3' if dim < 2 || dim > 3
FFIGeos.GEOSWKBWriter_setOutputDimension_r(Geos.current_handle_pointer, ptr, dim)
end
|
#write(geom, options = nil) ⇒ Object
Options can be set temporarily for individual writes using an options Hash. The only option currently available is :include_srid.
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/ffi-geos/wkb_writer.rb', line 29
def write(geom, options = nil)
unless options.nil?
old_options = {
include_srid: include_srid
}
set_options(options)
end
size_t = FFI::MemoryPointer.new(:size_t)
FFIGeos.GEOSWKBWriter_write_r(Geos.current_handle_pointer, ptr, geom.ptr, size_t).get_bytes(0, size_t.read_int)
ensure
set_options(old_options) unless old_options.nil?
end
|
#write_hex(geom, options = nil) ⇒ Object
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/ffi-geos/wkb_writer.rb', line 44
def write_hex(geom, options = nil)
unless options.nil?
old_options = {
include_srid: include_srid
}
set_options(options)
end
size_t = FFI::MemoryPointer.new(:size_t)
FFIGeos.GEOSWKBWriter_writeHEX_r(Geos.current_handle_pointer, ptr, geom.ptr, size_t).get_string(0, size_t.read_int)
ensure
set_options(old_options) unless old_options.nil?
end
|