Class: Geos::BufferParams
- Inherits:
-
Object
- Object
- Geos::BufferParams
- Includes:
- Tools
- Defined in:
- lib/ffi-geos/buffer_params.rb
Constant Summary collapse
- VALID_PARAMETERS =
[ :quad_segs, :endcap, :join, :mitre_limit, :single_sided ].freeze
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
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#ptr ⇒ Object
readonly
Returns the value of attribute ptr.
Class Method Summary collapse
-
.release(ptr) ⇒ Object
:nodoc:.
Instance Method Summary collapse
- #endcap=(value) ⇒ Object
-
#initialize(params = {}) ⇒ BufferParams
constructor
The defaults for the params according to GEOS are as found in Geos::Constants::BUFFER_PARAMS_DEFAULTS.
- #join=(value) ⇒ Object
- #mitre_limit=(value) ⇒ Object
- #quad_segs=(value) ⇒ Object
- #single_sided=(value) ⇒ Object
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(params = {}) ⇒ BufferParams
The defaults for the params according to GEOS are as found in Geos::Constants::BUFFER_PARAMS_DEFAULTS. Note that when setting the :quad_segs value that you should set it before setting other values like :join and :mitre_limit, as GEOS contains logic concerning how the :quad_segs value affects these parameters and vice versa. For details, refer to src/operation/buffer/BufferParameters.cpp and the BufferParameters::setQuadrantSegments(int) method in the GEOS source code for details.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/ffi-geos/buffer_params.rb', line 24 def initialize(params = {}) params = Geos::Constants::BUFFER_PARAM_DEFAULTS.merge(params) ptr = FFIGeos.GEOSBufferParams_create_r(Geos.current_handle) @ptr = FFI::AutoPointer.new( ptr, self.class.method(:release) ) @params = {} VALID_PARAMETERS.each do |param| self.send("#{param}=", params[param]) end end |
Instance Attribute Details
#params ⇒ Object (readonly)
Returns the value of attribute params.
14 15 16 |
# File 'lib/ffi-geos/buffer_params.rb', line 14 def params @params end |
#ptr ⇒ Object (readonly)
Returns the value of attribute ptr.
14 15 16 |
# File 'lib/ffi-geos/buffer_params.rb', line 14 def ptr @ptr end |
Class Method Details
.release(ptr) ⇒ Object
:nodoc:
39 40 41 |
# File 'lib/ffi-geos/buffer_params.rb', line 39 def self.release(ptr) #:nodoc: FFIGeos.GEOSBufferParams_destroy_r(Geos.current_handle, ptr) end |
Instance Method Details
#endcap=(value) ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/ffi-geos/buffer_params.rb', line 43 def endcap=(value) check_enum_value(Geos::BufferCapStyles, value) if bool_result(FFIGeos.GEOSBufferParams_setEndCapStyle_r(Geos.current_handle, ptr, value)) @params[:endcap] = symbol_for_enum(Geos::BufferCapStyles, value) end end |
#join=(value) ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/ffi-geos/buffer_params.rb', line 51 def join=(value) check_enum_value(Geos::BufferJoinStyles, value) if bool_result(FFIGeos.GEOSBufferParams_setJoinStyle_r(Geos.current_handle, ptr, value)) @params[:join] = symbol_for_enum(Geos::BufferJoinStyles, value) end end |
#mitre_limit=(value) ⇒ Object
59 60 61 62 63 |
# File 'lib/ffi-geos/buffer_params.rb', line 59 def mitre_limit=(value) if bool_result(FFIGeos.GEOSBufferParams_setMitreLimit_r(Geos.current_handle, ptr, value)) @params[:mitre_limit] = value end end |
#quad_segs=(value) ⇒ Object
65 66 67 68 69 |
# File 'lib/ffi-geos/buffer_params.rb', line 65 def quad_segs=(value) if bool_result(FFIGeos.GEOSBufferParams_setQuadrantSegments_r(Geos.current_handle, ptr, value)) @params[:quad_segs] = value end end |
#single_sided=(value) ⇒ Object
71 72 73 74 75 |
# File 'lib/ffi-geos/buffer_params.rb', line 71 def single_sided=(value) if bool_result(FFIGeos.GEOSBufferParams_setSingleSided_r(Geos.current_handle, ptr, value ? 1 : 0)) @params[:single_sided] = value end end |