ffi-gdal 1.0.0.beta6 → 1.0.0.beta11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.rubocop.yml +54 -19
- data/.rubocop_todo.yml +65 -0
- data/.ruby-version +1 -1
- data/Gemfile +2 -0
- data/History.md +74 -0
- data/README.md +5 -0
- data/Rakefile +11 -1
- data/bitbucket-pipelines.yml +16 -0
- data/examples/extract_and_colorize.rb +7 -10
- data/examples/geometries.rb +68 -1
- data/examples/gridding.rb +2 -0
- data/examples/ogr_layer_to_layer.rb +2 -0
- data/examples/raster_erasing.rb +15 -8
- data/examples/remove_small_polygons.rb +2 -0
- data/examples/testing_gdal.rb +9 -2
- data/examples/warping.rb +23 -5
- data/ffi-gdal.gemspec +7 -4
- data/lib/ext/error_symbols.rb +2 -0
- data/lib/ext/ffi_library_function_checks.rb +2 -0
- data/lib/ext/float_ext.rb +2 -0
- data/lib/ext/narray_ext.rb +2 -0
- data/lib/ext/numeric_as_data_type.rb +2 -0
- data/lib/ext/to_bool.rb +5 -3
- data/lib/ffi-gdal.rb +2 -0
- data/lib/ffi/cpl.rb +2 -0
- data/lib/ffi/cpl/conv.rb +4 -2
- data/lib/ffi/cpl/error.rb +2 -0
- data/lib/ffi/cpl/hash_set.rb +2 -0
- data/lib/ffi/cpl/http.rb +2 -0
- data/lib/ffi/cpl/http_result.rb +2 -0
- data/lib/ffi/cpl/list.rb +2 -0
- data/lib/ffi/cpl/mime_part.rb +2 -0
- data/lib/ffi/cpl/minixml.rb +2 -0
- data/lib/ffi/cpl/port.rb +2 -0
- data/lib/ffi/cpl/progress.rb +2 -0
- data/lib/ffi/cpl/quad_tree.rb +2 -0
- data/lib/ffi/cpl/rect_obj.rb +2 -0
- data/lib/ffi/cpl/string.rb +2 -0
- data/lib/ffi/cpl/vsi.rb +2 -0
- data/lib/ffi/cpl/xml_node.rb +2 -0
- data/lib/ffi/gdal.rb +3 -3
- data/lib/ffi/gdal/alg.rb +2 -0
- data/lib/ffi/gdal/color_entry.rb +2 -0
- data/lib/ffi/gdal/exceptions.rb +2 -0
- data/lib/ffi/gdal/gcp.rb +2 -0
- data/lib/ffi/gdal/gdal.rb +2 -0
- data/lib/ffi/gdal/grid.rb +2 -0
- data/lib/ffi/gdal/grid_data_metrics_options.rb +2 -0
- data/lib/ffi/gdal/grid_inverse_distance_to_a_power_options.rb +2 -0
- data/lib/ffi/gdal/grid_moving_average_options.rb +2 -0
- data/lib/ffi/gdal/grid_nearest_neighbor_options.rb +2 -0
- data/lib/ffi/gdal/matching.rb +2 -0
- data/lib/ffi/gdal/rpc_info.rb +2 -0
- data/lib/ffi/gdal/transformer_info.rb +2 -0
- data/lib/ffi/gdal/version.rb +3 -1
- data/lib/ffi/gdal/vrt.rb +2 -0
- data/lib/ffi/gdal/warp_options.rb +9 -4
- data/lib/ffi/gdal/warper.rb +19 -1
- data/lib/ffi/ogr.rb +2 -0
- data/lib/ffi/ogr/api.rb +2 -0
- data/lib/ffi/ogr/contour_writer_info.rb +2 -0
- data/lib/ffi/ogr/core.rb +2 -0
- data/lib/ffi/ogr/envelope.rb +2 -0
- data/lib/ffi/ogr/envelope_3d.rb +2 -0
- data/lib/ffi/ogr/featurestyle.rb +2 -0
- data/lib/ffi/ogr/field.rb +2 -0
- data/lib/ffi/ogr/geocoding.rb +2 -0
- data/lib/ffi/ogr/srs_api.rb +3 -0
- data/lib/ffi/ogr/style_param.rb +2 -0
- data/lib/ffi/ogr/style_value.rb +2 -0
- data/lib/gdal.rb +3 -0
- data/lib/gdal/color_entry.rb +2 -0
- data/lib/gdal/color_entry_mixins/extensions.rb +2 -14
- data/lib/gdal/color_interpretation.rb +2 -0
- data/lib/gdal/color_table.rb +2 -0
- data/lib/gdal/color_table_mixins/extensions.rb +3 -17
- data/lib/gdal/color_table_types/cmyk.rb +2 -0
- data/lib/gdal/color_table_types/gray.rb +2 -0
- data/lib/gdal/color_table_types/hls.rb +2 -0
- data/lib/gdal/color_table_types/rgb.rb +2 -0
- data/lib/gdal/cpl_error_handler.rb +2 -0
- data/lib/gdal/data_type.rb +2 -0
- data/lib/gdal/dataset.rb +11 -7
- data/lib/gdal/dataset_mixins/algorithm_methods.rb +7 -4
- data/lib/gdal/dataset_mixins/extensions.rb +7 -47
- data/lib/gdal/dataset_mixins/matching.rb +4 -1
- data/lib/gdal/dataset_mixins/warp_methods.rb +52 -11
- data/lib/gdal/driver.rb +6 -8
- data/lib/gdal/driver_mixins/extensions.rb +2 -0
- data/lib/gdal/environment_methods.rb +2 -0
- data/lib/gdal/exceptions.rb +2 -0
- data/lib/gdal/geo_transform.rb +3 -3
- data/lib/gdal/geo_transform_mixins/extensions.rb +2 -17
- data/lib/gdal/grid.rb +4 -1
- data/lib/gdal/grid_algorithms.rb +2 -0
- data/lib/gdal/grid_algorithms/data_metrics_base.rb +2 -0
- data/lib/gdal/grid_algorithms/inverse_distance_to_a_power.rb +2 -0
- data/lib/gdal/grid_algorithms/metric_average_distance.rb +2 -0
- data/lib/gdal/grid_algorithms/metric_average_distance_pts.rb +2 -0
- data/lib/gdal/grid_algorithms/metric_count.rb +2 -0
- data/lib/gdal/grid_algorithms/metric_maximum.rb +2 -0
- data/lib/gdal/grid_algorithms/metric_minimum.rb +2 -0
- data/lib/gdal/grid_algorithms/metric_range.rb +2 -0
- data/lib/gdal/grid_algorithms/moving_average.rb +2 -0
- data/lib/gdal/grid_algorithms/nearest_neighbor.rb +2 -0
- data/lib/gdal/gridder.rb +11 -3
- data/lib/gdal/gridder/point_extracting.rb +3 -2
- data/lib/gdal/gridder_options.rb +2 -0
- data/lib/gdal/internal_helpers.rb +3 -4
- data/lib/gdal/logger.rb +2 -0
- data/lib/gdal/major_object.rb +2 -0
- data/lib/gdal/merger.rb +2 -0
- data/lib/gdal/options.rb +16 -13
- data/lib/gdal/raster_attribute_table.rb +2 -0
- data/lib/gdal/raster_attribute_table_mixins/extensions.rb +3 -16
- data/lib/gdal/raster_band.rb +11 -6
- data/lib/gdal/raster_band_classifier.rb +52 -19
- data/lib/gdal/raster_band_mixins/algorithm_extensions.rb +2 -0
- data/lib/gdal/raster_band_mixins/algorithm_methods.rb +12 -5
- data/lib/gdal/raster_band_mixins/coloring_extensions.rb +3 -1
- data/lib/gdal/raster_band_mixins/extensions.rb +6 -35
- data/lib/gdal/raster_band_mixins/io_extensions.rb +7 -4
- data/lib/gdal/rpc_info.rb +2 -0
- data/lib/gdal/transformer.rb +2 -0
- data/lib/gdal/transformers/approximate_transformer.rb +4 -1
- data/lib/gdal/transformers/base_general_image_projection_transformer.rb +4 -1
- data/lib/gdal/transformers/gcp_transformer.rb +6 -2
- data/lib/gdal/transformers/general_image_projection_transformer.rb +2 -0
- data/lib/gdal/transformers/general_image_projection_transformer2.rb +4 -1
- data/lib/gdal/transformers/general_image_projection_transformer3.rb +4 -1
- data/lib/gdal/transformers/geolocation_transformer.rb +4 -1
- data/lib/gdal/transformers/reprojection_transformer.rb +2 -0
- data/lib/gdal/transformers/rpc_transformer.rb +4 -1
- data/lib/gdal/transformers/tps_transformer.rb +2 -0
- data/lib/gdal/version_info.rb +9 -7
- data/lib/gdal/virtual_dataset.rb +2 -0
- data/lib/gdal/warp_operation.rb +2 -0
- data/lib/gdal/warp_options.rb +105 -35
- data/lib/ogr.rb +2 -0
- data/lib/ogr/coordinate_transformation.rb +2 -0
- data/lib/ogr/data_source.rb +5 -9
- data/lib/ogr/data_source_extensions.rb +2 -19
- data/lib/ogr/data_source_mixins/capability_methods.rb +2 -0
- data/lib/ogr/driver.rb +4 -6
- data/lib/ogr/driver_mixins/capability_methods.rb +2 -0
- data/lib/ogr/envelope.rb +4 -2
- data/lib/ogr/envelope_extensions.rb +2 -22
- data/lib/ogr/error_handling.rb +3 -1
- data/lib/ogr/exceptions.rb +3 -1
- data/lib/ogr/feature.rb +17 -9
- data/lib/ogr/feature_definition.rb +7 -4
- data/lib/ogr/feature_definition_extensions.rb +2 -18
- data/lib/ogr/feature_extensions.rb +2 -27
- data/lib/ogr/field.rb +5 -1
- data/lib/ogr/field_definition.rb +5 -6
- data/lib/ogr/geocoder.rb +2 -0
- data/lib/ogr/geometries/geometry_collection.rb +2 -0
- data/lib/ogr/geometries/geometry_collection_25d.rb +2 -0
- data/lib/ogr/geometries/line_string.rb +2 -1
- data/lib/ogr/geometries/line_string_25d.rb +2 -0
- data/lib/ogr/geometries/linear_ring.rb +2 -0
- data/lib/ogr/geometries/multi_line_string.rb +2 -0
- data/lib/ogr/geometries/multi_line_string_25d.rb +2 -0
- data/lib/ogr/geometries/multi_point.rb +2 -0
- data/lib/ogr/geometries/multi_point_25d.rb +2 -0
- data/lib/ogr/geometries/multi_polygon.rb +2 -0
- data/lib/ogr/geometries/multi_polygon_25d.rb +2 -0
- data/lib/ogr/geometries/none_geometry.rb +2 -0
- data/lib/ogr/geometries/point.rb +2 -0
- data/lib/ogr/geometries/point_25d.rb +2 -0
- data/lib/ogr/geometries/polygon.rb +2 -0
- data/lib/ogr/geometries/polygon_25d.rb +2 -0
- data/lib/ogr/geometries/unknown_geometry.rb +2 -0
- data/lib/ogr/geometry.rb +3 -4
- data/lib/ogr/geometry_field_definition.rb +3 -4
- data/lib/ogr/geometry_mixins/container_mixins.rb +2 -0
- data/lib/ogr/geometry_mixins/extensions.rb +10 -39
- data/lib/ogr/geometry_types/container.rb +2 -0
- data/lib/ogr/geometry_types/curve.rb +3 -1
- data/lib/ogr/geometry_types/surface.rb +2 -0
- data/lib/ogr/internal_helpers.rb +2 -0
- data/lib/ogr/layer.rb +5 -1
- data/lib/ogr/layer_mixins/capability_methods.rb +2 -0
- data/lib/ogr/layer_mixins/extensions.rb +9 -27
- data/lib/ogr/layer_mixins/ogr_feature_methods.rb +6 -12
- data/lib/ogr/layer_mixins/ogr_field_methods.rb +10 -14
- data/lib/ogr/layer_mixins/ogr_layer_method_methods.rb +2 -0
- data/lib/ogr/layer_mixins/ogr_query_filter_methods.rb +8 -3
- data/lib/ogr/layer_mixins/ogr_sql_methods.rb +3 -3
- data/lib/ogr/spatial_reference.rb +12 -2
- data/lib/ogr/spatial_reference_extensions.rb +2 -26
- data/lib/ogr/spatial_reference_mixins/coordinate_system_getter_setters.rb +12 -5
- data/lib/ogr/spatial_reference_mixins/exporters.rb +2 -0
- data/lib/ogr/spatial_reference_mixins/importers.rb +6 -2
- data/lib/ogr/spatial_reference_mixins/morphers.rb +2 -0
- data/lib/ogr/spatial_reference_mixins/parameter_getter_setters.rb +2 -0
- data/lib/ogr/spatial_reference_mixins/type_checks.rb +2 -0
- data/lib/ogr/style_table.rb +2 -0
- data/lib/ogr/style_table_extensions.rb +2 -10
- data/lib/ogr/style_tool.rb +2 -0
- data/spec/ffi-gdal_spec.rb +2 -0
- data/spec/integration/gdal/color_table_info_spec.rb +2 -0
- data/spec/integration/gdal/dataset_info_spec.rb +15 -13
- data/spec/integration/gdal/driver_info_spec.rb +3 -1
- data/spec/integration/gdal/geo_transform_info_spec.rb +2 -0
- data/spec/integration/gdal/gridder_spec.rb +2 -0
- data/spec/integration/gdal/raster_attribute_table_info_spec.rb +2 -0
- data/spec/integration/gdal/raster_band_algorithms_spec.rb +2 -0
- data/spec/integration/gdal/raster_band_info_spec.rb +37 -15
- data/spec/integration/ogr/layer_spec.rb +2 -6
- data/spec/spec_helper.rb +3 -1
- data/spec/support/images/123.tiff +0 -0
- data/spec/support/integration_help.rb +2 -0
- data/spec/support/shared_contexts.rb +2 -0
- data/spec/support/shared_examples/gdal/major_object_examples.rb +2 -0
- data/spec/support/shared_examples/ogr/{a_25D_geometry.rb → a_25d_geometry.rb} +2 -0
- data/spec/support/shared_examples/ogr/a_container_geometry.rb +2 -0
- data/spec/support/shared_examples/ogr/a_geometry.rb +3 -1
- data/spec/support/shared_examples/ogr/a_line_string.rb +2 -0
- data/spec/unit/ext/error_symbols_spec.rb +2 -0
- data/spec/unit/ext/numeric_as_data_type_spec.rb +2 -0
- data/spec/unit/ffi/gdal_spec.rb +3 -0
- data/spec/unit/gdal/color_entry_spec.rb +2 -0
- data/spec/unit/gdal/color_interpretation_spec.rb +2 -0
- data/spec/unit/gdal/color_table_mixins/extensions_spec.rb +2 -0
- data/spec/unit/gdal/color_table_spec.rb +2 -0
- data/spec/unit/gdal/data_type_spec.rb +2 -0
- data/spec/unit/gdal/dataset_mixins/warp_methods_spec.rb +55 -0
- data/spec/unit/gdal/dataset_spec.rb +2 -0
- data/spec/unit/gdal/driver_mixins/extensions_spec.rb +2 -0
- data/spec/unit/gdal/driver_spec.rb +2 -0
- data/spec/unit/gdal/environment_methods_spec.rb +2 -0
- data/spec/unit/gdal/geo_transform_mixins/extensions_spec.rb +2 -0
- data/spec/unit/gdal/geo_transform_spec.rb +2 -13
- data/spec/unit/gdal/grid_spec.rb +10 -0
- data/spec/unit/gdal/gridder/point_extracting_spec.rb +2 -0
- data/spec/unit/gdal/gridder_options_spec.rb +2 -0
- data/spec/unit/gdal/gridder_spec.rb +42 -0
- data/spec/unit/gdal/internal_helpers_spec.rb +2 -0
- data/spec/unit/gdal/major_object_spec.rb +2 -0
- data/spec/unit/gdal/options_spec.rb +28 -1
- data/spec/unit/gdal/raster_attribute_table_spec.rb +2 -0
- data/spec/unit/gdal/raster_band_classifier_spec.rb +43 -5
- data/spec/unit/gdal/raster_band_mixins/extensions_spec.rb +2 -0
- data/spec/unit/gdal/raster_band_mixins/io_extensions_spec.rb +2 -0
- data/spec/unit/gdal/raster_band_spec.rb +2 -0
- data/spec/unit/gdal/rpc_info_spec.rb +2 -0
- data/spec/unit/gdal/version_info_spec.rb +2 -0
- data/spec/unit/gdal/virtual_dataset_spec.rb +2 -0
- data/spec/unit/gdal/warp_operation_spec.rb +2 -0
- data/spec/unit/gdal/warp_options_spec.rb +338 -0
- data/spec/unit/ogr/coordinate_transformation_spec.rb +2 -0
- data/spec/unit/ogr/data_source_mixins/capability_methods_spec.rb +2 -0
- data/spec/unit/ogr/data_source_spec.rb +2 -0
- data/spec/unit/ogr/driver_mixins/capability_methods_spec.rb +2 -0
- data/spec/unit/ogr/driver_spec.rb +3 -1
- data/spec/unit/ogr/envelope_spec.rb +2 -0
- data/spec/unit/ogr/feature_definition_spec.rb +2 -19
- data/spec/unit/ogr/feature_extensions_spec.rb +3 -1
- data/spec/unit/ogr/feature_spec.rb +3 -3
- data/spec/unit/ogr/field_definition_spec.rb +2 -19
- data/spec/unit/ogr/field_spec.rb +3 -1
- data/spec/unit/ogr/geometries/geometry_collection_25d_spec.rb +2 -0
- data/spec/unit/ogr/geometries/geometry_collection_spec.rb +2 -0
- data/spec/unit/ogr/geometries/line_string_25d_spec.rb +2 -0
- data/spec/unit/ogr/geometries/line_string_spec.rb +2 -0
- data/spec/unit/ogr/geometries/linear_ring_spec.rb +2 -0
- data/spec/unit/ogr/geometries/multi_line_string_25d_spec.rb +2 -0
- data/spec/unit/ogr/geometries/multi_line_string_spec.rb +2 -0
- data/spec/unit/ogr/geometries/multi_point_25d_spec.rb +2 -0
- data/spec/unit/ogr/geometries/multi_point_spec.rb +2 -0
- data/spec/unit/ogr/geometries/multi_polygon_25d_spec.rb +2 -0
- data/spec/unit/ogr/geometries/multi_polygon_spec.rb +2 -0
- data/spec/unit/ogr/geometries/none_geometry_spec.rb +2 -0
- data/spec/unit/ogr/geometries/point_25d_spec.rb +2 -0
- data/spec/unit/ogr/geometries/point_spec.rb +2 -0
- data/spec/unit/ogr/geometries/polygon_25d_spec.rb +2 -0
- data/spec/unit/ogr/geometries/polygon_spec.rb +2 -0
- data/spec/unit/ogr/geometries/unknown_geometry_spec.rb +2 -0
- data/spec/unit/ogr/geometry_field_definition_spec.rb +2 -16
- data/spec/unit/ogr/geometry_spec.rb +2 -0
- data/spec/unit/ogr/internal_helpers_spec.rb +2 -0
- data/spec/unit/ogr/layer_mixins/capability_methods_spec.rb +2 -0
- data/spec/unit/ogr/layer_mixins/ogr_feature_methods_spec.rb +2 -0
- data/spec/unit/ogr/layer_mixins/ogr_field_methods_spec.rb +2 -0
- data/spec/unit/ogr/layer_mixins/ogr_layer_method_methods_spec.rb +2 -0
- data/spec/unit/ogr/layer_mixins/ogr_query_filter_methods_spec.rb +2 -0
- data/spec/unit/ogr/layer_mixins/ogr_sql_methods_spec.rb +2 -0
- data/spec/unit/ogr/layer_spec.rb +2 -0
- data/spec/unit/ogr/spatial_reference_mixins/coordinate_system_getter_setters_spec.rb +2 -0
- data/spec/unit/ogr/spatial_reference_mixins/exporters_spec.rb +19 -15
- data/spec/unit/ogr/spatial_reference_mixins/importers_spec.rb +2 -0
- data/spec/unit/ogr/spatial_reference_mixins/morphers_spec.rb +9 -7
- data/spec/unit/ogr/spatial_reference_mixins/parameter_getter_setters_spec.rb +2 -0
- data/spec/unit/ogr/spatial_reference_mixins/type_checks_spec.rb +2 -0
- data/spec/unit/ogr/spatial_reference_spec.rb +4 -2
- data/spec/unit/ogr/style_table_spec.rb +2 -26
- data/spec/unit/ogr/style_tool_spec.rb +2 -0
- data/spec/unit/version_info_spec.rb +2 -0
- metadata +47 -15
- data/lib/ogr/field_definition_extensions.rb +0 -22
- data/lib/ogr/geometry_field_definition_extensions.rb +0 -19
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module GDAL
|
2
4
|
module DatasetMixins
|
3
5
|
module Matching
|
@@ -15,7 +17,8 @@ module GDAL
|
|
15
17
|
@c_pointer,
|
16
18
|
other_dataset_ptr,
|
17
19
|
options_ptr,
|
18
|
-
gcp_count_ptr
|
20
|
+
gcp_count_ptr
|
21
|
+
)
|
19
22
|
|
20
23
|
{ count: gcp_count_ptr.read_int, gcp: gcp }
|
21
24
|
end
|
@@ -1,10 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module GDAL
|
2
4
|
module DatasetMixins
|
3
5
|
# Methods used for warping; most taken from gdalwarper.h.
|
4
6
|
module WarpMethods
|
5
7
|
# @param destination_dataset [GDAL::Dataset]
|
6
8
|
# @param resample_algorithm [Symbol] One from FFI::GDAL::Warper::GDALResampleAlg.
|
7
|
-
# @param
|
9
|
+
# @param destination_projection [String]
|
8
10
|
# @param warp_memory_limit [Float] The amount of memory (in bytes) the API
|
9
11
|
# is allowed to use for caching. This is in addition to the amount of
|
10
12
|
# memory already allocated for caching (using GDALSetCacheMax). 0.0 uses
|
@@ -15,26 +17,65 @@ module GDAL
|
|
15
17
|
# callback for reporting progress.
|
16
18
|
# @param progress_arg [FFI::Pointer] Argument to be passed to
|
17
19
|
# +progress_function+.
|
18
|
-
# @param
|
19
|
-
def reproject_image(destination_dataset, resample_algorithm,
|
20
|
-
warp_memory_limit: 0.0, max_error: 0.0, progress_function: nil, progress_arg: nil,
|
21
|
-
|
22
|
-
destination_spatial_reference.to_wkt
|
23
|
-
end
|
24
|
-
|
25
|
-
options_ptr = GDAL::Options.pointer(options)
|
20
|
+
# @param warp_options [GDAL::WarpOptions] Warp options, normally empty.
|
21
|
+
def reproject_image(destination_dataset, resample_algorithm, destination_projection: nil,
|
22
|
+
warp_memory_limit: 0.0, max_error: 0.0, progress_function: nil, progress_arg: nil, warp_options: nil)
|
23
|
+
warp_options_struct = warp_options ? warp_options.c_struct : nil
|
26
24
|
|
27
25
|
FFI::GDAL::Warper.GDALReprojectImage(
|
28
26
|
@c_pointer, # hSrcDS
|
29
27
|
nil, # pszSrcWKT
|
30
28
|
destination_dataset.c_pointer, # hDstDS
|
31
|
-
|
29
|
+
destination_projection, # pszDstWKT
|
30
|
+
resample_algorithm, # eResampleAlg
|
31
|
+
warp_memory_limit, # dfWarpMemoryLimit
|
32
|
+
max_error, # dfMaxError
|
33
|
+
progress_function, # pfnProgress
|
34
|
+
progress_arg, # pProgressArg
|
35
|
+
warp_options_struct # psOptions
|
36
|
+
)
|
37
|
+
end
|
38
|
+
|
39
|
+
# @param destination_file_name [String] Path to the output dataset.
|
40
|
+
# @param resample_algorithm [Symbol] One from FFI::GDAL::Warper::GDALResampleAlg.
|
41
|
+
# @param destination_projection [String] WKT of the projection to
|
42
|
+
# be used for the destination dataset.
|
43
|
+
# @param destination_driver [GDAL::Driver] Driver to use for the
|
44
|
+
# destination dataset.
|
45
|
+
# @param creation_options [Hash] Driver-specific options to use during
|
46
|
+
# creation.
|
47
|
+
# @param warp_memory_limit [Float] The amount of memory (in bytes) the API
|
48
|
+
# is allowed to use for caching. This is in addition to the amount of
|
49
|
+
# memory already allocated for caching (using GDALSetCacheMax). 0.0 uses
|
50
|
+
# default settings.
|
51
|
+
# @param max_error [Float] Maximum error, measured in input pixels that is
|
52
|
+
# allowed in approximating the transformation. Defaults to 0.0.
|
53
|
+
# @param progress_function [Proc, FFI::GDAL::GDAL::GDALProgressFunc] A
|
54
|
+
# callback for reporting progress.
|
55
|
+
# @param progress_arg [FFI::Pointer] Argument to be passed to
|
56
|
+
# +progress_function+.
|
57
|
+
# @param warp_options [GDAL::WarpOptions] Warp options, normally empty.
|
58
|
+
def create_and_reproject_image(destination_file_name, resample_algorithm, destination_projection,
|
59
|
+
destination_driver, creation_options: {},
|
60
|
+
warp_memory_limit: 0.0, max_error: 0.0,
|
61
|
+
progress_function: nil, progress_arg: nil,
|
62
|
+
warp_options: nil)
|
63
|
+
creation_options_ptr = GDAL::Options.pointer(creation_options)
|
64
|
+
warp_options_struct = warp_options ? warp_options.c_struct : nil
|
65
|
+
|
66
|
+
FFI::GDAL::Warper.GDALCreateAndReprojectImage(
|
67
|
+
@c_pointer, # hSrcDS
|
68
|
+
nil, # pszSrcWKT
|
69
|
+
destination_file_name, # pszDstFilename
|
70
|
+
destination_projection, # pszDstWKT
|
71
|
+
destination_driver.c_pointer, # hDstDriver
|
72
|
+
creation_options_ptr, # papszCreateOptions
|
32
73
|
resample_algorithm, # eResampleAlg
|
33
74
|
warp_memory_limit, # dfWarpMemoryLimit
|
34
75
|
max_error, # dfMaxError
|
35
76
|
progress_function, # pfnProgress
|
36
77
|
progress_arg, # pProgressArg
|
37
|
-
|
78
|
+
warp_options_struct # psOptions
|
38
79
|
)
|
39
80
|
end
|
40
81
|
end
|
data/lib/gdal/driver.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'multi_xml'
|
2
4
|
require_relative '../gdal'
|
3
5
|
require_relative 'major_object'
|
@@ -11,7 +13,7 @@ module GDAL
|
|
11
13
|
include GDAL::Logger
|
12
14
|
include DriverMixins::Extensions
|
13
15
|
|
14
|
-
GDAL_DOCS_URL = 'http://gdal.org'
|
16
|
+
GDAL_DOCS_URL = 'http://gdal.org'
|
15
17
|
|
16
18
|
# @return [Fixnum]
|
17
19
|
def self.count
|
@@ -25,9 +27,7 @@ module GDAL
|
|
25
27
|
def self.by_name(name)
|
26
28
|
driver_ptr = FFI::GDAL::GDAL.GDALGetDriverByName(name)
|
27
29
|
|
28
|
-
if driver_ptr.null?
|
29
|
-
raise InvalidDriverName, "'#{name}' is not a valid driver name."
|
30
|
-
end
|
30
|
+
raise InvalidDriverName, "'#{name}' is not a valid driver name." if driver_ptr.null?
|
31
31
|
|
32
32
|
new(driver_ptr)
|
33
33
|
end
|
@@ -37,9 +37,7 @@ module GDAL
|
|
37
37
|
# @return [GDAL::Driver]
|
38
38
|
# @raise [GDAL::InvalidDriverIndex] If driver at +index+ does not exist.
|
39
39
|
def self.at_index(index)
|
40
|
-
if index > count
|
41
|
-
raise InvalidDriverIndex, "index must be between 0 and #{count - 1}."
|
42
|
-
end
|
40
|
+
raise InvalidDriverIndex, "index must be between 0 and #{count - 1}." if index > count
|
43
41
|
|
44
42
|
driver_ptr = FFI::GDAL::GDAL.GDALGetDriver(index)
|
45
43
|
|
@@ -174,7 +172,7 @@ module GDAL
|
|
174
172
|
def copy_dataset(source_dataset, destination_path, progress_block = nil, progress_arg = nil, strict: true,
|
175
173
|
**options)
|
176
174
|
source_dataset_ptr = make_dataset_pointer(source_dataset)
|
177
|
-
raise GDAL::OpenFailure, "Source dataset couldn't be read" if source_dataset_ptr
|
175
|
+
raise GDAL::OpenFailure, "Source dataset couldn't be read" if source_dataset_ptr&.null?
|
178
176
|
|
179
177
|
options_ptr = GDAL::Options.pointer(options)
|
180
178
|
|
data/lib/gdal/exceptions.rb
CHANGED
data/lib/gdal/geo_transform.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative '../gdal'
|
2
4
|
require_relative 'geo_transform_mixins/extensions'
|
3
5
|
|
@@ -168,9 +170,7 @@ module GDAL
|
|
168
170
|
def compose(other_geo_transform)
|
169
171
|
other_ptr = GDAL._pointer(GDAL::GeoTransform, other_geo_transform)
|
170
172
|
|
171
|
-
unless other_ptr
|
172
|
-
raise GDAL::NullObject, "Unable to access pointer for '#{other_geo_transform}'"
|
173
|
-
end
|
173
|
+
raise GDAL::NullObject, "Unable to access pointer for '#{other_geo_transform}'" unless other_ptr
|
174
174
|
|
175
175
|
new_gt_ptr = self.class.new_pointer
|
176
176
|
FFI::GDAL::GDAL.GDALComposeGeoTransforms(@c_pointer, other_ptr, new_gt_ptr)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'json'
|
2
4
|
require_relative '../exceptions'
|
3
5
|
|
@@ -90,23 +92,6 @@ module GDAL
|
|
90
92
|
pixel_height
|
91
93
|
]
|
92
94
|
end
|
93
|
-
|
94
|
-
# @return [Hash]
|
95
|
-
def as_json(_options = nil)
|
96
|
-
{
|
97
|
-
x_origin: x_origin,
|
98
|
-
x_rotation: x_rotation,
|
99
|
-
pixel_width: pixel_width,
|
100
|
-
y_origin: y_origin,
|
101
|
-
y_rotation: y_rotation,
|
102
|
-
pixel_height: pixel_height
|
103
|
-
}
|
104
|
-
end
|
105
|
-
|
106
|
-
# @return [String]
|
107
|
-
def to_json(options = nil)
|
108
|
-
as_json(options).to_json
|
109
|
-
end
|
110
95
|
end
|
111
96
|
end
|
112
97
|
end
|
data/lib/gdal/grid.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'forwardable'
|
2
4
|
require 'narray'
|
3
5
|
require_relative '../gdal'
|
@@ -36,8 +38,9 @@ module GDAL
|
|
36
38
|
points = points.to_a if points.is_a? NArray
|
37
39
|
point_count = points.length
|
38
40
|
log "Number of points: #{point_count}"
|
39
|
-
points
|
41
|
+
raise GDAL::NoValuesToGrid, 'No points to grid' if point_count.zero?
|
40
42
|
|
43
|
+
points = points.transpose
|
41
44
|
x_input_coordinates_ptr = make_points_pointer(points[0])
|
42
45
|
y_input_coordinates_ptr = make_points_pointer(points[1])
|
43
46
|
z_input_coordinates_ptr = make_points_pointer(points[2])
|
data/lib/gdal/grid_algorithms.rb
CHANGED
data/lib/gdal/gridder.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'narray'
|
2
4
|
require_relative '../gdal'
|
3
5
|
require_relative 'gridder_options'
|
@@ -249,7 +251,8 @@ module GDAL
|
|
249
251
|
block_number.to_f / block_count,
|
250
252
|
(block_number + 1).to_f / block_count,
|
251
253
|
@options.progress_formatter,
|
252
|
-
nil
|
254
|
+
nil
|
255
|
+
)
|
253
256
|
end
|
254
257
|
|
255
258
|
# Determines how large of a chunk of data to grid and rasterize.
|
@@ -287,8 +290,13 @@ module GDAL
|
|
287
290
|
# @return [Fixnum] The total number of blocks that should be iterated
|
288
291
|
# through during the grid+rasterize process.
|
289
292
|
def build_block_count(block_x_size, block_y_size, raster_width, raster_height)
|
290
|
-
(
|
291
|
-
|
293
|
+
build_block_size(raster_width, block_x_size) * build_block_size(raster_height, block_y_size)
|
294
|
+
end
|
295
|
+
|
296
|
+
# @param total_pixels [Fixnum] Number of pixels in the width or height.
|
297
|
+
# @param block_size [Fixnum] Size of the reported block.
|
298
|
+
def build_block_size(total_pixels, block_size)
|
299
|
+
(total_pixels + block_size - 1) / block_size
|
292
300
|
end
|
293
301
|
end
|
294
302
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module GDAL
|
2
4
|
class Gridder
|
3
5
|
# Methods used for extracting points from a OGR::Layer. Only used when
|
@@ -39,8 +41,7 @@ module GDAL
|
|
39
41
|
# set and the layer has no Z values.
|
40
42
|
def ensure_z_values
|
41
43
|
if layer_missing_specified_field?
|
42
|
-
raise OGR::InvalidFieldName,
|
43
|
-
"Field name not found in layer: '#{@options.input_field_name}'"
|
44
|
+
raise OGR::InvalidFieldName, "Field name not found in layer: '#{@options.input_field_name}'"
|
44
45
|
elsif !@options.input_field_name && !@source_layer.any_geometries_with_z?
|
45
46
|
raise GDAL::NoValuesToGrid,
|
46
47
|
"No input_field_name option given and source layer #{@source_layer.name} has no Z values."
|
data/lib/gdal/gridder_options.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module GDAL
|
2
4
|
# @private
|
3
5
|
module InternalHelpers
|
@@ -64,10 +66,7 @@ module GDAL
|
|
64
66
|
# @param strings [Array<String>]
|
65
67
|
# @return [FFI::MemoryPointer]
|
66
68
|
def _string_array_to_pointer(strings)
|
67
|
-
string_pointers = strings.map
|
68
|
-
FFI::MemoryPointer.from_string(string.to_s)
|
69
|
-
end
|
70
|
-
|
69
|
+
string_pointers = strings.map { |string| FFI::MemoryPointer.from_string(string.to_s) }
|
71
70
|
string_pointers << nil
|
72
71
|
array_pointer = FFI::MemoryPointer.new(:pointer, strings.size + 1)
|
73
72
|
i = 0
|
data/lib/gdal/logger.rb
CHANGED
data/lib/gdal/major_object.rb
CHANGED
data/lib/gdal/merger.rb
CHANGED
data/lib/gdal/options.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'ffi'
|
2
4
|
|
3
5
|
module GDAL
|
@@ -11,10 +13,20 @@ module GDAL
|
|
11
13
|
# +nil+. If +false+, creates a 0-size pointer.
|
12
14
|
# @return [FFI::MemoryPointer, nil]
|
13
15
|
def self.pointer(hash, nil_on_empty: true)
|
14
|
-
if nil_on_empty
|
15
|
-
|
16
|
-
|
17
|
-
|
16
|
+
return if nil_on_empty && hash.empty?
|
17
|
+
|
18
|
+
new(hash).c_pointer
|
19
|
+
end
|
20
|
+
|
21
|
+
# Takes a GDAL options pointer and turns it into a Ruby Hash.
|
22
|
+
#
|
23
|
+
# @param pointer [FFI::Pointer]
|
24
|
+
# @return [Hash]
|
25
|
+
def self.to_hash(pointer)
|
26
|
+
FFI::CPL::String.CSLCount(pointer).times.each_with_object({}) do |i, o|
|
27
|
+
key_and_value = FFI::CPL::String.CSLGetField(pointer, i)
|
28
|
+
key, value = key_and_value.split('=')
|
29
|
+
o[key.downcase.to_sym] = value
|
18
30
|
end
|
19
31
|
end
|
20
32
|
|
@@ -37,15 +49,6 @@ module GDAL
|
|
37
49
|
options_ptr
|
38
50
|
end
|
39
51
|
|
40
|
-
# def to_s
|
41
|
-
# options_ptr = to_gdal
|
42
|
-
# options_array = options_ptr.read_array_of_pointer(self.size)
|
43
|
-
#
|
44
|
-
# 0.upto(self.size).map do |i|
|
45
|
-
# options_array[i].first.read_string
|
46
|
-
# end
|
47
|
-
# end
|
48
|
-
|
49
52
|
private
|
50
53
|
|
51
54
|
def capitalize_keys!(hash)
|