Class: OGR::GeometryFieldDefinition
- Inherits:
-
Object
- Object
- OGR::GeometryFieldDefinition
- Defined in:
- lib/ogr/geometry_field_definition.rb
Instance Attribute Summary collapse
- #c_pointer ⇒ FFI::Pointer readonly
- #read_only ⇒ Object writeonly
Class Method Summary collapse
Instance Method Summary collapse
- #destroy! ⇒ Object
- #ignore=(value) ⇒ Object
- #ignored? ⇒ Boolean
-
#initialize(name_or_pointer, type = :wkbUnknown) ⇒ GeometryFieldDefinition
constructor
A new instance of GeometryFieldDefinition.
- #name ⇒ String
- #name=(new_name) ⇒ Object
- #read_only? ⇒ Boolean
- #spatial_reference ⇒ OGR::SpatialReference
-
#spatial_reference=(new_spatial_reference) ⇒ Object
This function drops the reference of the previously set SRS object and acquires a new reference on the passed object (if non-NULL).
- #type ⇒ FFI::OGR::API::WKBGeometryType
- #type=(new_type) ⇒ Object
Constructor Details
#initialize(name_or_pointer, type = :wkbUnknown) ⇒ GeometryFieldDefinition
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/ogr/geometry_field_definition.rb', line 20 def initialize(name_or_pointer, type = :wkbUnknown) pointer = if name_or_pointer.is_a? String FFI::OGR::API.OGR_GFld_Create(name_or_pointer, type) else name_or_pointer end if !pointer.is_a?(FFI::Pointer) || pointer.null? raise OGR::InvalidGeometryFieldDefinition, "Unable to create #{self.class.name} from #{name_or_pointer}" end @c_pointer = FFI::AutoPointer.new(pointer, GeometryFieldDefinition.method(:release)) @c_pointer.autorelease = false @read_only = false end |
Instance Attribute Details
#c_pointer ⇒ FFI::Pointer (readonly)
13 14 15 |
# File 'lib/ogr/geometry_field_definition.rb', line 13 def c_pointer @c_pointer end |
#read_only=(value) ⇒ Object (writeonly)
16 17 18 |
# File 'lib/ogr/geometry_field_definition.rb', line 16 def read_only=(value) @read_only = value end |
Class Method Details
Instance Method Details
#destroy! ⇒ Object
42 43 44 45 46 |
# File 'lib/ogr/geometry_field_definition.rb', line 42 def destroy! GeometryFieldDefinition.release(@c_pointer) @c_pointer = nil end |
#ignore=(value) ⇒ Object
110 111 112 113 114 |
# File 'lib/ogr/geometry_field_definition.rb', line 110 def ignore=(value) raise OGR::ReadOnlyObject if @read_only FFI::OGR::API.OGR_GFld_SetIgnored(@c_pointer, value) end |
#ignored? ⇒ Boolean
105 106 107 |
# File 'lib/ogr/geometry_field_definition.rb', line 105 def ignored? FFI::OGR::API.OGR_GFld_IsIgnored(@c_pointer) end |
#name ⇒ String
49 50 51 52 53 54 |
# File 'lib/ogr/geometry_field_definition.rb', line 49 def name name, ptr = FFI::OGR::API.OGR_GFld_GetNameRef(@c_pointer) ptr.autorelease = false name end |
#name=(new_name) ⇒ Object
57 58 59 60 61 |
# File 'lib/ogr/geometry_field_definition.rb', line 57 def name=(new_name) raise OGR::ReadOnlyObject if @read_only FFI::OGR::API.OGR_GFld_SetName(@c_pointer, new_name) end |
#read_only? ⇒ Boolean
38 39 40 |
# File 'lib/ogr/geometry_field_definition.rb', line 38 def read_only? @read_only || false end |
#spatial_reference ⇒ OGR::SpatialReference
76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/ogr/geometry_field_definition.rb', line 76 def spatial_reference spatial_ref_ptr = FFI::OGR::API.OGR_GFld_GetSpatialRef(@c_pointer) if spatial_ref_ptr.nil? || spatial_ref_ptr.null? nil else auto_ptr = FFI::AutoPointer.new(spatial_ref_ptr, OGR::SpatialReference.method(:release)) OGR::SpatialReference.new(auto_ptr) end end |
#spatial_reference=(new_spatial_reference) ⇒ Object
This function drops the reference of the previously set SRS object and acquires a new reference on the passed object (if non-NULL).
92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/ogr/geometry_field_definition.rb', line 92 def spatial_reference=(new_spatial_reference) raise OGR::ReadOnlyObject if @read_only spatial_ref_ptr = GDAL._pointer(OGR::SpatialReference, new_spatial_reference, autorelease: false) raise if spatial_ref_ptr.null? FFI::OGR::API.OGR_GFld_SetSpatialRef( @c_pointer, spatial_ref_ptr ) end |
#type ⇒ FFI::OGR::API::WKBGeometryType
64 65 66 |
# File 'lib/ogr/geometry_field_definition.rb', line 64 def type FFI::OGR::API.OGR_GFld_GetType(@c_pointer) end |
#type=(new_type) ⇒ Object
69 70 71 72 73 |
# File 'lib/ogr/geometry_field_definition.rb', line 69 def type=(new_type) raise OGR::ReadOnlyObject if @read_only FFI::OGR::API.OGR_GFld_SetType(@c_pointer, new_type) end |