ffi-gdal 1.0.0.beta16 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.dockerignore +17 -0
- data/.github/workflows/codacy.yml +61 -0
- data/.github/workflows/codeql.yml +74 -0
- data/.github/workflows/continuous-integration.yml +36 -0
- data/.github/workflows/dependency-review.yml +20 -0
- data/.github/workflows/specs-in-docker.yml +27 -0
- data/.gitignore +3 -0
- data/.rspec +1 -0
- data/.rubocop.yml +10 -80
- data/.rubocop_todo.yml +23 -40
- data/.ruby-version +1 -1
- data/Changelog-0.x.md +512 -0
- data/Changelog.md +12 -0
- data/Dockerfile.gdal2 +110 -0
- data/Dockerfile.gdal3 +73 -0
- data/README.md +25 -14
- data/Rakefile +0 -8
- data/Tiltfile +91 -0
- data/bin/bundle +123 -0
- data/bin/docker-clean +8 -0
- data/bin/rake +29 -0
- data/bin/rspec +29 -0
- data/bin/rubocop +29 -0
- data/docker-compose.yml +25 -0
- data/examples/extract_and_colorize.rb +0 -13
- data/examples/geometries.rb +14 -14
- data/examples/ogr_layer_to_layer.rb +1 -3
- data/examples/raster_erasing.rb +1 -0
- data/examples/remove_small_polygons.rb +1 -1
- data/examples/testing_gdal.rb +20 -17
- data/examples/warping.rb +9 -7
- data/ffi-gdal.gemspec +12 -6
- data/lib/ext/ffi_library_function_checks.rb +2 -2
- data/lib/ext/to_bool.rb +5 -3
- data/lib/ffi/cpl/conv.rb +27 -25
- data/lib/ffi/cpl/error.rb +19 -20
- data/lib/ffi/cpl/hash_set.rb +4 -4
- data/lib/ffi/cpl/http.rb +3 -3
- data/lib/ffi/cpl/http_result.rb +8 -8
- data/lib/ffi/cpl/list.rb +1 -1
- data/lib/ffi/cpl/mime_part.rb +2 -2
- data/lib/ffi/cpl/minixml.rb +7 -7
- data/lib/ffi/cpl/progress.rb +8 -8
- data/lib/ffi/cpl/quad_tree.rb +14 -14
- data/lib/ffi/cpl/rect_obj.rb +3 -3
- data/lib/ffi/cpl/string.rb +17 -20
- data/lib/ffi/cpl/vsi.rb +13 -13
- data/lib/ffi/cpl/xml_node.rb +3 -3
- data/lib/ffi/extensions/gdal/extensions/all.rb +4 -0
- data/lib/ffi/extensions/gdal/extensions/version.rb +9 -0
- data/lib/ffi/extensions/gdal/extensions.rb +12 -0
- data/lib/ffi/extensions/rttopo/gbox.rb +19 -0
- data/lib/ffi/extensions/rttopo/geom.rb +16 -0
- data/lib/ffi/extensions/rttopo.rb +41 -0
- data/lib/ffi/gdal/alg.rb +277 -277
- data/lib/ffi/gdal/color_entry.rb +3 -3
- data/lib/ffi/gdal/gcp.rb +6 -6
- data/lib/ffi/gdal/gdal.rb +349 -349
- data/lib/ffi/gdal/grid.rb +134 -134
- data/lib/ffi/gdal/grid_data_metrics_options.rb +4 -4
- data/lib/ffi/gdal/grid_inverse_distance_to_a_power_options.rb +9 -9
- data/lib/ffi/gdal/grid_moving_average_options.rb +4 -4
- data/lib/ffi/gdal/grid_nearest_neighbor_options.rb +3 -3
- data/lib/ffi/gdal/matching.rb +3 -3
- data/lib/ffi/gdal/rpc_info.rb +17 -17
- data/lib/ffi/gdal/transformer_info.rb +4 -4
- data/lib/ffi/gdal/version.rb +1 -1
- data/lib/ffi/gdal/vrt.rb +39 -39
- data/lib/ffi/gdal/warp_options.rb +34 -34
- data/lib/ffi/gdal/warper.rb +90 -90
- data/lib/ffi/gdal.rb +2 -31
- data/lib/ffi/ogr/api.rb +175 -167
- data/lib/ffi/ogr/contour_writer_info.rb +4 -4
- data/lib/ffi/ogr/core.rb +107 -107
- data/lib/ffi/ogr/envelope.rb +3 -3
- data/lib/ffi/ogr/envelope_3d.rb +5 -5
- data/lib/ffi/ogr/featurestyle.rb +3 -3
- data/lib/ffi/ogr/field.rb +22 -22
- data/lib/ffi/ogr/geocoding.rb +4 -4
- data/lib/ffi/ogr/srs_api.rb +154 -155
- data/lib/ffi/ogr/style_param.rb +3 -3
- data/lib/ffi/ogr/style_value.rb +4 -4
- data/lib/gdal/color_entry.rb +1 -5
- data/lib/gdal/color_interpretation.rb +7 -3
- data/lib/gdal/color_table.rb +46 -27
- data/lib/gdal/cpl_error_handler.rb +26 -6
- data/lib/gdal/data_type.rb +10 -3
- data/lib/gdal/dataset.rb +171 -85
- data/lib/gdal/dataset_mixins/algorithm_methods.rb +44 -44
- data/lib/gdal/dataset_mixins/matching.rb +1 -1
- data/lib/gdal/dataset_mixins/warp_methods.rb +4 -2
- data/lib/gdal/driver.rb +38 -21
- data/lib/gdal/environment_methods.rb +6 -6
- data/lib/gdal/extensions/all.rb +3 -0
- data/lib/gdal/{color_entry_mixins → extensions/color_entry}/extensions.rb +4 -1
- data/lib/gdal/{color_table_mixins → extensions/color_table}/extensions.rb +3 -0
- data/lib/gdal/extensions/dataset/extensions.rb +205 -0
- data/lib/gdal/{driver_mixins → extensions/driver}/extensions.rb +6 -2
- data/lib/gdal/{geo_transform_mixins → extensions/geo_transform}/extensions.rb +10 -8
- data/lib/gdal/{gridder → extensions/gridder}/point_extracting.rb +7 -5
- data/lib/gdal/{gridder.rb → extensions/gridder.rb} +33 -33
- data/lib/gdal/{gridder_options.rb → extensions/gridder_options.rb} +13 -14
- data/lib/gdal/{raster_attribute_table_mixins → extensions/raster_attribute_table}/extensions.rb +8 -6
- data/lib/gdal/{raster_band_mixins → extensions/raster_band}/algorithm_extensions.rb +8 -6
- data/lib/gdal/{raster_band_mixins → extensions/raster_band}/coloring_extensions.rb +6 -4
- data/lib/gdal/{raster_band_mixins → extensions/raster_band}/extensions.rb +9 -5
- data/lib/gdal/{raster_band_mixins → extensions/raster_band}/io_extensions.rb +18 -14
- data/lib/gdal/{raster_band_classifier.rb → extensions/raster_band_classifier.rb} +3 -5
- data/lib/gdal/geo_transform.rb +1 -6
- data/lib/gdal/grid.rb +3 -2
- data/lib/gdal/grid_algorithms.rb +9 -9
- data/lib/gdal/internal_helpers.rb +46 -9
- data/lib/gdal/major_object.rb +11 -3
- data/lib/gdal/options.rb +26 -32
- data/lib/gdal/raster_attribute_table.rb +63 -37
- data/lib/gdal/raster_band.rb +164 -116
- data/lib/gdal/raster_band_mixins/algorithm_methods.rb +26 -25
- data/lib/gdal/rpc_info.rb +3 -2
- data/lib/gdal/transformers/approximate_transformer.rb +12 -3
- data/lib/gdal/transformers/base_general_image_projection_transformer.rb +15 -2
- data/lib/gdal/transformers/gcp_transformer.rb +27 -19
- data/lib/gdal/transformers/general_image_projection_transformer.rb +8 -6
- data/lib/gdal/transformers/general_image_projection_transformer2.rb +9 -6
- data/lib/gdal/transformers/general_image_projection_transformer3.rb +6 -2
- data/lib/gdal/transformers/geolocation_transformer.rb +12 -4
- data/lib/gdal/transformers/reprojection_transformer.rb +11 -3
- data/lib/gdal/transformers/rpc_transformer.rb +11 -2
- data/lib/gdal/transformers/tps_transformer.rb +12 -4
- data/lib/gdal/version_info.rb +2 -2
- data/lib/gdal/virtual_dataset.rb +2 -0
- data/lib/gdal/warp_operation.rb +65 -54
- data/lib/gdal/warp_options.rb +9 -11
- data/lib/ogr/coordinate_transformation.rb +23 -9
- data/lib/ogr/data_source.rb +68 -37
- data/lib/ogr/driver.rb +18 -17
- data/lib/ogr/envelope.rb +0 -3
- data/lib/ogr/error_handling.rb +22 -24
- data/lib/ogr/extensions/all.rb +3 -0
- data/lib/ogr/{data_source_mixins → extensions/data_source}/capability_methods.rb +2 -0
- data/lib/ogr/extensions/data_source/data_source_extensions.rb +16 -0
- data/lib/ogr/{driver_mixins → extensions/driver}/capability_methods.rb +5 -1
- data/lib/ogr/extensions/envelope/extensions.rb +114 -0
- data/lib/ogr/extensions/feature/extensions.rb +87 -0
- data/lib/ogr/extensions/feature_definition/extensions.rb +43 -0
- data/lib/ogr/extensions/geometries/point/extensions.rb +19 -0
- data/lib/ogr/extensions/geometry/container_mixins.rb +56 -0
- data/lib/ogr/extensions/geometry/ewkb_io_extensions.rb +44 -0
- data/lib/ogr/extensions/geometry/ewkb_record.rb +94 -0
- data/lib/ogr/{geometry_mixins → extensions/geometry}/extensions.rb +16 -9
- data/lib/ogr/extensions/geometry/rttopo_extensions.rb +48 -0
- data/lib/ogr/extensions/geometry/wkb_record.rb +63 -0
- data/lib/ogr/extensions/geometry_types/curve/extensions.rb +68 -0
- data/lib/ogr/{layer_mixins → extensions/layer}/capability_methods.rb +4 -0
- data/lib/ogr/{layer_mixins → extensions/layer}/extensions.rb +11 -6
- data/lib/ogr/extensions/spatial_reference/extensions.rb +38 -0
- data/lib/ogr/extensions/spatial_reference/initializers.rb +138 -0
- data/lib/ogr/extensions/style_table/extensions.rb +31 -0
- data/lib/ogr/feature.rb +173 -88
- data/lib/ogr/feature_definition.rb +53 -45
- data/lib/ogr/field.rb +17 -19
- data/lib/ogr/field_definition.rb +30 -18
- data/lib/ogr/geocoder.rb +11 -4
- data/lib/ogr/geometries/line_string.rb +1 -0
- data/lib/ogr/geometries/line_string_25d.rb +0 -9
- data/lib/ogr/geometries/linear_ring.rb +2 -2
- data/lib/ogr/geometries/point.rb +0 -9
- data/lib/ogr/geometry.rb +116 -49
- data/lib/ogr/geometry_field_definition.rb +31 -15
- data/lib/ogr/geometry_types/container.rb +26 -28
- data/lib/ogr/geometry_types/curve.rb +5 -61
- data/lib/ogr/geometry_types/surface.rb +1 -1
- data/lib/ogr/internal_helpers.rb +2 -2
- data/lib/ogr/layer.rb +12 -10
- data/lib/ogr/layer_mixins/ogr_feature_methods.rb +39 -27
- data/lib/ogr/layer_mixins/ogr_field_methods.rb +66 -50
- data/lib/ogr/layer_mixins/ogr_layer_method_methods.rb +17 -8
- data/lib/ogr/layer_mixins/ogr_query_filter_methods.rb +7 -6
- data/lib/ogr/layer_mixins/ogr_sql_methods.rb +15 -7
- data/lib/ogr/spatial_reference.rb +79 -42
- data/lib/ogr/spatial_reference_mixins/coordinate_system_getter_setters.rb +149 -118
- data/lib/ogr/spatial_reference_mixins/exporters.rb +87 -51
- data/lib/ogr/spatial_reference_mixins/importers.rb +88 -43
- data/lib/ogr/spatial_reference_mixins/morphers.rb +12 -8
- data/lib/ogr/spatial_reference_mixins/parameter_getter_setters.rb +27 -13
- data/lib/ogr/style_table.rb +15 -5
- data/lib/ogr/style_tool.rb +29 -15
- data/lib/ogr.rb +1 -0
- data/rakelib/docker.rake +10 -0
- data/sorbet/rbi/hidden-definitions/errors.txt +21790 -0
- data/tilt/gdal2.yml +22 -0
- data/tilt/gdal3.yml +22 -0
- metadata +116 -280
- data/History.md +0 -360
- data/lib/ext/error_symbols.rb +0 -7
- data/lib/gdal/dataset_mixins/extensions.rb +0 -380
- data/lib/gdal/merger.rb +0 -132
- data/lib/ogr/data_source_extensions.rb +0 -10
- data/lib/ogr/envelope_extensions.rb +0 -110
- data/lib/ogr/feature_definition_extensions.rb +0 -39
- data/lib/ogr/feature_extensions.rb +0 -87
- data/lib/ogr/geometry_mixins/container_mixins.rb +0 -25
- data/lib/ogr/spatial_reference_extensions.rb +0 -34
- data/lib/ogr/style_table_extensions.rb +0 -26
- data/spec/ffi-gdal_spec.rb +0 -24
- data/spec/integration/gdal/color_table_info_spec.rb +0 -78
- data/spec/integration/gdal/dataset_info_spec.rb +0 -342
- data/spec/integration/gdal/driver_info_spec.rb +0 -170
- data/spec/integration/gdal/geo_transform_info_spec.rb +0 -226
- data/spec/integration/gdal/gridder_spec.rb +0 -331
- data/spec/integration/gdal/raster_attribute_table_info_spec.rb +0 -229
- data/spec/integration/gdal/raster_band_algorithms_spec.rb +0 -35
- data/spec/integration/gdal/raster_band_info_spec.rb +0 -320
- data/spec/integration/ogr/layer_spec.rb +0 -95
- data/spec/spec_helper.rb +0 -116
- data/spec/support/images/123.tiff +0 -0
- data/spec/support/images/osgeo/gdal/data/hfa/float-rle.img +0 -0
- data/spec/support/images/osgeo/geotiff/GeogToWGS84GeoKey/GeogToWGS84GeoKey5.lgo +0 -31
- data/spec/support/images/osgeo/geotiff/GeogToWGS84GeoKey/GeogToWGS84GeoKey5.tif +0 -0
- data/spec/support/images/osgeo/geotiff/GeogToWGS84GeoKey/GeogToWGS84GeoKey5.tif.msk +0 -0
- data/spec/support/images/osgeo/geotiff/GeogToWGS84GeoKey/GeogToWGS84GeoKey5.txt +0 -10
- data/spec/support/images/osgeo/geotiff/gdal_eg/cea.tif +0 -0
- data/spec/support/images/osgeo/geotiff/gdal_eg/cea.txt +0 -84
- data/spec/support/images/osgeo/geotiff/zi_imaging/image0.lgo +0 -45
- data/spec/support/images/osgeo/geotiff/zi_imaging/image0.tif +0 -0
- data/spec/support/integration_help.rb +0 -34
- data/spec/support/shapefiles/states_21basic/states.dbf +0 -0
- data/spec/support/shapefiles/states_21basic/states.prj +0 -1
- data/spec/support/shapefiles/states_21basic/states.sbn +0 -0
- data/spec/support/shapefiles/states_21basic/states.sbx +0 -0
- data/spec/support/shapefiles/states_21basic/states.shp +0 -0
- data/spec/support/shapefiles/states_21basic/states.shp.xml +0 -3
- data/spec/support/shapefiles/states_21basic/states.shx +0 -0
- data/spec/support/shared_contexts.rb +0 -28
- data/spec/support/shared_examples/gdal/major_object_examples.rb +0 -55
- data/spec/support/shared_examples/ogr/a_25d_geometry.rb +0 -9
- data/spec/support/shared_examples/ogr/a_container_geometry.rb +0 -49
- data/spec/support/shared_examples/ogr/a_geometry.rb +0 -406
- data/spec/support/shared_examples/ogr/a_line_string.rb +0 -18
- data/spec/support/test_style_table.txt +0 -3
- data/spec/support/worldfiles/SR_50M/SR_50M.VERSION.txt +0 -1
- data/spec/support/worldfiles/SR_50M/SR_50M.prj +0 -1
- data/spec/support/worldfiles/SR_50M/SR_50M.tfw +0 -6
- data/spec/support/worldfiles/SR_50M/SR_50M.tif +0 -0
- data/spec/unit/ext/error_symbols_spec.rb +0 -69
- data/spec/unit/ext/numeric_as_data_type_spec.rb +0 -115
- data/spec/unit/ffi/gdal_spec.rb +0 -73
- data/spec/unit/gdal/color_entry_spec.rb +0 -8
- data/spec/unit/gdal/color_interpretation_spec.rb +0 -8
- data/spec/unit/gdal/color_table_mixins/extensions_spec.rb +0 -62
- data/spec/unit/gdal/color_table_spec.rb +0 -146
- data/spec/unit/gdal/data_type_spec.rb +0 -74
- data/spec/unit/gdal/dataset_mixins/warp_methods_spec.rb +0 -55
- data/spec/unit/gdal/dataset_spec.rb +0 -148
- data/spec/unit/gdal/driver_mixins/extensions_spec.rb +0 -24
- data/spec/unit/gdal/driver_spec.rb +0 -51
- data/spec/unit/gdal/environment_methods_spec.rb +0 -8
- data/spec/unit/gdal/geo_transform_mixins/extensions_spec.rb +0 -69
- data/spec/unit/gdal/geo_transform_spec.rb +0 -265
- data/spec/unit/gdal/grid_spec.rb +0 -98
- data/spec/unit/gdal/gridder/point_extracting_spec.rb +0 -101
- data/spec/unit/gdal/gridder_options_spec.rb +0 -185
- data/spec/unit/gdal/gridder_spec.rb +0 -182
- data/spec/unit/gdal/internal_helpers_spec.rb +0 -278
- data/spec/unit/gdal/major_object_spec.rb +0 -10
- data/spec/unit/gdal/options_spec.rb +0 -33
- data/spec/unit/gdal/raster_attribute_table_spec.rb +0 -7
- data/spec/unit/gdal/raster_band_classifier_spec.rb +0 -260
- data/spec/unit/gdal/raster_band_mixins/extensions_spec.rb +0 -73
- data/spec/unit/gdal/raster_band_mixins/io_extensions_spec.rb +0 -135
- data/spec/unit/gdal/raster_band_spec.rb +0 -8
- data/spec/unit/gdal/rpc_info_spec.rb +0 -8
- data/spec/unit/gdal/version_info_spec.rb +0 -10
- data/spec/unit/gdal/virtual_dataset_spec.rb +0 -34
- data/spec/unit/gdal/warp_operation_spec.rb +0 -8
- data/spec/unit/gdal/warp_options_spec.rb +0 -338
- data/spec/unit/ogr/coordinate_transformation_spec.rb +0 -104
- data/spec/unit/ogr/data_source_mixins/capability_methods_spec.rb +0 -32
- data/spec/unit/ogr/data_source_spec.rb +0 -223
- data/spec/unit/ogr/driver_mixins/capability_methods_spec.rb +0 -20
- data/spec/unit/ogr/driver_spec.rb +0 -152
- data/spec/unit/ogr/envelope_spec.rb +0 -324
- data/spec/unit/ogr/feature_definition_spec.rb +0 -296
- data/spec/unit/ogr/feature_extensions_spec.rb +0 -90
- data/spec/unit/ogr/feature_spec.rb +0 -363
- data/spec/unit/ogr/field_definition_spec.rb +0 -118
- data/spec/unit/ogr/field_spec.rb +0 -195
- data/spec/unit/ogr/geometries/geometry_collection_25d_spec.rb +0 -25
- data/spec/unit/ogr/geometries/geometry_collection_spec.rb +0 -188
- data/spec/unit/ogr/geometries/line_string_25d_spec.rb +0 -25
- data/spec/unit/ogr/geometries/line_string_spec.rb +0 -107
- data/spec/unit/ogr/geometries/linear_ring_spec.rb +0 -92
- data/spec/unit/ogr/geometries/multi_line_string_25d_spec.rb +0 -25
- data/spec/unit/ogr/geometries/multi_line_string_spec.rb +0 -16
- data/spec/unit/ogr/geometries/multi_point_25d_spec.rb +0 -25
- data/spec/unit/ogr/geometries/multi_point_spec.rb +0 -16
- data/spec/unit/ogr/geometries/multi_polygon_25d_spec.rb +0 -25
- data/spec/unit/ogr/geometries/multi_polygon_spec.rb +0 -43
- data/spec/unit/ogr/geometries/none_geometry_spec.rb +0 -14
- data/spec/unit/ogr/geometries/point_25d_spec.rb +0 -25
- data/spec/unit/ogr/geometries/point_spec.rb +0 -307
- data/spec/unit/ogr/geometries/polygon_25d_spec.rb +0 -25
- data/spec/unit/ogr/geometries/polygon_spec.rb +0 -19
- data/spec/unit/ogr/geometries/unknown_geometry_spec.rb +0 -12
- data/spec/unit/ogr/geometry_field_definition_spec.rb +0 -73
- data/spec/unit/ogr/geometry_spec.rb +0 -711
- data/spec/unit/ogr/internal_helpers_spec.rb +0 -70
- data/spec/unit/ogr/layer_mixins/capability_methods_spec.rb +0 -90
- data/spec/unit/ogr/layer_mixins/ogr_feature_methods_spec.rb +0 -155
- data/spec/unit/ogr/layer_mixins/ogr_field_methods_spec.rb +0 -434
- data/spec/unit/ogr/layer_mixins/ogr_layer_method_methods_spec.rb +0 -22
- data/spec/unit/ogr/layer_mixins/ogr_query_filter_methods_spec.rb +0 -44
- data/spec/unit/ogr/layer_mixins/ogr_sql_methods_spec.rb +0 -14
- data/spec/unit/ogr/layer_spec.rb +0 -98
- data/spec/unit/ogr/spatial_reference_mixins/coordinate_system_getter_setters_spec.rb +0 -48
- data/spec/unit/ogr/spatial_reference_mixins/exporters_spec.rb +0 -151
- data/spec/unit/ogr/spatial_reference_mixins/importers_spec.rb +0 -40
- data/spec/unit/ogr/spatial_reference_mixins/morphers_spec.rb +0 -38
- data/spec/unit/ogr/spatial_reference_mixins/parameter_getter_setters_spec.rb +0 -105
- data/spec/unit/ogr/spatial_reference_mixins/type_checks_spec.rb +0 -159
- data/spec/unit/ogr/spatial_reference_spec.rb +0 -44
- data/spec/unit/ogr/style_table_spec.rb +0 -108
- data/spec/unit/ogr/style_tool_spec.rb +0 -159
- data/spec/unit/version_info_spec.rb +0 -50
data/lib/gdal/warp_operation.rb
CHANGED
@@ -4,95 +4,106 @@ require_relative '../gdal'
|
|
4
4
|
|
5
5
|
module GDAL
|
6
6
|
class WarpOperation
|
7
|
+
# @param pointer [FFI::Pointer]
|
8
|
+
def self.release(pointer)
|
9
|
+
return unless pointer && !pointer.null?
|
10
|
+
|
11
|
+
FFI::GDAL::Warper.GDALDestroyWarpOperation(pointer)
|
12
|
+
end
|
13
|
+
|
7
14
|
# @return [FFI::Pointer]
|
8
15
|
attr_reader :c_pointer
|
9
16
|
|
10
17
|
# @param warp_options [GDAL::WarpOptions]
|
11
18
|
def initialize(warp_options)
|
12
|
-
|
13
|
-
|
19
|
+
pointer = FFI::GDAL::Warper.GDALCreateWarpOperation(warp_options.c_struct)
|
20
|
+
|
21
|
+
raise GDAL::Error, 'Unable to create warp operation' if pointer.null?
|
22
|
+
|
23
|
+
@c_pointer = FFI::AutoPointer.new(pointer, WarpOperation.method(:release))
|
14
24
|
end
|
15
25
|
|
16
26
|
def destroy!
|
17
|
-
|
27
|
+
WarpOperation.release(@c_pointer)
|
18
28
|
|
19
|
-
FFI::GDAL::Warper.GDALDestroyWarpOperation(@c_pointer)
|
20
29
|
@c_pointer = nil
|
21
30
|
end
|
22
31
|
|
23
|
-
# @param x_offset [
|
24
|
-
# @param y_offset [
|
25
|
-
# @param x_size [
|
26
|
-
# @param y_size [
|
32
|
+
# @param x_offset [Integer] X offset of the destination image.
|
33
|
+
# @param y_offset [Integer] Y offset of the destination image.
|
34
|
+
# @param x_size [Integer] X size (width) of the destination image.
|
35
|
+
# @param y_size [Integer] Y size (height) of the destination image.
|
27
36
|
def chunk_and_warp_image(x_offset, y_offset, x_size, y_size)
|
28
37
|
!!FFI::GDAL::Warper.GDALChunkAndWarpImage(@c_pointer,
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
38
|
+
x_offset,
|
39
|
+
y_offset,
|
40
|
+
x_size,
|
41
|
+
y_size)
|
33
42
|
end
|
34
43
|
|
35
|
-
# @param x_offset [
|
36
|
-
# @param y_offset [
|
37
|
-
# @param x_size [
|
38
|
-
# @param y_size [
|
44
|
+
# @param x_offset [Integer] X offset of the destination image.
|
45
|
+
# @param y_offset [Integer] Y offset of the destination image.
|
46
|
+
# @param x_size [Integer] X size (width) of the destination image.
|
47
|
+
# @param y_size [Integer] Y size (height) of the destination image.
|
39
48
|
def chunk_and_warp_multi(x_offset, y_offset, x_size, y_size)
|
40
49
|
FFI::GDAL::Warper.GDALChunkAndWarpMulti(@c_pointer,
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
50
|
+
x_offset,
|
51
|
+
y_offset,
|
52
|
+
x_size,
|
53
|
+
y_size)
|
45
54
|
end
|
46
55
|
|
47
|
-
# @param destination_x_offset [
|
48
|
-
# @param destination_y_offset [
|
49
|
-
# @param destination_x_size [
|
50
|
-
# @param destination_y_size [
|
51
|
-
# @param source_x_offset [
|
52
|
-
# @param source_y_offset [
|
53
|
-
# @param source_x_size [
|
54
|
-
# @param source_y_size [
|
56
|
+
# @param destination_x_offset [Integer] X offset of the destination image.
|
57
|
+
# @param destination_y_offset [Integer] Y offset of the destination image.
|
58
|
+
# @param destination_x_size [Integer] X size (width) of the destination image.
|
59
|
+
# @param destination_y_size [Integer] Y size (height) of the destination image.
|
60
|
+
# @param source_x_offset [Integer] X offset of the source image.
|
61
|
+
# @param source_y_offset [Integer] Y offset of the source image.
|
62
|
+
# @param source_x_size [Integer] X size (width) of the source image.
|
63
|
+
# @param source_y_size [Integer] Y size (height) of the source image.
|
55
64
|
def warp_region(destination_x_offset, destination_y_offset,
|
56
65
|
destination_x_size, destination_y_size,
|
57
66
|
source_x_offset, source_y_offset,
|
58
67
|
source_x_size, source_y_size)
|
59
68
|
!!FFI::GDAL::Warper.GDALWarpRegion(@c_pointer,
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
69
|
+
destination_x_offset,
|
70
|
+
destination_y_offset,
|
71
|
+
destination_x_size,
|
72
|
+
destination_y_size,
|
73
|
+
source_x_offset,
|
74
|
+
source_y_offset,
|
75
|
+
source_x_size,
|
76
|
+
source_y_size)
|
68
77
|
end
|
69
78
|
|
70
|
-
# @param destination_x_offset [
|
71
|
-
# @param destination_y_offset [
|
72
|
-
# @param destination_x_size [
|
73
|
-
# @param destination_y_size [
|
79
|
+
# @param destination_x_offset [Integer] X offset of the destination image.
|
80
|
+
# @param destination_y_offset [Integer] Y offset of the destination image.
|
81
|
+
# @param destination_x_size [Integer] X size (width) of the destination image.
|
82
|
+
# @param destination_y_size [Integer] Y size (height) of the destination image.
|
74
83
|
# @param buffer [FFI::Pointer]
|
75
84
|
# @param data_type [FFI::GDAL::DataType]
|
76
|
-
# @param source_x_offset [
|
77
|
-
# @param source_y_offset [
|
78
|
-
# @param source_x_size [
|
79
|
-
# @param source_y_size [
|
85
|
+
# @param source_x_offset [Integer] X offset of the source image.
|
86
|
+
# @param source_y_offset [Integer] Y offset of the source image.
|
87
|
+
# @param source_x_size [Integer] X size (width) of the source image.
|
88
|
+
# @param source_y_size [Integer] Y size (height) of the source image.
|
89
|
+
# rubocop:disable Metrics/ParameterLists
|
80
90
|
def warp_region_to_buffer(destination_x_offset, destination_y_offset,
|
81
91
|
destination_x_size, destination_y_size,
|
82
92
|
buffer, data_type,
|
83
93
|
source_x_offset, source_y_offset,
|
84
94
|
source_x_size, source_y_size)
|
85
95
|
!!FFI::GDAL::Warper.GDALWarpRegionToBuffer(@c_pointer,
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
+
destination_x_offset,
|
97
|
+
destination_y_offset,
|
98
|
+
destination_x_size,
|
99
|
+
destination_y_size,
|
100
|
+
buffer,
|
101
|
+
data_type,
|
102
|
+
source_x_offset,
|
103
|
+
source_y_offset,
|
104
|
+
source_x_size,
|
105
|
+
source_y_size)
|
96
106
|
end
|
107
|
+
# rubocop:enable Metrics/ParameterLists
|
97
108
|
end
|
98
109
|
end
|
data/lib/gdal/warp_options.rb
CHANGED
@@ -4,10 +4,7 @@ require_relative '../gdal'
|
|
4
4
|
|
5
5
|
module GDAL
|
6
6
|
class WarpOptions
|
7
|
-
attr_reader :c_struct
|
8
|
-
attr_reader :source_dataset
|
9
|
-
attr_reader :destination_dataset
|
10
|
-
attr_reader :cutline
|
7
|
+
attr_reader :c_struct, :source_dataset, :destination_dataset, :cutline
|
11
8
|
|
12
9
|
def initialize(options = {})
|
13
10
|
@c_struct = FFI::GDAL::WarpOptions.new
|
@@ -23,8 +20,8 @@ module GDAL
|
|
23
20
|
else
|
24
21
|
@c_struct[k] = options[k]
|
25
22
|
end
|
26
|
-
rescue ArgumentError =>
|
27
|
-
new_message = "#{k}; #{
|
23
|
+
rescue ArgumentError => e
|
24
|
+
new_message = "#{k}; #{e.message}"
|
28
25
|
raise $ERROR_INFO, new_message, $ERROR_INFO.backtrace
|
29
26
|
end
|
30
27
|
end
|
@@ -58,7 +55,7 @@ module GDAL
|
|
58
55
|
@c_struct[:destination_dataset] = dataset.c_pointer
|
59
56
|
end
|
60
57
|
|
61
|
-
# @param band_numbers [Array<
|
58
|
+
# @param band_numbers [Array<Integer>]
|
62
59
|
def source_bands=(band_numbers)
|
63
60
|
bands_ptr = FFI::MemoryPointer.new(:int, band_numbers.length)
|
64
61
|
bands_ptr.write_array_of_int(band_numbers)
|
@@ -67,7 +64,7 @@ module GDAL
|
|
67
64
|
@c_struct[:band_count] = band_numbers.length if band_numbers.length > @c_struct[:band_count]
|
68
65
|
end
|
69
66
|
|
70
|
-
# @return [Array<
|
67
|
+
# @return [Array<Integer>]
|
71
68
|
def source_bands
|
72
69
|
pointer = @c_struct[:source_bands]
|
73
70
|
return [] if pointer.null?
|
@@ -75,7 +72,7 @@ module GDAL
|
|
75
72
|
pointer.read_array_of_int(@c_struct[:band_count])
|
76
73
|
end
|
77
74
|
|
78
|
-
# @param band_numbers [Array<
|
75
|
+
# @param band_numbers [Array<Integer>]
|
79
76
|
def destination_bands=(band_numbers)
|
80
77
|
bands_ptr = FFI::MemoryPointer.new(:pointer, band_numbers.length)
|
81
78
|
bands_ptr.write_array_of_int(band_numbers)
|
@@ -84,7 +81,7 @@ module GDAL
|
|
84
81
|
@c_struct[:band_count] = band_numbers.length if band_numbers.length > @c_struct[:band_count]
|
85
82
|
end
|
86
83
|
|
87
|
-
# @return [Array<
|
84
|
+
# @return [Array<Integer>]
|
88
85
|
def destination_bands
|
89
86
|
pointer = @c_struct[:destination_bands]
|
90
87
|
return [] if pointer.null?
|
@@ -101,6 +98,7 @@ module GDAL
|
|
101
98
|
# @param geometry [OGR::Geometry]
|
102
99
|
def cutline=(geometry)
|
103
100
|
raise 'Not a geom' unless geometry.is_a?(OGR::Geometry)
|
101
|
+
|
104
102
|
@cutline = geometry
|
105
103
|
|
106
104
|
@c_struct[:cutline] = geometry.c_pointer
|
@@ -171,7 +169,7 @@ module GDAL
|
|
171
169
|
end
|
172
170
|
|
173
171
|
# Set a Proc per source band; number of procs in +band_procs+ should equal
|
174
|
-
#
|
172
|
+
# the internal +band_count+.
|
175
173
|
#
|
176
174
|
# @param band_procs [Array<Proc>]
|
177
175
|
def source_per_band_validity_mask_function=(band_procs)
|
@@ -13,10 +13,17 @@ module OGR
|
|
13
13
|
FFI::GDAL::GDAL.OCTProj4Normalize(proj4_source)
|
14
14
|
else
|
15
15
|
raise OGR::UnsupportedOperation,
|
16
|
-
|
16
|
+
'Your version of GDAL/OGR does not support OCTProj4Normalize'
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
+
# @param pointer [FFI::Pointer]
|
21
|
+
def self.release(pointer)
|
22
|
+
return unless pointer && !pointer.null?
|
23
|
+
|
24
|
+
FFI::OGR::SRSAPI.OCTDestroyCoordinateTransformation(pointer)
|
25
|
+
end
|
26
|
+
|
20
27
|
# @return [OGR::SpatialReference]
|
21
28
|
attr_reader :source_coordinate_system
|
22
29
|
|
@@ -31,16 +38,23 @@ module OGR
|
|
31
38
|
def initialize(source_srs, destination_srs)
|
32
39
|
source_ptr = GDAL._pointer(OGR::SpatialReference, source_srs)
|
33
40
|
destination_ptr = GDAL._pointer(OGR::SpatialReference, destination_srs)
|
34
|
-
@c_pointer = FFI::OGR::SRSAPI.OCTNewCoordinateTransformation(source_ptr, destination_ptr)
|
35
41
|
|
36
|
-
|
42
|
+
# Input spatial reference system objects are assigned by copy (calling clone() method)
|
43
|
+
# and no ownership transfer occurs.
|
44
|
+
# NOTE: In GDAL 3, this will cause the GDAL error handler to raise a
|
45
|
+
# GDAL::Error; in < 3, this just returns a null pointer, then gets handled
|
46
|
+
# by the null-pointer check below.
|
47
|
+
pointer = FFI::OGR::SRSAPI.OCTNewCoordinateTransformation(source_ptr, destination_ptr)
|
48
|
+
|
49
|
+
raise GDAL::Error, 'Unable to create coordinate transformation' if pointer.null?
|
50
|
+
|
51
|
+
@c_pointer = pointer
|
37
52
|
end
|
38
53
|
|
39
54
|
# Deletes the object and deallocates all related C resources.
|
40
55
|
def destroy!
|
41
|
-
|
56
|
+
CoordinateTransformation.release(@c_pointer)
|
42
57
|
|
43
|
-
FFI::OGR::SRSAPI.OCTDestroyCoordinateTransformation(@c_pointer)
|
44
58
|
@c_pointer = nil
|
45
59
|
end
|
46
60
|
|
@@ -83,10 +97,10 @@ module OGR
|
|
83
97
|
# @param x_vertices [Array<Float>]
|
84
98
|
# @param y_vertices [Array<Float>]
|
85
99
|
# @param z_vertices [Array<Float>]
|
86
|
-
# @yieldparam point_count [
|
87
|
-
# @yieldparam x_ptr [FFI::
|
88
|
-
# @yieldparam y_ptr [FFI::
|
89
|
-
# @yieldparam z_ptr [FFI::
|
100
|
+
# @yieldparam point_count [Integer]
|
101
|
+
# @yieldparam x_ptr [FFI::MemoryPointer]
|
102
|
+
# @yieldparam y_ptr [FFI::MemoryPointer]
|
103
|
+
# @yieldparam z_ptr [FFI::MemoryPointer]
|
90
104
|
# @yieldreturn [Boolean]
|
91
105
|
# @return [Array<Array<Float>,Array<Float>,Array<Float>>] [[x1, x2, etc], [y1, y2, etc]]
|
92
106
|
# Will include a 3rd array of Z values if z vertices are given.
|
data/lib/ogr/data_source.rb
CHANGED
@@ -1,18 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'json'
|
4
3
|
require_relative '../gdal'
|
5
4
|
require_relative '../ogr'
|
6
|
-
require_relative 'data_source_extensions'
|
7
|
-
require_relative 'data_source_mixins/capability_methods'
|
8
5
|
require_relative '../gdal/major_object'
|
9
6
|
|
10
7
|
module OGR
|
11
8
|
class DataSource
|
12
9
|
include GDAL::MajorObject
|
13
10
|
include GDAL::Logger
|
14
|
-
include DataSourceExtensions
|
15
|
-
include DataSourceMixins::CapabilityMethods
|
16
11
|
|
17
12
|
# Same as +.new+.
|
18
13
|
#
|
@@ -31,6 +26,23 @@ module OGR
|
|
31
26
|
end
|
32
27
|
end
|
33
28
|
|
29
|
+
# @param pointer [FFI::Pointer]
|
30
|
+
def self.release(pointer)
|
31
|
+
return unless pointer && !pointer.null?
|
32
|
+
|
33
|
+
FFI::OGR::API.OGR_DS_Destroy(pointer)
|
34
|
+
end
|
35
|
+
|
36
|
+
# Use to release the resulting data pointer from #execute_sql.
|
37
|
+
#
|
38
|
+
# @param data_source_pointer [FFI::Pointer]
|
39
|
+
# @param layer_pointer [FFI::Pointer]
|
40
|
+
def self.release_result_set(data_source_pointer, layer_pointer)
|
41
|
+
return unless data_source_pointer && !data_source_pointer.null? && layer_pointer && !layer_pointer.null?
|
42
|
+
|
43
|
+
FFI::OGR::API.OGR_DS_ReleaseResultSet(data_source_pointer, layer_pointer)
|
44
|
+
end
|
45
|
+
|
34
46
|
# @return [FFI::Pointer]
|
35
47
|
attr_reader :c_pointer
|
36
48
|
|
@@ -45,16 +57,23 @@ module OGR
|
|
45
57
|
path_or_pointer
|
46
58
|
end
|
47
59
|
|
48
|
-
|
60
|
+
if @c_pointer.null?
|
61
|
+
error_msg, ptr = FFI::CPL::Error.CPLGetLastErrorMsg
|
62
|
+
ptr.autorelease = false
|
63
|
+
|
64
|
+
error_type = FFI::CPL::Error.CPLGetLastErrorType
|
65
|
+
FFI::CPL::Error.CPLErrorReset
|
66
|
+
|
67
|
+
raise OGR::OpenFailure, "#{error_type}: #{error_msg} (#{path_or_pointer})"
|
68
|
+
end
|
49
69
|
|
50
70
|
@layers = []
|
51
71
|
end
|
52
72
|
|
53
73
|
# Closes opened data source and releases allocated resources.
|
54
74
|
def destroy!
|
55
|
-
|
75
|
+
DataSource.release(@c_pointer)
|
56
76
|
|
57
|
-
FFI::OGR::API.OGR_DS_Destroy(@c_pointer)
|
58
77
|
@c_pointer = nil
|
59
78
|
end
|
60
79
|
alias close destroy!
|
@@ -63,7 +82,11 @@ module OGR
|
|
63
82
|
#
|
64
83
|
# @return [String]
|
65
84
|
def name
|
66
|
-
|
85
|
+
# This is an internal string and should not be modified or freed.
|
86
|
+
name_ptr = FFI::OGR::API.OGR_DS_GetName(@c_pointer)
|
87
|
+
name_ptr.autorelease = false
|
88
|
+
|
89
|
+
name_ptr.read_string_to_null
|
67
90
|
end
|
68
91
|
|
69
92
|
# @return [OGR::Driver]
|
@@ -74,16 +97,19 @@ module OGR
|
|
74
97
|
OGR::Driver.new(driver_ptr)
|
75
98
|
end
|
76
99
|
|
77
|
-
# @return [
|
100
|
+
# @return [Integer]
|
78
101
|
def layer_count
|
79
102
|
FFI::OGR::API.OGR_DS_GetLayerCount(@c_pointer)
|
80
103
|
end
|
81
104
|
|
82
|
-
# @param index [
|
105
|
+
# @param index [Integer] 0-offset index of the layer to retrieve.
|
83
106
|
# @return [OGR::Layer]
|
84
107
|
def layer(index)
|
85
108
|
@layers.fetch(index) do
|
109
|
+
# The returned layer remains owned by the OGRDataSource and should not be deleted by the application.
|
86
110
|
layer_pointer = FFI::OGR::API.OGR_DS_GetLayer(@c_pointer, index)
|
111
|
+
layer_pointer.autorelease = false
|
112
|
+
|
87
113
|
return nil if layer_pointer.null?
|
88
114
|
|
89
115
|
l = OGR::Layer.new(layer_pointer)
|
@@ -96,7 +122,10 @@ module OGR
|
|
96
122
|
# @param name [String]
|
97
123
|
# @return [OGR::Layer]
|
98
124
|
def layer_by_name(name)
|
125
|
+
# The returned layer remains owned by the OGRDataSource and should not be deleted by the application.
|
99
126
|
layer_pointer = FFI::OGR::API.OGR_DS_GetLayerByName(@c_pointer, name)
|
127
|
+
layer_pointer.autorelease = false
|
128
|
+
|
100
129
|
return nil if layer_pointer.null?
|
101
130
|
|
102
131
|
OGR::Layer.new(layer_pointer)
|
@@ -109,13 +138,16 @@ module OGR
|
|
109
138
|
# @param options [Hash] Driver-specific options.
|
110
139
|
# @return [OGR::Layer]
|
111
140
|
def create_layer(name, geometry_type: :wkbUnknown, spatial_reference: nil, **options)
|
112
|
-
|
141
|
+
unless test_capability('CreateLayer')
|
142
|
+
raise OGR::UnsupportedOperation,
|
143
|
+
'This data source does not support creating layers.'
|
144
|
+
end
|
113
145
|
|
114
|
-
spatial_ref_ptr = GDAL._pointer(OGR::SpatialReference, spatial_reference) if spatial_reference
|
146
|
+
spatial_ref_ptr = GDAL._pointer(OGR::SpatialReference, spatial_reference, autorelease: false) if spatial_reference
|
115
147
|
options_obj = GDAL::Options.pointer(options)
|
116
148
|
|
117
|
-
layer_ptr =
|
118
|
-
spatial_ref_ptr, geometry_type, options_obj)
|
149
|
+
layer_ptr =
|
150
|
+
FFI::OGR::API.OGR_DS_CreateLayer(@c_pointer, name, spatial_ref_ptr, geometry_type, options_obj)
|
119
151
|
|
120
152
|
raise OGR::InvalidLayer, "Unable to create layer '#{name}'." unless layer_ptr
|
121
153
|
|
@@ -133,20 +165,23 @@ module OGR
|
|
133
165
|
options_ptr = GDAL::Options.pointer(options)
|
134
166
|
|
135
167
|
layer_ptr = FFI::OGR::API.OGR_DS_CopyLayer(@c_pointer, source_layer_ptr,
|
136
|
-
|
168
|
+
new_name, options_ptr)
|
137
169
|
return nil if layer_ptr.null?
|
138
170
|
|
139
171
|
OGR::Layer.new(layer_ptr)
|
140
172
|
end
|
141
173
|
|
142
|
-
# @param index [
|
143
|
-
# @
|
174
|
+
# @param index [Integer]
|
175
|
+
# @raise [OGR::Failure]
|
144
176
|
def delete_layer(index)
|
145
|
-
|
146
|
-
|
147
|
-
|
177
|
+
unless test_capability('DeleteLayer')
|
178
|
+
raise OGR::UnsupportedOperation,
|
179
|
+
'This data source does not support deleting layers.'
|
180
|
+
end
|
148
181
|
|
149
|
-
|
182
|
+
OGR::ErrorHandling.handle_ogr_err("Unable to delete layer at index #{index}") do
|
183
|
+
FFI::OGR::API.OGR_DS_DeleteLayer(@c_pointer, index)
|
184
|
+
end
|
150
185
|
end
|
151
186
|
|
152
187
|
# @param command [String] The SQL to execute.
|
@@ -158,25 +193,21 @@ module OGR
|
|
158
193
|
def execute_sql(command, spatial_filter = nil, dialect = nil)
|
159
194
|
geometry_ptr = GDAL._pointer(OGR::Geometry, spatial_filter) if spatial_filter
|
160
195
|
|
161
|
-
layer_ptr = FFI::OGR::API.OGR_DS_ExecuteSQL(@c_pointer, command, geometry_ptr,
|
162
|
-
|
196
|
+
layer_ptr = FFI::OGR::API.OGR_DS_ExecuteSQL(@c_pointer, command, geometry_ptr, dialect)
|
197
|
+
layer_ptr.autorelease = false
|
163
198
|
|
164
199
|
return nil if layer_ptr.null?
|
165
200
|
|
166
|
-
OGR::Layer.new(layer_ptr
|
167
|
-
|
168
|
-
|
169
|
-
# Use to release the resulting data pointer from #execute_sql.
|
170
|
-
#
|
171
|
-
# @param layer [OGR::Layer, FFI::Pointer]
|
172
|
-
def release_result_set(layer)
|
173
|
-
layer_ptr = GDAL._pointer(OGR::Layer, layer)
|
174
|
-
FFI::OGR::API.OGR_DS_ReleaseResultSet(@c_pointer, layer_ptr)
|
201
|
+
OGR::Layer.new(FFI::AutoPointer.new(layer_ptr, lambda { |ptr|
|
202
|
+
DataSource.release_result_set(@c_pointer, ptr)
|
203
|
+
}))
|
175
204
|
end
|
176
205
|
|
177
206
|
# @return [OGR::StyleTable, nil]
|
178
207
|
def style_table
|
179
208
|
style_table_ptr = FFI::OGR::API.OGR_DS_GetStyleTable(@c_pointer)
|
209
|
+
style_table_ptr.autorelease = false
|
210
|
+
|
180
211
|
return nil if style_table_ptr.null?
|
181
212
|
|
182
213
|
OGR::StyleTable.new(style_table_ptr)
|
@@ -203,11 +234,11 @@ module OGR
|
|
203
234
|
FFI::OGR::API.OGR_DS_TestCapability(@c_pointer, capability)
|
204
235
|
end
|
205
236
|
|
206
|
-
# @
|
237
|
+
# @raise [OGR::Failure]
|
207
238
|
def sync_to_disk
|
208
|
-
|
209
|
-
|
210
|
-
|
239
|
+
OGR::ErrorHandling.handle_ogr_err('Unable to syn datasource to disk') do
|
240
|
+
FFI::OGR::API.OGR_DS_SyncToDisk(@c_pointer)
|
241
|
+
end
|
211
242
|
end
|
212
243
|
end
|
213
244
|
end
|
data/lib/ogr/driver.rb
CHANGED
@@ -3,7 +3,6 @@
|
|
3
3
|
require_relative '../ogr'
|
4
4
|
require_relative '../gdal'
|
5
5
|
require_relative '../gdal/major_object'
|
6
|
-
require_relative 'driver_mixins/capability_methods'
|
7
6
|
|
8
7
|
module OGR
|
9
8
|
# Wrapper for OGR's Driver class. In this case, to use a driver, find the
|
@@ -14,9 +13,8 @@ module OGR
|
|
14
13
|
class Driver
|
15
14
|
include GDAL::MajorObject
|
16
15
|
include GDAL::Logger
|
17
|
-
include DriverMixins::CapabilityMethods
|
18
16
|
|
19
|
-
# @return [
|
17
|
+
# @return [Integer]
|
20
18
|
def self.count
|
21
19
|
FFI::OGR::API.OGRGetDriverCount
|
22
20
|
end
|
@@ -31,7 +29,7 @@ module OGR
|
|
31
29
|
new(driver_ptr)
|
32
30
|
end
|
33
31
|
|
34
|
-
# @param index [
|
32
|
+
# @param index [Integer] Index of the registered driver. Must be less than
|
35
33
|
# OGR::Driver.count.
|
36
34
|
# @return [OGR::Driver]
|
37
35
|
# @raise [OGR::DriverNotFound] if a driver at +index+ isn't found.
|
@@ -39,7 +37,6 @@ module OGR
|
|
39
37
|
raise OGR::DriverNotFound, index if index > count
|
40
38
|
|
41
39
|
driver_ptr = FFI::OGR::API.OGRGetDriver(index)
|
42
|
-
return nil if driver_ptr.null?
|
43
40
|
raise OGR::DriverNotFound, index if driver_ptr.null?
|
44
41
|
|
45
42
|
new(driver_ptr)
|
@@ -63,7 +60,10 @@ module OGR
|
|
63
60
|
|
64
61
|
# @return [String]
|
65
62
|
def name
|
66
|
-
FFI::OGR::API.OGR_Dr_GetName(@c_pointer)
|
63
|
+
name, ptr = FFI::OGR::API.OGR_Dr_GetName(@c_pointer)
|
64
|
+
ptr.autorelease = false
|
65
|
+
|
66
|
+
name
|
67
67
|
end
|
68
68
|
|
69
69
|
# @param file_name [String]
|
@@ -87,15 +87,15 @@ module OGR
|
|
87
87
|
# @param options [Hash]
|
88
88
|
# @return [OGR::DataSource, nil]
|
89
89
|
def create_data_source(file_name, **options)
|
90
|
-
unless
|
90
|
+
unless test_capability('CreateDataSource')
|
91
91
|
raise OGR::UnsupportedOperation, 'This driver does not support data source creation.'
|
92
92
|
end
|
93
93
|
|
94
94
|
options_ptr = GDAL::Options.pointer(options)
|
95
95
|
|
96
96
|
data_source_ptr = FFI::OGR::API.OGR_Dr_CreateDataSource(@c_pointer,
|
97
|
-
|
98
|
-
|
97
|
+
file_name, options_ptr)
|
98
|
+
raise OGR::CreateFailure, "Unable to create DataSource '#{file_name}'" if data_source_ptr.null?
|
99
99
|
|
100
100
|
ds = OGR::DataSource.new(data_source_ptr, 'w')
|
101
101
|
yield ds if block_given?
|
@@ -104,15 +104,15 @@ module OGR
|
|
104
104
|
end
|
105
105
|
|
106
106
|
# @param file_name [String]
|
107
|
-
# @
|
107
|
+
# @raise [OGR::Failure]
|
108
108
|
def delete_data_source(file_name)
|
109
|
-
unless
|
109
|
+
unless test_capability('DeleteDataSource')
|
110
110
|
raise OGR::UnsupportedOperation, 'This driver does not support deleting data sources.'
|
111
111
|
end
|
112
112
|
|
113
|
-
|
114
|
-
|
115
|
-
|
113
|
+
OGR::ErrorHandling.handle_ogr_err("Unable to delete data source '#{file_name}'") do
|
114
|
+
FFI::OGR::API.OGR_Dr_DeleteDataSource(@c_pointer, file_name)
|
115
|
+
end
|
116
116
|
end
|
117
117
|
|
118
118
|
# @param source_data_source [OGR::DataSource, FFI::Pointer]
|
@@ -126,9 +126,10 @@ module OGR
|
|
126
126
|
|
127
127
|
options_ptr = GDAL::Options.pointer(options)
|
128
128
|
|
129
|
-
data_source_ptr =
|
130
|
-
source_ptr, new_file_name, options_ptr)
|
131
|
-
|
129
|
+
data_source_ptr =
|
130
|
+
FFI::OGR::API.OGR_Dr_CopyDataSource(@c_pointer, source_ptr, new_file_name, options_ptr)
|
131
|
+
|
132
|
+
raise OGR::InvalidDataSource, "Unable to copy data source to #{new_file_name}" if data_source_ptr.null?
|
132
133
|
|
133
134
|
OGR::DataSource.new(data_source_ptr, nil)
|
134
135
|
end
|
data/lib/ogr/envelope.rb
CHANGED
@@ -1,12 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative '../ogr'
|
4
|
-
require_relative 'envelope_extensions'
|
5
4
|
|
6
5
|
module OGR
|
7
6
|
class Envelope
|
8
|
-
include EnvelopeExtensions
|
9
|
-
|
10
7
|
# @return [FFI::OGR::Envelope, FFI::OGR::Envelope3D] The C struct that this
|
11
8
|
# object wraps.
|
12
9
|
attr_reader :c_struct
|