ffi-gdal 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +15 -0
- data/.github/workflows/codacy.yml +1 -1
- data/.github/workflows/dependency-review.yml +1 -1
- data/.github/workflows/specs-in-docker.yml +3 -1
- data/.prettierrc.yml +4 -0
- data/.rubocop.yml +9 -5
- data/.rubocop_todo.yml +5 -11
- data/.solargraph.yml +13 -0
- data/Changelog-0.x.md +229 -174
- data/Changelog.md +20 -4
- data/Dockerfile.gdal2 +2 -85
- data/Gemfile +12 -2
- data/LICENSE.txt +1 -1
- data/README.md +14 -16
- data/Rakefile +6 -6
- data/bin/bundle +12 -12
- data/bin/rake +6 -6
- data/bin/rspec +6 -6
- data/bin/rubocop +6 -6
- data/examples/extract_and_colorize.rb +15 -15
- data/examples/geometries.rb +12 -12
- data/examples/gridding.rb +17 -17
- data/examples/ogr_layer_to_layer.rb +3 -3
- data/examples/raster_erasing.rb +9 -9
- data/examples/remove_small_polygons.rb +11 -11
- data/examples/testing_gdal.rb +20 -20
- data/examples/warping.rb +13 -13
- data/ffi-gdal.gemspec +16 -27
- data/lib/ext/ffi_library_function_checks.rb +3 -3
- data/lib/ext/narray_ext.rb +1 -1
- data/lib/ext/to_bool.rb +2 -2
- data/lib/ffi/cpl/conv.rb +2 -2
- data/lib/ffi/cpl/error.rb +1 -1
- data/lib/ffi/cpl/hash_set.rb +2 -2
- data/lib/ffi/cpl/http.rb +3 -3
- data/lib/ffi/cpl/http_result.rb +2 -2
- data/lib/ffi/cpl/list.rb +1 -1
- data/lib/ffi/cpl/mime_part.rb +1 -1
- data/lib/ffi/cpl/minixml.rb +2 -2
- data/lib/ffi/cpl/port.rb +1 -1
- data/lib/ffi/cpl/progress.rb +2 -2
- data/lib/ffi/cpl/quad_tree.rb +3 -3
- data/lib/ffi/cpl/rect_obj.rb +1 -1
- data/lib/ffi/cpl/string.rb +1 -1
- data/lib/ffi/cpl/vsi.rb +2 -2
- data/lib/ffi/cpl/xml_node.rb +1 -1
- data/lib/ffi/cpl.rb +11 -11
- data/lib/ffi/extensions/gdal/extensions/all.rb +2 -2
- data/lib/ffi/extensions/gdal/extensions.rb +2 -2
- data/lib/ffi/extensions/rttopo/gbox.rb +1 -1
- data/lib/ffi/extensions/rttopo/geom.rb +2 -2
- data/lib/ffi/extensions/rttopo.rb +3 -3
- data/lib/ffi/gdal/alg.rb +2 -2
- data/lib/ffi/gdal/color_entry.rb +1 -1
- data/lib/ffi/gdal/gcp.rb +1 -1
- data/lib/ffi/gdal/gdal.rb +3 -3
- data/lib/ffi/gdal/grid.rb +2 -2
- data/lib/ffi/gdal/grid_data_metrics_options.rb +1 -1
- data/lib/ffi/gdal/grid_inverse_distance_to_a_power_options.rb +1 -1
- data/lib/ffi/gdal/grid_moving_average_options.rb +1 -1
- data/lib/ffi/gdal/grid_nearest_neighbor_options.rb +1 -1
- data/lib/ffi/gdal/matching.rb +2 -2
- data/lib/ffi/gdal/rpc_info.rb +1 -1
- data/lib/ffi/gdal/transformer_info.rb +1 -1
- data/lib/ffi/gdal/version.rb +1 -1
- data/lib/ffi/gdal/vrt.rb +2 -2
- data/lib/ffi/gdal/warp_options.rb +1 -1
- data/lib/ffi/gdal/warper.rb +2 -2
- data/lib/ffi/gdal.rb +22 -22
- data/lib/ffi/ogr/api.rb +3 -3
- data/lib/ffi/ogr/contour_writer_info.rb +1 -1
- data/lib/ffi/ogr/core.rb +9 -9
- data/lib/ffi/ogr/envelope.rb +1 -1
- data/lib/ffi/ogr/envelope_3d.rb +1 -1
- data/lib/ffi/ogr/featurestyle.rb +1 -1
- data/lib/ffi/ogr/field.rb +1 -1
- data/lib/ffi/ogr/geocoding.rb +2 -2
- data/lib/ffi/ogr/srs_api.rb +63 -63
- data/lib/ffi/ogr/style_param.rb +2 -2
- data/lib/ffi/ogr/style_value.rb +1 -1
- data/lib/ffi/ogr.rb +11 -11
- data/lib/ffi-gdal.rb +8 -8
- data/lib/gdal/color_table.rb +6 -6
- data/lib/gdal/dataset/accessors.rb +101 -0
- data/lib/gdal/{dataset_mixins → dataset}/algorithm_methods.rb +1 -1
- data/lib/gdal/dataset/class_methods.rb +69 -0
- data/lib/gdal/dataset/internal_functions.rb +22 -0
- data/lib/gdal/{dataset_mixins → dataset}/matching.rb +1 -1
- data/lib/gdal/dataset/raster_band_methods.rb +181 -0
- data/lib/gdal/{dataset_mixins → dataset}/warp_methods.rb +1 -1
- data/lib/gdal/dataset.rb +21 -359
- data/lib/gdal/driver.rb +10 -10
- data/lib/gdal/environment_methods.rb +1 -1
- data/lib/gdal/extensions/all.rb +1 -1
- data/lib/gdal/extensions/color_entry/extensions.rb +2 -2
- data/lib/gdal/extensions/color_table/extensions.rb +2 -2
- data/lib/gdal/extensions/dataset/extensions.rb +11 -11
- data/lib/gdal/extensions/driver/extensions.rb +7 -7
- data/lib/gdal/extensions/geo_transform/extensions.rb +2 -2
- data/lib/gdal/extensions/gridder.rb +8 -8
- data/lib/gdal/extensions/gridder_options.rb +6 -6
- data/lib/gdal/extensions/raster_attribute_table/extensions.rb +1 -1
- data/lib/gdal/extensions/raster_band/algorithm_extensions.rb +4 -4
- data/lib/gdal/extensions/raster_band/coloring_extensions.rb +1 -1
- data/lib/gdal/extensions/raster_band/extensions.rb +3 -3
- data/lib/gdal/extensions/raster_band/io_extensions.rb +4 -4
- data/lib/gdal/extensions/raster_band_classifier.rb +3 -3
- data/lib/gdal/geo_transform.rb +1 -1
- data/lib/gdal/grid.rb +6 -6
- data/lib/gdal/grid_algorithms/metric_average_distance.rb +1 -1
- data/lib/gdal/grid_algorithms/metric_average_distance_pts.rb +1 -1
- data/lib/gdal/grid_algorithms/metric_count.rb +1 -1
- data/lib/gdal/grid_algorithms/metric_maximum.rb +1 -1
- data/lib/gdal/grid_algorithms/metric_minimum.rb +1 -1
- data/lib/gdal/grid_algorithms/metric_range.rb +1 -1
- data/lib/gdal/grid_algorithms.rb +9 -9
- data/lib/gdal/internal_helpers.rb +3 -3
- data/lib/gdal/logger.rb +1 -1
- data/lib/gdal/major_object.rb +6 -6
- data/lib/gdal/options.rb +2 -2
- data/lib/gdal/raster_attribute_table.rb +5 -5
- data/lib/gdal/raster_band.rb +24 -24
- data/lib/gdal/rpc_info.rb +2 -2
- data/lib/gdal/transformer.rb +1 -1
- data/lib/gdal/transformers/general_image_projection_transformer.rb +1 -1
- data/lib/gdal/transformers/general_image_projection_transformer2.rb +1 -1
- data/lib/gdal/transformers/general_image_projection_transformer3.rb +1 -1
- data/lib/gdal/version_info.rb +9 -9
- data/lib/gdal/virtual_dataset.rb +4 -4
- data/lib/gdal/warp_operation.rb +2 -2
- data/lib/gdal/warp_options.rb +2 -2
- data/lib/gdal.rb +17 -17
- data/lib/ogr/coordinate_transformation.rb +5 -5
- data/lib/ogr/data_source.rb +9 -9
- data/lib/ogr/driver.rb +9 -9
- data/lib/ogr/envelope.rb +1 -1
- data/lib/ogr/error_handling.rb +1 -1
- data/lib/ogr/extensions/all.rb +1 -1
- data/lib/ogr/extensions/data_source/capability_methods.rb +4 -4
- data/lib/ogr/extensions/data_source/data_source_extensions.rb +1 -1
- data/lib/ogr/extensions/driver/capability_methods.rb +3 -3
- data/lib/ogr/extensions/envelope/extensions.rb +1 -1
- data/lib/ogr/extensions/feature/extensions.rb +1 -1
- data/lib/ogr/extensions/feature_definition/extensions.rb +1 -1
- data/lib/ogr/extensions/geometries/point/extensions.rb +1 -1
- data/lib/ogr/extensions/geometry/container_mixins.rb +10 -10
- data/lib/ogr/extensions/geometry/ewkb_io_extensions.rb +3 -3
- data/lib/ogr/extensions/geometry/ewkb_record.rb +4 -4
- data/lib/ogr/extensions/geometry/extensions.rb +4 -7
- data/lib/ogr/extensions/geometry/rttopo_extensions.rb +2 -2
- data/lib/ogr/extensions/geometry/wkb_record.rb +3 -3
- data/lib/ogr/extensions/geometry_types/curve/extensions.rb +2 -2
- data/lib/ogr/extensions/layer/capability_methods.rb +17 -17
- data/lib/ogr/extensions/layer/extensions.rb +1 -1
- data/lib/ogr/extensions/spatial_reference/extensions.rb +1 -1
- data/lib/ogr/extensions/spatial_reference/initializers.rb +2 -2
- data/lib/ogr/extensions/style_table/extensions.rb +1 -1
- data/lib/ogr/feature.rb +15 -15
- data/lib/ogr/feature_definition.rb +2 -2
- data/lib/ogr/field.rb +5 -5
- data/lib/ogr/field_definition.rb +1 -1
- data/lib/ogr/geocoder.rb +1 -1
- data/lib/ogr/geometries/geometry_collection.rb +2 -2
- data/lib/ogr/geometries/geometry_collection_25d.rb +1 -1
- data/lib/ogr/geometries/line_string.rb +1 -1
- data/lib/ogr/geometries/line_string_25d.rb +1 -1
- data/lib/ogr/geometries/linear_ring.rb +2 -2
- data/lib/ogr/geometries/multi_line_string.rb +2 -2
- data/lib/ogr/geometries/multi_line_string_25d.rb +1 -1
- data/lib/ogr/geometries/multi_point.rb +1 -1
- data/lib/ogr/geometries/multi_point_25d.rb +1 -1
- data/lib/ogr/geometries/multi_polygon.rb +2 -2
- data/lib/ogr/geometries/multi_polygon_25d.rb +1 -1
- data/lib/ogr/geometries/point_25d.rb +1 -1
- data/lib/ogr/geometries/polygon.rb +2 -2
- data/lib/ogr/geometries/polygon_25d.rb +1 -1
- data/lib/ogr/geometry.rb +11 -11
- data/lib/ogr/geometry_types/container.rb +1 -1
- data/lib/ogr/geometry_types/curve.rb +1 -1
- data/lib/ogr/internal_helpers.rb +4 -4
- data/lib/ogr/layer.rb +8 -8
- data/lib/ogr/layer_mixins/ogr_feature_methods.rb +9 -9
- data/lib/ogr/layer_mixins/ogr_field_methods.rb +15 -15
- data/lib/ogr/layer_mixins/ogr_sql_methods.rb +2 -2
- data/lib/ogr/spatial_reference.rb +19 -19
- data/lib/ogr/spatial_reference_mixins/coordinate_system_getter_setters.rb +4 -4
- data/lib/ogr/spatial_reference_mixins/exporters.rb +9 -9
- data/lib/ogr/spatial_reference_mixins/importers.rb +2 -2
- data/lib/ogr/spatial_reference_mixins/morphers.rb +2 -2
- data/lib/ogr/spatial_reference_mixins/parameter_getter_setters.rb +1 -1
- data/lib/ogr/style_table.rb +3 -3
- data/lib/ogr/style_tool.rb +1 -1
- data/lib/ogr.rb +33 -33
- data/rakelib/docker.rake +2 -2
- metadata +14 -150
- data/bitbucket-pipelines.yml +0 -16
- data/tilt/gdal2.yml +0 -22
- data/tilt/gdal3.yml +0 -22
@@ -27,12 +27,12 @@ module OGR
|
|
27
27
|
# @param feature [OGR::Feature] [description]
|
28
28
|
# @raise [OGR::Failure]
|
29
29
|
def create_feature(feature)
|
30
|
-
unless test_capability(
|
30
|
+
unless test_capability("SequentialWrite")
|
31
31
|
raise OGR::UnsupportedOperation,
|
32
|
-
|
32
|
+
"This layer does not support feature creation."
|
33
33
|
end
|
34
34
|
|
35
|
-
OGR::ErrorHandling.handle_ogr_err(
|
35
|
+
OGR::ErrorHandling.handle_ogr_err("Unable to create feature") do
|
36
36
|
FFI::OGR::API.OGR_L_CreateFeature(@c_pointer, feature.c_pointer)
|
37
37
|
end
|
38
38
|
end
|
@@ -43,9 +43,9 @@ module OGR
|
|
43
43
|
# @raise [OGR::Failure] When trying to delete a feature with an ID that
|
44
44
|
# does not exist.
|
45
45
|
def delete_feature(feature_id)
|
46
|
-
unless test_capability(
|
46
|
+
unless test_capability("DeleteFeature")
|
47
47
|
raise OGR::UnsupportedOperation,
|
48
|
-
|
48
|
+
"This layer does not support feature deletion."
|
49
49
|
end
|
50
50
|
|
51
51
|
OGR::ErrorHandling.handle_ogr_err("Unable to delete feature with ID '#{feature_id}'") do
|
@@ -67,12 +67,12 @@ module OGR
|
|
67
67
|
# @param new_feature [OGR::Feature, FFI::Pointer]
|
68
68
|
# @raise [OGR::Failure]
|
69
69
|
def feature=(new_feature)
|
70
|
-
raise OGR::UnsupportedOperation,
|
70
|
+
raise OGR::UnsupportedOperation, "#feature= not supported by this Layer" unless test_capability("RandomWrite")
|
71
71
|
|
72
72
|
new_feature_ptr = GDAL._pointer(OGR::Feature, new_feature)
|
73
73
|
raise OGR::InvalidFeature if new_feature_ptr.nil? || new_feature_ptr.null?
|
74
74
|
|
75
|
-
OGR::ErrorHandling.handle_ogr_err(
|
75
|
+
OGR::ErrorHandling.handle_ogr_err("Unable to set feature") do
|
76
76
|
FFI::OGR::API.OGR_L_SetFeature(@c_pointer, new_feature_ptr)
|
77
77
|
end
|
78
78
|
end
|
@@ -81,9 +81,9 @@ module OGR
|
|
81
81
|
# be <= +feature_count+, but no checking is done to ensure.
|
82
82
|
# @return [OGR::Feature, nil]
|
83
83
|
def feature(index)
|
84
|
-
unless test_capability(
|
84
|
+
unless test_capability("RandomRead")
|
85
85
|
raise OGR::UnsupportedOperation,
|
86
|
-
|
86
|
+
"#feature(index) not supported by this Layer"
|
87
87
|
end
|
88
88
|
|
89
89
|
# This feature needs to be Destroyed.
|
@@ -12,14 +12,14 @@ module OGR
|
|
12
12
|
# different form, depending on the limitations of the format driver.
|
13
13
|
# @raise [OGR::Failure]
|
14
14
|
def create_field(field_definition, approx_ok: false)
|
15
|
-
unless test_capability(
|
15
|
+
unless test_capability("CreateField")
|
16
16
|
raise OGR::UnsupportedOperation,
|
17
|
-
|
17
|
+
"This layer does not support field creation."
|
18
18
|
end
|
19
19
|
|
20
20
|
field_definition_ptr = GDAL._pointer(OGR::FieldDefinition, field_definition)
|
21
21
|
|
22
|
-
OGR::ErrorHandling.handle_ogr_err(
|
22
|
+
OGR::ErrorHandling.handle_ogr_err("Unable to create field") do
|
23
23
|
FFI::OGR::API.OGR_L_CreateField(@c_pointer, field_definition_ptr, approx_ok)
|
24
24
|
end
|
25
25
|
end
|
@@ -28,12 +28,12 @@ module OGR
|
|
28
28
|
#
|
29
29
|
# @raise [OGR::Failure]
|
30
30
|
def delete_field(field_id)
|
31
|
-
unless test_capability(
|
31
|
+
unless test_capability("DeleteField")
|
32
32
|
raise OGR::UnsupportedOperation,
|
33
|
-
|
33
|
+
"This driver does not support field deletion."
|
34
34
|
end
|
35
35
|
|
36
|
-
OGR::ErrorHandling.handle_ogr_err(
|
36
|
+
OGR::ErrorHandling.handle_ogr_err("Unable to delete field") do
|
37
37
|
FFI::OGR::API.OGR_L_DeleteField(@c_pointer, field_id)
|
38
38
|
end
|
39
39
|
end
|
@@ -42,9 +42,9 @@ module OGR
|
|
42
42
|
# which they should be reordered. I.e. [0, 2, 3, 1, 4].
|
43
43
|
# @raise [OGR::Failure]
|
44
44
|
def reorder_fields(*new_order)
|
45
|
-
unless test_capability(
|
45
|
+
unless test_capability("ReorderFields")
|
46
46
|
raise OGR::UnsupportedOperation,
|
47
|
-
|
47
|
+
"This driver does not support field reordering."
|
48
48
|
end
|
49
49
|
|
50
50
|
return false if new_order.empty? || new_order.any? { |i| i > feature_definition.field_count }
|
@@ -63,9 +63,9 @@ module OGR
|
|
63
63
|
# @param new_position [Integer]
|
64
64
|
# @raise [OGR::Failure]
|
65
65
|
def reorder_field(old_position, new_position)
|
66
|
-
unless test_capability(
|
66
|
+
unless test_capability("ReorderFields")
|
67
67
|
raise OGR::UnsupportedOperation,
|
68
|
-
|
68
|
+
"This driver does not support field reordering."
|
69
69
|
end
|
70
70
|
|
71
71
|
OGR::ErrorHandling.handle_ogr_err("Unable to reorder field: #{old_position} to #{new_position}") do
|
@@ -80,8 +80,8 @@ module OGR
|
|
80
80
|
# ALTER_WIDTH_PRECISION_FLAG, or ALTER_ALL_FLAG.
|
81
81
|
# @raise [OGR::Failure]
|
82
82
|
def alter_field_definition(field_index, new_field_definition, flags)
|
83
|
-
unless test_capability(
|
84
|
-
raise OGR::UnsupportedOperation,
|
83
|
+
unless test_capability("AlterFieldDefn")
|
84
|
+
raise OGR::UnsupportedOperation, "This layer does not support field definition altering."
|
85
85
|
end
|
86
86
|
|
87
87
|
new_field_definition_ptr = GDAL._pointer(OGR::FieldDefinition, new_field_definition)
|
@@ -116,13 +116,13 @@ module OGR
|
|
116
116
|
# @param approx_ok [Boolean]
|
117
117
|
# @raise [OGR::Failure]
|
118
118
|
def create_geometry_field(geometry_field_def, approx_ok: false)
|
119
|
-
unless test_capability(
|
120
|
-
raise OGR::UnsupportedOperation,
|
119
|
+
unless test_capability("CreateGeomField")
|
120
|
+
raise OGR::UnsupportedOperation, "This layer does not support geometry field creation"
|
121
121
|
end
|
122
122
|
|
123
123
|
geometry_field_definition_ptr = GDAL._pointer(OGR::GeometryFieldDefinition, geometry_field_def)
|
124
124
|
|
125
|
-
OGR::ErrorHandling.handle_ogr_err(
|
125
|
+
OGR::ErrorHandling.handle_ogr_err("Unable to create geometry field") do
|
126
126
|
FFI::OGR::API.OGR_L_CreateGeomField(
|
127
127
|
@c_pointer,
|
128
128
|
geometry_field_definition_ptr,
|
@@ -43,11 +43,11 @@ module OGR
|
|
43
43
|
|
44
44
|
# @raise [OGR::Failure]
|
45
45
|
def transact
|
46
|
-
raise OGR::UnsupportedOperation,
|
46
|
+
raise OGR::UnsupportedOperation, "This layer does not support transactions." unless supports_transactions?
|
47
47
|
|
48
48
|
ogr_err = yield
|
49
49
|
|
50
|
-
OGR::ErrorHandling.handle_ogr_err(
|
50
|
+
OGR::ErrorHandling.handle_ogr_err("Unable to set geometry directly on feature") do
|
51
51
|
ogr_err
|
52
52
|
end
|
53
53
|
end
|
@@ -1,13 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative
|
4
|
-
require_relative
|
5
|
-
require_relative
|
6
|
-
require_relative
|
7
|
-
require_relative
|
8
|
-
require_relative
|
9
|
-
require_relative
|
10
|
-
require_relative
|
3
|
+
require_relative "../ogr"
|
4
|
+
require_relative "../gdal"
|
5
|
+
require_relative "spatial_reference_mixins/coordinate_system_getter_setters"
|
6
|
+
require_relative "spatial_reference_mixins/exporters"
|
7
|
+
require_relative "spatial_reference_mixins/importers"
|
8
|
+
require_relative "spatial_reference_mixins/morphers"
|
9
|
+
require_relative "spatial_reference_mixins/parameter_getter_setters"
|
10
|
+
require_relative "spatial_reference_mixins/type_checks"
|
11
11
|
|
12
12
|
module OGR
|
13
13
|
# Represents a geographic coordinate system. There are two primary types:
|
@@ -46,7 +46,7 @@ module OGR
|
|
46
46
|
|
47
47
|
list = pointer_array.map(&:read_string).sort
|
48
48
|
|
49
|
-
strip_underscores ? list.map! { |l| l.tr(
|
49
|
+
strip_underscores ? list.map! { |l| l.tr("_", " ") } : list
|
50
50
|
end
|
51
51
|
|
52
52
|
# @deprecated This was removed in GDAL 3.0.
|
@@ -141,13 +141,13 @@ module OGR
|
|
141
141
|
def initialize(spatial_reference_or_wkt = nil)
|
142
142
|
pointer =
|
143
143
|
case spatial_reference_or_wkt.class.name
|
144
|
-
when
|
144
|
+
when "OGR::SpatialReference"
|
145
145
|
# This is basically getting a reference to the SpatialReference that
|
146
146
|
# was passed in, thus when this SpatialReference gets garbage-collected,
|
147
147
|
# it shouldn't release anything.
|
148
148
|
ptr = spatial_reference_or_wkt.c_pointer
|
149
149
|
ptr.autorelease = false
|
150
|
-
when
|
150
|
+
when "String", "NilClass"
|
151
151
|
# FWIW, the docs say:
|
152
152
|
# Note that newly created objects are given a reference count of one.
|
153
153
|
#
|
@@ -157,7 +157,7 @@ module OGR
|
|
157
157
|
|
158
158
|
# We're instantiating a new SR, so we can use .destroy.
|
159
159
|
FFI::AutoPointer.new(ptr, SpatialReference.method(:release))
|
160
|
-
when
|
160
|
+
when "FFI::AutoPointer", "FFI::Pointer", "FFI::MemoryPointer"
|
161
161
|
# If we got a pointer, we don't know who owns the data, so don't
|
162
162
|
# touch anything about autorelease/AutoPointer.
|
163
163
|
spatial_reference_or_wkt
|
@@ -165,7 +165,7 @@ module OGR
|
|
165
165
|
log "Dunno what to do with #{spatial_reference_or_wkt.inspect}"
|
166
166
|
end
|
167
167
|
|
168
|
-
raise OGR::CreateFailure,
|
168
|
+
raise OGR::CreateFailure, "Unable to create SpatialReference." if pointer.nil? || pointer.null?
|
169
169
|
|
170
170
|
@c_pointer = pointer
|
171
171
|
end
|
@@ -201,28 +201,28 @@ module OGR
|
|
201
201
|
other_spatial_ref_ptr = GDAL._pointer(OGR::SpatialReference, other_spatial_ref)
|
202
202
|
raise OGR::InvalidSpatialReference if other_spatial_ref_ptr.nil? || other_spatial_ref_ptr.null?
|
203
203
|
|
204
|
-
OGR::ErrorHandling.handle_ogr_err(
|
204
|
+
OGR::ErrorHandling.handle_ogr_err("Unable to copy GEOGCS") do
|
205
205
|
FFI::OGR::SRSAPI.OSRCopyGeogCSFrom(@c_pointer, other_spatial_ref_ptr)
|
206
206
|
end
|
207
207
|
end
|
208
208
|
|
209
209
|
# @raise [OGR::Failure]
|
210
210
|
def validate
|
211
|
-
OGR::ErrorHandling.handle_ogr_err(
|
211
|
+
OGR::ErrorHandling.handle_ogr_err("Unable to validate") do
|
212
212
|
FFI::OGR::SRSAPI.OSRValidate(@c_pointer)
|
213
213
|
end
|
214
214
|
end
|
215
215
|
|
216
216
|
# @raise [OGR::Failure]
|
217
217
|
def fixup_ordering!
|
218
|
-
OGR::ErrorHandling.handle_ogr_err(
|
218
|
+
OGR::ErrorHandling.handle_ogr_err("Unable to fixup ordering") do
|
219
219
|
FFI::OGR::SRSAPI.OSRFixupOrdering(@c_pointer)
|
220
220
|
end
|
221
221
|
end
|
222
222
|
|
223
223
|
# @raise [OGR::Failure]
|
224
224
|
def fixup!
|
225
|
-
OGR::ErrorHandling.handle_ogr_err(
|
225
|
+
OGR::ErrorHandling.handle_ogr_err("Unable to fixup") do
|
226
226
|
FFI::OGR::SRSAPI.OSRFixup(@c_pointer)
|
227
227
|
end
|
228
228
|
end
|
@@ -231,7 +231,7 @@ module OGR
|
|
231
231
|
#
|
232
232
|
# @raise [OGR::Failure]
|
233
233
|
def strip_ct_parameters!
|
234
|
-
OGR::ErrorHandling.handle_ogr_err(
|
234
|
+
OGR::ErrorHandling.handle_ogr_err("Unable to strip coordinate transformation parameters") do
|
235
235
|
FFI::OGR::SRSAPI.OSRStripCTParms(@c_pointer)
|
236
236
|
end
|
237
237
|
end
|
@@ -240,7 +240,7 @@ module OGR
|
|
240
240
|
#
|
241
241
|
# @raise [OGR::Failure]
|
242
242
|
def auto_identify_epsg!
|
243
|
-
OGR::ErrorHandling.handle_ogr_err(
|
243
|
+
OGR::ErrorHandling.handle_ogr_err("Unable to determine SRS from EPSG") do
|
244
244
|
FFI::OGR::SRSAPI.OSRAutoIdentifyEPSG(@c_pointer)
|
245
245
|
end
|
246
246
|
end
|
@@ -50,7 +50,7 @@ module OGR
|
|
50
50
|
# @param definition [String]
|
51
51
|
# @raise [OGR::Failure]
|
52
52
|
def set_from_user_input(definition) # rubocop:disable Naming/AccessorMethodName
|
53
|
-
OGR::ErrorHandling.handle_ogr_err(
|
53
|
+
OGR::ErrorHandling.handle_ogr_err("Invalid projection info given.") do
|
54
54
|
FFI::OGR::SRSAPI.OSRSetFromUserInput(@c_pointer, definition)
|
55
55
|
end
|
56
56
|
end
|
@@ -60,7 +60,7 @@ module OGR
|
|
60
60
|
def towgs84
|
61
61
|
coefficients = FFI::MemoryPointer.new(:double, 7)
|
62
62
|
|
63
|
-
OGR::ErrorHandling.handle_ogr_err(
|
63
|
+
OGR::ErrorHandling.handle_ogr_err("No TOWGS84 node available") do
|
64
64
|
FFI::OGR::SRSAPI.OSRGetTOWGS84(@c_pointer, coefficients, 7)
|
65
65
|
end
|
66
66
|
|
@@ -77,7 +77,7 @@ module OGR
|
|
77
77
|
# @raise [OGR::Failure]
|
78
78
|
def set_towgs84(x_distance: nil, y_distance: nil, z_distance: 0.0,
|
79
79
|
x_rotation: 0.0, y_rotation: 0.0, z_rotation: 0.0, scaling_factor: 0.0)
|
80
|
-
OGR::ErrorHandling.handle_ogr_err(
|
80
|
+
OGR::ErrorHandling.handle_ogr_err("No existing DATUM node") do
|
81
81
|
FFI::OGR::SRSAPI.OSRSetTOWGS84(
|
82
82
|
@c_pointer,
|
83
83
|
x_distance, y_distance, z_distance,
|
@@ -488,7 +488,7 @@ module OGR
|
|
488
488
|
# @param false_northing [Float]
|
489
489
|
# @raise [OGR::Failure]
|
490
490
|
def set_transverse_mercator(center_lat, center_long, scale, false_easting, false_northing)
|
491
|
-
msg =
|
491
|
+
msg = "Unable to set transverse mercator: " \
|
492
492
|
"#{center_lat}, #{center_long}, #{scale}, #{false_easting}, #{false_northing}"
|
493
493
|
|
494
494
|
OGR::ErrorHandling.handle_ogr_err(msg) do
|
@@ -10,7 +10,7 @@ module OGR
|
|
10
10
|
datum_name = FFI::MemoryPointer.new(:string, 32)
|
11
11
|
units = FFI::MemoryPointer.new(:string, 32)
|
12
12
|
|
13
|
-
OGR::ErrorHandling.handle_ogr_err(
|
13
|
+
OGR::ErrorHandling.handle_ogr_err("Required parameters (name, datum name, units) are not defined") do
|
14
14
|
FFI::OGR::SRSAPI.OSRExportToERM(@c_pointer, projection_name, datum_name, units)
|
15
15
|
end
|
16
16
|
|
@@ -25,7 +25,7 @@ module OGR
|
|
25
25
|
# @raise [OGR::Failure]
|
26
26
|
def to_mapinfo
|
27
27
|
GDAL._cpl_read_and_free_string do |return_ptr_ptr|
|
28
|
-
OGR::ErrorHandling.handle_ogr_err(
|
28
|
+
OGR::ErrorHandling.handle_ogr_err("Unable to export to MapInfo") do
|
29
29
|
FFI::OGR::SRSAPI.OSRExportToMICoordSys(@c_pointer, return_ptr_ptr)
|
30
30
|
end
|
31
31
|
end
|
@@ -41,7 +41,7 @@ module OGR
|
|
41
41
|
prj_params_ptr_ptr = GDAL._pointer_pointer(:double)
|
42
42
|
prj_params_ptr_ptr.autorelease = false
|
43
43
|
|
44
|
-
OGR::ErrorHandling.handle_ogr_err(
|
44
|
+
OGR::ErrorHandling.handle_ogr_err("Unable to export to PCI") do
|
45
45
|
FFI::OGR::SRSAPI.OSRExportToPCI(@c_pointer, proj_ptr_ptr, units_ptr_ptr, prj_params_ptr_ptr)
|
46
46
|
end
|
47
47
|
|
@@ -66,7 +66,7 @@ module OGR
|
|
66
66
|
# @raise [GDAL::UnsupportedOperation] If empty definition.
|
67
67
|
def to_proj4
|
68
68
|
GDAL._cpl_read_and_free_string do |proj4_ptr_ptr|
|
69
|
-
OGR::ErrorHandling.handle_ogr_err(
|
69
|
+
OGR::ErrorHandling.handle_ogr_err("Unable to export to PROJ.4") do
|
70
70
|
FFI::OGR::SRSAPI.OSRExportToProj4(@c_pointer, proj4_ptr_ptr)
|
71
71
|
end
|
72
72
|
end
|
@@ -81,7 +81,7 @@ module OGR
|
|
81
81
|
prj_params_ptr_ptr = GDAL._pointer_pointer(:double)
|
82
82
|
prj_params_ptr_ptr.autorelease = false
|
83
83
|
|
84
|
-
OGR::ErrorHandling.handle_ogr_err(
|
84
|
+
OGR::ErrorHandling.handle_ogr_err("Unable to export to USGS GCTP") do
|
85
85
|
FFI::OGR::SRSAPI.OSRExportToUSGS(@c_pointer, proj_sys_ptr, zone_ptr, prj_params_ptr_ptr, datum_ptr)
|
86
86
|
end
|
87
87
|
|
@@ -106,7 +106,7 @@ module OGR
|
|
106
106
|
# @raise [OGR::Failure]
|
107
107
|
def to_wkt
|
108
108
|
GDAL._cpl_read_and_free_string do |wkt_ptr_ptr|
|
109
|
-
OGR::ErrorHandling.handle_ogr_err(
|
109
|
+
OGR::ErrorHandling.handle_ogr_err("Unable to export to WKT") do
|
110
110
|
FFI::OGR::SRSAPI.OSRExportToWkt(@c_pointer, wkt_ptr_ptr)
|
111
111
|
end
|
112
112
|
end
|
@@ -117,10 +117,10 @@ module OGR
|
|
117
117
|
# @raise [OGR::Failure]
|
118
118
|
# @return [String]
|
119
119
|
def to_pretty_wkt(simplify: false)
|
120
|
-
return +
|
120
|
+
return +"" if @c_pointer.null?
|
121
121
|
|
122
122
|
GDAL._cpl_read_and_free_string do |wkt_ptr_ptr|
|
123
|
-
OGR::ErrorHandling.handle_ogr_err(
|
123
|
+
OGR::ErrorHandling.handle_ogr_err("Unable to export to pretty WKT") do
|
124
124
|
FFI::OGR::SRSAPI.OSRExportToPrettyWkt(@c_pointer, wkt_ptr_ptr, simplify)
|
125
125
|
end
|
126
126
|
end
|
@@ -130,7 +130,7 @@ module OGR
|
|
130
130
|
# @raise [OGR::Failure]
|
131
131
|
def to_xml
|
132
132
|
GDAL._cpl_read_and_free_string do |xml_ptr_ptr|
|
133
|
-
OGR::ErrorHandling.handle_ogr_err(
|
133
|
+
OGR::ErrorHandling.handle_ogr_err("Unable to export to XML (GML)") do
|
134
134
|
FFI::OGR::SRSAPI.OSRExportToXML(@c_pointer, xml_ptr_ptr, nil)
|
135
135
|
end
|
136
136
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative
|
3
|
+
require_relative "../error_handling"
|
4
4
|
|
5
5
|
module OGR
|
6
6
|
module SpatialReferenceMixins
|
@@ -124,7 +124,7 @@ module OGR
|
|
124
124
|
object = new(spatial_reference_or_wkt)
|
125
125
|
ogr_err = yield object.c_pointer
|
126
126
|
|
127
|
-
OGR::ErrorHandling.handle_ogr_err(
|
127
|
+
OGR::ErrorHandling.handle_ogr_err("Unable to build SpatialReference") do
|
128
128
|
ogr_err
|
129
129
|
end
|
130
130
|
|
@@ -8,7 +8,7 @@ module OGR
|
|
8
8
|
# @return [OGR::SpatialReference] If successful, returns self.
|
9
9
|
# @raise [OGR::Failure]
|
10
10
|
def morph_to_esri!
|
11
|
-
OGR::ErrorHandling.handle_ogr_err(
|
11
|
+
OGR::ErrorHandling.handle_ogr_err("Unable to morph self to ESRI") do
|
12
12
|
FFI::OGR::SRSAPI.OSRMorphToESRI(@c_pointer)
|
13
13
|
end
|
14
14
|
|
@@ -20,7 +20,7 @@ module OGR
|
|
20
20
|
# @return [OGR::SpatialReference] If successful, returns self.
|
21
21
|
# @raise [OGR::Failure]
|
22
22
|
def morph_from_esri!
|
23
|
-
OGR::ErrorHandling.handle_ogr_err(
|
23
|
+
OGR::ErrorHandling.handle_ogr_err("Unable to morph self from ESRI") do
|
24
24
|
FFI::OGR::SRSAPI.OSRMorphFromESRI(@c_pointer)
|
25
25
|
end
|
26
26
|
|
@@ -74,7 +74,7 @@ module OGR
|
|
74
74
|
# @raise [OGR::Failure]
|
75
75
|
def set_linear_units_and_update_parameters(unit_label, transform_to_meters)
|
76
76
|
msg = "Unable to set linear units to #{unit_label} (transform to meters? #{transform_to_meters}) and update" \
|
77
|
-
|
77
|
+
"parameters"
|
78
78
|
|
79
79
|
OGR::ErrorHandling.handle_ogr_err(msg) do
|
80
80
|
FFI::OGR::SRSAPI.OSRSetLinearUnitsAndUpdateParameters(@c_pointer, unit_label, transform_to_meters.to_f)
|
data/lib/ogr/style_table.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative
|
4
|
-
require_relative
|
3
|
+
require_relative "../gdal"
|
4
|
+
require_relative "../ogr"
|
5
5
|
|
6
6
|
module OGR
|
7
7
|
class StyleTable
|
@@ -25,7 +25,7 @@ module OGR
|
|
25
25
|
FFI::AutoPointer.new(pointer, StyleTable.method(:release))
|
26
26
|
end
|
27
27
|
|
28
|
-
raise
|
28
|
+
raise "Unable to create StyleTable" if @c_pointer.null?
|
29
29
|
end
|
30
30
|
|
31
31
|
def destroy!
|
data/lib/ogr/style_tool.rb
CHANGED
data/lib/ogr.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative
|
4
|
-
require_relative
|
5
|
-
require_relative
|
6
|
-
require_relative
|
3
|
+
require_relative "ffi-gdal"
|
4
|
+
require_relative "ogr/internal_helpers"
|
5
|
+
require_relative "ogr/exceptions"
|
6
|
+
require_relative "ogr/error_handling"
|
7
7
|
|
8
8
|
module OGR
|
9
9
|
include InternalHelpers
|
@@ -15,35 +15,35 @@ module OGR
|
|
15
15
|
end
|
16
16
|
|
17
17
|
# Autoload OGR Geometry object types.
|
18
|
-
autoload :GeometryCollection, ogr_require(
|
19
|
-
autoload :GeometryCollection25D, ogr_require(
|
20
|
-
autoload :LineString, ogr_require(
|
21
|
-
autoload :LineString25D, ogr_require(
|
22
|
-
autoload :LinearRing, ogr_require(
|
23
|
-
autoload :MultiLineString, ogr_require(
|
24
|
-
autoload :MultiLineString25D, ogr_require(
|
25
|
-
autoload :MultiPoint, ogr_require(
|
26
|
-
autoload :MultiPoint25D, ogr_require(
|
27
|
-
autoload :MultiPolygon, ogr_require(
|
28
|
-
autoload :MultiPolygon25D, ogr_require(
|
29
|
-
autoload :NoneGeometry, ogr_require(
|
30
|
-
autoload :Point, ogr_require(
|
31
|
-
autoload :Point25D, ogr_require(
|
32
|
-
autoload :Polygon, ogr_require(
|
33
|
-
autoload :Polygon25D, ogr_require(
|
34
|
-
autoload :UnknownGeometry, ogr_require(
|
18
|
+
autoload :GeometryCollection, ogr_require("ogr/geometries/geometry_collection")
|
19
|
+
autoload :GeometryCollection25D, ogr_require("ogr/geometries/geometry_collection_25d")
|
20
|
+
autoload :LineString, ogr_require("ogr/geometries/line_string")
|
21
|
+
autoload :LineString25D, ogr_require("ogr/geometries/line_string_25d")
|
22
|
+
autoload :LinearRing, ogr_require("ogr/geometries/linear_ring")
|
23
|
+
autoload :MultiLineString, ogr_require("ogr/geometries/multi_line_string")
|
24
|
+
autoload :MultiLineString25D, ogr_require("ogr/geometries/multi_line_string_25d")
|
25
|
+
autoload :MultiPoint, ogr_require("ogr/geometries/multi_point")
|
26
|
+
autoload :MultiPoint25D, ogr_require("ogr/geometries/multi_point_25d")
|
27
|
+
autoload :MultiPolygon, ogr_require("ogr/geometries/multi_polygon")
|
28
|
+
autoload :MultiPolygon25D, ogr_require("ogr/geometries/multi_polygon_25d")
|
29
|
+
autoload :NoneGeometry, ogr_require("ogr/geometries/none_geometry")
|
30
|
+
autoload :Point, ogr_require("ogr/geometries/point")
|
31
|
+
autoload :Point25D, ogr_require("ogr/geometries/point_25d")
|
32
|
+
autoload :Polygon, ogr_require("ogr/geometries/polygon")
|
33
|
+
autoload :Polygon25D, ogr_require("ogr/geometries/polygon_25d")
|
34
|
+
autoload :UnknownGeometry, ogr_require("ogr/geometries/unknown_geometry")
|
35
35
|
|
36
36
|
# Autoload core OGR types
|
37
|
-
autoload :CoordinateTransformation, ogr_require(
|
38
|
-
autoload :DataSource, ogr_require(
|
39
|
-
autoload :Driver, ogr_require(
|
40
|
-
autoload :Envelope, ogr_require(
|
41
|
-
autoload :Feature, ogr_require(
|
42
|
-
autoload :FeatureDefinition, ogr_require(
|
43
|
-
autoload :FieldDefinition, ogr_require(
|
44
|
-
autoload :Geometry, ogr_require(
|
45
|
-
autoload :GeometryFieldDefinition, ogr_require(
|
46
|
-
autoload :Layer, ogr_require(
|
47
|
-
autoload :SpatialReference, ogr_require(
|
48
|
-
autoload :StyleTable, ogr_require(
|
37
|
+
autoload :CoordinateTransformation, ogr_require("ogr/coordinate_transformation")
|
38
|
+
autoload :DataSource, ogr_require("ogr/data_source")
|
39
|
+
autoload :Driver, ogr_require("ogr/driver")
|
40
|
+
autoload :Envelope, ogr_require("ogr/envelope")
|
41
|
+
autoload :Feature, ogr_require("ogr/feature")
|
42
|
+
autoload :FeatureDefinition, ogr_require("ogr/feature_definition")
|
43
|
+
autoload :FieldDefinition, ogr_require("ogr/field_definition")
|
44
|
+
autoload :Geometry, ogr_require("ogr/geometry")
|
45
|
+
autoload :GeometryFieldDefinition, ogr_require("ogr/geometry_field_definition")
|
46
|
+
autoload :Layer, ogr_require("ogr/layer")
|
47
|
+
autoload :SpatialReference, ogr_require("ogr/spatial_reference")
|
48
|
+
autoload :StyleTable, ogr_require("ogr/style_table")
|
49
49
|
end
|
data/rakelib/docker.rake
CHANGED
@@ -2,9 +2,9 @@
|
|
2
2
|
|
3
3
|
namespace :docker do
|
4
4
|
namespace :gdal2 do
|
5
|
-
desc
|
5
|
+
desc "Run specs in the gdal2 docker container"
|
6
6
|
task :spec do
|
7
|
-
sh
|
7
|
+
sh "docker-compose run --rm gdal2 bundle exec rake spec"
|
8
8
|
end
|
9
9
|
end
|
10
10
|
end
|