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
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "ogr/layer"
|
4
4
|
|
5
5
|
module OGR
|
6
6
|
module LayerMixins
|
@@ -10,17 +10,17 @@ module OGR
|
|
10
10
|
# manner for this layer (as opposed to using #next_feature and
|
11
11
|
# #reset_reading).
|
12
12
|
def can_random_read?
|
13
|
-
test_capability(
|
13
|
+
test_capability("RandomRead")
|
14
14
|
end
|
15
15
|
|
16
16
|
# @return [Boolean] +true+ if #create_feature is allowed on this layer.
|
17
17
|
def can_sequential_write?
|
18
|
-
test_capability(
|
18
|
+
test_capability("SequentialWrite")
|
19
19
|
end
|
20
20
|
|
21
21
|
# @return [Boolean] +true+ if #feature= is allowed on this layer.
|
22
22
|
def can_random_write?
|
23
|
-
test_capability(
|
23
|
+
test_capability("RandomWrite")
|
24
24
|
end
|
25
25
|
|
26
26
|
# @return [Boolean] +true+ if this layer implements spatial filtering
|
@@ -28,78 +28,78 @@ module OGR
|
|
28
28
|
# it should build and maintain its own spatial index for features in
|
29
29
|
# this layer.
|
30
30
|
def can_fast_spatial_filter?
|
31
|
-
test_capability(
|
31
|
+
test_capability("FastSpatialFilter")
|
32
32
|
end
|
33
33
|
|
34
34
|
# @return [Boolean] +true+ if this layer can return a feature count
|
35
35
|
# efficiently (i.e. without counting all of the features).
|
36
36
|
def can_fast_feature_count?
|
37
|
-
test_capability(
|
37
|
+
test_capability("FastFeatureCount")
|
38
38
|
end
|
39
39
|
|
40
40
|
# @return [Boolean] +true+ if this Layer can return its extent
|
41
41
|
# efficiently (i.e. without scanning all of the features.).
|
42
42
|
def can_fast_get_extent?
|
43
|
-
test_capability(
|
43
|
+
test_capability("FastGetExtent")
|
44
44
|
end
|
45
45
|
|
46
46
|
# @return [Boolean] +true+ if this layer can perform the
|
47
47
|
# #next_feature_index= call efficiently.
|
48
48
|
def can_fast_set_next_by_index?
|
49
|
-
test_capability(
|
49
|
+
test_capability("FastSetNextByIndex")
|
50
50
|
end
|
51
51
|
|
52
52
|
# @return [Boolean] +true+ if new Fields can be created on this Layer.
|
53
53
|
def can_create_field?
|
54
|
-
test_capability(
|
54
|
+
test_capability("CreateField")
|
55
55
|
end
|
56
56
|
|
57
57
|
# @return [Boolean] +true+ if the Layer supports creating new geometry
|
58
58
|
# fields on the current layer.
|
59
59
|
def can_create_geometry_field?
|
60
|
-
test_capability(
|
60
|
+
test_capability("CreateGeomField")
|
61
61
|
end
|
62
62
|
|
63
63
|
# @return [Boolean] +true+ if the Layer supports deleting existing fields
|
64
64
|
# on the current layer.
|
65
65
|
def can_delete_field?
|
66
|
-
test_capability(
|
66
|
+
test_capability("DeleteField")
|
67
67
|
end
|
68
68
|
|
69
69
|
# @return [Boolean] +true+ if the Layer supports reording fields on the
|
70
70
|
# current layer.
|
71
71
|
def can_reorder_fields?
|
72
|
-
test_capability(
|
72
|
+
test_capability("ReorderFields")
|
73
73
|
end
|
74
74
|
|
75
75
|
# @return [Boolean] +true+ if the Layer supports altering the defintition
|
76
76
|
# of an existing field on the current layer.
|
77
77
|
def can_alter_field_definition?
|
78
|
-
test_capability(
|
78
|
+
test_capability("AlterFieldDefn")
|
79
79
|
end
|
80
80
|
|
81
81
|
# @return [Boolean] +true+ if the Layer supports deleting Features.
|
82
82
|
def can_delete_feature?
|
83
|
-
test_capability(
|
83
|
+
test_capability("DeleteFeature")
|
84
84
|
end
|
85
85
|
|
86
86
|
# @return [Boolean] +true+ if :OFTString fields are guaranteed to be in
|
87
87
|
# UTF-8.
|
88
88
|
def strings_are_utf_8?
|
89
|
-
test_capability(
|
89
|
+
test_capability("StringsAsUTF8")
|
90
90
|
end
|
91
91
|
|
92
92
|
# @return [Boolean] +true+ if this Layer supports transactions. If not,
|
93
93
|
# #start_transaction, #commit_transaction, and #rollback_transaction
|
94
94
|
# will not work in a meaningful manner.
|
95
95
|
def supports_transactions?
|
96
|
-
test_capability(
|
96
|
+
test_capability("Transactions")
|
97
97
|
end
|
98
98
|
|
99
99
|
# @return [Boolean] +true+ if this Layer supports reading or writing
|
100
100
|
# curve geometries.
|
101
101
|
def supports_curve_geometries?
|
102
|
-
test_capability(
|
102
|
+
test_capability("CurveGeometries")
|
103
103
|
end
|
104
104
|
end
|
105
105
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "ogr/spatial_reference"
|
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
|
|
data/lib/ogr/feature.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require_relative
|
5
|
-
require_relative
|
3
|
+
require "date"
|
4
|
+
require_relative "../ogr"
|
5
|
+
require_relative "../gdal"
|
6
6
|
|
7
7
|
module OGR
|
8
8
|
class Feature
|
@@ -26,7 +26,7 @@ module OGR
|
|
26
26
|
fd_or_pointer.autorelease = false
|
27
27
|
fd_or_pointer
|
28
28
|
else
|
29
|
-
raise OGR::InvalidFeature,
|
29
|
+
raise OGR::InvalidFeature, "OGR::Feature must be instantiated with valid feature"
|
30
30
|
end
|
31
31
|
|
32
32
|
if !pointer.is_a?(FFI::Pointer) || pointer.null?
|
@@ -50,7 +50,7 @@ module OGR
|
|
50
50
|
def clone
|
51
51
|
# This new feature is owned by the caller and must be released accordingly.
|
52
52
|
feature_ptr = FFI::OGR::API.OGR_F_Clone(@c_pointer)
|
53
|
-
raise OGR::Failure,
|
53
|
+
raise OGR::Failure, "Unable to clone feature" if feature_ptr.nil?
|
54
54
|
|
55
55
|
OGR::Feature.new(feature_ptr)
|
56
56
|
end
|
@@ -59,7 +59,7 @@ module OGR
|
|
59
59
|
#
|
60
60
|
# @param file_path [String]
|
61
61
|
def dump_readable(file_path = nil)
|
62
|
-
file_ptr = file_path ? FFI::CPL::Conv.CPLOpenShared(file_path,
|
62
|
+
file_ptr = file_path ? FFI::CPL::Conv.CPLOpenShared(file_path, "w", false) : nil
|
63
63
|
FFI::OGR::API.OGR_F_DumpReadable(@c_pointer, file_ptr)
|
64
64
|
FFI::CPL::Conv.CPLCloseShared(file_ptr) if file_ptr
|
65
65
|
end
|
@@ -74,9 +74,9 @@ module OGR
|
|
74
74
|
# @raise [OGR::Failure]
|
75
75
|
# TODO: Implement +with_map+
|
76
76
|
def set_from!(_other_feature, _be_forgiving: false, with_map: nil)
|
77
|
-
raise NotImplementedError,
|
77
|
+
raise NotImplementedError, "with_map: is not yet supported" if with_map
|
78
78
|
|
79
|
-
OGR::ErrorHandling.handle_ogr_err(
|
79
|
+
OGR::ErrorHandling.handle_ogr_err("Unable to set from other feature") do
|
80
80
|
FFI::OGR::API.OGR_F_SetFrom(@c_pointer, other_feature_ptr)
|
81
81
|
end
|
82
82
|
end
|
@@ -159,7 +159,7 @@ module OGR
|
|
159
159
|
# @param index [Integer]
|
160
160
|
# @param value [String]
|
161
161
|
def set_field_binary(index, value)
|
162
|
-
raise TypeError,
|
162
|
+
raise TypeError, "value must be a binary string" unless value.is_a? String
|
163
163
|
|
164
164
|
value_ptr = FFI::MemoryPointer.new(:uchar, value.length)
|
165
165
|
value_ptr.put_bytes(0, value)
|
@@ -249,7 +249,7 @@ module OGR
|
|
249
249
|
# @param new_geometry [OGR::Geometry]
|
250
250
|
# @raise [OGR::Failure]
|
251
251
|
def set_geometry(new_geometry) # rubocop:disable Naming/AccessorMethodName
|
252
|
-
OGR::ErrorHandling.handle_ogr_err(
|
252
|
+
OGR::ErrorHandling.handle_ogr_err("Unable to set geometry on feature") do
|
253
253
|
FFI::OGR::API.OGR_F_SetGeometry(@c_pointer, new_geometry.c_pointer)
|
254
254
|
end
|
255
255
|
end
|
@@ -261,7 +261,7 @@ module OGR
|
|
261
261
|
def set_geometry_directly(new_geometry) # rubocop:disable Naming/AccessorMethodName
|
262
262
|
new_geometry.c_pointer.autorelease = false
|
263
263
|
|
264
|
-
OGR::ErrorHandling.handle_ogr_err(
|
264
|
+
OGR::ErrorHandling.handle_ogr_err("Unable to set geometry directly on feature") do
|
265
265
|
FFI::OGR::API.OGR_F_SetGeometryDirectly(@c_pointer, new_geometry.c_pointer)
|
266
266
|
end
|
267
267
|
end
|
@@ -272,7 +272,7 @@ module OGR
|
|
272
272
|
# @return [OGR::Geometry]
|
273
273
|
def steal_geometry
|
274
274
|
geometry_ptr = FFI::OGR::API.OGR_F_StealGeometry(@c_pointer)
|
275
|
-
raise OGR::Failure,
|
275
|
+
raise OGR::Failure, "Unable to steal geometry." if geometry_ptr.nil? || geometry_ptr.null?
|
276
276
|
|
277
277
|
OGR::Geometry.factory(geometry_ptr)
|
278
278
|
end
|
@@ -285,7 +285,7 @@ module OGR
|
|
285
285
|
# @param new_fid [Integer]
|
286
286
|
# @raise [OGR::Failure]
|
287
287
|
def fid=(new_fid)
|
288
|
-
OGR::ErrorHandling.handle_ogr_err(
|
288
|
+
OGR::ErrorHandling.handle_ogr_err("Unable to set FID") do
|
289
289
|
FFI::OGR::API.OGR_F_SetFID(@c_pointer, new_fid)
|
290
290
|
end
|
291
291
|
end
|
@@ -443,9 +443,9 @@ module OGR
|
|
443
443
|
binary_data_ptr.autorelease = false
|
444
444
|
|
445
445
|
byte_count = byte_count_ptr.read_int
|
446
|
-
string = byte_count.positive? ? binary_data_ptr.read_bytes(byte_count) :
|
446
|
+
string = byte_count.positive? ? binary_data_ptr.read_bytes(byte_count) : ""
|
447
447
|
|
448
|
-
string.unpack(
|
448
|
+
string.unpack("C*")
|
449
449
|
end
|
450
450
|
|
451
451
|
def field_as_date_time(index)
|
data/lib/ogr/field.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require_relative
|
5
|
-
require_relative
|
3
|
+
require "date"
|
4
|
+
require_relative "../ogr"
|
5
|
+
require_relative "../gdal"
|
6
6
|
|
7
7
|
module OGR
|
8
8
|
class Field
|
@@ -53,7 +53,7 @@ module OGR
|
|
53
53
|
|
54
54
|
# TODO: This blows up when another value type has been set.
|
55
55
|
def string
|
56
|
-
return
|
56
|
+
return "" if @c_struct[:string]&.null?
|
57
57
|
|
58
58
|
@c_struct[:string].read_string
|
59
59
|
end
|
@@ -150,7 +150,7 @@ module OGR
|
|
150
150
|
def binary
|
151
151
|
b = @c_struct[:binary]
|
152
152
|
|
153
|
-
b[:count].positive? ? b[:data].read_bytes(b[:count]) :
|
153
|
+
b[:count].positive? ? b[:data].read_bytes(b[:count]) : ""
|
154
154
|
end
|
155
155
|
|
156
156
|
# @param new_binary [String] Binary string of 8-bit, unsigned data (uchar).
|
data/lib/ogr/field_definition.rb
CHANGED
data/lib/ogr/geocoder.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative
|
4
|
-
require_relative
|
3
|
+
require_relative "../geometry_types/container"
|
4
|
+
require_relative "../geometry_types/surface"
|
5
5
|
|
6
6
|
module OGR
|
7
7
|
class GeometryCollection
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative
|
3
|
+
require_relative "line_string"
|
4
4
|
|
5
5
|
module OGR
|
6
6
|
class LinearRing < LineString
|
@@ -14,7 +14,7 @@ module OGR
|
|
14
14
|
def to_line_string
|
15
15
|
line_string = OGR::LineString.new
|
16
16
|
line_string.spatial_reference = spatial_reference if spatial_reference
|
17
|
-
line_string.import_from_wkt(to_wkt.sub(
|
17
|
+
line_string.import_from_wkt(to_wkt.sub("LINEARRING", "LINESTRING"))
|
18
18
|
|
19
19
|
line_string
|
20
20
|
end
|
data/lib/ogr/geometry.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative
|
4
|
-
require_relative
|
3
|
+
require_relative "../ogr"
|
4
|
+
require_relative "../gdal"
|
5
5
|
|
6
6
|
module OGR
|
7
7
|
module Geometry
|
@@ -213,7 +213,7 @@ module OGR
|
|
213
213
|
FFI::OGR::API.OGR_G_GetEnvelope3D(@c_pointer, envelope)
|
214
214
|
when 0 then return nil
|
215
215
|
else
|
216
|
-
raise
|
216
|
+
raise "Unknown envelope dimension."
|
217
217
|
end
|
218
218
|
|
219
219
|
return if envelope.null?
|
@@ -268,7 +268,7 @@ module OGR
|
|
268
268
|
# @param file_path [String] The text file to write to.
|
269
269
|
# @param prefix [String] The prefix to put on each line of output.
|
270
270
|
def dump_readable(file_path = nil, prefix: nil)
|
271
|
-
file_ptr = file_path ? FFI::CPL::Conv.CPLOpenShared(file_path,
|
271
|
+
file_ptr = file_path ? FFI::CPL::Conv.CPLOpenShared(file_path, "w", false) : nil
|
272
272
|
FFI::OGR::API.OGR_G_DumpReadable(@c_pointer, file_ptr, prefix)
|
273
273
|
FFI::CPL::Conv.CPLCloseShared(file_ptr) if file_ptr
|
274
274
|
end
|
@@ -363,7 +363,7 @@ module OGR
|
|
363
363
|
def ring?
|
364
364
|
FFI::OGR::API.OGR_G_IsRing(@c_pointer)
|
365
365
|
rescue GDAL::Error => e
|
366
|
-
return false if e.message.include?
|
366
|
+
return false if e.message.include? "IllegalArgumentException"
|
367
367
|
|
368
368
|
raise
|
369
369
|
end
|
@@ -467,7 +467,7 @@ module OGR
|
|
467
467
|
|
468
468
|
return if coord_trans_ptr.nil? || coord_trans_ptr.null?
|
469
469
|
|
470
|
-
OGR::ErrorHandling.handle_ogr_err(
|
470
|
+
OGR::ErrorHandling.handle_ogr_err("Unable to transform geometry") do
|
471
471
|
FFI::OGR::API.OGR_G_Transform(@c_pointer, coord_trans_ptr)
|
472
472
|
end
|
473
473
|
end
|
@@ -489,7 +489,7 @@ module OGR
|
|
489
489
|
new_spatial_ref_ptr = GDAL._pointer(OGR::SpatialReference, new_spatial_ref, autorelease: false)
|
490
490
|
return if new_spatial_ref_ptr.null?
|
491
491
|
|
492
|
-
OGR::ErrorHandling.handle_ogr_err(
|
492
|
+
OGR::ErrorHandling.handle_ogr_err("Unable to transform geometry") do
|
493
493
|
FFI::OGR::API.OGR_G_TransformTo(@c_pointer, new_spatial_ref_ptr)
|
494
494
|
end
|
495
495
|
end
|
@@ -552,7 +552,7 @@ module OGR
|
|
552
552
|
# @param wkb_data [String] Binary WKB data.
|
553
553
|
# @raise [OGR::Failure]
|
554
554
|
def import_from_wkb(wkb_data)
|
555
|
-
OGR::ErrorHandling.handle_ogr_err(
|
555
|
+
OGR::ErrorHandling.handle_ogr_err("Unable to import geometry from WKB") do
|
556
556
|
FFI::OGR::API.OGR_G_ImportFromWkb(@c_pointer, wkb_data, wkb_data.length)
|
557
557
|
end
|
558
558
|
end
|
@@ -592,7 +592,7 @@ module OGR
|
|
592
592
|
# @raise [OGR::Failure]
|
593
593
|
def to_wkt
|
594
594
|
GDAL._cpl_read_and_free_string do |output_ptr|
|
595
|
-
OGR::ErrorHandling.handle_ogr_err(
|
595
|
+
OGR::ErrorHandling.handle_ogr_err("Unable to export to WKT") do
|
596
596
|
FFI::OGR::API.OGR_G_ExportToWkt(@c_pointer, output_ptr)
|
597
597
|
end
|
598
598
|
end
|
@@ -602,7 +602,7 @@ module OGR
|
|
602
602
|
# @raise [OGR::Failure]
|
603
603
|
def to_iso_wkt
|
604
604
|
GDAL._cpl_read_and_free_string do |output_ptr|
|
605
|
-
OGR::ErrorHandling.handle_ogr_err(
|
605
|
+
OGR::ErrorHandling.handle_ogr_err("Unable to export to WKT") do
|
606
606
|
FFI::OGR::API.OGR_G_ExportToIsoWkt(@c_pointer, output_ptr)
|
607
607
|
end
|
608
608
|
end
|
@@ -683,7 +683,7 @@ module OGR
|
|
683
683
|
|
684
684
|
linear_ring.spatial_reference = line_string.spatial_reference.clone if line_string.spatial_reference
|
685
685
|
|
686
|
-
linear_ring.import_from_wkt(line_string.to_wkt.tr(
|
686
|
+
linear_ring.import_from_wkt(line_string.to_wkt.tr("LINESTRING", "LINEARRING"))
|
687
687
|
linear_ring.close_rings! if close_rings
|
688
688
|
|
689
689
|
linear_ring
|
@@ -75,7 +75,7 @@ module OGR
|
|
75
75
|
x_buffer, x_stride, y_buffer,
|
76
76
|
y_stride, z_buffer, z_stride)
|
77
77
|
|
78
|
-
log
|
78
|
+
log "Got different number of points than point_count in #point_values" unless num_points == point_count
|
79
79
|
|
80
80
|
x_array = x_buffer.read_array_of_double(buffer_size)
|
81
81
|
y_array = y_buffer.read_array_of_double(buffer_size)
|
data/lib/ogr/internal_helpers.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "time"
|
4
4
|
|
5
5
|
module OGR
|
6
6
|
module InternalHelpers
|
@@ -15,8 +15,8 @@ module OGR
|
|
15
15
|
# @param flag [String] 'w' for writing, 'r' for reading.
|
16
16
|
def _boolean_access_flag(flag)
|
17
17
|
case flag
|
18
|
-
when
|
19
|
-
when
|
18
|
+
when "w" then true
|
19
|
+
when "r" then false
|
20
20
|
else raise "Invalid access_flag '#{flag}'. Use 'r' or 'w'."
|
21
21
|
end
|
22
22
|
end
|
@@ -33,7 +33,7 @@ module OGR
|
|
33
33
|
case time_zone
|
34
34
|
when 0 then nil
|
35
35
|
when 1 then (Time.now.getlocal.utc_offset / 3600).to_s
|
36
|
-
when 100 then
|
36
|
+
when 100 then "+0"
|
37
37
|
else raise "Unable to process time zone: #{time_zone}"
|
38
38
|
end
|
39
39
|
end
|
data/lib/ogr/layer.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
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
|
3
|
+
require_relative "../ogr"
|
4
|
+
require_relative "../gdal"
|
5
|
+
require_relative "layer_mixins/ogr_feature_methods"
|
6
|
+
require_relative "layer_mixins/ogr_field_methods"
|
7
|
+
require_relative "layer_mixins/ogr_layer_method_methods"
|
8
|
+
require_relative "layer_mixins/ogr_query_filter_methods"
|
9
|
+
require_relative "layer_mixins/ogr_sql_methods"
|
10
10
|
|
11
11
|
module OGR
|
12
12
|
class Layer
|
@@ -42,7 +42,7 @@ module OGR
|
|
42
42
|
# TODO: This seems to occasionally lead to: 28352 illegal hardware
|
43
43
|
# instruction, and sometimes full crashes.
|
44
44
|
def sync_to_disk
|
45
|
-
OGR::ErrorHandling.handle_ogr_err(
|
45
|
+
OGR::ErrorHandling.handle_ogr_err("Unable to sync layer to disk") do
|
46
46
|
FFI::OGR::API.OGR_L_SyncToDisk(@c_pointer)
|
47
47
|
end
|
48
48
|
end
|