class Geos::WkbWriter
Attributes
ptr[R]
Public Class Methods
new(options = {})
click to toggle source
# 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
Public Instance Methods
byte_order()
click to toggle source
# File lib/ffi-geos/wkb_writer.rb, line 77 def byte_order FFIGeos.GEOSWKBWriter_getByteOrder_r(Geos.current_handle_pointer, ptr) end
byte_order=(val)
click to toggle source
# File lib/ffi-geos/wkb_writer.rb, line 81 def byte_order=(val) check_enum_value(Geos::ByteOrders, val) FFIGeos.GEOSWKBWriter_setByteOrder_r(Geos.current_handle_pointer, ptr, val) end
flavor()
click to toggle source
# File lib/ffi-geos/wkb_writer.rb, line 87 def flavor FFIGeos.GEOSWKBWriter_getFlavor_r(Geos.current_handle_pointer, ptr) end
flavor=(val)
click to toggle source
# File lib/ffi-geos/wkb_writer.rb, line 93 def flavor=(val) FFIGeos.GEOSWKBWriter_setFlavor_r(Geos.current_handle_pointer, ptr, val) end
include_srid()
click to toggle source
# File lib/ffi-geos/wkb_writer.rb, line 69 def include_srid bool_result(FFIGeos.GEOSWKBWriter_getIncludeSRID_r(Geos.current_handle_pointer, ptr)) end
include_srid=(val)
click to toggle source
# File lib/ffi-geos/wkb_writer.rb, line 73 def include_srid=(val) FFIGeos.GEOSWKBWriter_setIncludeSRID_r(Geos.current_handle_pointer, ptr, Geos::Tools.bool_to_int(val)) end
output_dimensions()
click to toggle source
# File lib/ffi-geos/wkb_writer.rb, line 65 def output_dimensions FFIGeos.GEOSWKBWriter_getOutputDimension_r(Geos.current_handle_pointer, ptr) end
output_dimensions=(dim)
click to toggle source
# 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)
click to toggle source
Options can be set temporarily for individual writes using an options Hash. The only option currently available is :include_srid.
# 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)
click to toggle source
# 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