ffi-gdal 1.0.0.beta3 → 1.0.0.beta4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/.rubocop.yml +62 -0
- data/Gemfile +1 -1
- data/History.md +53 -28
- data/README.md +6 -0
- data/Rakefile +23 -1
- data/examples/extract_and_colorize.rb +21 -22
- data/examples/geometries.rb +2 -2
- data/examples/gridding.rb +106 -0
- data/examples/ogr_layer_to_layer.rb +1 -1
- data/examples/points.txt +127 -0
- data/examples/testing_gdal.rb +3 -4
- data/ffi-gdal.gemspec +3 -2
- data/lib/ext/error_symbols.rb +2 -57
- data/lib/ext/ffi_library_function_checks.rb +26 -0
- data/lib/ext/float_ext.rb +2 -2
- data/lib/ext/narray_ext.rb +2 -0
- data/lib/ext/numeric_as_data_type.rb +19 -0
- data/lib/ext/to_bool.rb +4 -4
- data/lib/ffi/cpl/conv.rb +132 -0
- data/lib/ffi/cpl/error.rb +67 -0
- data/lib/ffi/cpl/hash_set.rb +39 -0
- data/lib/ffi/cpl/http.rb +25 -0
- data/lib/ffi/cpl/http_result.rb +18 -0
- data/lib/ffi/cpl/list.rb +38 -0
- data/lib/ffi/cpl/mime_part.rb +11 -0
- data/lib/ffi/cpl/minixml.rb +47 -0
- data/lib/ffi/cpl/port.rb +23 -0
- data/lib/ffi/cpl/quad_tree.rb +51 -0
- data/lib/ffi/{ogr/ogr_envelope.rb → cpl/rect_obj.rb} +3 -3
- data/lib/ffi/cpl/string.rb +95 -0
- data/lib/ffi/cpl/vsi.rb +115 -0
- data/lib/ffi/cpl/xml_node.rb +6 -6
- data/lib/ffi/gdal/alg.rb +385 -0
- data/lib/ffi/gdal/{gdal_color_entry.rb → color_entry.rb} +1 -2
- data/lib/ffi/gdal/exceptions.rb +6 -0
- data/lib/ffi/gdal/{gdal_gcp.rb → gcp.rb} +1 -3
- data/lib/ffi/gdal/{gdal_h.rb → gdal.rb} +253 -252
- data/lib/ffi/gdal/grid.rb +58 -0
- data/lib/ffi/gdal/{gdal_grid_data_metrics_options.rb → grid_data_metrics_options.rb} +1 -2
- data/lib/ffi/gdal/{gdal_grid_inverse_distance_to_a_power_options.rb → grid_inverse_distance_to_a_power_options.rb} +1 -2
- data/lib/ffi/gdal/{gdal_grid_moving_average_options.rb → grid_moving_average_options.rb} +1 -2
- data/lib/ffi/gdal/{gdal_grid_nearest_neighbor_options.rb → grid_nearest_neighbor_options.rb} +1 -2
- data/lib/ffi/gdal/matching.rb +20 -0
- data/lib/ffi/gdal/{gdal_rpc_info.rb → rpc_info.rb} +1 -2
- data/lib/ffi/gdal/{gdal_transformer_info.rb → transformer_info.rb} +1 -2
- data/lib/ffi/gdal/version.rb +1 -1
- data/lib/ffi/gdal/vrt.rb +92 -0
- data/lib/ffi/gdal/{gdal_warp_options.rb → warp_options.rb} +8 -4
- data/lib/ffi/gdal/warper.rb +70 -0
- data/lib/ffi/gdal.rb +56 -69
- data/lib/ffi/ogr/api.rb +567 -0
- data/lib/ffi/ogr/{ogr_contour_writer_info.rb → contour_writer_info.rb} +2 -3
- data/lib/ffi/ogr/core.rb +181 -0
- data/lib/ffi/ogr/envelope.rb +12 -0
- data/lib/ffi/ogr/{ogr_envelope_3d.rb → envelope_3d.rb} +2 -2
- data/lib/ffi/ogr/featurestyle.rb +29 -0
- data/lib/ffi/ogr/field.rb +63 -0
- data/lib/ffi/ogr/geocoding.rb +30 -0
- data/lib/ffi/ogr/srs_api.rb +407 -0
- data/lib/ffi/ogr/style_param.rb +13 -0
- data/lib/ffi/ogr/{ogr_style_value.rb → style_value.rb} +4 -3
- data/lib/ffi/ogr.rb +7 -7
- data/lib/ffi-gdal.rb +7 -145
- data/lib/gdal/color_entry.rb +18 -14
- data/lib/gdal/color_entry_mixins/extensions.rb +32 -0
- data/lib/gdal/color_interpretation.rb +2 -2
- data/lib/gdal/color_table.rb +37 -32
- data/lib/gdal/color_table_mixins/extensions.rb +48 -0
- data/lib/gdal/cpl_error_handler.rb +119 -0
- data/lib/gdal/data_type.rb +7 -7
- data/lib/gdal/dataset.rb +131 -238
- data/lib/gdal/dataset_mixins/algorithm_methods.rb +182 -0
- data/lib/gdal/dataset_mixins/extensions.rb +542 -0
- data/lib/gdal/dataset_mixins/matching.rb +26 -0
- data/lib/gdal/driver.rb +68 -92
- data/lib/gdal/driver_mixins/extensions.rb +93 -0
- data/lib/gdal/exceptions.rb +32 -4
- data/lib/gdal/geo_transform.rb +63 -43
- data/lib/gdal/geo_transform_mixins/extensions.rb +57 -0
- data/lib/gdal/grid.rb +144 -0
- data/lib/gdal/grid_types/data_metrics_base.rb +14 -0
- data/lib/gdal/grid_types/inverse_distance_to_a_power.rb +19 -0
- data/lib/gdal/grid_types/metric_average_distance.rb +12 -0
- data/lib/gdal/grid_types/metric_average_distance_pts.rb +12 -0
- data/lib/gdal/grid_types/metric_count.rb +12 -0
- data/lib/gdal/grid_types/metric_maximum.rb +12 -0
- data/lib/gdal/grid_types/metric_minimum.rb +12 -0
- data/lib/gdal/grid_types/metric_range.rb +12 -0
- data/lib/gdal/grid_types/moving_average.rb +19 -0
- data/lib/gdal/grid_types/nearest_neighbor.rb +19 -0
- data/lib/gdal/grid_types.rb +22 -0
- data/lib/gdal/internal_helpers.rb +94 -0
- data/lib/gdal/major_object.rb +4 -7
- data/lib/gdal/options.rb +14 -7
- data/lib/gdal/raster_attribute_table.rb +38 -47
- data/lib/gdal/raster_attribute_table_mixins/extensions.rb +41 -0
- data/lib/gdal/raster_band.rb +193 -227
- data/lib/gdal/raster_band_classifier.rb +107 -0
- data/lib/gdal/raster_band_mixins/algorithm_methods.rb +292 -0
- data/lib/gdal/raster_band_mixins/extensions.rb +238 -0
- data/lib/gdal/rpc_info.rb +35 -0
- data/lib/gdal/transformer.rb +15 -0
- data/lib/gdal/transformers/approximate_transformer.rb +48 -0
- data/lib/gdal/transformers/base_general_image_projection_transformer.rb +45 -0
- data/lib/gdal/transformers/gcp_transformer.rb +55 -0
- data/lib/gdal/transformers/general_image_projection_transformer.rb +31 -0
- data/lib/gdal/transformers/general_image_projection_transformer2.rb +52 -0
- data/lib/gdal/transformers/general_image_projection_transformer3.rb +25 -0
- data/lib/gdal/transformers/geolocation_transformer.rb +42 -0
- data/lib/gdal/transformers/reprojection_transformer.rb +39 -0
- data/lib/gdal/transformers/rpc_transformer.rb +56 -0
- data/lib/gdal/transformers/tps_transformer.rb +40 -0
- data/lib/gdal/virtual_dataset.rb +96 -0
- data/lib/gdal/warp_operation.rb +20 -23
- data/lib/gdal.rb +17 -0
- data/lib/ogr/coordinate_transformation.rb +16 -41
- data/lib/ogr/data_source.rb +103 -58
- data/lib/ogr/data_source_extensions.rb +5 -6
- data/lib/ogr/data_source_mixins/capability_methods.rb +27 -0
- data/lib/ogr/driver.rb +61 -33
- data/lib/ogr/driver_mixins/capability_methods.rb +16 -0
- data/lib/ogr/envelope.rb +29 -18
- data/lib/ogr/envelope_extensions.rb +70 -49
- data/lib/ogr/error_handling.rb +46 -0
- data/lib/ogr/exceptions.rb +58 -12
- data/lib/ogr/feature.rb +334 -86
- data/lib/ogr/feature_definition.rb +94 -51
- data/lib/ogr/feature_definition_extensions.rb +36 -13
- data/lib/ogr/feature_extensions.rb +62 -11
- data/lib/ogr/field.rb +175 -54
- data/lib/ogr/field_definition.rb +110 -0
- data/lib/ogr/{field_extensions.rb → field_definition_extensions.rb} +4 -5
- data/lib/ogr/{geocoding_session.rb → geocoder.rb} +14 -13
- data/lib/ogr/geometries/geometry_collection.rb +13 -0
- data/lib/ogr/geometries/line_string.rb +35 -0
- data/lib/ogr/geometries/linear_ring.rb +11 -0
- data/lib/ogr/geometries/multi_line_string.rb +16 -0
- data/lib/ogr/geometries/multi_point.rb +14 -0
- data/lib/ogr/geometries/multi_polygon.rb +21 -0
- data/lib/ogr/geometries/none_geometry.rb +13 -0
- data/lib/ogr/geometries/point.rb +65 -0
- data/lib/ogr/geometries/point_extensions.rb +32 -0
- data/lib/ogr/geometries/polygon.rb +14 -0
- data/lib/ogr/geometries/unknown_geometry.rb +10 -0
- data/lib/ogr/geometry.rb +270 -242
- data/lib/ogr/geometry_extensions.rb +8 -9
- data/lib/ogr/geometry_field_definition.rb +99 -0
- data/lib/ogr/geometry_field_definition_extensions.rb +19 -0
- data/lib/ogr/geometry_types/container.rb +75 -0
- data/lib/ogr/geometry_types/curve.rb +25 -28
- data/lib/ogr/geometry_types/surface.rb +13 -4
- data/lib/ogr/internal_helpers.rb +57 -0
- data/lib/ogr/layer.rb +60 -181
- data/lib/ogr/layer_mixins/capability_methods.rb +102 -0
- data/lib/ogr/layer_mixins/extensions.rb +59 -0
- data/lib/ogr/layer_mixins/ogr_feature_methods.rb +127 -0
- data/lib/ogr/layer_mixins/ogr_field_methods.rb +143 -0
- data/lib/ogr/layer_mixins/ogr_layer_method_methods.rb +163 -0
- data/lib/ogr/layer_mixins/ogr_query_filter_methods.rb +89 -0
- data/lib/ogr/layer_mixins/ogr_sql_methods.rb +48 -0
- data/lib/ogr/spatial_reference.rb +108 -589
- data/lib/ogr/spatial_reference_extensions.rb +29 -3
- data/lib/ogr/spatial_reference_mixins/coordinate_system_getter_setters.rb +494 -0
- data/lib/ogr/spatial_reference_mixins/exporters.rb +134 -0
- data/lib/ogr/spatial_reference_mixins/importers.rb +243 -0
- data/lib/ogr/spatial_reference_mixins/morphers.rb +25 -0
- data/lib/ogr/spatial_reference_mixins/parameter_getter_setters.rb +122 -0
- data/lib/ogr/spatial_reference_mixins/type_checks.rb +62 -0
- data/lib/ogr/style_table.rb +53 -5
- data/lib/ogr/style_table_extensions.rb +21 -5
- data/lib/ogr/style_tool.rb +118 -0
- data/lib/ogr.rb +8 -0
- data/spec/ffi-gdal_spec.rb +1 -2
- data/spec/integration/{color_table_info_spec.rb → gdal/color_table_info_spec.rb} +12 -12
- data/spec/integration/{dataset_info_spec.rb → gdal/dataset_info_spec.rb} +2 -6
- data/spec/integration/{driver_info_spec.rb → gdal/driver_info_spec.rb} +5 -5
- data/spec/integration/{geo_transform_info_spec.rb → gdal/geo_transform_info_spec.rb} +1 -14
- data/spec/integration/{raster_attribute_table_info_spec.rb → gdal/raster_attribute_table_info_spec.rb} +1 -2
- data/spec/integration/{raster_band_info_spec.rb → gdal/raster_band_info_spec.rb} +30 -42
- data/spec/integration/ogr/layer_spec.rb +97 -0
- data/spec/spec_helper.rb +94 -5
- data/spec/support/integration_help.rb +1 -0
- data/spec/support/shared_contexts.rb +26 -0
- data/spec/support/shared_examples/{major_object_examples.rb → gdal/major_object_examples.rb} +5 -5
- data/spec/support/shared_examples/ogr/a_25D_geometry.rb +7 -0
- data/spec/support/shared_examples/ogr/a_container_geometry.rb +47 -0
- data/spec/support/shared_examples/ogr/a_geometry.rb +404 -0
- data/spec/support/shared_examples/ogr/a_line_string.rb +16 -0
- data/spec/support/test_style_table.txt +3 -0
- data/spec/unit/ext/error_symbols_spec.rb +41 -53
- data/spec/unit/ext/numeric_as_data_type_spec.rb +113 -0
- data/spec/unit/ffi/gdal_spec.rb +70 -0
- data/spec/unit/gdal/color_entry_spec.rb +5 -0
- data/spec/unit/gdal/color_interpretation_spec.rb +5 -0
- data/spec/unit/gdal/{color_table_extensions_spec.rb → color_table_mixins/extensions_spec.rb} +3 -3
- data/spec/unit/gdal/color_table_spec.rb +14 -16
- data/spec/unit/gdal/data_type_spec.rb +10 -17
- data/spec/unit/gdal/dataset_spec.rb +4 -7
- data/spec/unit/gdal/driver_mixins/extensions_spec.rb +22 -0
- data/spec/unit/gdal/driver_spec.rb +49 -0
- data/spec/unit/gdal/environment_methods_spec.rb +6 -0
- data/spec/unit/gdal/geo_transform_spec.rb +276 -0
- data/spec/unit/gdal/grid_spec.rb +5 -0
- data/spec/unit/gdal/internal_helpers_spec.rb +112 -0
- data/spec/unit/gdal/major_object_spec.rb +6 -0
- data/spec/unit/gdal/options_spec.rb +5 -0
- data/spec/unit/gdal/raster_attribute_table_spec.rb +5 -0
- data/spec/unit/gdal/raster_band_classifier_spec.rb +134 -0
- data/spec/unit/gdal/raster_band_spec.rb +5 -0
- data/spec/unit/gdal/rpc_info_spec.rb +5 -0
- data/spec/unit/gdal/version_info_spec.rb +6 -0
- data/spec/unit/gdal/virtual_dataset_spec.rb +32 -0
- data/spec/unit/gdal/warp_operation_spec.rb +5 -0
- data/spec/unit/ogr/data_source_mixins/capability_methods_spec.rb +30 -0
- data/spec/unit/ogr/data_source_spec.rb +209 -0
- data/spec/unit/ogr/driver_mixins/capability_methods_spec.rb +18 -0
- data/spec/unit/ogr/driver_spec.rb +150 -0
- data/spec/unit/ogr/envelope_spec.rb +322 -0
- data/spec/unit/ogr/feature_definition_spec.rb +313 -0
- data/spec/unit/ogr/feature_spec.rb +379 -0
- data/spec/unit/ogr/field_definition_spec.rb +135 -0
- data/spec/unit/ogr/field_spec.rb +193 -0
- data/spec/unit/ogr/geometries/geometry_collection_spec.rb +186 -0
- data/spec/unit/ogr/geometries/line_string_spec.rb +105 -0
- data/spec/unit/ogr/{linear_ring_spec.rb → geometries/linear_ring_spec.rb} +10 -31
- data/spec/unit/ogr/geometries/multi_line_string_spec.rb +14 -0
- data/spec/unit/ogr/geometries/multi_point_spec.rb +14 -0
- data/spec/unit/ogr/geometries/multi_polygon_spec.rb +41 -0
- data/spec/unit/ogr/geometries/none_geometry_spec.rb +12 -0
- data/spec/unit/ogr/{point_spec.rb → geometries/point_spec.rb} +19 -25
- data/spec/unit/ogr/geometries/polygon_spec.rb +17 -0
- data/spec/unit/ogr/geometries/unknown_geometry_spec.rb +10 -0
- data/spec/unit/ogr/geometry_field_definition_spec.rb +87 -0
- data/spec/unit/ogr/geometry_spec.rb +542 -0
- data/spec/unit/ogr/internal_helpers_spec.rb +57 -0
- data/spec/unit/ogr/layer_mixins/capability_methods_spec.rb +88 -0
- data/spec/unit/ogr/layer_mixins/ogr_feature_methods_spec.rb +145 -0
- data/spec/unit/ogr/layer_mixins/ogr_field_methods_spec.rb +432 -0
- data/spec/unit/ogr/layer_mixins/ogr_layer_method_methods_spec.rb +20 -0
- data/spec/unit/ogr/layer_mixins/ogr_query_filter_methods_spec.rb +42 -0
- data/spec/unit/ogr/layer_mixins/ogr_sql_methods_spec.rb +12 -0
- data/spec/unit/ogr/layer_spec.rb +66 -67
- data/spec/unit/ogr/spatial_reference_mixins/coordinate_system_getter_setters_spec.rb +46 -0
- data/spec/unit/ogr/spatial_reference_mixins/exporters_spec.rb +139 -0
- data/spec/unit/ogr/spatial_reference_mixins/importers_spec.rb +38 -0
- data/spec/unit/ogr/spatial_reference_mixins/morphers_spec.rb +36 -0
- data/spec/unit/ogr/spatial_reference_mixins/parameter_getter_setters_spec.rb +102 -0
- data/spec/unit/ogr/spatial_reference_mixins/type_checks_spec.rb +157 -0
- data/spec/unit/ogr/spatial_reference_spec.rb +42 -0
- data/spec/unit/ogr/style_table_spec.rb +132 -0
- data/spec/unit/ogr/style_tool_spec.rb +157 -0
- data/spec/unit/version_info_spec.rb +1 -1
- metadata +285 -75
- data/lib/ffi/cpl/conv_h.rb +0 -143
- data/lib/ffi/cpl/error_h.rb +0 -63
- data/lib/ffi/cpl/minixml_h.rb +0 -14
- data/lib/ffi/cpl/string_h.rb +0 -81
- data/lib/ffi/cpl/vsi_h.rb +0 -112
- data/lib/ffi/gdal/alg_h.rb +0 -127
- data/lib/ffi/gdal/grid_h.rb +0 -51
- data/lib/ffi/gdal/warper_h.rb +0 -48
- data/lib/ffi/ogr/api_h.rb +0 -553
- data/lib/ffi/ogr/core_h.rb +0 -148
- data/lib/ffi/ogr/featurestyle_h.rb +0 -22
- data/lib/ffi/ogr/geocoding_h.rb +0 -21
- data/lib/ffi/ogr/ogr_field.rb +0 -50
- data/lib/ffi/ogr/ogr_style_param.rb +0 -12
- data/lib/ffi/ogr/srs_api_h.rb +0 -325
- data/lib/gdal/color_entry_extensions.rb +0 -30
- data/lib/gdal/color_table_extensions.rb +0 -47
- data/lib/gdal/dataset_extensions.rb +0 -496
- data/lib/gdal/driver_extensions.rb +0 -56
- data/lib/gdal/geo_transform_extensions.rb +0 -90
- data/lib/gdal/raster_attribute_table_extensions.rb +0 -40
- data/lib/gdal/raster_band_extensions.rb +0 -198
- data/lib/ogr/geometry_types/collection.rb +0 -45
- data/lib/ogr/layer_extensions.rb +0 -55
- data/lib/ogr/line_string.rb +0 -7
- data/lib/ogr/linear_ring.rb +0 -6
- data/lib/ogr/multi_line_string.rb +0 -9
- data/lib/ogr/multi_point.rb +0 -7
- data/lib/ogr/multi_polygon.rb +0 -14
- data/lib/ogr/point.rb +0 -89
- data/lib/ogr/polygon.rb +0 -9
@@ -1,17 +1,9 @@
|
|
1
1
|
require_relative '../ffi/gdal'
|
2
|
-
require_relative '
|
3
|
-
|
2
|
+
require_relative 'raster_attribute_table_mixins/extensions'
|
4
3
|
|
5
4
|
module GDAL
|
6
5
|
class RasterAttributeTable
|
7
|
-
include
|
8
|
-
|
9
|
-
# @return [GDAL::RasterAttributeTable]
|
10
|
-
def self.create
|
11
|
-
raster_attribute_table_ptr = FFI::GDAL.GDALCreateRasterAttributeTable
|
12
|
-
|
13
|
-
new(raster_attribute_table_ptr)
|
14
|
-
end
|
6
|
+
include RasterAttributeTableMixins::Extensions
|
15
7
|
|
16
8
|
# Create an object from a ColorTable.
|
17
9
|
#
|
@@ -20,30 +12,31 @@ module GDAL
|
|
20
12
|
def self.from_color_table(color_table)
|
21
13
|
color_table_ptr = GDAL._pointer(GDAL::ColorTable, color_table)
|
22
14
|
rat_ptr = FFI::GDAL.GDALCreateRasterAttributeTable
|
23
|
-
|
24
|
-
cpl_err.to_bool
|
15
|
+
FFI::GDAL.GDALRATInitializeFromColorTable(rat_ptr, color_table_ptr)
|
25
16
|
|
26
17
|
new(rat_ptr)
|
27
18
|
end
|
28
19
|
|
29
|
-
# @
|
30
|
-
|
31
|
-
|
20
|
+
# @return [FFI::Pointer] The C pointer that represents the C RAT.
|
21
|
+
attr_reader :c_pointer
|
22
|
+
|
23
|
+
# @param pointer [FFI::Pointer]
|
24
|
+
def initialize(pointer = nil)
|
25
|
+
@c_pointer = pointer || FFI::GDAL.GDALCreateRasterAttributeTable
|
32
26
|
end
|
33
27
|
|
34
28
|
def destroy!
|
35
|
-
|
36
|
-
end
|
29
|
+
return unless @c_pointer
|
37
30
|
|
38
|
-
|
39
|
-
@
|
31
|
+
FFI::GDAL.GDALDestroyRasterAttributeTable(@c_pointer)
|
32
|
+
@c_pointer = nil
|
40
33
|
end
|
41
34
|
|
42
35
|
# Clone using the C API.
|
43
36
|
#
|
44
37
|
# @return [GDAL::RasterAttributeTable]
|
45
38
|
def clone
|
46
|
-
rat_ptr = FFI::GDAL.GDALRATClone(@
|
39
|
+
rat_ptr = FFI::GDAL.GDALRATClone(@c_pointer)
|
47
40
|
return nil if rat_ptr.null?
|
48
41
|
|
49
42
|
self.class.new(rat_ptr)
|
@@ -54,36 +47,36 @@ module GDAL
|
|
54
47
|
#
|
55
48
|
# @return [Boolean]
|
56
49
|
def changes_written_to_file?
|
57
|
-
FFI::GDAL.GDALRATChangesAreWrittenToFile(@
|
50
|
+
FFI::GDAL.GDALRATChangesAreWrittenToFile(@c_pointer)
|
58
51
|
end
|
59
52
|
|
60
53
|
# @return [Fixnum]
|
61
54
|
def column_count
|
62
|
-
FFI::GDAL.GDALRATGetColumnCount(@
|
55
|
+
FFI::GDAL.GDALRATGetColumnCount(@c_pointer)
|
63
56
|
end
|
64
57
|
|
65
58
|
# @param index [Fixnum] The column number.
|
66
59
|
# @return [String]
|
67
60
|
def column_name(index)
|
68
|
-
FFI::GDAL.GDALRATGetNameOfCol(@
|
61
|
+
FFI::GDAL.GDALRATGetNameOfCol(@c_pointer, index)
|
69
62
|
end
|
70
63
|
|
71
64
|
# @param index [Fixnum] The column number.
|
72
65
|
# @return [GDALRATFieldUsage]
|
73
66
|
def column_usage(index)
|
74
|
-
FFI::GDAL.GDALRATGetUsageOfCol(@
|
67
|
+
FFI::GDAL.GDALRATGetUsageOfCol(@c_pointer, index)
|
75
68
|
end
|
76
69
|
|
77
70
|
# @param index [Fixnum] The column number.
|
78
71
|
# @return [GDALRATFieldType]
|
79
72
|
def column_type(index)
|
80
|
-
FFI::GDAL.GDALRATGetTypeOfCol(@
|
73
|
+
FFI::GDAL.GDALRATGetTypeOfCol(@c_pointer, index)
|
81
74
|
end
|
82
75
|
|
83
76
|
# @param field_usage [GDALRATFieldUsage]
|
84
77
|
# @return [Fixnum] The column number.
|
85
78
|
def column_of_usage(field_usage)
|
86
|
-
FFI::GDAL.GDALRATGetColOfUsage(@
|
79
|
+
FFI::GDAL.GDALRATGetColOfUsage(@c_pointer, field_usage)
|
87
80
|
end
|
88
81
|
|
89
82
|
# @param name [String]
|
@@ -91,19 +84,17 @@ module GDAL
|
|
91
84
|
# @param usage [FFI::GDALRATFieldUsage]
|
92
85
|
# @return [Boolean]
|
93
86
|
def create_column(name, type, usage)
|
94
|
-
|
95
|
-
|
96
|
-
cpl_err.to_bool
|
87
|
+
!!FFI::GDAL.GDALRATCreateColumn(@c_pointer, name, type, usage)
|
97
88
|
end
|
98
89
|
|
99
90
|
# @return [Fixnum] The number of rows.
|
100
91
|
def row_count
|
101
|
-
FFI::GDAL.GDALRATGetRowCount(@
|
92
|
+
FFI::GDAL.GDALRATGetRowCount(@c_pointer)
|
102
93
|
end
|
103
94
|
|
104
95
|
# @return [Fixnum] The number of rows.
|
105
96
|
def row_count=(count)
|
106
|
-
FFI::GDAL.GDALRATSetRowCount(@
|
97
|
+
FFI::GDAL.GDALRATSetRowCount(@c_pointer, count)
|
107
98
|
end
|
108
99
|
|
109
100
|
# Get the row for a pixel value.
|
@@ -111,28 +102,28 @@ module GDAL
|
|
111
102
|
# @param value [Float]
|
112
103
|
# @return [Fixnum]
|
113
104
|
def row_of_value(value)
|
114
|
-
FFI::GDAL.GDALRATGetRowOfValue(@
|
105
|
+
FFI::GDAL.GDALRATGetRowOfValue(@c_pointer, value)
|
115
106
|
end
|
116
107
|
|
117
108
|
# @param row [Fixnum]
|
118
109
|
# @param field [Fixnum]
|
119
110
|
# @return [String]
|
120
111
|
def value_to_s(row, field)
|
121
|
-
FFI::GDAL.GDALRATGetValueAsString(@
|
112
|
+
FFI::GDAL.GDALRATGetValueAsString(@c_pointer, row, field)
|
122
113
|
end
|
123
114
|
|
124
115
|
# @param row [Fixnum]
|
125
116
|
# @param field [Fixnum]
|
126
117
|
# @return [Fixnum]
|
127
118
|
def value_to_i(row, field)
|
128
|
-
FFI::GDAL.GDALRATGetValueAsInt(@
|
119
|
+
FFI::GDAL.GDALRATGetValueAsInt(@c_pointer, row, field)
|
129
120
|
end
|
130
121
|
|
131
122
|
# @param row [Fixnum]
|
132
123
|
# @param field [Fixnum]
|
133
124
|
# @return [Float]
|
134
125
|
def value_to_f(row, field)
|
135
|
-
FFI::GDAL.GDALRATGetValueAsDouble(@
|
126
|
+
FFI::GDAL.GDALRATGetValueAsDouble(@c_pointer, row, field)
|
136
127
|
end
|
137
128
|
|
138
129
|
# @param row [Fixnum]
|
@@ -141,13 +132,13 @@ module GDAL
|
|
141
132
|
def add_value(row, field, value)
|
142
133
|
case value.class.name
|
143
134
|
when 'String'
|
144
|
-
FFI::GDAL.GDALRATSetValueAsString(@
|
135
|
+
FFI::GDAL.GDALRATSetValueAsString(@c_pointer, row, field, value)
|
145
136
|
when 'Float'
|
146
|
-
FFI::GDAL.GDALRATSetValueAsDouble(@
|
137
|
+
FFI::GDAL.GDALRATSetValueAsDouble(@c_pointer, row, field, value)
|
147
138
|
when 'Fixnum'
|
148
|
-
FFI::GDAL.GDALRATSetValueAsInt(@
|
139
|
+
FFI::GDAL.GDALRATSetValueAsInt(@c_pointer, row, field, value)
|
149
140
|
else
|
150
|
-
|
141
|
+
fail "Unknown value type for value '#{value}'"
|
151
142
|
end
|
152
143
|
end
|
153
144
|
|
@@ -155,7 +146,7 @@ module GDAL
|
|
155
146
|
def linear_binning
|
156
147
|
row_0_min_ptr = FFI::MemoryPointer.new(:double)
|
157
148
|
bin_size_ptr = FFI::MemoryPointer.new(:double)
|
158
|
-
FFI::GDAL.GDALRATGetLinearBinning(@
|
149
|
+
FFI::GDAL.GDALRATGetLinearBinning(@c_pointer, row_0_min_ptr, bin_size_ptr)
|
159
150
|
|
160
151
|
{
|
161
152
|
row_0_minimum: row_0_min_ptr.read_double,
|
@@ -167,19 +158,19 @@ module GDAL
|
|
167
158
|
# will try to auto-determine the number.
|
168
159
|
# @return [GDAL::ColorTable]
|
169
160
|
def to_color_table(entry_count = -1)
|
170
|
-
color_table_pointer = FFI::GDAL.GDALRATTranslateToColorTable(@
|
161
|
+
color_table_pointer = FFI::GDAL.GDALRATTranslateToColorTable(@c_pointer, entry_count)
|
171
162
|
|
172
163
|
GDAL::ColorTable.new(color_table_pointer)
|
173
164
|
end
|
174
165
|
|
175
166
|
# @param file_path [String]
|
176
|
-
def dump_readable(file_path=nil)
|
167
|
+
def dump_readable(file_path = nil)
|
177
168
|
file = if file_path
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
FFI::GDAL.GDALRATDumpReadable(@
|
169
|
+
File.open(file_path, 'r')
|
170
|
+
else
|
171
|
+
file_path
|
172
|
+
end
|
173
|
+
FFI::GDAL.GDALRATDumpReadable(@c_pointer, file)
|
183
174
|
end
|
184
175
|
end
|
185
176
|
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module GDAL
|
4
|
+
module RasterAttributeTableMixins
|
5
|
+
module Extensions
|
6
|
+
# Get +column_name+, +column_usage+, +column_type+ as a Hash.
|
7
|
+
#
|
8
|
+
# @param index [Fixnum]
|
9
|
+
# @return [Hash]
|
10
|
+
def column(index)
|
11
|
+
{
|
12
|
+
name: column_name(index),
|
13
|
+
usage: column_usage(index),
|
14
|
+
type: column_type(index)
|
15
|
+
}
|
16
|
+
end
|
17
|
+
|
18
|
+
# @return [Array<Hash>]
|
19
|
+
def columns
|
20
|
+
column_count.times.map do |i|
|
21
|
+
column(i)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# @return [Hash]
|
26
|
+
def as_json(_options = nil)
|
27
|
+
{
|
28
|
+
column_count: column_count,
|
29
|
+
columns: columns,
|
30
|
+
linear_binning: linear_binning,
|
31
|
+
row_count: row_count
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
# @return [String]
|
36
|
+
def to_json(options = nil)
|
37
|
+
as_json(options).to_json
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|