class OGR::Layer
Attributes
geometry_type[RW]
name[RW]
ptr[RW]
Public Class Methods
new(ptr)
click to toggle source
# File lib/ffi-ogr/layer.rb, line 5 def initialize(ptr) @ptr = FFI::AutoPointer.new(ptr, self.class.method(:release)) #@ptr = FFI::AutoPointer.new(ptr) @ptr.autorelease = false end
release(ptr)
click to toggle source
# File lib/ffi-ogr/layer.rb, line 11 def self.release(ptr);end
Public Instance Methods
add_feature(feature)
click to toggle source
# File lib/ffi-ogr/layer.rb, line 65 def add_feature(feature) FFIOGR.OGR_L_CreateFeature(@ptr, feature.ptr) end
add_field(name, field_type, options={})
click to toggle source
# File lib/ffi-ogr/layer.rb, line 43 def add_field(name, field_type, options={}) type = field_type.to_sym precision = options[:precision] || 1 width = options[:width] || 32 field = FFIOGR.OGR_Fld_Create(name, field_type.to_sym) if type == :real FFIOGR.OGR_Fld_SetPrecision(field, precision) else FFIOGR.OGR_Fld_SetWidth(field, width) end FFIOGR.OGR_L_CreateField(@ptr, field, 1) FFIOGR.OGR_Fld_Destroy(field) end
create_feature()
click to toggle source
# File lib/ffi-ogr/layer.rb, line 60 def create_feature feature = FFIOGR.OGR_F_Create(FFIOGR.OGR_L_GetLayerDefn(@ptr)) OGR::Tools.cast_feature(feature) end
free()
click to toggle source
# File lib/ffi-ogr/layer.rb, line 13 def free @ptr.free end
get_envelope()
click to toggle source
# File lib/ffi-ogr/layer.rb, line 21 def get_envelope envelope = FFI::MemoryPointer.new :pointer, 4 FFIOGR.OGR_L_GetExtent(@ptr, envelope, 0) OGR::Envelope.new(envelope.read_array_of_double(4)) end
Also aliased as: envelope
get_features()
click to toggle source
# File lib/ffi-ogr/layer.rb, line 69 def get_features features = [] FFIOGR.OGR_L_ResetReading(@ptr) num_features = FFIOGR.OGR_L_GetFeatureCount(@ptr, 0) for i in (0...num_features) do features << OGR::Tools.cast_feature(FFIOGR.OGR_L_GetNextFeature(@ptr)) end features end
Also aliased as: features
get_geometry_type()
click to toggle source
# File lib/ffi-ogr/layer.rb, line 33 def get_geometry_type FFIOGR.OGR_L_GetGeomType(@ptr) end
Also aliased as: geometry_type
get_name()
click to toggle source
# File lib/ffi-ogr/layer.rb, line 28 def get_name FFIOGR.OGR_L_GetName(@ptr) end
Also aliased as: name
get_spatial_ref()
click to toggle source
# File lib/ffi-ogr/layer.rb, line 38 def get_spatial_ref OGR::Tools.cast_spatial_reference(FFIOGR.OGR_L_GetSpatialRef(@ptr)) end
Also aliased as: spatial_ref
sync()
click to toggle source
# File lib/ffi-ogr/layer.rb, line 17 def sync FFIOGR.OGR_L_SyncToDisk(@ptr) end