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
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
require_relative '../ogr'
|
4
4
|
require_relative '../gdal'
|
5
|
-
require_relative 'spatial_reference_extensions'
|
6
5
|
require_relative 'spatial_reference_mixins/coordinate_system_getter_setters'
|
7
6
|
require_relative 'spatial_reference_mixins/exporters'
|
8
7
|
require_relative 'spatial_reference_mixins/importers'
|
@@ -16,7 +15,6 @@ module OGR
|
|
16
15
|
# 2. "projected", where positions are measure in meters or feet.
|
17
16
|
class SpatialReference
|
18
17
|
include GDAL::Logger
|
19
|
-
include SpatialReferenceExtensions
|
20
18
|
include SpatialReferenceMixins::CoordinateSystemGetterSetters
|
21
19
|
include SpatialReferenceMixins::Exporters
|
22
20
|
include SpatialReferenceMixins::Importers
|
@@ -37,8 +35,9 @@ module OGR
|
|
37
35
|
|
38
36
|
RADIAN_TO_RADIAN = 1.0
|
39
37
|
|
38
|
+
# @deprecated This was removed in GDAL 3.0.
|
40
39
|
# @return [Array<String>]
|
41
|
-
def self.projection_methods(strip_underscores
|
40
|
+
def self.projection_methods(strip_underscores: false)
|
42
41
|
methods_ptr_ptr = FFI::OGR::SRSAPI.OPTGetProjectionMethods
|
43
42
|
count = FFI::CPL::String.CSLCount(methods_ptr_ptr)
|
44
43
|
|
@@ -50,6 +49,7 @@ module OGR
|
|
50
49
|
strip_underscores ? list.map! { |l| l.tr('_', ' ') } : list
|
51
50
|
end
|
52
51
|
|
52
|
+
# @deprecated This was removed in GDAL 3.0.
|
53
53
|
# @param projection_method [String] One of
|
54
54
|
# OGR::SpatialReference.projection_methods.
|
55
55
|
# @return [Hash{parameter => Array<String>, user_visible_name => String}]
|
@@ -70,6 +70,7 @@ module OGR
|
|
70
70
|
|
71
71
|
# Fetch info about a single parameter of a projection method.
|
72
72
|
#
|
73
|
+
# @deprecated This was removed in GDAL 3.0.
|
73
74
|
# @param projection_method [String]
|
74
75
|
# @param parameter_name [String]
|
75
76
|
def self.parameter_info(projection_method, parameter_name)
|
@@ -78,7 +79,7 @@ module OGR
|
|
78
79
|
default_value_ptr = FFI::MemoryPointer.new(:double)
|
79
80
|
|
80
81
|
result = FFI::OGR::SRSAPI.OPTGetParameterInfo(projection_method, parameter_name,
|
81
|
-
|
82
|
+
name_ptr_ptr, type_ptr_ptr, default_value_ptr)
|
82
83
|
|
83
84
|
return {} unless result
|
84
85
|
|
@@ -103,39 +104,75 @@ module OGR
|
|
103
104
|
FFI::OGR::SRSAPI.OSRCleanup
|
104
105
|
end
|
105
106
|
|
107
|
+
# This static method will destroy a OGRSpatialReference. It is equivalent
|
108
|
+
# to calling delete on the object, but it ensures that the deallocation is
|
109
|
+
# properly executed within the OGR libraries heap on platforms where this
|
110
|
+
# can matter (win32).
|
111
|
+
#
|
112
|
+
# @param pointer [FFI::Pointer]
|
113
|
+
def self.destroy(pointer)
|
114
|
+
return unless pointer && !pointer.null?
|
115
|
+
|
116
|
+
FFI::OGR::SRSAPI.OSRDestroySpatialReference(pointer)
|
117
|
+
end
|
118
|
+
|
119
|
+
# Decrements the reference count by one, and destroy if zero.
|
120
|
+
#
|
121
|
+
# @param pointer [FFI::Pointer]
|
122
|
+
def self.release(pointer)
|
123
|
+
return unless pointer && !pointer.null?
|
124
|
+
|
125
|
+
FFI::OGR::SRSAPI.OSRRelease(pointer)
|
126
|
+
end
|
127
|
+
|
106
128
|
# @return [FFI::Pointer] C pointer to the C Spatial Reference.
|
107
129
|
attr_reader :c_pointer
|
108
130
|
|
109
131
|
# Builds a spatial reference object using either the passed-in WKT string,
|
110
132
|
# OGR::SpatialReference object, or a pointer to an in-memory
|
111
|
-
# SpatialReference object.
|
133
|
+
# SpatialReference object. If nothing is passed in, an empty
|
112
134
|
# SpatialReference object is created, in which case you'll need to populate
|
113
135
|
# relevant attributes.
|
114
136
|
#
|
115
|
-
#
|
116
|
-
#
|
137
|
+
# If a OGR::SpatialReference is given, this clones that object so it can
|
138
|
+
# have it's own object (relevant for cleaning up when garbage collecting).
|
139
|
+
#
|
140
|
+
# @param spatial_reference_or_wkt [OGR::SpatialReference, FFI::Pointer, String]
|
117
141
|
def initialize(spatial_reference_or_wkt = nil)
|
118
|
-
|
142
|
+
pointer =
|
119
143
|
case spatial_reference_or_wkt.class.name
|
120
144
|
when 'OGR::SpatialReference'
|
121
|
-
|
145
|
+
# This is basically getting a reference to the SpatialReference that
|
146
|
+
# was passed in, thus when this SpatialReference gets garbage-collected,
|
147
|
+
# it shouldn't release anything.
|
148
|
+
ptr = spatial_reference_or_wkt.c_pointer
|
149
|
+
ptr.autorelease = false
|
122
150
|
when 'String', 'NilClass'
|
123
|
-
|
124
|
-
|
151
|
+
# FWIW, the docs say:
|
152
|
+
# Note that newly created objects are given a reference count of one.
|
153
|
+
#
|
154
|
+
# ...which implies that we should use Release here instead of Destroy.
|
155
|
+
ptr = FFI::OGR::SRSAPI.OSRNewSpatialReference(spatial_reference_or_wkt)
|
156
|
+
ptr.autorelease = false
|
157
|
+
|
158
|
+
# We're instantiating a new SR, so we can use .destroy.
|
159
|
+
FFI::AutoPointer.new(ptr, SpatialReference.method(:release))
|
160
|
+
when 'FFI::AutoPointer', 'FFI::Pointer', 'FFI::MemoryPointer'
|
161
|
+
# If we got a pointer, we don't know who owns the data, so don't
|
162
|
+
# touch anything about autorelease/AutoPointer.
|
125
163
|
spatial_reference_or_wkt
|
126
164
|
else
|
127
|
-
log "Dunno what to do with #{spatial_reference_or_wkt}"
|
165
|
+
log "Dunno what to do with #{spatial_reference_or_wkt.inspect}"
|
128
166
|
end
|
129
167
|
|
130
|
-
|
168
|
+
raise OGR::CreateFailure, 'Unable to create SpatialReference.' if pointer.nil? || pointer.null?
|
131
169
|
|
132
|
-
|
170
|
+
@c_pointer = pointer
|
133
171
|
end
|
134
172
|
|
135
173
|
def destroy!
|
136
|
-
|
174
|
+
SpatialReference.destroy(@c_pointer)
|
137
175
|
|
138
|
-
FFI::OGR::SRSAPI.OSRDestroySpatialReference(@c_pointer)
|
139
176
|
@c_pointer = nil
|
140
177
|
end
|
141
178
|
|
@@ -145,7 +182,7 @@ module OGR
|
|
145
182
|
def clone
|
146
183
|
new_spatial_ref_ptr = FFI::OGR::SRSAPI.OSRClone(@c_pointer)
|
147
184
|
|
148
|
-
|
185
|
+
SpatialReference.new(new_spatial_ref_ptr)
|
149
186
|
end
|
150
187
|
|
151
188
|
# Makes a duplicate of the GEOGCS node of this spatial reference.
|
@@ -154,58 +191,58 @@ module OGR
|
|
154
191
|
def clone_geog_cs
|
155
192
|
new_spatial_ref_ptr = FFI::OGR::SRSAPI.OSRCloneGeogCS(@c_pointer)
|
156
193
|
|
157
|
-
|
194
|
+
SpatialReference.new(new_spatial_ref_ptr)
|
158
195
|
end
|
159
196
|
|
160
197
|
# @param other_spatial_ref [OGR::SpatialReference] The SpatialReference to
|
161
198
|
# copy GeocCS info from.
|
162
|
-
# @
|
199
|
+
# @raise [OGR::Failure]
|
163
200
|
def copy_geog_cs_from(other_spatial_ref)
|
164
201
|
other_spatial_ref_ptr = GDAL._pointer(OGR::SpatialReference, other_spatial_ref)
|
165
202
|
raise OGR::InvalidSpatialReference if other_spatial_ref_ptr.nil? || other_spatial_ref_ptr.null?
|
166
203
|
|
167
|
-
|
168
|
-
|
169
|
-
|
204
|
+
OGR::ErrorHandling.handle_ogr_err('Unable to copy GEOGCS') do
|
205
|
+
FFI::OGR::SRSAPI.OSRCopyGeogCSFrom(@c_pointer, other_spatial_ref_ptr)
|
206
|
+
end
|
170
207
|
end
|
171
208
|
|
172
|
-
# @
|
209
|
+
# @raise [OGR::Failure]
|
173
210
|
def validate
|
174
|
-
|
175
|
-
|
176
|
-
|
211
|
+
OGR::ErrorHandling.handle_ogr_err('Unable to validate') do
|
212
|
+
FFI::OGR::SRSAPI.OSRValidate(@c_pointer)
|
213
|
+
end
|
177
214
|
end
|
178
215
|
|
179
|
-
# @
|
216
|
+
# @raise [OGR::Failure]
|
180
217
|
def fixup_ordering!
|
181
|
-
|
182
|
-
|
183
|
-
|
218
|
+
OGR::ErrorHandling.handle_ogr_err('Unable to fixup ordering') do
|
219
|
+
FFI::OGR::SRSAPI.OSRFixupOrdering(@c_pointer)
|
220
|
+
end
|
184
221
|
end
|
185
222
|
|
186
|
-
# @
|
223
|
+
# @raise [OGR::Failure]
|
187
224
|
def fixup!
|
188
|
-
|
189
|
-
|
190
|
-
|
225
|
+
OGR::ErrorHandling.handle_ogr_err('Unable to fixup') do
|
226
|
+
FFI::OGR::SRSAPI.OSRFixup(@c_pointer)
|
227
|
+
end
|
191
228
|
end
|
192
229
|
|
193
230
|
# Strips all OGC coordinate transformation parameters.
|
194
231
|
#
|
195
|
-
# @
|
232
|
+
# @raise [OGR::Failure]
|
196
233
|
def strip_ct_parameters!
|
197
|
-
|
198
|
-
|
199
|
-
|
234
|
+
OGR::ErrorHandling.handle_ogr_err('Unable to strip coordinate transformation parameters') do
|
235
|
+
FFI::OGR::SRSAPI.OSRStripCTParms(@c_pointer)
|
236
|
+
end
|
200
237
|
end
|
201
238
|
|
202
239
|
# Sets the EPSG authority info if possible.
|
203
240
|
#
|
204
|
-
# @
|
241
|
+
# @raise [OGR::Failure]
|
205
242
|
def auto_identify_epsg!
|
206
|
-
|
207
|
-
|
208
|
-
|
243
|
+
OGR::ErrorHandling.handle_ogr_err('Unable to determine SRS from EPSG') do
|
244
|
+
FFI::OGR::SRSAPI.OSRAutoIdentifyEPSG(@c_pointer)
|
245
|
+
end
|
209
246
|
end
|
210
247
|
|
211
248
|
# @return [Boolean] +true+ if this coordinate system should be treated as
|
@@ -6,63 +6,65 @@ module OGR
|
|
6
6
|
# Set the user-visible LOCAL_CS name.
|
7
7
|
#
|
8
8
|
# @param name [String]
|
9
|
-
# @
|
10
|
-
def set_local_cs(name)
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
# @raise [OGR::Failure]
|
10
|
+
def set_local_cs(name) # rubocop:disable Naming/AccessorMethodName
|
11
|
+
OGR::ErrorHandling.handle_ogr_err("Unable to set LOCAL_CS to '#{name}'") do
|
12
|
+
FFI::OGR::SRSAPI.OSRSetLocalCS(@c_pointer, name)
|
13
|
+
end
|
14
14
|
end
|
15
15
|
alias local_cs= set_local_cs
|
16
16
|
|
17
17
|
# Set the user-visible PROJCS name.
|
18
18
|
#
|
19
19
|
# @param name [String]
|
20
|
-
# @
|
21
|
-
def set_proj_cs(name)
|
22
|
-
|
23
|
-
|
24
|
-
|
20
|
+
# @raise [OGR::Failure]
|
21
|
+
def set_proj_cs(name) # rubocop:disable Naming/AccessorMethodName
|
22
|
+
OGR::ErrorHandling.handle_ogr_err("Unable to set PROJCS to '#{name}'") do
|
23
|
+
FFI::OGR::SRSAPI.OSRSetProjCS(@c_pointer, name)
|
24
|
+
end
|
25
25
|
end
|
26
26
|
alias proj_cs= set_proj_cs
|
27
27
|
|
28
28
|
# Set the user-visible PROJCS name.
|
29
29
|
#
|
30
30
|
# @param name [String]
|
31
|
-
# @
|
32
|
-
def set_geoc_cs(name)
|
33
|
-
|
34
|
-
|
35
|
-
|
31
|
+
# @raise [OGR::Failure]
|
32
|
+
def set_geoc_cs(name) # rubocop:disable Naming/AccessorMethodName
|
33
|
+
OGR::ErrorHandling.handle_ogr_err("Unable to set GEOCCS to '#{name}'") do
|
34
|
+
FFI::OGR::SRSAPI.OSRSetGeocCS(@c_pointer, name)
|
35
|
+
end
|
36
36
|
end
|
37
37
|
alias geoc_cs= set_geoc_cs
|
38
38
|
|
39
39
|
# Set the GEOGCS based on a well-known name.
|
40
40
|
#
|
41
41
|
# @param name [String]
|
42
|
-
# @
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
ogr_err.handle_result
|
42
|
+
# @raise [OGR::Failure]
|
43
|
+
def set_well_known_geog_cs(name) # rubocop:disable Naming/AccessorMethodName
|
44
|
+
OGR::ErrorHandling.handle_ogr_err("Unable to set GEOGCS to '#{name}'") do
|
45
|
+
FFI::OGR::SRSAPI.OSRSetWellKnownGeogCS(@c_pointer, name)
|
46
|
+
end
|
49
47
|
end
|
50
48
|
alias well_known_geog_cs= set_well_known_geog_cs
|
51
49
|
|
52
50
|
# @param definition [String]
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
51
|
+
# @raise [OGR::Failure]
|
52
|
+
def set_from_user_input(definition) # rubocop:disable Naming/AccessorMethodName
|
53
|
+
OGR::ErrorHandling.handle_ogr_err('Invalid projection info given.') do
|
54
|
+
FFI::OGR::SRSAPI.OSRSetFromUserInput(@c_pointer, definition)
|
55
|
+
end
|
57
56
|
end
|
58
57
|
|
59
58
|
# @return [Array<Float>]
|
59
|
+
# @raise [OGR::Failure]
|
60
60
|
def towgs84
|
61
61
|
coefficients = FFI::MemoryPointer.new(:double, 7)
|
62
|
-
ogr_err = FFI::OGR::SRSAPI.OSRGetTOWGS84(@c_pointer, coefficients, 7)
|
63
|
-
ogr_err.handle_result
|
64
62
|
|
65
|
-
|
63
|
+
OGR::ErrorHandling.handle_ogr_err('No TOWGS84 node available') do
|
64
|
+
FFI::OGR::SRSAPI.OSRGetTOWGS84(@c_pointer, coefficients, 7)
|
65
|
+
end
|
66
|
+
|
67
|
+
coefficients.get_array_of_double(0, 7)
|
66
68
|
end
|
67
69
|
|
68
70
|
# @param x_distance [Float] (In meters.)
|
@@ -72,37 +74,38 @@ module OGR
|
|
72
74
|
# @param y_rotation [Float] (In arc seconds.)
|
73
75
|
# @param z_rotation [Float] (In arc seconds.)
|
74
76
|
# @param scaling_factor [Float] (In parts-per-million.)
|
75
|
-
|
77
|
+
# @raise [OGR::Failure]
|
78
|
+
def set_towgs84(x_distance: nil, y_distance: nil, z_distance: 0.0,
|
76
79
|
x_rotation: 0.0, y_rotation: 0.0, z_rotation: 0.0, scaling_factor: 0.0)
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
80
|
+
OGR::ErrorHandling.handle_ogr_err('No existing DATUM node') do
|
81
|
+
FFI::OGR::SRSAPI.OSRSetTOWGS84(
|
82
|
+
@c_pointer,
|
83
|
+
x_distance, y_distance, z_distance,
|
84
|
+
x_rotation, y_rotation, z_rotation,
|
85
|
+
scaling_factor
|
86
|
+
)
|
87
|
+
end
|
85
88
|
end
|
86
89
|
|
87
90
|
# @param name [String]
|
88
91
|
# @param horizontal_spatial_ref [OGR::SpatialReference] (a PROJCS or GEOGCS)
|
89
92
|
# @param vertical_spatial_ref [OGR::SpatialReference] (a VERT_CS)
|
90
|
-
# @
|
93
|
+
# @raise [OGR::Failure]
|
91
94
|
def set_compound_cs(name, horizontal_spatial_ref, vertical_spatial_ref)
|
92
95
|
horizontal_spatial_ref_ptr = GDAL._pointer(OGR::SpatialReference, horizontal_spatial_ref)
|
93
96
|
vertical_spatial_ref_ptr = GDAL._pointer(OGR::SpatialReference, vertical_spatial_ref)
|
94
97
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
98
|
+
OGR::ErrorHandling.handle_ogr_err("Unable to set compound CS '#{name}'") do
|
99
|
+
FFI::OGR::SRSAPI.OSRSetCompoundCS(
|
100
|
+
@c_pointer,
|
101
|
+
name,
|
102
|
+
horizontal_spatial_ref_ptr,
|
103
|
+
vertical_spatial_ref_ptr
|
104
|
+
)
|
105
|
+
end
|
103
106
|
end
|
104
107
|
|
105
|
-
# Set the user-visible
|
108
|
+
# Set the user-visible GEOGCS name.
|
106
109
|
#
|
107
110
|
# @param [String] geog_name
|
108
111
|
# @param [String] datum_name
|
@@ -113,18 +116,18 @@ module OGR
|
|
113
116
|
# @param [Double] offset
|
114
117
|
# @param [String] angular_unit_label
|
115
118
|
# @param [Float] transform_to_radians
|
116
|
-
# @
|
119
|
+
# @raise [OGR::Failure]
|
117
120
|
def set_geog_cs(geog_name, datum_name, spheroid_name, semi_major, spheroid_inverse_flattening,
|
118
121
|
prime_meridian, offset, angular_unit_label, transform_to_radians)
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
122
|
+
OGR::ErrorHandling.handle_ogr_err("Unable to set GEOGCS '#{name}'") do
|
123
|
+
FFI::OGR::SRSAPI.OSRSetGeogCS(
|
124
|
+
@c_pointer,
|
125
|
+
geog_name, datum_name, spheroid_name,
|
126
|
+
semi_major, spheroid_inverse_flattening,
|
127
|
+
prime_meridian, offset,
|
128
|
+
angular_unit_label, transform_to_radians
|
129
|
+
)
|
130
|
+
end
|
128
131
|
end
|
129
132
|
|
130
133
|
# Set the vertical coordinate system.
|
@@ -132,11 +135,12 @@ module OGR
|
|
132
135
|
# @param name [String] User-visible name of the CS.
|
133
136
|
# @param datum_name [String] User-visible name of the datum. It's helpful
|
134
137
|
# to have this match the EPSG name.
|
135
|
-
# @param datum_type [
|
138
|
+
# @param datum_type [Integer] The OGC datum type, usually 2005.
|
139
|
+
# @raise [OGR::Failure]
|
136
140
|
def set_vert_cs(name, datum_name, datum_type)
|
137
|
-
|
138
|
-
|
139
|
-
|
141
|
+
OGR::ErrorHandling.handle_ogr_err("Unable to set vertical CS '#{name}'") do
|
142
|
+
FFI::OGR::SRSAPI.OSRSetVertCS(@c_pointer, name, datum_name, datum_type)
|
143
|
+
end
|
140
144
|
end
|
141
145
|
|
142
146
|
# @param return_wgs84_on_nil [Boolean] The C-API gives you the option to
|
@@ -144,7 +148,7 @@ module OGR
|
|
144
148
|
# semi-major is found. If set to +true+, this will return that value if
|
145
149
|
# the semi-major isn't found.
|
146
150
|
# @return [Float]
|
147
|
-
def semi_major(return_wgs84_on_nil
|
151
|
+
def semi_major(return_wgs84_on_nil: false)
|
148
152
|
err_ptr = FFI::MemoryPointer.new(:int)
|
149
153
|
value = FFI::OGR::SRSAPI.OSRGetSemiMajor(@c_pointer, err_ptr)
|
150
154
|
ogr_err = FFI::OGR::Core::Err[err_ptr.read_int]
|
@@ -158,7 +162,7 @@ module OGR
|
|
158
162
|
# semi-major is found. If set to +true+, this will return that value if
|
159
163
|
# the semi-major isn't found.
|
160
164
|
# @return [Float]
|
161
|
-
def semi_minor(return_wgs84_on_nil
|
165
|
+
def semi_minor(return_wgs84_on_nil: false)
|
162
166
|
err_ptr = FFI::MemoryPointer.new(:int)
|
163
167
|
value = FFI::OGR::SRSAPI.OSRGetSemiMinor(@c_pointer, err_ptr)
|
164
168
|
ogr_err = FFI::OGR::Core::Err[err_ptr.read_int]
|
@@ -172,7 +176,7 @@ module OGR
|
|
172
176
|
# if no semi-major is found. If set to +true+, this will return that
|
173
177
|
# value if the semi-major isn't found.
|
174
178
|
# @return [Float]
|
175
|
-
def spheroid_inverse_flattening(return_wgs84_on_nil
|
179
|
+
def spheroid_inverse_flattening(return_wgs84_on_nil: false)
|
176
180
|
err_ptr = FFI::MemoryPointer.new(:int)
|
177
181
|
value = FFI::OGR::SRSAPI.OSRGetInvFlattening(@c_pointer, err_ptr)
|
178
182
|
ogr_err = FFI::OGR::Core::Err[err_ptr.read_int]
|
@@ -184,16 +188,17 @@ module OGR
|
|
184
188
|
# @param target_key [String] The partial or complete path to the node to
|
185
189
|
# set an authority on ("PROJCS", "GEOGCS|UNIT").
|
186
190
|
# @param authority [String] I.e. "EPSG".
|
187
|
-
# @param code [
|
191
|
+
# @param code [Integer] Code value for the authority.
|
192
|
+
# @raise [OGR::Failure]
|
188
193
|
def set_authority(target_key, authority, code)
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
194
|
+
OGR::ErrorHandling.handle_ogr_err("Unable to set authority: '#{target_key}', '#{authority}', '#{code}'") do
|
195
|
+
FFI::OGR::SRSAPI.OSRSetAuthority(
|
196
|
+
@c_pointer,
|
197
|
+
target_key,
|
198
|
+
authority,
|
199
|
+
code
|
200
|
+
)
|
201
|
+
end
|
197
202
|
end
|
198
203
|
|
199
204
|
# @param target_key [String] The partial or complete path to the node to get
|
@@ -201,7 +206,10 @@ module OGR
|
|
201
206
|
# search at the root element.
|
202
207
|
# @return [String, nil]
|
203
208
|
def authority_code(target_key = nil)
|
204
|
-
FFI::OGR::SRSAPI.OSRGetAuthorityCode(@c_pointer, target_key)
|
209
|
+
code, ptr = FFI::OGR::SRSAPI.OSRGetAuthorityCode(@c_pointer, target_key)
|
210
|
+
ptr.autorelease = false
|
211
|
+
|
212
|
+
code
|
205
213
|
end
|
206
214
|
|
207
215
|
# @param target_key [String] The partial or complete path to the node to get
|
@@ -209,39 +217,56 @@ module OGR
|
|
209
217
|
# search at the root element.
|
210
218
|
# @return [String, nil]
|
211
219
|
def authority_name(target_key = nil)
|
212
|
-
FFI::OGR::SRSAPI.OSRGetAuthorityName(@c_pointer, target_key)
|
220
|
+
name, ptr = FFI::OGR::SRSAPI.OSRGetAuthorityName(@c_pointer, target_key)
|
221
|
+
ptr.autorelease = false
|
222
|
+
|
223
|
+
name
|
213
224
|
end
|
214
225
|
|
215
226
|
# @param projection_name [String]
|
216
|
-
# @
|
217
|
-
def set_projection(projection_name)
|
218
|
-
|
219
|
-
|
220
|
-
|
227
|
+
# @raise [OGR::Failure]
|
228
|
+
def set_projection(projection_name) # rubocop:disable Naming/AccessorMethodName
|
229
|
+
OGR::ErrorHandling.handle_ogr_err("Unable to set projection to '#{projection_name}'") do
|
230
|
+
FFI::OGR::SRSAPI.OSRSetProjection(@c_pointer, projection_name)
|
231
|
+
end
|
221
232
|
end
|
222
233
|
alias projection= set_projection
|
223
234
|
|
224
235
|
# @param param_name [String]
|
225
236
|
# @param value [Float]
|
237
|
+
# @raise [OGR::Failure]
|
226
238
|
def set_projection_parameter(param_name, value)
|
227
|
-
|
228
|
-
|
229
|
-
|
239
|
+
OGR::ErrorHandling.handle_ogr_err("Unable to set projection parameter '#{param_name}' to #{value}") do
|
240
|
+
FFI::OGR::SRSAPI.OSRSetProjParm(@c_pointer, param_name, value)
|
241
|
+
end
|
230
242
|
end
|
231
243
|
|
232
244
|
# @param name [String]
|
233
245
|
# @param default_value [Float] The value to return if the parameter
|
234
246
|
# doesn't exist.
|
247
|
+
# @raise [OGR::Failure]
|
235
248
|
def projection_parameter(name, default_value = 0.0)
|
236
|
-
|
249
|
+
value = default_value
|
250
|
+
|
251
|
+
OGR::ErrorHandling.handle_ogr_err("Unable to get projection parameter '#{name}'") do
|
252
|
+
ogr_err_ptr = FFI::MemoryPointer.new(:int)
|
253
|
+
value = FFI::OGR::SRSAPI.OSRGetProjParm(@c_pointer, name, default_value, ogr_err_ptr)
|
254
|
+
ogr_err_int = ogr_err_ptr.null? ? 0 : ogr_err_ptr.read_int
|
255
|
+
FFI::OGR::Core::Err[ogr_err_int]
|
256
|
+
end
|
257
|
+
|
258
|
+
value
|
237
259
|
end
|
238
260
|
|
239
261
|
# @param param_name [String]
|
240
262
|
# @param value [Float]
|
263
|
+
# @raise [OGR::Failure]
|
241
264
|
def set_normalized_projection_parameter(param_name, value)
|
242
|
-
|
265
|
+
msg = "Unable to set normalized projection parameter '#{param_name}' to '#{value}'"
|
243
266
|
|
244
|
-
|
267
|
+
OGR::ErrorHandling.handle_ogr_err(msg) do
|
268
|
+
FFI::OGR::SRSAPI.OSRSetNormProjParm(@c_pointer, param_name, value)
|
269
|
+
end
|
245
270
|
end
|
246
271
|
|
247
272
|
# @param name [String] Name of the parameter to fetch; must be from the
|
@@ -252,16 +277,17 @@ module OGR
|
|
252
277
|
FFI::OGR::SRSAPI.OSRGetNormProjParm(@c_pointer, name, default_value, nil)
|
253
278
|
end
|
254
279
|
|
255
|
-
# @param zone [
|
280
|
+
# @param zone [Integer]
|
256
281
|
# @param north [Boolean] True for northern hemisphere, false for southern.
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
282
|
+
# @raise [OGR::Failure]
|
283
|
+
def set_utm(zone, north: true)
|
284
|
+
OGR::ErrorHandling.handle_ogr_err("Unable to set UTM to zome #{zone} (north: #{north})") do
|
285
|
+
FFI::OGR::SRSAPI.OSRSetUTM(@c_pointer, zone, north)
|
286
|
+
end
|
261
287
|
end
|
262
288
|
|
263
289
|
# @param hemisphere [Symbol] :north or :south.
|
264
|
-
# @return [
|
290
|
+
# @return [Integer] The zone, or 0 if this isn't a UTM definition.
|
265
291
|
def utm_zone(hemisphere = :north)
|
266
292
|
north =
|
267
293
|
case hemisphere
|
@@ -275,30 +301,31 @@ module OGR
|
|
275
301
|
FFI::OGR::SRSAPI.OSRGetUTMZone(@c_pointer, north_ptr)
|
276
302
|
end
|
277
303
|
|
278
|
-
# @param zone [
|
304
|
+
# @param zone [Integer] State plane zone number (USGS numbering scheme).
|
279
305
|
# @param nad83 [Boolean] Use NAD83 zone definition or not.
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
# @param
|
306
|
+
# @raise [OGR::Failure]
|
307
|
+
def set_state_plane(zone, override_unit_label = nil, override_unit_transform = 0.0, nad83: true)
|
308
|
+
OGR::ErrorHandling.handle_ogr_err("Unable to set state plane to zone #{zone}") do
|
309
|
+
FFI::OGR::SRSAPI.OSRSetStatePlaneWithUnits(
|
310
|
+
@c_pointer,
|
311
|
+
zone,
|
312
|
+
nad83,
|
313
|
+
override_unit_label,
|
314
|
+
override_unit_transform
|
315
|
+
)
|
316
|
+
end
|
317
|
+
end
|
318
|
+
|
319
|
+
# @param axis_number [Integer] The Axis to query (0, 1, or 2)
|
320
|
+
# @param target_key [String] 'GEOGCS' or 'PROJCS'.
|
294
321
|
# @return [String, nil]
|
295
|
-
def axis(axis_number, target_key
|
322
|
+
def axis(axis_number, target_key)
|
296
323
|
axis_orientation_ptr = FFI::MemoryPointer.new(:int)
|
297
324
|
|
298
325
|
name = FFI::OGR::SRSAPI.OSRGetAxis(@c_pointer, target_key, axis_number, axis_orientation_ptr)
|
299
326
|
ao_value = axis_orientation_ptr.read_int
|
300
327
|
|
301
|
-
{ name: name, orientation: AxisOrientation[ao_value] }
|
328
|
+
{ name: name, orientation: FFI::OGR::SRSAPI::AxisOrientation[ao_value] }
|
302
329
|
end
|
303
330
|
|
304
331
|
def set_albers_conic_equal_area
|
@@ -459,15 +486,19 @@ module OGR
|
|
459
486
|
# @param scale [Float]
|
460
487
|
# @param false_easting [Float]
|
461
488
|
# @param false_northing [Float]
|
489
|
+
# @raise [OGR::Failure]
|
462
490
|
def set_transverse_mercator(center_lat, center_long, scale, false_easting, false_northing)
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
491
|
+
msg = 'Unable to set transverse mercator: ' \
|
492
|
+
"#{center_lat}, #{center_long}, #{scale}, #{false_easting}, #{false_northing}"
|
493
|
+
|
494
|
+
OGR::ErrorHandling.handle_ogr_err(msg) do
|
495
|
+
FFI::OGR::SRSAPI.OSRSetTM(
|
496
|
+
@c_pointer,
|
497
|
+
center_lat, center_long,
|
498
|
+
scale,
|
499
|
+
false_easting, false_northing
|
500
|
+
)
|
501
|
+
end
|
471
502
|
end
|
472
503
|
alias set_tm set_transverse_mercator
|
473
504
|
|