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
@@ -1,11 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative '../gdal'
|
3
4
|
require_relative '../ogr'
|
4
|
-
require_relative 'feature_definition_extensions'
|
5
5
|
|
6
6
|
module OGR
|
7
7
|
class FeatureDefinition
|
8
|
-
|
8
|
+
# @param pointer [FFI::Pointer]
|
9
|
+
def self.release(pointer)
|
10
|
+
return unless pointer && !pointer.null?
|
11
|
+
|
12
|
+
FFI::OGR::API.OGR_FD_Release(pointer)
|
13
|
+
end
|
9
14
|
|
10
15
|
# @return [FFI::Pointer] C pointer of the C FeatureDefn.
|
11
16
|
attr_reader :c_pointer
|
@@ -15,39 +20,45 @@ module OGR
|
|
15
20
|
# FFI::Pointer, the new object will simply wrap the C FeatureDefinition
|
16
21
|
# at that address.
|
17
22
|
def initialize(name_or_pointer)
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
23
|
+
pointer = if name_or_pointer.is_a? String
|
24
|
+
FFI::OGR::API.OGR_FD_Create(name_or_pointer)
|
25
|
+
else
|
26
|
+
name_or_pointer
|
27
|
+
end
|
28
|
+
|
29
|
+
if !pointer.is_a?(FFI::Pointer) || pointer.null?
|
30
|
+
raise OGR::InvalidFeatureDefinition, "Unable to create #{self.class.name} from #{name_or_pointer}"
|
31
|
+
end
|
25
32
|
|
26
|
-
|
33
|
+
@c_pointer = FFI::AutoPointer.new(pointer, FeatureDefinition.method(:release))
|
34
|
+
@c_pointer.autorelease = false
|
27
35
|
end
|
28
36
|
|
29
37
|
def release!
|
30
|
-
|
38
|
+
FeatureDefinition.release(@c_pointer)
|
31
39
|
|
32
|
-
FFI::OGR::API.OGR_FD_Release(@c_pointer)
|
33
40
|
@c_pointer = nil
|
34
41
|
end
|
35
42
|
|
36
43
|
# @return [String]
|
37
44
|
def name
|
38
|
-
FFI::OGR::API.OGR_FD_GetName(@c_pointer)
|
45
|
+
name, ptr = FFI::OGR::API.OGR_FD_GetName(@c_pointer)
|
46
|
+
ptr.autorelease = false
|
47
|
+
|
48
|
+
name
|
39
49
|
end
|
40
50
|
|
41
|
-
# @return [
|
51
|
+
# @return [Integer]
|
42
52
|
def field_count
|
43
53
|
FFI::OGR::API.OGR_FD_GetFieldCount(@c_pointer)
|
44
54
|
end
|
45
55
|
|
46
|
-
# @param index [
|
56
|
+
# @param index [Integer]
|
47
57
|
# @return [OGR::FieldDefinition]
|
48
58
|
def field_definition(index)
|
49
|
-
field_definition_ptr =
|
50
|
-
|
59
|
+
field_definition_ptr = FFI::OGR::API.OGR_FD_GetFieldDefn(@c_pointer, index)
|
60
|
+
field_definition_ptr.autorelease = false
|
61
|
+
|
51
62
|
return nil if field_definition_ptr.null?
|
52
63
|
|
53
64
|
OGR::FieldDefinition.new(field_definition_ptr, nil)
|
@@ -64,23 +75,23 @@ module OGR
|
|
64
75
|
FFI::OGR::API.OGR_FD_AddFieldDefn(@c_pointer, field_definition_ptr)
|
65
76
|
end
|
66
77
|
|
67
|
-
# @param index [
|
68
|
-
# @
|
78
|
+
# @param index [Integer] Index of the field definition to delete.
|
79
|
+
# @raise [OGR::Failure]
|
69
80
|
def delete_field_definition(index)
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
81
|
+
OGR::ErrorHandling.handle_ogr_err("Unable to delete field definition at index #{index}") do
|
82
|
+
FFI::OGR::API.OGR_FD_DeleteFieldDefn(
|
83
|
+
@c_pointer,
|
84
|
+
index
|
85
|
+
)
|
86
|
+
end
|
76
87
|
end
|
77
88
|
|
78
89
|
# @param name [String]
|
79
|
-
# @return [
|
90
|
+
# @return [Integer] nil if no match found
|
80
91
|
def field_index(name)
|
81
92
|
result = FFI::OGR::API.OGR_FD_GetFieldIndex(@c_pointer, name)
|
82
93
|
|
83
|
-
result
|
94
|
+
result.negative? ? nil : result
|
84
95
|
end
|
85
96
|
|
86
97
|
# @return [FFI::OGR::API::WKBGeometryType]
|
@@ -99,7 +110,7 @@ module OGR
|
|
99
110
|
end
|
100
111
|
|
101
112
|
# @param ignore [Boolean]
|
102
|
-
def ignore_geometry!(ignore
|
113
|
+
def ignore_geometry!(ignore: true)
|
103
114
|
FFI::OGR::API.OGR_FD_SetGeometryIgnored(@c_pointer, ignore)
|
104
115
|
end
|
105
116
|
|
@@ -109,48 +120,45 @@ module OGR
|
|
109
120
|
end
|
110
121
|
|
111
122
|
# @param ignore [Boolean]
|
112
|
-
def ignore_style!(ignore
|
123
|
+
def ignore_style!(ignore: true)
|
113
124
|
FFI::OGR::API.OGR_FD_SetStyleIgnored(@c_pointer, ignore)
|
114
125
|
end
|
115
126
|
|
116
|
-
# @return [
|
127
|
+
# @return [Integer]
|
117
128
|
def geometry_field_count
|
118
129
|
FFI::OGR::API.OGR_FD_GetGeomFieldCount(@c_pointer)
|
119
130
|
end
|
120
131
|
|
121
|
-
# @param index [
|
132
|
+
# @param index [Integer]
|
122
133
|
# @return [OGR::GeometryFieldDefinition]
|
123
134
|
def geometry_field_definition(index)
|
124
|
-
geometry_field_definition_ptr =
|
125
|
-
|
135
|
+
geometry_field_definition_ptr = FFI::OGR::API.OGR_FD_GetGeomFieldDefn(@c_pointer, index)
|
136
|
+
|
126
137
|
return nil if geometry_field_definition_ptr.null?
|
127
138
|
|
128
139
|
OGR::GeometryFieldDefinition.new(geometry_field_definition_ptr)
|
129
140
|
end
|
130
141
|
|
131
142
|
# @param name [String]
|
132
|
-
# @return [
|
143
|
+
# @return [Integer]
|
133
144
|
def geometry_field_index(name)
|
134
145
|
result = FFI::OGR::API.OGR_FD_GetGeomFieldIndex(@c_pointer, name)
|
135
146
|
|
136
|
-
result
|
147
|
+
result.negative? ? nil : result
|
137
148
|
end
|
138
149
|
|
139
150
|
# @param geometry_field_definition [OGR::GeometryFieldDefinition, FFI::Pointer]
|
140
151
|
def add_geometry_field_definition(geometry_field_definition)
|
141
|
-
geometry_field_definition_ptr = GDAL._pointer(OGR::GeometryFieldDefinition,
|
142
|
-
|
143
|
-
FFI::OGR::API.OGR_FD_AddGeomFieldDefn(@c_pointer,
|
144
|
-
geometry_field_definition_ptr)
|
152
|
+
geometry_field_definition_ptr = GDAL._pointer(OGR::GeometryFieldDefinition, geometry_field_definition)
|
153
|
+
FFI::OGR::API.OGR_FD_AddGeomFieldDefn(@c_pointer, geometry_field_definition_ptr)
|
145
154
|
end
|
146
155
|
|
147
|
-
# @param index [
|
148
|
-
# @
|
156
|
+
# @param index [Integer]
|
157
|
+
# @raise [OGR::Failure]
|
149
158
|
def delete_geometry_field_definition(index)
|
150
|
-
|
151
|
-
index)
|
152
|
-
|
153
|
-
ogr_err.handle_result "Unable to delete geometry field definition at index #{index}"
|
159
|
+
OGR::ErrorHandling.handle_ogr_err("Unable to delete geometry field definition at index #{index}") do
|
160
|
+
FFI::OGR::API.OGR_FD_DeleteGeomFieldDefn(@c_pointer, index)
|
161
|
+
end
|
154
162
|
end
|
155
163
|
|
156
164
|
# @param other_feature_definition [OGR::Feature, FFI::Pointer]
|
data/lib/ogr/field.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'date'
|
4
4
|
require_relative '../ogr'
|
5
|
+
require_relative '../gdal'
|
5
6
|
|
6
7
|
module OGR
|
7
8
|
class Field
|
@@ -18,23 +19,23 @@ module OGR
|
|
18
19
|
@c_struct.to_ptr
|
19
20
|
end
|
20
21
|
|
21
|
-
# @return [
|
22
|
+
# @return [Integer]
|
22
23
|
def integer
|
23
24
|
@c_struct[:integer]
|
24
25
|
end
|
25
26
|
alias to_i integer
|
26
27
|
|
27
|
-
# @param new_int [
|
28
|
+
# @param new_int [Integer]
|
28
29
|
def integer=(new_int)
|
29
30
|
@c_struct[:integer] = new_int
|
30
31
|
end
|
31
32
|
|
32
|
-
# @return [
|
33
|
+
# @return [Integer]
|
33
34
|
def integer64
|
34
35
|
@c_struct[:integer64]
|
35
36
|
end
|
36
37
|
|
37
|
-
# @param new_int64 [
|
38
|
+
# @param new_int64 [Integer]
|
38
39
|
def integer64=(new_int64)
|
39
40
|
@c_struct[:integer64] = new_int64
|
40
41
|
end
|
@@ -61,7 +62,7 @@ module OGR
|
|
61
62
|
@c_struct[:string] = FFI::MemoryPointer.from_string(new_string)
|
62
63
|
end
|
63
64
|
|
64
|
-
# @return [Array<
|
65
|
+
# @return [Array<Integer>]
|
65
66
|
def integer_list
|
66
67
|
il = @c_struct[:integer_list]
|
67
68
|
return [] if il[:count].zero?
|
@@ -69,7 +70,7 @@ module OGR
|
|
69
70
|
il[:list].read_array_of_int(il[:count])
|
70
71
|
end
|
71
72
|
|
72
|
-
# @param new_integer_list [Array<
|
73
|
+
# @param new_integer_list [Array<Integer>]
|
73
74
|
def integer_list=(new_integer_list)
|
74
75
|
list_ptr = FFI::MemoryPointer.new(:int, new_integer_list.length)
|
75
76
|
list_ptr.write_array_of_int(new_integer_list)
|
@@ -81,7 +82,7 @@ module OGR
|
|
81
82
|
@c_struct[:integer_list] = il
|
82
83
|
end
|
83
84
|
|
84
|
-
# @return [Array<
|
85
|
+
# @return [Array<Integer>]
|
85
86
|
def integer64_list
|
86
87
|
il = @c_struct[:integer_list]
|
87
88
|
return [] if il[:count].zero?
|
@@ -90,7 +91,7 @@ module OGR
|
|
90
91
|
end
|
91
92
|
alias to_bignum integer64_list
|
92
93
|
|
93
|
-
# @param new_integer64_list [Array<
|
94
|
+
# @param new_integer64_list [Array<Integer>]
|
94
95
|
def integer64_list=(new_integer64_list)
|
95
96
|
list_ptr = FFI::MemoryPointer.new(:int64, new_integer64_list.size)
|
96
97
|
list_ptr.write_array_of_int64(new_integer64_list)
|
@@ -149,7 +150,7 @@ module OGR
|
|
149
150
|
def binary
|
150
151
|
b = @c_struct[:binary]
|
151
152
|
|
152
|
-
b[:count]
|
153
|
+
b[:count].positive? ? b[:data].read_bytes(b[:count]) : ''
|
153
154
|
end
|
154
155
|
|
155
156
|
# @param new_binary [String] Binary string of 8-bit, unsigned data (uchar).
|
@@ -170,7 +171,7 @@ module OGR
|
|
170
171
|
{ marker1: @c_struct[:set][:marker1], marker2: @c_struct[:set][:marker2] }
|
171
172
|
end
|
172
173
|
|
173
|
-
# @param new_set [Hash{marker1 =>
|
174
|
+
# @param new_set [Hash{marker1 => Integer, marker2 => Integer}]
|
174
175
|
def set=(new_set)
|
175
176
|
set = FFI::OGR::FieldTypes::Set.new
|
176
177
|
set[:marker1] = new_set[:marker1]
|
@@ -185,16 +186,13 @@ module OGR
|
|
185
186
|
return if c_date[:year].zero? || c_date[:month].zero? || c_date[:day].zero?
|
186
187
|
|
187
188
|
formatted_tz = OGR._format_time_zone_for_ruby(c_date[:tz_flag].to_i)
|
188
|
-
|
189
|
-
# rubocop:disable Style/DateTime
|
190
189
|
DateTime.new(c_date[:year],
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
# rubocop:enable Style/DateTime
|
190
|
+
c_date[:month],
|
191
|
+
c_date[:day],
|
192
|
+
c_date[:hour],
|
193
|
+
c_date[:minute],
|
194
|
+
c_date[:second],
|
195
|
+
formatted_tz)
|
198
196
|
end
|
199
197
|
|
200
198
|
# @param new_date [Date, Time, DateTime]
|
data/lib/ogr/field_definition.rb
CHANGED
@@ -4,27 +4,36 @@ require_relative '../ogr'
|
|
4
4
|
|
5
5
|
module OGR
|
6
6
|
class FieldDefinition
|
7
|
+
# @param pointer [FFI::Pointer]
|
8
|
+
def self.release(pointer)
|
9
|
+
return unless pointer && !pointer.null?
|
10
|
+
|
11
|
+
FFI::OGR::API.OGR_Fld_Destroy(pointer)
|
12
|
+
end
|
13
|
+
|
7
14
|
# @return [FFI::Pointer] C pointer to the C FieldDefn.
|
8
15
|
attr_reader :c_pointer
|
9
16
|
|
10
17
|
# @param name_or_pointer [String, FFI::Pointer]
|
11
18
|
# @param type [FFI::OGR::FieldType]
|
12
19
|
def initialize(name_or_pointer, type)
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
20
|
+
pointer = if name_or_pointer.is_a? String
|
21
|
+
FFI::OGR::API.OGR_Fld_Create(name_or_pointer, type)
|
22
|
+
else
|
23
|
+
name_or_pointer
|
24
|
+
end
|
25
|
+
|
26
|
+
if !pointer.is_a?(FFI::Pointer) || pointer.null?
|
27
|
+
raise OGR::InvalidFieldDefinition, "Unable to create #{self.class.name} from #{name_or_pointer}"
|
28
|
+
end
|
29
|
+
|
30
|
+
@c_pointer = FFI::AutoPointer.new(pointer, FieldDefinition.method(:release))
|
31
|
+
@c_pointer.autorelease = false
|
22
32
|
end
|
23
33
|
|
24
34
|
def destroy!
|
25
|
-
|
35
|
+
FieldDefinition.release(@c_pointer)
|
26
36
|
|
27
|
-
FFI::OGR::API.OGR_Fld_Destroy(@c_pointer)
|
28
37
|
@c_pointer = nil
|
29
38
|
end
|
30
39
|
|
@@ -32,8 +41,8 @@ module OGR
|
|
32
41
|
#
|
33
42
|
# @param name [String]
|
34
43
|
# @param type [FFI::OGR::FieldType]
|
35
|
-
# @param width [
|
36
|
-
# @param precision [
|
44
|
+
# @param width [Integer]
|
45
|
+
# @param precision [Integer]
|
37
46
|
# @param justification [FFI::OGR::Justification]
|
38
47
|
def set(name, type, width, precision, justification)
|
39
48
|
FFI::OGR::API.OGR_Fld_Set(
|
@@ -48,7 +57,10 @@ module OGR
|
|
48
57
|
|
49
58
|
# @return [String]
|
50
59
|
def name
|
51
|
-
FFI::OGR::API.OGR_Fld_GetNameRef(@c_pointer)
|
60
|
+
name, ptr = FFI::OGR::API.OGR_Fld_GetNameRef(@c_pointer)
|
61
|
+
ptr.autorelease = false
|
62
|
+
|
63
|
+
name
|
52
64
|
end
|
53
65
|
|
54
66
|
# @param new_value [String]
|
@@ -66,12 +78,12 @@ module OGR
|
|
66
78
|
FFI::OGR::API.OGR_Fld_SetJustify(@c_pointer, new_value)
|
67
79
|
end
|
68
80
|
|
69
|
-
# @return [
|
81
|
+
# @return [Integer]
|
70
82
|
def precision
|
71
83
|
FFI::OGR::API.OGR_Fld_GetPrecision(@c_pointer)
|
72
84
|
end
|
73
85
|
|
74
|
-
# @param new_value [
|
86
|
+
# @param new_value [Integer]
|
75
87
|
def precision=(new_value)
|
76
88
|
FFI::OGR::API.OGR_Fld_SetPrecision(@c_pointer, new_value)
|
77
89
|
end
|
@@ -86,12 +98,12 @@ module OGR
|
|
86
98
|
FFI::OGR::API.OGR_Fld_SetType(@c_pointer, new_value)
|
87
99
|
end
|
88
100
|
|
89
|
-
# @return [
|
101
|
+
# @return [Integer]
|
90
102
|
def width
|
91
103
|
FFI::OGR::API.OGR_Fld_GetWidth(@c_pointer)
|
92
104
|
end
|
93
105
|
|
94
|
-
# @param new_value [
|
106
|
+
# @param new_value [Integer]
|
95
107
|
def width=(new_value)
|
96
108
|
FFI::OGR::API.OGR_Fld_SetWidth(@c_pointer, new_value)
|
97
109
|
end
|
data/lib/ogr/geocoder.rb
CHANGED
@@ -5,6 +5,13 @@ require_relative '../ogr'
|
|
5
5
|
module OGR
|
6
6
|
# Geocode things! http://www.gdal.org/ogr__geocoding_8h.html
|
7
7
|
class Geocoder
|
8
|
+
# @param pointer [FFI::Pointer]
|
9
|
+
def self.release(pointer)
|
10
|
+
return unless pointer && !pointer.null?
|
11
|
+
|
12
|
+
FFI::GDAL::GDAL.OGRGeocodeDestroySession(pointer)
|
13
|
+
end
|
14
|
+
|
8
15
|
# @return [FFI::Pointer] C pointer to the C geocoding session.
|
9
16
|
attr_reader :c_pointer
|
10
17
|
|
@@ -36,13 +43,13 @@ module OGR
|
|
36
43
|
|
37
44
|
options_ptr = GDAL::Options.pointer(converted_options)
|
38
45
|
|
39
|
-
|
46
|
+
pointer = FFI::GDAL::GDAL.OGRGeocodeCreateSession(options_ptr)
|
47
|
+
@c_pointer = FFI::AutoPointer.new(pointer, Geocoder.method(:release))
|
40
48
|
end
|
41
49
|
|
42
50
|
def destroy!
|
43
|
-
|
51
|
+
Geocoder.release(@c_pointer)
|
44
52
|
|
45
|
-
FFI::GDAL::GDAL.OGRGeocodeDestroySession(@c_pointer)
|
46
53
|
@c_pointer = nil
|
47
54
|
end
|
48
55
|
|
@@ -52,7 +59,7 @@ module OGR
|
|
52
59
|
# the address into elements. Only works with some geocoding services.
|
53
60
|
# @option options countrycodes [Array<String, Symbol>] Limit the search to a
|
54
61
|
# specific country or countries. Only works with some geocoding services.
|
55
|
-
# @option options limit [
|
62
|
+
# @option options limit [Integer] Limit the number of records returned. Only
|
56
63
|
# works with some geocoding services.
|
57
64
|
# @option options raw_feature ["YES"] Adds a raw feature to the returned
|
58
65
|
# feature that includes that raw XML response body.
|
@@ -6,6 +6,7 @@ module OGR
|
|
6
6
|
class LineString
|
7
7
|
include OGR::Geometry
|
8
8
|
include GeometryTypes::Curve
|
9
|
+
|
9
10
|
def self.approximate_arc_angles(center_x, center_y, z, primary_radius, secondary_radius,
|
10
11
|
rotation, start_angle, end_angle, max_angle_step_size_degrees = 0)
|
11
12
|
geometry_ptr = FFI::GDAL::GDAL.OGR_G_ApproximateArcAngles(
|
@@ -10,14 +10,5 @@ module OGR
|
|
10
10
|
geometry_ptr ||= OGR::Geometry.create(:wkbLineString25D)
|
11
11
|
super(geometry_ptr, spatial_reference: spatial_reference)
|
12
12
|
end
|
13
|
-
|
14
|
-
# Adds a point to a LineString or Point geometry.
|
15
|
-
#
|
16
|
-
# @param x [Float]
|
17
|
-
# @param y [Float]
|
18
|
-
# @param z [Float]
|
19
|
-
def add_point(x, y, z)
|
20
|
-
super(x, y, z)
|
21
|
-
end
|
22
13
|
end
|
23
14
|
end
|
@@ -7,8 +7,8 @@ module OGR
|
|
7
7
|
# @param [FFI::Pointer] geometry_ptr
|
8
8
|
def initialize(geometry_ptr = nil, spatial_reference: nil)
|
9
9
|
geometry_ptr ||= OGR::Geometry.create(:wkbLinearRing)
|
10
|
-
|
11
|
-
|
10
|
+
|
11
|
+
super(geometry_ptr, spatial_reference: spatial_reference)
|
12
12
|
end
|
13
13
|
|
14
14
|
def to_line_string
|
data/lib/ogr/geometries/point.rb
CHANGED
@@ -38,15 +38,6 @@ module OGR
|
|
38
38
|
end
|
39
39
|
alias point_value point
|
40
40
|
|
41
|
-
# Wrapper around {#point_value} to provide API parity with other geometries
|
42
|
-
# that can have multiple points.
|
43
|
-
#
|
44
|
-
# @return [Array<Array<Float, Float>>]
|
45
|
-
# TODO: move to an extension
|
46
|
-
def point_values
|
47
|
-
[point]
|
48
|
-
end
|
49
|
-
|
50
41
|
# @param x [Number]
|
51
42
|
# @param y [Number]
|
52
43
|
def set_point(x, y)
|