class OGR::StyleTool
Attributes
@return [FFI::Pointer] C pointer to the C style tool.
Public Class Methods
@param style_tool_class [FFI::OGR::Core::STClassId] Must be one of :OGRSTCPen,
:OGRSTCBrush, :OGRSTCSymbol, :OGRSTCLabel.
# File lib/ogr/style_tool.rb, line 19 def initialize(style_tool_class) pointer = FFI::OGR::API.OGR_ST_Create(style_tool_class) if !pointer || pointer.null? raise OGR::CreateFailure, "Unable to create StyleTool using class #{style_tool_class}" end @c_pointer = FFI::AutoPointer.new(pointer, StyleTool.method(:release)) end
@param pointer [FFI::Pointer]
# File lib/ogr/style_tool.rb, line 8 def self.release(pointer) return unless pointer && !pointer.null? FFI::OGR::API.OGR_ST_Destroy(pointer) end
Public Instance Methods
@param param_number [Integer] @return [Float, nil]
# File lib/ogr/style_tool.rb, line 55 def param_as_double(param_number) value_is_null_ptr = FFI::MemoryPointer.new(:int) value = FFI::OGR::API.OGR_ST_GetParamDbl(@c_pointer, param_number, value_is_null_ptr) value_is_null_ptr.read_int.to_bool ? nil : value end
@param param_number [Integer] @return [Integer, nil]
# File lib/ogr/style_tool.rb, line 72 def param_as_number(param_number) value_is_null_ptr = FFI::MemoryPointer.new(:int) value = FFI::OGR::API.OGR_ST_GetParamNum(@c_pointer, param_number, value_is_null_ptr) value_is_null_ptr.read_int.to_bool ? nil : value end
@param param_number [Integer] @return [String, nil]
# File lib/ogr/style_tool.rb, line 89 def param_as_string(param_number) value_is_null_ptr = FFI::MemoryPointer.new(:int) value, ptr = FFI::OGR::API.OGR_ST_GetParamStr(@c_pointer, param_number, value_is_null_ptr) ptr.autorelease = false value_is_null_ptr.read_int.to_bool ? nil : value end
Returns the R, G, B, A components of a RRGGBB[AA] formatted string.
@param color_string [String] @return [Hash{red => Integer
, green => Integer
, blue => Integer
, alpha => Integer}]
# File lib/ogr/style_tool.rb, line 107 def rgb_from_string(color_string) red_ptr = FFI::MemoryPointer.new(:int) green_ptr = FFI::MemoryPointer.new(:int) blue_ptr = FFI::MemoryPointer.new(:int) alpha_ptr = FFI::MemoryPointer.new(:int) boolean_result = FFI::OGR::API.OGR_ST_GetRGBFromString(@c_pointer, color_string, red_ptr, green_ptr, blue_ptr, alpha_ptr) if boolean_result { red: red_ptr.read_int, green: green_ptr.read_int, blue: blue_ptr.read_int, alpha: alpha_ptr.read_int } else { red: nil, green: nil, blue: nil, alpha: nil } end end
@param param_number [Integer] @param value [Float]
# File lib/ogr/style_tool.rb, line 65 def set_param_as_double(param_number, value) FFI::OGR::API.OGR_ST_SetParamDbl(@c_pointer, param_number, value) end
@param param_number [Integer] @param value [Integer]
# File lib/ogr/style_tool.rb, line 82 def set_param_as_number(param_number, value) FFI::OGR::API.OGR_ST_SetParamNum(@c_pointer, param_number, value) end
@param param_number [Integer] @param value [String]
# File lib/ogr/style_tool.rb, line 99 def set_param_as_string(param_number, value) FFI::OGR::API.OGR_ST_SetParamStr(@c_pointer, param_number, value) end
@param new_unit [FFI::OGR::Core::STUnitId] @param ground_to_paper_scale [Float]
# File lib/ogr/style_tool.rb, line 49 def set_unit(new_unit, ground_to_paper_scale) FFI::OGR::API.OGR_ST_SetUnit(@c_pointer, new_unit, ground_to_paper_scale) end
@return [String, nil]
# File lib/ogr/style_tool.rb, line 30 def style_string style, ptr = FFI::OGR::API.OGR_ST_GetStyleString(@c_pointer) ptr.autorelease = false style end
@return [FFI::OGR::Core::STClassId]
# File lib/ogr/style_tool.rb, line 38 def type FFI::OGR::API.OGR_ST_GetType(@c_pointer) end
@return [FFI::OGR::Core::STUnitId]
# File lib/ogr/style_tool.rb, line 43 def unit FFI::OGR::API.OGR_ST_GetUnit(@c_pointer) end