Class: Geos::WktWriter
- Inherits:
-
Object
- Object
- Geos::WktWriter
- Defined in:
- lib/ffi-geos/wkt_writer.rb
Instance Attribute Summary collapse
-
#old_3d ⇒ Object
Returns the value of attribute old_3d.
-
#ptr ⇒ Object
readonly
Returns the value of attribute ptr.
-
#rounding_precision ⇒ Object
Returns the value of attribute rounding_precision.
-
#trim ⇒ Object
Returns the value of attribute trim.
Class Method Summary collapse
-
.release(ptr) ⇒ Object
:nodoc:.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ WktWriter
constructor
A new instance of WktWriter.
-
#output_dimensions ⇒ Object
Available in GEOS 3.3+.
-
#output_dimensions=(dim) ⇒ Object
Available in GEOS 3.3+.
-
#write(geom, options = nil) ⇒ Object
Options can be set temporarily for individual writes using an options Hash.
Constructor Details
#initialize(options = {}) ⇒ WktWriter
Returns a new instance of WktWriter.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/ffi-geos/wkt_writer.rb', line 7 def initialize( = {}) = { trim: false, old_3d: false, rounding_precision: -1, output_dimensions: 2 }.merge() ptr = FFIGeos.GEOSWKTWriter_create_r(Geos.current_handle_pointer) @ptr = FFI::AutoPointer.new( ptr, self.class.method(:release) ) () end |
Instance Attribute Details
#old_3d ⇒ Object
Returns the value of attribute old_3d.
5 6 7 |
# File 'lib/ffi-geos/wkt_writer.rb', line 5 def old_3d @old_3d end |
#ptr ⇒ Object (readonly)
Returns the value of attribute ptr.
5 6 7 |
# File 'lib/ffi-geos/wkt_writer.rb', line 5 def ptr @ptr end |
#rounding_precision ⇒ Object
Returns the value of attribute rounding_precision.
5 6 7 |
# File 'lib/ffi-geos/wkt_writer.rb', line 5 def rounding_precision @rounding_precision end |
#trim ⇒ Object
Returns the value of attribute trim.
5 6 7 |
# File 'lib/ffi-geos/wkt_writer.rb', line 5 def trim @trim end |
Class Method Details
.release(ptr) ⇒ Object
:nodoc:
24 25 26 |
# File 'lib/ffi-geos/wkt_writer.rb', line 24 def self.release(ptr) # :nodoc: FFIGeos.GEOSWKTWriter_destroy_r(Geos.current_handle_pointer, ptr) end |
Instance Method Details
#output_dimensions ⇒ Object
Available in GEOS 3.3+.
94 95 96 |
# File 'lib/ffi-geos/wkt_writer.rb', line 94 def output_dimensions FFIGeos.GEOSWKTWriter_getOutputDimension_r(Geos.current_handle_pointer, ptr) end |
#output_dimensions=(dim) ⇒ Object
Available in GEOS 3.3+.
84 85 86 87 88 89 |
# File 'lib/ffi-geos/wkt_writer.rb', line 84 def output_dimensions=(dim) dim = dim.to_i raise ArgumentError, 'Output dimensions must be either 2 or 3' if dim < 2 || dim > 3 FFIGeos.GEOSWKTWriter_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. Options include :trim, :old_3d, :rounding_precision and :output_dimensions
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/ffi-geos/wkt_writer.rb', line 38 def write(geom, = nil) unless .nil? = { trim: trim, old_3d: old_3d, rounding_precision: rounding_precision, output_dimensions: output_dimensions } () end FFIGeos.GEOSWKTWriter_write_r(Geos.current_handle_pointer, ptr, geom.ptr) ensure () unless .nil? end |