Module: OGR::Feature::Extensions
- Included in:
- OGR::Feature
- Defined in:
- lib/ogr/extensions/feature/extensions.rb
Instance Method Summary collapse
-
#each_field {|| ... } ⇒ Enumerator
Retrieves the value for each field and yields it.
- #each_geometry_field {|| ... } ⇒ Enumerator
- #each_geometry_field_definition {|| ... } ⇒ Enumerator
-
#field(index) ⇒ Number, ...
Retrieves a field using
index
, but uses its type from the associated OGR::FieldDefinition to determine it’s core type to return as. -
#fields ⇒ Array
Uses each FieldDefinition to determine the field type at each index and returns maps the field as that value type.
- #geometry_field_definitions ⇒ Array<OGR::GeometryFieldDefinition>
- #geometry_fields ⇒ Array<OGR::Geometry>
Instance Method Details
#each_field {|| ... } ⇒ Enumerator
Retrieves the value for each field and yields it.
12 13 14 15 16 17 18 |
# File 'lib/ogr/extensions/feature/extensions.rb', line 12 def each_field return enum_for(:each_field) unless block_given? field_count.times do |i| yield field(i) end end |
#each_geometry_field {|| ... } ⇒ Enumerator
71 72 73 74 75 76 77 |
# File 'lib/ogr/extensions/feature/extensions.rb', line 71 def each_geometry_field return enum_for(:each_geometry_field) unless block_given? geometry_field_count.times do |i| yield geometry_field(i) end end |
#each_geometry_field_definition {|| ... } ⇒ Enumerator
56 57 58 59 60 61 62 |
# File 'lib/ogr/extensions/feature/extensions.rb', line 56 def each_geometry_field_definition return enum_for(:each_geometry_field_definition) unless block_given? geometry_field_count.times do |i| yield geometry_field_definition(i) end end |
#field(index) ⇒ Number, ...
Retrieves a field using index
, but uses its type from the associated OGR::FieldDefinition to determine it’s core type to return as. This saves from having to find out the type then call the associated field_as_[type]
method if you just want the data in it’s originally intended form.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/ogr/extensions/feature/extensions.rb', line 36 def field(index) field_type = field_definition(index).type case field_type when :OFTInteger, :OFTInteger64 then field_as_integer(index) when :OFTIntegerList, :OFTInteger64List then field_as_integer_list(index) when :OFTReal then field_as_double(index) when :OFTRealList then field_as_double_list(index) when :OFTString, :OFTWideString then field_as_string(index) when :OFTStringList, :OFTWideStringList then field_as_string_list(index) when :OFTBinary then field_as_binary(index) when :OFTDate, :OFTTime, :OFTDateTime, :OFTMaxType then field_as_date_time(index) else raise OGR::UnsupportedFieldType, "Don't know how to fetch field for field type: #{field_type}" end end |
#fields ⇒ Array
Returns Uses each FieldDefinition to determine the field type at each index and returns maps the field as that value type.
22 23 24 |
# File 'lib/ogr/extensions/feature/extensions.rb', line 22 def fields each_field.to_a end |
#geometry_field_definitions ⇒ Array<OGR::GeometryFieldDefinition>
65 66 67 |
# File 'lib/ogr/extensions/feature/extensions.rb', line 65 def geometry_field_definitions each_geometry_field_definition.to_a end |
#geometry_fields ⇒ Array<OGR::Geometry>
80 81 82 |
# File 'lib/ogr/extensions/feature/extensions.rb', line 80 def geometry_fields each_geometry_field.to_a end |