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.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/ffi-geos/wkt_writer.rb', line 10 def initialize( = {}) = { :trim => false, :old_3d => false, :rounding_precision => -1, :output_dimensions => 2 }.merge() ptr = FFIGeos.GEOSWKTWriter_create_r(Geos.current_handle) @ptr = FFI::AutoPointer.new( ptr, self.class.method(:release) ) () end |
Instance Attribute Details
#old_3d ⇒ Object
Returns the value of attribute old_3d.
6 7 8 |
# File 'lib/ffi-geos/wkt_writer.rb', line 6 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.
7 8 9 |
# File 'lib/ffi-geos/wkt_writer.rb', line 7 def rounding_precision @rounding_precision end |
#trim ⇒ Object
Returns the value of attribute trim.
8 9 10 |
# File 'lib/ffi-geos/wkt_writer.rb', line 8 def trim @trim end |
Class Method Details
.release(ptr) ⇒ Object
:nodoc:
27 28 29 |
# File 'lib/ffi-geos/wkt_writer.rb', line 27 def self.release(ptr) #:nodoc: FFIGeos.GEOSWKTWriter_destroy_r(Geos.current_handle, ptr) end |
Instance Method Details
#output_dimensions ⇒ Object
Available in GEOS 3.3+.
104 105 106 |
# File 'lib/ffi-geos/wkt_writer.rb', line 104 def output_dimensions FFIGeos.GEOSWKTWriter_getOutputDimension_r(Geos.current_handle, self.ptr) end |
#output_dimensions=(dim) ⇒ Object
Available in GEOS 3.3+.
93 94 95 96 97 98 99 |
# File 'lib/ffi-geos/wkt_writer.rb', line 93 def output_dimensions=(dim) dim = dim.to_i if dim < 2 || dim > 3 raise RuntimeError.new("Output dimensions must be either 2 or 3") end FFIGeos.GEOSWKTWriter_setOutputDimension_r(Geos.current_handle, self.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
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/ffi-geos/wkt_writer.rb', line 41 def write(geom, = nil) unless .nil? = { :trim => self.trim, :old_3d => self.old_3d, :rounding_precision => self.rounding_precision, :output_dimensions => self.output_dimensions } () end FFIGeos.GEOSWKTWriter_write_r(Geos.current_handle, self.ptr, geom.ptr) ensure () unless .nil? end |