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
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'ffi'
|
2
|
+
require_relative '../../ext/ffi_library_function_checks'
|
3
|
+
|
4
|
+
module FFI
|
5
|
+
module GDAL
|
6
|
+
module Grid
|
7
|
+
extend ::FFI::Library
|
8
|
+
ffi_lib [::FFI::CURRENT_PROCESS, ::FFI::GDAL.gdal_library_path]
|
9
|
+
|
10
|
+
#------------------------------------------------------------------------
|
11
|
+
# Typedefs
|
12
|
+
#------------------------------------------------------------------------
|
13
|
+
callback :GDALGridFunction,
|
14
|
+
%i[pointer GUInt32 pointer pointer pointer double double pointer pointer],
|
15
|
+
CPLErr
|
16
|
+
|
17
|
+
#------------------------------------------------------------------------
|
18
|
+
# Functions
|
19
|
+
#------------------------------------------------------------------------
|
20
|
+
attach_function :GDALGridInverseDistanceToAPower,
|
21
|
+
%i[pointer GUInt32 pointer pointer pointer double double pointer pointer],
|
22
|
+
CPLErr
|
23
|
+
attach_function :GDALGridInverseDistanceToAPointerNoSearch,
|
24
|
+
%i[pointer GUInt32 pointer pointer pointer double double pointer pointer],
|
25
|
+
CPLErr
|
26
|
+
|
27
|
+
attach_function :GDALGridMovingAverage,
|
28
|
+
%i[pointer GUInt32 pointer pointer pointer double double pointer pointer],
|
29
|
+
CPLErr
|
30
|
+
|
31
|
+
attach_function :GDALGridNearestNeighbor,
|
32
|
+
%i[pointer GUInt32 pointer pointer pointer double double pointer pointer],
|
33
|
+
CPLErr
|
34
|
+
|
35
|
+
attach_function :GDALGridDataMetricMinimum,
|
36
|
+
%i[pointer GUInt32 pointer pointer pointer double double pointer pointer],
|
37
|
+
CPLErr
|
38
|
+
attach_function :GDALGridDataMetricMaximum,
|
39
|
+
%i[pointer GUInt32 pointer pointer pointer double double pointer pointer],
|
40
|
+
CPLErr
|
41
|
+
attach_function :GDALGridDataMetricRange,
|
42
|
+
%i[pointer GUInt32 pointer pointer pointer double double pointer pointer],
|
43
|
+
CPLErr
|
44
|
+
attach_function :GDALGridDataMetricCount,
|
45
|
+
%i[pointer GUInt32 pointer pointer pointer double double pointer pointer],
|
46
|
+
CPLErr
|
47
|
+
attach_function :GDALGridDataMetricAverageDistance,
|
48
|
+
%i[pointer GUInt32 pointer pointer pointer double double pointer pointer],
|
49
|
+
CPLErr
|
50
|
+
attach_function :GDALGridDataMetricAverageDistancePts,
|
51
|
+
%i[pointer GUInt32 pointer pointer pointer double double pointer pointer],
|
52
|
+
CPLErr
|
53
|
+
attach_function :ParseAlgorithmAndOptions,
|
54
|
+
[:string, GDALGridAlgorithm, :pointer],
|
55
|
+
CPLErr
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'ffi'
|
2
|
+
require_relative '../../ext/ffi_library_function_checks'
|
3
|
+
require_relative 'gdal'
|
4
|
+
require_relative 'gcp'
|
5
|
+
|
6
|
+
module FFI
|
7
|
+
module GDAL
|
8
|
+
module Matching
|
9
|
+
extend ::FFI::Library
|
10
|
+
ffi_lib [::FFI::CURRENT_PROCESS, ::FFI::GDAL.gdal_library_path]
|
11
|
+
|
12
|
+
# TODO: Seems like this should return an array of GCPs, not just a single
|
13
|
+
# GCP.
|
14
|
+
attach_function :GDALComputeMatchingPoints,
|
15
|
+
[GDAL.find_type(:GDALDatasetH), GDAL.find_type(:GDALDatasetH), :pointer, :pointer],
|
16
|
+
# :pointer
|
17
|
+
GCP.ptr
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/ffi/gdal/version.rb
CHANGED
data/lib/ffi/gdal/vrt.rb
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
require 'ffi'
|
2
|
+
require_relative '../../ext/ffi_library_function_checks'
|
3
|
+
require_relative '../cpl/error'
|
4
|
+
require_relative '../cpl/xml_node'
|
5
|
+
|
6
|
+
module FFI
|
7
|
+
module GDAL
|
8
|
+
module VRT
|
9
|
+
extend ::FFI::Library
|
10
|
+
ffi_lib [::FFI::CURRENT_PROCESS, ::FFI::GDAL.gdal_library_path]
|
11
|
+
|
12
|
+
#-------------------------------------------------------------------------
|
13
|
+
# Typedefs
|
14
|
+
#-------------------------------------------------------------------------
|
15
|
+
typedef :pointer, :VRTDriverH
|
16
|
+
|
17
|
+
typedef :pointer, :VRTSourceH
|
18
|
+
typedef :pointer, :VRTSimpleSourceH
|
19
|
+
typedef :pointer, :VRTAveragedSourceH
|
20
|
+
typedef :pointer, :VRTComplexSourceH
|
21
|
+
typedef :pointer, :VRTFilteredSourceH
|
22
|
+
typedef :pointer, :VRTKernelFilteredSourceH
|
23
|
+
typedef :pointer, :VRTAverageFilteredSourceH
|
24
|
+
typedef :pointer, :VRTFuncSourceH
|
25
|
+
|
26
|
+
typedef :pointer, :VRTDatasetH
|
27
|
+
typedef :pointer, :VRTWarpedDatasetH
|
28
|
+
|
29
|
+
typedef :pointer, :VRTRasterBandH
|
30
|
+
typedef :pointer, :VRTSourcedRasterBandH
|
31
|
+
typedef :pointer, :VRTWarpedRasterBandH
|
32
|
+
typedef :pointer, :VRTDerivedRasterBandH
|
33
|
+
typedef :pointer, :VRTRawRasterBandH
|
34
|
+
|
35
|
+
callback :VRTImageReadFunc,
|
36
|
+
%i[pointer int int int int pointer],
|
37
|
+
CPL::Error::CPLErr
|
38
|
+
|
39
|
+
#-------------------------------------------------------------------------
|
40
|
+
# Functions
|
41
|
+
#-------------------------------------------------------------------------
|
42
|
+
attach_function :GDALRegister_VRT, [], :void
|
43
|
+
attach_function :VRTCreate, %i[int int], :VRTDatasetH
|
44
|
+
attach_function :VRTFlushCache, %i[VRTDatasetH], :void
|
45
|
+
attach_function :VRTSerializeToXML, %i[VRTDatasetH string], CPL::XMLNode.ptr
|
46
|
+
|
47
|
+
attach_function :VRTAddBand,
|
48
|
+
[:VRTDatasetH, GDAL::DataType, :pointer],
|
49
|
+
:int
|
50
|
+
|
51
|
+
attach_function :VRTAddSource,
|
52
|
+
%i[VRTSourcedRasterBandH VRTSourceH],
|
53
|
+
CPL::Error::CPLErr
|
54
|
+
attach_function :VRTAddSimpleSource,
|
55
|
+
[
|
56
|
+
:VRTSourcedRasterBandH, # hVRTBand
|
57
|
+
GDAL.find_type(:GDALRasterBandH), # hSrcBand
|
58
|
+
:int, # nSrcXOff
|
59
|
+
:int, # nSrcYOff
|
60
|
+
:int, # nSrcXSize
|
61
|
+
:int, # nSrcYSize
|
62
|
+
:int, # nDstXOff
|
63
|
+
:int, # nDstYOff
|
64
|
+
:int, # nDstXSize
|
65
|
+
:int, # nDstYSize
|
66
|
+
:string, # pszResampling
|
67
|
+
:double # dfNoDataValue
|
68
|
+
],
|
69
|
+
CPL::Error::CPLErr
|
70
|
+
attach_function :VRTAddComplexSource,
|
71
|
+
[
|
72
|
+
:VRTSourcedRasterBandH, # hVRTBand
|
73
|
+
GDAL.find_type(:GDALRasterBandH), # hSrcBand
|
74
|
+
:int, # nSrcXOff
|
75
|
+
:int, # nSrcYOff
|
76
|
+
:int, # nSrcXSize
|
77
|
+
:int, # nSrcYSize
|
78
|
+
:int, # nDstXOff
|
79
|
+
:int, # nDstYOff
|
80
|
+
:int, # nDstXSize
|
81
|
+
:int, # nDstYSize
|
82
|
+
:double, # dfScaleOff
|
83
|
+
:double, # dfScaleRation
|
84
|
+
:double # dfNoDataValue
|
85
|
+
],
|
86
|
+
CPL::Error::CPLErr
|
87
|
+
attach_function :VRTAddFuncSource,
|
88
|
+
%i[VRTSourcedRasterBandH VRTImageReadFunc pointer double],
|
89
|
+
CPL::Error::CPLErr
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -1,12 +1,16 @@
|
|
1
1
|
require 'ffi'
|
2
|
+
require_relative 'gdal'
|
3
|
+
require_relative 'alg'
|
2
4
|
|
3
5
|
module FFI
|
4
6
|
module GDAL
|
5
|
-
|
7
|
+
autoload :Warper, File.expand_path('warper', __dir__)
|
8
|
+
|
9
|
+
class WarpOptions < FFI::Struct
|
6
10
|
layout :warp_options, :pointer,
|
7
11
|
:warp_memory_limit, :double,
|
8
|
-
:resample_alg, FFI::GDAL::
|
9
|
-
:working_data_type, FFI::GDAL::
|
12
|
+
:resample_alg, FFI::GDAL::Warper::ResampleAlg,
|
13
|
+
:working_data_type, FFI::GDAL::DataType,
|
10
14
|
:source_dataset, :GDALDatasetH,
|
11
15
|
:destination_dataset, :GDALDatasetH,
|
12
16
|
:band_count, :int,
|
@@ -20,7 +24,7 @@ module FFI
|
|
20
24
|
:destination_no_data_imaginary, :pointer,
|
21
25
|
:progress, :GDALProgressFunc,
|
22
26
|
:progress_arg, :pointer,
|
23
|
-
:transformer, :GDALTransformerFunc,
|
27
|
+
:transformer, GDAL::Alg.find_type(:GDALTransformerFunc),
|
24
28
|
:transformer_arg, :pointer,
|
25
29
|
:source_per_band_validity_mask_function, :pointer,
|
26
30
|
:source_per_band_validity_mask_function_arg, :pointer,
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'ffi'
|
2
|
+
require_relative '../../ext/ffi_library_function_checks'
|
3
|
+
require_relative '../cpl/error'
|
4
|
+
|
5
|
+
module FFI
|
6
|
+
module GDAL
|
7
|
+
autoload :WarpOptions, File.expand_path('warp_options', __dir__)
|
8
|
+
|
9
|
+
module Warper
|
10
|
+
extend ::FFI::Library
|
11
|
+
ffi_lib [FFI::CURRENT_PROCESS, FFI::GDAL.gdal_library_path]
|
12
|
+
|
13
|
+
#------------------------------------------------------------------------
|
14
|
+
# Typedefs
|
15
|
+
#------------------------------------------------------------------------
|
16
|
+
typedef :pointer, :GDALWarpOperationH
|
17
|
+
callback :GDALMaskFunc,
|
18
|
+
[
|
19
|
+
:pointer,
|
20
|
+
:int,
|
21
|
+
FFI::GDAL::DataType,
|
22
|
+
:int,
|
23
|
+
:int,
|
24
|
+
:int,
|
25
|
+
:int,
|
26
|
+
:pointer,
|
27
|
+
:int,
|
28
|
+
:pointer
|
29
|
+
],
|
30
|
+
:pointer
|
31
|
+
|
32
|
+
#------------------------------------------------------------------------
|
33
|
+
# Enums
|
34
|
+
#------------------------------------------------------------------------
|
35
|
+
ResampleAlg = enum :GRA_NearestNeighbor, 0,
|
36
|
+
:GRA_Bilinear, 1,
|
37
|
+
:GRA_Cubic, 2,
|
38
|
+
:GRA_CubicSpline, 3,
|
39
|
+
:GRA_Lanczos, 4,
|
40
|
+
:GRA_Average, 5,
|
41
|
+
:GRA_Mode, 6
|
42
|
+
|
43
|
+
#------------------------------------------------------------------------
|
44
|
+
# Functions
|
45
|
+
#------------------------------------------------------------------------
|
46
|
+
attach_function :GDALCreateWarpOptions, [], FFI::GDAL::WarpOptions.ptr
|
47
|
+
attach_function :GDALSerializeWarpOptions,
|
48
|
+
[FFI::GDAL::WarpOptions.ptr],
|
49
|
+
FFI::CPL::XMLNode.ptr
|
50
|
+
|
51
|
+
attach_function :GDALCreateWarpOperation,
|
52
|
+
[FFI::GDAL::WarpOptions.ptr],
|
53
|
+
:GDALWarpOperationH
|
54
|
+
attach_function :GDALDestroyWarpOperation, [:GDALWarpOperationH], :void
|
55
|
+
|
56
|
+
attach_function :GDALChunkAndWarpImage,
|
57
|
+
%i[GDALWarpOperationH int int int int],
|
58
|
+
CPL::Error::CPLErr
|
59
|
+
attach_function :GDALChunkAndWarpMulti,
|
60
|
+
%i[GDALWarpOperationH int int int int],
|
61
|
+
CPL::Error::CPLErr
|
62
|
+
attach_function :GDALWarpRegion,
|
63
|
+
%i[GDALWarpOperationH int int int int int int int int],
|
64
|
+
CPL::Error::CPLErr
|
65
|
+
attach_function :GDALWarpRegionToBuffer,
|
66
|
+
[:GDALWarpOperationH, :int, :int, :int, :int, :pointer, DataType, :int, :int, :int, :int],
|
67
|
+
CPL::Error::CPLErr
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
data/lib/ffi/gdal.rb
CHANGED
@@ -1,83 +1,75 @@
|
|
1
1
|
require 'ffi'
|
2
|
+
require 'ffi/tools/const_generator'
|
3
|
+
require_relative 'gdal/exceptions'
|
4
|
+
require_relative '../ext/ffi_library_function_checks'
|
2
5
|
|
3
6
|
module FFI
|
4
|
-
module
|
5
|
-
|
6
|
-
|
7
|
-
def attach_function(*args)
|
8
|
-
old_attach_function(*args)
|
9
|
-
rescue FFI::NotFoundError
|
10
|
-
@unsupported_gdal_functions ||= []
|
11
|
-
warn "ffi-gdal warning: function '#{args.first}' is not available in this build of GDAL/OGR (v#{FFI::GDAL.GDALVersionInfo('RELEASE_NAME')})"
|
12
|
-
@unsupported_gdal_functions << args.first
|
13
|
-
end
|
7
|
+
module GDAL
|
8
|
+
extend ::FFI::Library
|
14
9
|
|
15
|
-
|
16
|
-
|
10
|
+
# @return [String]
|
11
|
+
def self.gdal_library_path
|
12
|
+
@gdal_library_path ||= find_lib('{lib,}gdal*')
|
17
13
|
end
|
18
|
-
end
|
19
14
|
|
20
|
-
|
21
|
-
|
15
|
+
# @param [String] lib Name of the library file to find.
|
16
|
+
# @return [String] Path to the library file.
|
17
|
+
def self.find_lib(lib)
|
18
|
+
lib_file_name = "#{lib}.#{FFI::Platform::LIBSUFFIX}*"
|
22
19
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
autoload :GDALGridNearestNeighborOptions,
|
34
|
-
File.expand_path('gdal/gdal_grid_nearest_neighbor_options', __dir__)
|
35
|
-
autoload :GDALRPCInfo,
|
36
|
-
File.expand_path('gdal/gdal_rpc_info', __dir__)
|
37
|
-
autoload :GDALTransformerInfo,
|
38
|
-
File.expand_path('gdal/gdal_transformer_info', __dir__)
|
39
|
-
autoload :GDALWarpOptions,
|
40
|
-
File.expand_path('gdal/gdal_warp_options', __dir__)
|
41
|
-
|
42
|
-
autoload :OGRContourWriterInfo,
|
43
|
-
File.expand_path('ogr/ogr_contour_writer_info', __dir__)
|
44
|
-
autoload :OGREnvelope,
|
45
|
-
File.expand_path('ogr/ogr_envelope', __dir__)
|
46
|
-
autoload :OGREnvelope3D,
|
47
|
-
File.expand_path('ogr/ogr_envelope_3d', __dir__)
|
48
|
-
autoload :OGRField,
|
49
|
-
File.expand_path('ogr/ogr_field', __dir__)
|
50
|
-
autoload :OGRStyleParam,
|
51
|
-
File.expand_path('ogr/ogr_style_param', __dir__)
|
52
|
-
autoload :OGRStyleValue,
|
53
|
-
File.expand_path('ogr/ogr_style_value', __dir__)
|
20
|
+
if ENV['GDAL_LIBRARY_PATH']
|
21
|
+
return File.join(ENV['GDAL_LIBRARY_PATH'], lib_file_name)
|
22
|
+
end
|
23
|
+
|
24
|
+
search_paths.map do |search_path|
|
25
|
+
Dir.glob(search_path).map do |path|
|
26
|
+
Dir.glob(File.join(path, lib_file_name))
|
27
|
+
end
|
28
|
+
end.flatten.uniq.first
|
29
|
+
end
|
54
30
|
|
31
|
+
# @return [Array<String>] List of paths to search for libs in.
|
55
32
|
def self.search_paths
|
33
|
+
return ENV['GDAL_LIBRARY_PATH'] if ENV['GDAL_LIBRARY_PATH']
|
34
|
+
|
56
35
|
@search_paths ||= begin
|
57
|
-
|
36
|
+
paths = ENV['PATH'].split(File::PATH_SEPARATOR)
|
58
37
|
|
59
|
-
|
60
|
-
|
61
|
-
else
|
62
|
-
%w[/usr/local/{lib64,lib} /opt/local/{lib64,lib} /usr/{lib64,lib} /usr/lib/{x86_64,i386}-linux-gnu]
|
38
|
+
unless FFI::Platform.windows?
|
39
|
+
paths += %w[/usr/local/{lib64,lib} /opt/local/{lib64,lib} /usr/{lib64,lib} /usr/lib/{x86_64,i386}-linux-gnu]
|
63
40
|
end
|
41
|
+
|
42
|
+
paths
|
64
43
|
end
|
65
44
|
end
|
66
45
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
46
|
+
# @return [Array<String>] Related files that contain C constants.
|
47
|
+
def self._files_with_constants
|
48
|
+
header_files = %w[
|
49
|
+
cpl_conv.h cpl_error.h cpl_port.h cpl_string.h cpl_vsi.h
|
50
|
+
gdal.h gdal_alg.h gdal_vrt.h gdalwarper.h
|
51
|
+
ogr_core.h ogr_srs_api.h
|
52
|
+
]
|
53
|
+
|
54
|
+
header_search_paths = %w[/usr/local/include /usr/include /usr/include/gdal]
|
55
|
+
|
56
|
+
header_files.map do |file|
|
57
|
+
dir = header_search_paths.find do |d|
|
58
|
+
File.exist?("#{d}/#{file}")
|
59
|
+
end
|
60
|
+
dir ? "#{dir}/#{file}" : nil
|
61
|
+
end.compact
|
75
62
|
end
|
76
63
|
|
77
|
-
|
78
|
-
|
64
|
+
# Locates one of the files that has constants.
|
65
|
+
#
|
66
|
+
# @return [String] Full path to +file_name+.
|
67
|
+
def self._file_with_constants(file_name)
|
68
|
+
_files_with_constants.find { |f| f.end_with?(file_name) }
|
69
|
+
end
|
79
70
|
|
80
|
-
|
71
|
+
if gdal_library_path.nil? || gdal_library_path.empty?
|
72
|
+
fail FFI::GDAL::LibraryNotFound, "Can't find required gdal library using path: '#{gdal_library_path}'"
|
81
73
|
end
|
82
74
|
|
83
75
|
ffi_lib(gdal_library_path)
|
@@ -87,12 +79,7 @@ module FFI
|
|
87
79
|
end
|
88
80
|
end
|
89
81
|
|
82
|
+
require_relative 'cpl/conv'
|
83
|
+
require_relative 'gdal/gdal'
|
90
84
|
require_relative 'gdal/version'
|
91
|
-
require_relative 'cpl/conv_h'
|
92
|
-
require_relative 'cpl/error_h'
|
93
|
-
require_relative 'cpl/minixml_h'
|
94
|
-
require_relative 'cpl/string_h'
|
95
|
-
require_relative 'cpl/vsi_h'
|
96
85
|
require_relative '../ext/to_bool'
|
97
|
-
|
98
|
-
require_relative 'gdal/gdal_h'
|