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
@@ -10,8 +10,9 @@ module OGR
|
|
10
10
|
datum_name = FFI::MemoryPointer.new(:string, 32)
|
11
11
|
units = FFI::MemoryPointer.new(:string, 32)
|
12
12
|
|
13
|
-
|
14
|
-
|
13
|
+
OGR::ErrorHandling.handle_ogr_err('Required parameters (name, datum name, units) are not defined') do
|
14
|
+
FFI::OGR::SRSAPI.OSRExportToERM(@c_pointer, projection_name, datum_name, units)
|
15
|
+
end
|
15
16
|
|
16
17
|
{
|
17
18
|
projection_name: projection_name.read_string,
|
@@ -21,85 +22,120 @@ module OGR
|
|
21
22
|
end
|
22
23
|
|
23
24
|
# @return [Array<String>]
|
25
|
+
# @raise [OGR::Failure]
|
24
26
|
def to_mapinfo
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
27
|
+
GDAL._cpl_read_and_free_string do |return_ptr_ptr|
|
28
|
+
OGR::ErrorHandling.handle_ogr_err('Unable to export to MapInfo') do
|
29
|
+
FFI::OGR::SRSAPI.OSRExportToMICoordSys(@c_pointer, return_ptr_ptr)
|
30
|
+
end
|
31
|
+
end
|
30
32
|
end
|
31
33
|
|
32
34
|
# @return [Hash]
|
35
|
+
# @raise [OGR::Failure]
|
33
36
|
def to_pci
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
+
proj_ptr_ptr = GDAL._pointer_pointer(:string)
|
38
|
+
proj_ptr_ptr.autorelease = false
|
39
|
+
units_ptr_ptr = GDAL._pointer_pointer(:string)
|
40
|
+
units_ptr_ptr.autorelease = false
|
41
|
+
prj_params_ptr_ptr = GDAL._pointer_pointer(:double)
|
42
|
+
prj_params_ptr_ptr.autorelease = false
|
43
|
+
|
44
|
+
OGR::ErrorHandling.handle_ogr_err('Unable to export to PCI') do
|
45
|
+
FFI::OGR::SRSAPI.OSRExportToPCI(@c_pointer, proj_ptr_ptr, units_ptr_ptr, prj_params_ptr_ptr)
|
46
|
+
end
|
47
|
+
|
48
|
+
projection = proj_ptr_ptr.read_pointer.read_string
|
49
|
+
units = units_ptr_ptr.read_pointer.read_string
|
50
|
+
projection_parameters = prj_params_ptr_ptr.read_array_of_double(0)
|
51
|
+
|
52
|
+
result = {
|
53
|
+
projection: projection,
|
54
|
+
units: units,
|
55
|
+
projection_parameters: projection_parameters
|
56
|
+
}
|
37
57
|
|
38
|
-
|
39
|
-
|
58
|
+
FFI::CPL::VSI.VSIFree(proj_ptr_ptr)
|
59
|
+
FFI::CPL::VSI.VSIFree(units_ptr_ptr)
|
60
|
+
FFI::CPL::VSI.VSIFree(prj_params_ptr_ptr)
|
40
61
|
|
41
|
-
|
42
|
-
projection: proj_ptr.read_pointer.read_string,
|
43
|
-
units: units_ptr.read_pointer.read_string,
|
44
|
-
projection_parameters: prj_params_ptr.read_array_of_double(0)
|
45
|
-
}
|
62
|
+
result
|
46
63
|
end
|
47
64
|
|
48
65
|
# @return [String]
|
49
66
|
# @raise [GDAL::UnsupportedOperation] If empty definition.
|
50
67
|
def to_proj4
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
68
|
+
GDAL._cpl_read_and_free_string do |proj4_ptr_ptr|
|
69
|
+
OGR::ErrorHandling.handle_ogr_err('Unable to export to PROJ.4') do
|
70
|
+
FFI::OGR::SRSAPI.OSRExportToProj4(@c_pointer, proj4_ptr_ptr)
|
71
|
+
end
|
72
|
+
end
|
56
73
|
end
|
57
74
|
|
58
75
|
# @return [Hash]
|
76
|
+
# @raise [OGR::Failure]
|
59
77
|
def to_usgs
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
78
|
+
proj_sys_ptr = FFI::MemoryPointer.new(:long)
|
79
|
+
zone_ptr = FFI::MemoryPointer.new(:long)
|
80
|
+
datum_ptr = FFI::MemoryPointer.new(:long)
|
81
|
+
prj_params_ptr_ptr = GDAL._pointer_pointer(:double)
|
82
|
+
prj_params_ptr_ptr.autorelease = false
|
83
|
+
|
84
|
+
OGR::ErrorHandling.handle_ogr_err('Unable to export to USGS GCTP') do
|
85
|
+
FFI::OGR::SRSAPI.OSRExportToUSGS(@c_pointer, proj_sys_ptr, zone_ptr, prj_params_ptr_ptr, datum_ptr)
|
86
|
+
end
|
87
|
+
|
88
|
+
projection_system_code = proj_sy_ptrs.read_long
|
89
|
+
zone = zon_ptre.read_long
|
90
|
+
projection_parameters = prj_params_pt_ptrr.read_array_of_double(0)
|
91
|
+
datum = datu_ptrm.read_long
|
92
|
+
|
93
|
+
result = {
|
94
|
+
projection_system_code: projection_system_code,
|
95
|
+
zone: zone,
|
96
|
+
projection_parameters: projection_parameters,
|
97
|
+
datum: datum
|
98
|
+
}
|
64
99
|
|
65
|
-
|
66
|
-
ogr_err.handle_result
|
100
|
+
FFI::CPL::VSI.VSIFree(prj_params_ptr_ptr)
|
67
101
|
|
68
|
-
|
69
|
-
projection_system_code: proj_sys.read_long,
|
70
|
-
zone: zone.read_long,
|
71
|
-
projection_parameters: prj_params_ptr.read_array_of_double(0),
|
72
|
-
datum: datum.read_long
|
73
|
-
}
|
102
|
+
result
|
74
103
|
end
|
75
104
|
|
76
105
|
# @return [String]
|
106
|
+
# @raise [OGR::Failure]
|
77
107
|
def to_wkt
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
108
|
+
GDAL._cpl_read_and_free_string do |wkt_ptr_ptr|
|
109
|
+
OGR::ErrorHandling.handle_ogr_err('Unable to export to WKT') do
|
110
|
+
FFI::OGR::SRSAPI.OSRExportToWkt(@c_pointer, wkt_ptr_ptr)
|
111
|
+
end
|
112
|
+
end
|
83
113
|
end
|
84
114
|
|
85
115
|
# @param simplify [Boolean] +true+ strips off +AXIS+, +AUTHORITY+ and
|
86
116
|
# +EXTENSION+ nodes.
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
GDAL.
|
117
|
+
# @raise [OGR::Failure]
|
118
|
+
# @return [String]
|
119
|
+
def to_pretty_wkt(simplify: false)
|
120
|
+
return +'' if @c_pointer.null?
|
121
|
+
|
122
|
+
GDAL._cpl_read_and_free_string do |wkt_ptr_ptr|
|
123
|
+
OGR::ErrorHandling.handle_ogr_err('Unable to export to pretty WKT') do
|
124
|
+
FFI::OGR::SRSAPI.OSRExportToPrettyWkt(@c_pointer, wkt_ptr_ptr, simplify)
|
125
|
+
end
|
126
|
+
end
|
93
127
|
end
|
94
128
|
|
95
129
|
# @return [String]
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
130
|
+
# @raise [OGR::Failure]
|
131
|
+
def to_xml
|
132
|
+
GDAL._cpl_read_and_free_string do |xml_ptr_ptr|
|
133
|
+
OGR::ErrorHandling.handle_ogr_err('Unable to export to XML (GML)') do
|
134
|
+
FFI::OGR::SRSAPI.OSRExportToXML(@c_pointer, xml_ptr_ptr, nil)
|
135
|
+
end
|
136
|
+
end
|
102
137
|
end
|
138
|
+
alias to_gml to_xml
|
103
139
|
end
|
104
140
|
end
|
105
141
|
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative '../error_handling'
|
4
|
+
|
3
5
|
module OGR
|
4
6
|
module SpatialReferenceMixins
|
5
7
|
module Importers
|
@@ -8,7 +10,7 @@ module OGR
|
|
8
10
|
end
|
9
11
|
|
10
12
|
module ClassMethods
|
11
|
-
# @param code [
|
13
|
+
# @param code [Integer]
|
12
14
|
# @return [OGR::SpatialReference]
|
13
15
|
def new_from_epsg(code)
|
14
16
|
srs = new
|
@@ -17,11 +19,11 @@ module OGR
|
|
17
19
|
srs
|
18
20
|
end
|
19
21
|
|
20
|
-
# @param code [
|
22
|
+
# @param code [Integer]
|
21
23
|
# @return [OGR::SpatialReference]
|
22
24
|
def new_from_epsga(code)
|
23
25
|
srs = new
|
24
|
-
srs.
|
26
|
+
srs.import_from_epsga(code)
|
25
27
|
|
26
28
|
srs
|
27
29
|
end
|
@@ -117,59 +119,81 @@ module OGR
|
|
117
119
|
end
|
118
120
|
|
119
121
|
# @return [OGR::SpatialReference]
|
122
|
+
# @raise [OGR::Failure]
|
120
123
|
def build_spatial_ref(spatial_reference_or_wkt = nil)
|
121
124
|
object = new(spatial_reference_or_wkt)
|
122
125
|
ogr_err = yield object.c_pointer
|
123
|
-
|
126
|
+
|
127
|
+
OGR::ErrorHandling.handle_ogr_err('Unable to build SpatialReference') do
|
128
|
+
ogr_err
|
129
|
+
end
|
124
130
|
|
125
131
|
object
|
126
132
|
end
|
127
133
|
end
|
128
134
|
|
129
|
-
# @param code [
|
135
|
+
# @param code [Integer]
|
136
|
+
# @return [OGR::SpatialReference] `self`, but updated with the EPSG code.
|
130
137
|
# @raise [GDAL::UnsupportedOperation] On unknown EPSG code.
|
131
138
|
def import_from_epsg(code)
|
132
|
-
|
139
|
+
OGR::ErrorHandling.handle_ogr_err("Unable to import from EPSG: #{code}") do
|
140
|
+
FFI::OGR::SRSAPI.OSRImportFromEPSG(@c_pointer, code)
|
141
|
+
end
|
133
142
|
|
134
|
-
|
143
|
+
self
|
135
144
|
end
|
136
145
|
|
137
|
-
# @param code [
|
146
|
+
# @param code [Integer]
|
147
|
+
# @raise [OGR::Failure]
|
138
148
|
def import_from_epsga(code)
|
139
|
-
|
149
|
+
OGR::ErrorHandling.handle_ogr_err("Unable to import from EPSGA: #{code}") do
|
150
|
+
FFI::OGR::SRSAPI.OSRImportFromEPSGA(@c_pointer, code)
|
151
|
+
end
|
140
152
|
|
141
|
-
|
153
|
+
self
|
142
154
|
end
|
143
155
|
|
144
156
|
# @param wkt [String]
|
157
|
+
# @raise [OGR::Failure]
|
145
158
|
def import_from_wkt(wkt)
|
146
159
|
wkt_ptr = FFI::MemoryPointer.from_string(wkt)
|
147
160
|
wkt_ptr_ptr = FFI::MemoryPointer.new(:pointer)
|
148
161
|
wkt_ptr_ptr.write_pointer(wkt_ptr)
|
149
|
-
ogr_err = FFI::OGR::SRSAPI.OSRImportFromWkt(@c_pointer, wkt_ptr_ptr)
|
150
162
|
|
151
|
-
|
163
|
+
OGR::ErrorHandling.handle_ogr_err("Unable to import from WKT: #{wkt}") do
|
164
|
+
FFI::OGR::SRSAPI.OSRImportFromWkt(@c_pointer, wkt_ptr_ptr)
|
165
|
+
end
|
166
|
+
|
167
|
+
self
|
152
168
|
end
|
153
169
|
|
154
170
|
# @param proj4 [String]
|
171
|
+
# @raise [OGR::Failure]
|
155
172
|
def import_from_proj4(proj4)
|
156
|
-
|
173
|
+
OGR::ErrorHandling.handle_ogr_err("Unable to import from PROJ.4: #{proj4}") do
|
174
|
+
FFI::OGR::SRSAPI.OSRImportFromProj4(@c_pointer, proj4)
|
175
|
+
end
|
157
176
|
|
158
|
-
|
177
|
+
self
|
159
178
|
end
|
160
179
|
|
161
180
|
# @param esri_text [Array<String>]
|
181
|
+
# @raise [OGR::Failure]
|
162
182
|
def import_from_esri(esri_text)
|
163
183
|
text_array = esri_text.split("\n")
|
164
184
|
esri_ptr_ptr = GDAL._string_array_to_pointer(text_array)
|
165
|
-
ogr_err = FFI::OGR::SRSAPI.OSRImportFromESRI(@c_pointer, esri_ptr_ptr)
|
166
185
|
|
167
|
-
|
186
|
+
OGR::ErrorHandling.handle_ogr_err("Unable to import from ESRI: #{esri_text}") do
|
187
|
+
FFI::OGR::SRSAPI.OSRImportFromESRI(@c_pointer, esri_ptr_ptr)
|
188
|
+
end
|
189
|
+
|
190
|
+
self
|
168
191
|
end
|
169
192
|
|
170
193
|
# @param proj [String]
|
171
194
|
# @param units [String]
|
172
195
|
# @param proj_params [Array<String>]
|
196
|
+
# @raise [OGR::Failure]
|
173
197
|
def import_from_pci(proj, units, *proj_params)
|
174
198
|
if proj_params.empty?
|
175
199
|
proj_ptr = nil
|
@@ -178,15 +202,18 @@ module OGR
|
|
178
202
|
proj_ptr.write_array_of_double(proj_params)
|
179
203
|
end
|
180
204
|
|
181
|
-
|
205
|
+
OGR::ErrorHandling.handle_ogr_err("Unable to import from PCI: #{proj}") do
|
206
|
+
FFI::OGR::SRSAPI.OSRImportFromPCI(@c_pointer, proj, units, proj_ptr)
|
207
|
+
end
|
182
208
|
|
183
|
-
|
209
|
+
self
|
184
210
|
end
|
185
211
|
|
186
|
-
# @param projection_system_code [
|
187
|
-
# @param zone [
|
188
|
-
# @param datum [
|
212
|
+
# @param projection_system_code [Integer]
|
213
|
+
# @param zone [Integer]
|
214
|
+
# @param datum [Integer]
|
189
215
|
# @param proj_params [Array<Float>]
|
216
|
+
# @raise [OGR::Failure]
|
190
217
|
def import_from_usgs(projection_system_code, zone, datum, *proj_params)
|
191
218
|
if proj_params.empty?
|
192
219
|
proj_ptr = nil
|
@@ -195,52 +222,70 @@ module OGR
|
|
195
222
|
proj_ptr.write_array_of_double(proj_params)
|
196
223
|
end
|
197
224
|
|
198
|
-
|
199
|
-
@c_pointer,
|
200
|
-
projection_system_code,
|
201
|
-
zone,
|
202
|
-
proj_ptr,
|
203
|
-
datum
|
204
|
-
)
|
225
|
+
msg = "Unable to import from USGS: #{projection_system_code}, #{zone}, #{datum}, #{proj_params}"
|
205
226
|
|
206
|
-
|
227
|
+
OGR::ErrorHandling.handle_ogr_err(msg) do
|
228
|
+
FFI::OGR::SRSAPI.OSRImportFromUSGS(
|
229
|
+
@c_pointer,
|
230
|
+
projection_system_code,
|
231
|
+
zone,
|
232
|
+
proj_ptr,
|
233
|
+
datum
|
234
|
+
)
|
235
|
+
end
|
236
|
+
|
237
|
+
self
|
207
238
|
end
|
208
239
|
|
209
240
|
# Use for importing a GML coordinate system.
|
210
241
|
#
|
211
242
|
# @param xml [String]
|
243
|
+
# @raise [OGR::Failure]
|
212
244
|
def import_from_xml(xml)
|
213
|
-
|
245
|
+
OGR::ErrorHandling.handle_ogr_err("Unable to import from XML: #{xml}") do
|
246
|
+
FFI::OGR::SRSAPI.OSRImportFromXML(@c_pointer, xml)
|
247
|
+
end
|
214
248
|
|
215
|
-
|
249
|
+
self
|
216
250
|
end
|
217
251
|
|
218
252
|
# @param coord_sys [String] The Mapinfo style CoordSys definition string.
|
253
|
+
# @raise [OGR::Failure]
|
219
254
|
def import_from_mapinfo(coord_sys)
|
220
|
-
|
255
|
+
OGR::ErrorHandling.handle_ogr_err("Unable to import from MapInfo: #{coord_sys}") do
|
256
|
+
FFI::OGR::SRSAPI.OSRImportFromMICoordSys(@c_pointer, coord_sys)
|
257
|
+
end
|
221
258
|
|
222
|
-
|
259
|
+
self
|
223
260
|
end
|
224
261
|
|
225
262
|
# @param projection_name [String] I.e. "NUTM11" or "GEOGRAPHIC".
|
226
263
|
# @param datum_name [String] I.e. "NAD83".
|
227
264
|
# @param linear_unit_name [String] Plural form of linear units, i.e. "FEET".
|
265
|
+
# @raise [OGR::Failure]
|
228
266
|
def import_from_erm(projection_name, datum_name, linear_unit_name)
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
267
|
+
msg = "Unable to import from ERMapper: #{projection_name}, #{datum_name}, #{linear_unit_name}"
|
268
|
+
|
269
|
+
OGR::ErrorHandling.handle_ogr_err(msg) do
|
270
|
+
FFI::OGR::SRSAPI.OSRImportFromERM(
|
271
|
+
@c_pointer,
|
272
|
+
projection_name,
|
273
|
+
datum_name,
|
274
|
+
linear_unit_name
|
275
|
+
)
|
276
|
+
end
|
277
|
+
|
278
|
+
self
|
237
279
|
end
|
238
280
|
|
239
281
|
# @param url [String] URL to fetch the spatial reference from.
|
282
|
+
# @raise [OGR::Failure]
|
240
283
|
def import_from_url(url)
|
241
|
-
|
284
|
+
OGR::ErrorHandling.handle_ogr_err("Unable to import from URL: #{url}") do
|
285
|
+
FFI::OGR::SRSAPI.OSRImportFromUrl(@c_pointer, url)
|
286
|
+
end
|
242
287
|
|
243
|
-
|
288
|
+
self
|
244
289
|
end
|
245
290
|
end
|
246
291
|
end
|
@@ -5,22 +5,26 @@ module OGR
|
|
5
5
|
module Morphers
|
6
6
|
# Converts, in place, to ESRI WKT format.
|
7
7
|
#
|
8
|
-
# @return [OGR::SpatialReference
|
8
|
+
# @return [OGR::SpatialReference] If successful, returns self.
|
9
|
+
# @raise [OGR::Failure]
|
9
10
|
def morph_to_esri!
|
10
|
-
|
11
|
-
|
11
|
+
OGR::ErrorHandling.handle_ogr_err('Unable to morph self to ESRI') do
|
12
|
+
FFI::OGR::SRSAPI.OSRMorphToESRI(@c_pointer)
|
13
|
+
end
|
12
14
|
|
13
|
-
|
15
|
+
self
|
14
16
|
end
|
15
17
|
|
16
18
|
# Converts, in place, from ESRI WKT format.
|
17
19
|
#
|
18
|
-
# @return [OGR::SpatialReference
|
20
|
+
# @return [OGR::SpatialReference] If successful, returns self.
|
21
|
+
# @raise [OGR::Failure]
|
19
22
|
def morph_from_esri!
|
20
|
-
|
21
|
-
|
23
|
+
OGR::ErrorHandling.handle_ogr_err('Unable to morph self from ESRI') do
|
24
|
+
FFI::OGR::SRSAPI.OSRMorphFromESRI(@c_pointer)
|
25
|
+
end
|
22
26
|
|
23
|
-
|
27
|
+
self
|
24
28
|
end
|
25
29
|
end
|
26
30
|
end
|
@@ -4,7 +4,7 @@ module OGR
|
|
4
4
|
module SpatialReferenceMixins
|
5
5
|
module ParameterGetterSetters
|
6
6
|
# @param name [String] The case-insensitive tree node to look for.
|
7
|
-
# @param child [
|
7
|
+
# @param child [Integer] The child of the node to fetch.
|
8
8
|
# @return [String, nil]
|
9
9
|
def attribute_value(name, child = 0)
|
10
10
|
FFI::OGR::SRSAPI.OSRGetAttrValue(@c_pointer, name, child)
|
@@ -14,10 +14,11 @@ module OGR
|
|
14
14
|
# pipe symbol to denote nesting. i.e. 'GEOCCS|UNIT'.
|
15
15
|
# @param value [String] The new value for the node/path. Should be a String,
|
16
16
|
# but if not, will be converted for you.
|
17
|
+
# @raise [OGR::Failure]
|
17
18
|
def set_attribute_value(path, value)
|
18
|
-
|
19
|
-
|
20
|
-
|
19
|
+
OGR::ErrorHandling.handle_ogr_err("Unable to set attribute (#{path}) to value #{value}") do
|
20
|
+
FFI::OGR::SRSAPI.OSRSetAttrValue(@c_pointer, path, value.to_s)
|
21
|
+
end
|
21
22
|
end
|
22
23
|
|
23
24
|
# @return [Hash{unit_name: String, value: Float}] +unit_name+ is the name
|
@@ -33,10 +34,13 @@ module OGR
|
|
33
34
|
# @param unit_label [String]
|
34
35
|
# @param transform_to_radians [Float] The value to multiply an angle to
|
35
36
|
# transform the value to radians.
|
37
|
+
# @raise [OGR::Failure]
|
36
38
|
def set_angular_units(unit_label, transform_to_radians)
|
37
|
-
|
39
|
+
msg = "Unable to set angular units to #{unit_label} (transform to radians? #{transform_to_radians})"
|
38
40
|
|
39
|
-
|
41
|
+
OGR::ErrorHandling.handle_ogr_err(msg) do
|
42
|
+
FFI::OGR::SRSAPI.OSRSetAngularUnits(@c_pointer, unit_label, transform_to_radians.to_f)
|
43
|
+
end
|
40
44
|
end
|
41
45
|
|
42
46
|
# @return [Hash{unit_name: String, value: Float}] +unit_name+ is the name
|
@@ -52,10 +56,13 @@ module OGR
|
|
52
56
|
# @param unit_label [String]
|
53
57
|
# @param transform_to_meters [Float] The value to multiply a length to
|
54
58
|
# transform the value to meters.
|
59
|
+
# @raise [OGR::Failure]
|
55
60
|
def set_linear_units(unit_label, transform_to_meters)
|
56
|
-
|
61
|
+
msg = "Unable to set linear units to #{unit_label} (transform to meters? #{transform_to_meters})"
|
57
62
|
|
58
|
-
|
63
|
+
OGR::ErrorHandling.handle_ogr_err(msg) do
|
64
|
+
FFI::OGR::SRSAPI.OSRSetLinearUnits(@c_pointer, unit_label, transform_to_meters.to_f)
|
65
|
+
end
|
59
66
|
end
|
60
67
|
|
61
68
|
# Does the same as #set_linear_units, but also converts parameters to use
|
@@ -64,11 +71,14 @@ module OGR
|
|
64
71
|
# @param unit_label [String]
|
65
72
|
# @param transform_to_meters [Float] The value to multiply a length to
|
66
73
|
# transform the value to meters.
|
74
|
+
# @raise [OGR::Failure]
|
67
75
|
def set_linear_units_and_update_parameters(unit_label, transform_to_meters)
|
68
|
-
|
69
|
-
|
76
|
+
msg = "Unable to set linear units to #{unit_label} (transform to meters? #{transform_to_meters}) and update" \
|
77
|
+
'parameters'
|
70
78
|
|
71
|
-
|
79
|
+
OGR::ErrorHandling.handle_ogr_err(msg) do
|
80
|
+
FFI::OGR::SRSAPI.OSRSetLinearUnitsAndUpdateParameters(@c_pointer, unit_label, transform_to_meters.to_f)
|
81
|
+
end
|
72
82
|
end
|
73
83
|
|
74
84
|
# The linear units for the projection.
|
@@ -87,10 +97,14 @@ module OGR
|
|
87
97
|
# @param unit_label [String] Name of the units to be used.
|
88
98
|
# @param transform_to_meters [Float] The value to multiple a length to
|
89
99
|
# transform the value to meters.
|
100
|
+
# @raise [OGR::Failure]
|
90
101
|
def set_target_linear_units(target_key, unit_label, transform_to_meters)
|
91
|
-
|
102
|
+
msg = "Unable to set target (#{target_key}) linear units to #{unit_label} " \
|
103
|
+
"(transform to meters? #{transform_to_meters})"
|
92
104
|
|
93
|
-
|
105
|
+
OGR::ErrorHandling.handle_ogr_err(msg) do
|
106
|
+
FFI::OGR::SRSAPI.OSRSetTargetLinearUnits(@c_pointer, target_key, unit_label, transform_to_meters)
|
107
|
+
end
|
94
108
|
end
|
95
109
|
|
96
110
|
# @return [Hash]
|
data/lib/ogr/style_table.rb
CHANGED
@@ -1,26 +1,36 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative '../gdal'
|
3
4
|
require_relative '../ogr'
|
4
|
-
require_relative 'style_table_extensions'
|
5
5
|
|
6
6
|
module OGR
|
7
7
|
class StyleTable
|
8
|
-
|
8
|
+
# @param pointer [FFI::Pointer]
|
9
|
+
def self.release(pointer)
|
10
|
+
return unless pointer && !pointer.null?
|
11
|
+
|
12
|
+
FFI::OGR::API.OGR_STBL_Destroy(pointer)
|
13
|
+
end
|
9
14
|
|
10
15
|
# @return [FFI::Pointer] C pointer to the C style table.
|
11
16
|
attr_reader :c_pointer
|
12
17
|
|
13
18
|
# @param [FFI::Pointer] c_pointer
|
14
19
|
def initialize(c_pointer = nil)
|
15
|
-
@c_pointer =
|
20
|
+
@c_pointer = if c_pointer
|
21
|
+
c_pointer
|
22
|
+
else
|
23
|
+
pointer = FFI::OGR::API.OGR_STBL_Create
|
24
|
+
pointer.autorelease = false
|
25
|
+
FFI::AutoPointer.new(pointer, StyleTable.method(:release))
|
26
|
+
end
|
16
27
|
|
17
28
|
raise 'Unable to create StyleTable' if @c_pointer.null?
|
18
29
|
end
|
19
30
|
|
20
31
|
def destroy!
|
21
|
-
|
32
|
+
StyleTable.release(@c_pointer)
|
22
33
|
|
23
|
-
FFI::OGR::API.OGR_STBL_Destroy(@c_pointer)
|
24
34
|
@c_pointer = nil
|
25
35
|
end
|
26
36
|
|