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, #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(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.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/ffi-geos/buffer_params.rb', line 25 def initialize(params = {}) params = Geos::Constants::BUFFER_PARAM_DEFAULTS.merge(params) ptr = FFIGeos.GEOSBufferParams_create_r(Geos.current_handle_pointer) @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.
15 16 17 |
# File 'lib/ffi-geos/buffer_params.rb', line 15 def params @params end |
#ptr ⇒ Object (readonly)
Returns the value of attribute ptr.
15 16 17 |
# File 'lib/ffi-geos/buffer_params.rb', line 15 def ptr @ptr end |
Class Method Details
.release(ptr) ⇒ Object
:nodoc:
40 41 42 |
# File 'lib/ffi-geos/buffer_params.rb', line 40 def self.release(ptr) #:nodoc: FFIGeos.GEOSBufferParams_destroy_r(Geos.current_handle_pointer, ptr) end |
Instance Method Details
#endcap=(value) ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/ffi-geos/buffer_params.rb', line 44 def endcap=(value) check_enum_value(Geos::BufferCapStyles, value) if bool_result(FFIGeos.GEOSBufferParams_setEndCapStyle_r(Geos.current_handle_pointer, ptr, value)) @params[:endcap] = symbol_for_enum(Geos::BufferCapStyles, value) end end |
#join=(value) ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/ffi-geos/buffer_params.rb', line 52 def join=(value) check_enum_value(Geos::BufferJoinStyles, value) if bool_result(FFIGeos.GEOSBufferParams_setJoinStyle_r(Geos.current_handle_pointer, ptr, value)) @params[:join] = symbol_for_enum(Geos::BufferJoinStyles, value) end end |
#mitre_limit=(value) ⇒ Object
60 61 62 63 64 |
# File 'lib/ffi-geos/buffer_params.rb', line 60 def mitre_limit=(value) if bool_result(FFIGeos.GEOSBufferParams_setMitreLimit_r(Geos.current_handle_pointer, ptr, value)) @params[:mitre_limit] = value end end |
#quad_segs=(value) ⇒ Object
66 67 68 69 70 |
# File 'lib/ffi-geos/buffer_params.rb', line 66 def quad_segs=(value) if bool_result(FFIGeos.GEOSBufferParams_setQuadrantSegments_r(Geos.current_handle_pointer, ptr, value)) @params[:quad_segs] = value end end |
#single_sided=(value) ⇒ Object
72 73 74 75 76 |
# File 'lib/ffi-geos/buffer_params.rb', line 72 def single_sided=(value) if bool_result(FFIGeos.GEOSBufferParams_setSingleSided_r(Geos.current_handle_pointer, ptr, Geos::Tools.bool_to_int(value))) @params[:single_sided] = value end end |