ffi-gdal 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- 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 +15 -5
- data/Dockerfile.gdal2 +1 -1
- data/Gemfile +12 -2
- data/README.md +13 -10
- 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 +15 -26
- 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 +11 -145
@@ -1,15 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require
|
11
|
-
require
|
12
|
-
require
|
3
|
+
require "ogr/geometries/geometry_collection"
|
4
|
+
require "ogr/geometries/geometry_collection_25d"
|
5
|
+
require "ogr/geometries/multi_line_string"
|
6
|
+
require "ogr/geometries/multi_line_string_25d"
|
7
|
+
require "ogr/geometries/multi_point"
|
8
|
+
require "ogr/geometries/multi_point_25d"
|
9
|
+
require "ogr/geometries/multi_polygon"
|
10
|
+
require "ogr/geometries/multi_polygon_25d"
|
11
|
+
require "ogr/geometries/polygon"
|
12
|
+
require "ogr/geometries/polygon_25d"
|
13
13
|
|
14
14
|
module OGR
|
15
15
|
module GeometryMixins
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require_relative
|
5
|
-
require_relative
|
3
|
+
require "ogr/spatial_reference"
|
4
|
+
require_relative "ewkb_record"
|
5
|
+
require_relative "wkb_record"
|
6
6
|
|
7
7
|
module OGR
|
8
8
|
module Geometry
|
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require_relative
|
3
|
+
require "bindata"
|
4
|
+
require "ffi-gdal"
|
5
|
+
require "ogr"
|
6
|
+
require_relative "wkb_record"
|
7
7
|
|
8
8
|
# rubocop:disable Naming/PredicateName
|
9
9
|
module OGR
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "ogr/geometry"
|
4
4
|
|
5
5
|
module OGR
|
6
6
|
module GeometryMixins
|
@@ -10,15 +10,12 @@ module OGR
|
|
10
10
|
return unless spatial_reference
|
11
11
|
|
12
12
|
self_as4326 =
|
13
|
-
if spatial_reference.authority_code ==
|
13
|
+
if spatial_reference.authority_code == "4326"
|
14
14
|
self
|
15
15
|
else
|
16
16
|
# NOTE: #clone here has overridden Ruby's clone and calls OGR_G_Clone;
|
17
17
|
# it's important to do this and
|
18
|
-
as4326
|
19
|
-
return unless as4326.transform_to!(OGR::SpatialReference.new.import_from_epsg(4326))
|
20
|
-
|
21
|
-
as4326
|
18
|
+
clone.tap { |as4326| as4326.transform_to!(OGR::SpatialReference.new.import_from_epsg(4326)) }
|
22
19
|
end
|
23
20
|
|
24
21
|
self_as4326 = self_as4326.buffer(0) unless valid?
|
@@ -64,7 +61,7 @@ module OGR
|
|
64
61
|
false
|
65
62
|
end
|
66
63
|
|
67
|
-
def to_vector(file_name, driver, layer_name:
|
64
|
+
def to_vector(file_name, driver, layer_name: "vectorized_geometry", spatial_reference: nil)
|
68
65
|
driver = OGR::Driver.by_name(driver)
|
69
66
|
|
70
67
|
data_source = driver.create_data_source(file_name)
|
@@ -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
|