Class: OGR::FeatureDefinition
- Inherits:
-
Object
- Object
- OGR::FeatureDefinition
show all
- Includes:
- Extensions
- Defined in:
- lib/ogr/feature_definition.rb,
lib/ogr/extensions/feature_definition/extensions.rb
Defined Under Namespace
Modules: Extensions
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Extensions
#field_definition_by_name, #field_definitions, #geometry_field_definition_by_name, #geometry_field_definitions
Constructor Details
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/ogr/feature_definition.rb', line 22
def initialize(name_or_pointer)
pointer = if name_or_pointer.is_a? String
FFI::OGR::API.OGR_FD_Create(name_or_pointer)
else
name_or_pointer
end
if !pointer.is_a?(FFI::Pointer) || pointer.null?
raise OGR::InvalidFeatureDefinition, "Unable to create #{self.class.name} from #{name_or_pointer}"
end
@c_pointer = FFI::AutoPointer.new(pointer, FeatureDefinition.method(:release))
@c_pointer.autorelease = false
end
|
Instance Attribute Details
#c_pointer ⇒ FFI::Pointer
16
17
18
|
# File 'lib/ogr/feature_definition.rb', line 16
def c_pointer
@c_pointer
end
|
Class Method Details
.release(pointer) ⇒ Object
9
10
11
12
13
|
# File 'lib/ogr/feature_definition.rb', line 9
def self.release(pointer)
return unless pointer && !pointer.null?
FFI::OGR::API.OGR_FD_Release(pointer)
end
|
Instance Method Details
#add_field_definition(field_definition) ⇒ Object
68
69
70
71
72
73
74
75
76
|
# File 'lib/ogr/feature_definition.rb', line 68
def add_field_definition(field_definition)
field_definition_ptr = GDAL._pointer(OGR::FieldDefinition, field_definition)
if field_definition_ptr.nil?
raise OGR::InvalidFieldDefinition, "Unable to add OGR::FieldDefinition: '#{field_definition}'"
end
FFI::OGR::API.OGR_FD_AddFieldDefn(@c_pointer, field_definition_ptr)
end
|
#add_geometry_field_definition(geometry_field_definition) ⇒ Object
151
152
153
154
|
# File 'lib/ogr/feature_definition.rb', line 151
def add_geometry_field_definition(geometry_field_definition)
geometry_field_definition_ptr = GDAL._pointer(OGR::GeometryFieldDefinition, geometry_field_definition)
FFI::OGR::API.OGR_FD_AddGeomFieldDefn(@c_pointer, geometry_field_definition_ptr)
end
|
#delete_field_definition(index) ⇒ Object
80
81
82
83
84
85
86
87
|
# File 'lib/ogr/feature_definition.rb', line 80
def delete_field_definition(index)
OGR::ErrorHandling.handle_ogr_err("Unable to delete field definition at index #{index}") do
FFI::OGR::API.OGR_FD_DeleteFieldDefn(
@c_pointer,
index
)
end
end
|
#delete_geometry_field_definition(index) ⇒ Object
158
159
160
161
162
|
# File 'lib/ogr/feature_definition.rb', line 158
def delete_geometry_field_definition(index)
OGR::ErrorHandling.handle_ogr_err("Unable to delete geometry field definition at index #{index}") do
FFI::OGR::API.OGR_FD_DeleteGeomFieldDefn(@c_pointer, index)
end
end
|
#field_count ⇒ Integer
52
53
54
|
# File 'lib/ogr/feature_definition.rb', line 52
def field_count
FFI::OGR::API.OGR_FD_GetFieldCount(@c_pointer)
end
|
58
59
60
61
62
63
64
65
|
# File 'lib/ogr/feature_definition.rb', line 58
def field_definition(index)
field_definition_ptr = FFI::OGR::API.OGR_FD_GetFieldDefn(@c_pointer, index)
field_definition_ptr.autorelease = false
return nil if field_definition_ptr.null?
OGR::FieldDefinition.new(field_definition_ptr, nil)
end
|
#field_index(name) ⇒ Integer
91
92
93
94
95
|
# File 'lib/ogr/feature_definition.rb', line 91
def field_index(name)
result = FFI::OGR::API.OGR_FD_GetFieldIndex(@c_pointer, name)
result.negative? ? nil : result
end
|
#geometry_field_count ⇒ Integer
128
129
130
|
# File 'lib/ogr/feature_definition.rb', line 128
def geometry_field_count
FFI::OGR::API.OGR_FD_GetGeomFieldCount(@c_pointer)
end
|
134
135
136
137
138
139
140
|
# File 'lib/ogr/feature_definition.rb', line 134
def geometry_field_definition(index)
geometry_field_definition_ptr = FFI::OGR::API.OGR_FD_GetGeomFieldDefn(@c_pointer, index)
return nil if geometry_field_definition_ptr.null?
OGR::GeometryFieldDefinition.new(geometry_field_definition_ptr)
end
|
#geometry_field_index(name) ⇒ Integer
144
145
146
147
148
|
# File 'lib/ogr/feature_definition.rb', line 144
def geometry_field_index(name)
result = FFI::OGR::API.OGR_FD_GetGeomFieldIndex(@c_pointer, name)
result.negative? ? nil : result
end
|
#geometry_ignored? ⇒ Boolean
108
109
110
|
# File 'lib/ogr/feature_definition.rb', line 108
def geometry_ignored?
FFI::OGR::API.OGR_FD_IsGeometryIgnored(@c_pointer)
end
|
#geometry_type ⇒ FFI::OGR::API::WKBGeometryType
98
99
100
|
# File 'lib/ogr/feature_definition.rb', line 98
def geometry_type
FFI::OGR::API.OGR_FD_GetGeomType(@c_pointer)
end
|
#geometry_type=(new_type) ⇒ Object
103
104
105
|
# File 'lib/ogr/feature_definition.rb', line 103
def geometry_type=(new_type)
FFI::OGR::API.OGR_FD_SetGeomType(@c_pointer, new_type)
end
|
#ignore_geometry!(ignore: true) ⇒ Object
113
114
115
|
# File 'lib/ogr/feature_definition.rb', line 113
def ignore_geometry!(ignore: true)
FFI::OGR::API.OGR_FD_SetGeometryIgnored(@c_pointer, ignore)
end
|
#ignore_style!(ignore: true) ⇒ Object
123
124
125
|
# File 'lib/ogr/feature_definition.rb', line 123
def ignore_style!(ignore: true)
FFI::OGR::API.OGR_FD_SetStyleIgnored(@c_pointer, ignore)
end
|
44
45
46
47
48
49
|
# File 'lib/ogr/feature_definition.rb', line 44
def name
name, ptr = FFI::OGR::API.OGR_FD_GetName(@c_pointer)
ptr.autorelease = false
name
end
|
#release! ⇒ Object
37
38
39
40
41
|
# File 'lib/ogr/feature_definition.rb', line 37
def release!
FeatureDefinition.release(@c_pointer)
@c_pointer = nil
end
|
#same?(other_feature_definition) ⇒ Boolean
166
167
168
169
170
|
# File 'lib/ogr/feature_definition.rb', line 166
def same?(other_feature_definition)
fd_ptr = GDAL._pointer(OGR::FeatureDefinition, other_feature_definition)
FFI::OGR::API.OGR_FD_IsSame(@c_pointer, fd_ptr)
end
|
#style_ignored? ⇒ Boolean
118
119
120
|
# File 'lib/ogr/feature_definition.rb', line 118
def style_ignored?
FFI::OGR::API.OGR_FD_IsStyleIgnored(@c_pointer)
end
|