ffi-gdal 1.0.0.beta6 → 1.0.0.beta11
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 +5 -5
- data/.rubocop.yml +54 -19
- data/.rubocop_todo.yml +65 -0
- data/.ruby-version +1 -1
- data/Gemfile +2 -0
- data/History.md +74 -0
- data/README.md +5 -0
- data/Rakefile +11 -1
- data/bitbucket-pipelines.yml +16 -0
- data/examples/extract_and_colorize.rb +7 -10
- data/examples/geometries.rb +68 -1
- data/examples/gridding.rb +2 -0
- data/examples/ogr_layer_to_layer.rb +2 -0
- data/examples/raster_erasing.rb +15 -8
- data/examples/remove_small_polygons.rb +2 -0
- data/examples/testing_gdal.rb +9 -2
- data/examples/warping.rb +23 -5
- data/ffi-gdal.gemspec +7 -4
- data/lib/ext/error_symbols.rb +2 -0
- data/lib/ext/ffi_library_function_checks.rb +2 -0
- data/lib/ext/float_ext.rb +2 -0
- data/lib/ext/narray_ext.rb +2 -0
- data/lib/ext/numeric_as_data_type.rb +2 -0
- data/lib/ext/to_bool.rb +5 -3
- data/lib/ffi-gdal.rb +2 -0
- data/lib/ffi/cpl.rb +2 -0
- data/lib/ffi/cpl/conv.rb +4 -2
- data/lib/ffi/cpl/error.rb +2 -0
- data/lib/ffi/cpl/hash_set.rb +2 -0
- data/lib/ffi/cpl/http.rb +2 -0
- data/lib/ffi/cpl/http_result.rb +2 -0
- data/lib/ffi/cpl/list.rb +2 -0
- data/lib/ffi/cpl/mime_part.rb +2 -0
- data/lib/ffi/cpl/minixml.rb +2 -0
- data/lib/ffi/cpl/port.rb +2 -0
- data/lib/ffi/cpl/progress.rb +2 -0
- data/lib/ffi/cpl/quad_tree.rb +2 -0
- data/lib/ffi/cpl/rect_obj.rb +2 -0
- data/lib/ffi/cpl/string.rb +2 -0
- data/lib/ffi/cpl/vsi.rb +2 -0
- data/lib/ffi/cpl/xml_node.rb +2 -0
- data/lib/ffi/gdal.rb +3 -3
- data/lib/ffi/gdal/alg.rb +2 -0
- data/lib/ffi/gdal/color_entry.rb +2 -0
- data/lib/ffi/gdal/exceptions.rb +2 -0
- data/lib/ffi/gdal/gcp.rb +2 -0
- data/lib/ffi/gdal/gdal.rb +2 -0
- data/lib/ffi/gdal/grid.rb +2 -0
- data/lib/ffi/gdal/grid_data_metrics_options.rb +2 -0
- data/lib/ffi/gdal/grid_inverse_distance_to_a_power_options.rb +2 -0
- data/lib/ffi/gdal/grid_moving_average_options.rb +2 -0
- data/lib/ffi/gdal/grid_nearest_neighbor_options.rb +2 -0
- data/lib/ffi/gdal/matching.rb +2 -0
- data/lib/ffi/gdal/rpc_info.rb +2 -0
- data/lib/ffi/gdal/transformer_info.rb +2 -0
- data/lib/ffi/gdal/version.rb +3 -1
- data/lib/ffi/gdal/vrt.rb +2 -0
- data/lib/ffi/gdal/warp_options.rb +9 -4
- data/lib/ffi/gdal/warper.rb +19 -1
- data/lib/ffi/ogr.rb +2 -0
- data/lib/ffi/ogr/api.rb +2 -0
- data/lib/ffi/ogr/contour_writer_info.rb +2 -0
- data/lib/ffi/ogr/core.rb +2 -0
- data/lib/ffi/ogr/envelope.rb +2 -0
- data/lib/ffi/ogr/envelope_3d.rb +2 -0
- data/lib/ffi/ogr/featurestyle.rb +2 -0
- data/lib/ffi/ogr/field.rb +2 -0
- data/lib/ffi/ogr/geocoding.rb +2 -0
- data/lib/ffi/ogr/srs_api.rb +3 -0
- data/lib/ffi/ogr/style_param.rb +2 -0
- data/lib/ffi/ogr/style_value.rb +2 -0
- data/lib/gdal.rb +3 -0
- data/lib/gdal/color_entry.rb +2 -0
- data/lib/gdal/color_entry_mixins/extensions.rb +2 -14
- data/lib/gdal/color_interpretation.rb +2 -0
- data/lib/gdal/color_table.rb +2 -0
- data/lib/gdal/color_table_mixins/extensions.rb +3 -17
- data/lib/gdal/color_table_types/cmyk.rb +2 -0
- data/lib/gdal/color_table_types/gray.rb +2 -0
- data/lib/gdal/color_table_types/hls.rb +2 -0
- data/lib/gdal/color_table_types/rgb.rb +2 -0
- data/lib/gdal/cpl_error_handler.rb +2 -0
- data/lib/gdal/data_type.rb +2 -0
- data/lib/gdal/dataset.rb +11 -7
- data/lib/gdal/dataset_mixins/algorithm_methods.rb +7 -4
- data/lib/gdal/dataset_mixins/extensions.rb +7 -47
- data/lib/gdal/dataset_mixins/matching.rb +4 -1
- data/lib/gdal/dataset_mixins/warp_methods.rb +52 -11
- data/lib/gdal/driver.rb +6 -8
- data/lib/gdal/driver_mixins/extensions.rb +2 -0
- data/lib/gdal/environment_methods.rb +2 -0
- data/lib/gdal/exceptions.rb +2 -0
- data/lib/gdal/geo_transform.rb +3 -3
- data/lib/gdal/geo_transform_mixins/extensions.rb +2 -17
- data/lib/gdal/grid.rb +4 -1
- data/lib/gdal/grid_algorithms.rb +2 -0
- data/lib/gdal/grid_algorithms/data_metrics_base.rb +2 -0
- data/lib/gdal/grid_algorithms/inverse_distance_to_a_power.rb +2 -0
- data/lib/gdal/grid_algorithms/metric_average_distance.rb +2 -0
- data/lib/gdal/grid_algorithms/metric_average_distance_pts.rb +2 -0
- data/lib/gdal/grid_algorithms/metric_count.rb +2 -0
- data/lib/gdal/grid_algorithms/metric_maximum.rb +2 -0
- data/lib/gdal/grid_algorithms/metric_minimum.rb +2 -0
- data/lib/gdal/grid_algorithms/metric_range.rb +2 -0
- data/lib/gdal/grid_algorithms/moving_average.rb +2 -0
- data/lib/gdal/grid_algorithms/nearest_neighbor.rb +2 -0
- data/lib/gdal/gridder.rb +11 -3
- data/lib/gdal/gridder/point_extracting.rb +3 -2
- data/lib/gdal/gridder_options.rb +2 -0
- data/lib/gdal/internal_helpers.rb +3 -4
- data/lib/gdal/logger.rb +2 -0
- data/lib/gdal/major_object.rb +2 -0
- data/lib/gdal/merger.rb +2 -0
- data/lib/gdal/options.rb +16 -13
- data/lib/gdal/raster_attribute_table.rb +2 -0
- data/lib/gdal/raster_attribute_table_mixins/extensions.rb +3 -16
- data/lib/gdal/raster_band.rb +11 -6
- data/lib/gdal/raster_band_classifier.rb +52 -19
- data/lib/gdal/raster_band_mixins/algorithm_extensions.rb +2 -0
- data/lib/gdal/raster_band_mixins/algorithm_methods.rb +12 -5
- data/lib/gdal/raster_band_mixins/coloring_extensions.rb +3 -1
- data/lib/gdal/raster_band_mixins/extensions.rb +6 -35
- data/lib/gdal/raster_band_mixins/io_extensions.rb +7 -4
- data/lib/gdal/rpc_info.rb +2 -0
- data/lib/gdal/transformer.rb +2 -0
- data/lib/gdal/transformers/approximate_transformer.rb +4 -1
- data/lib/gdal/transformers/base_general_image_projection_transformer.rb +4 -1
- data/lib/gdal/transformers/gcp_transformer.rb +6 -2
- data/lib/gdal/transformers/general_image_projection_transformer.rb +2 -0
- data/lib/gdal/transformers/general_image_projection_transformer2.rb +4 -1
- data/lib/gdal/transformers/general_image_projection_transformer3.rb +4 -1
- data/lib/gdal/transformers/geolocation_transformer.rb +4 -1
- data/lib/gdal/transformers/reprojection_transformer.rb +2 -0
- data/lib/gdal/transformers/rpc_transformer.rb +4 -1
- data/lib/gdal/transformers/tps_transformer.rb +2 -0
- data/lib/gdal/version_info.rb +9 -7
- data/lib/gdal/virtual_dataset.rb +2 -0
- data/lib/gdal/warp_operation.rb +2 -0
- data/lib/gdal/warp_options.rb +105 -35
- data/lib/ogr.rb +2 -0
- data/lib/ogr/coordinate_transformation.rb +2 -0
- data/lib/ogr/data_source.rb +5 -9
- data/lib/ogr/data_source_extensions.rb +2 -19
- data/lib/ogr/data_source_mixins/capability_methods.rb +2 -0
- data/lib/ogr/driver.rb +4 -6
- data/lib/ogr/driver_mixins/capability_methods.rb +2 -0
- data/lib/ogr/envelope.rb +4 -2
- data/lib/ogr/envelope_extensions.rb +2 -22
- data/lib/ogr/error_handling.rb +3 -1
- data/lib/ogr/exceptions.rb +3 -1
- data/lib/ogr/feature.rb +17 -9
- data/lib/ogr/feature_definition.rb +7 -4
- data/lib/ogr/feature_definition_extensions.rb +2 -18
- data/lib/ogr/feature_extensions.rb +2 -27
- data/lib/ogr/field.rb +5 -1
- data/lib/ogr/field_definition.rb +5 -6
- data/lib/ogr/geocoder.rb +2 -0
- data/lib/ogr/geometries/geometry_collection.rb +2 -0
- data/lib/ogr/geometries/geometry_collection_25d.rb +2 -0
- data/lib/ogr/geometries/line_string.rb +2 -1
- data/lib/ogr/geometries/line_string_25d.rb +2 -0
- data/lib/ogr/geometries/linear_ring.rb +2 -0
- data/lib/ogr/geometries/multi_line_string.rb +2 -0
- data/lib/ogr/geometries/multi_line_string_25d.rb +2 -0
- data/lib/ogr/geometries/multi_point.rb +2 -0
- data/lib/ogr/geometries/multi_point_25d.rb +2 -0
- data/lib/ogr/geometries/multi_polygon.rb +2 -0
- data/lib/ogr/geometries/multi_polygon_25d.rb +2 -0
- data/lib/ogr/geometries/none_geometry.rb +2 -0
- data/lib/ogr/geometries/point.rb +2 -0
- data/lib/ogr/geometries/point_25d.rb +2 -0
- data/lib/ogr/geometries/polygon.rb +2 -0
- data/lib/ogr/geometries/polygon_25d.rb +2 -0
- data/lib/ogr/geometries/unknown_geometry.rb +2 -0
- data/lib/ogr/geometry.rb +3 -4
- data/lib/ogr/geometry_field_definition.rb +3 -4
- data/lib/ogr/geometry_mixins/container_mixins.rb +2 -0
- data/lib/ogr/geometry_mixins/extensions.rb +10 -39
- data/lib/ogr/geometry_types/container.rb +2 -0
- data/lib/ogr/geometry_types/curve.rb +3 -1
- data/lib/ogr/geometry_types/surface.rb +2 -0
- data/lib/ogr/internal_helpers.rb +2 -0
- data/lib/ogr/layer.rb +5 -1
- data/lib/ogr/layer_mixins/capability_methods.rb +2 -0
- data/lib/ogr/layer_mixins/extensions.rb +9 -27
- data/lib/ogr/layer_mixins/ogr_feature_methods.rb +6 -12
- data/lib/ogr/layer_mixins/ogr_field_methods.rb +10 -14
- data/lib/ogr/layer_mixins/ogr_layer_method_methods.rb +2 -0
- data/lib/ogr/layer_mixins/ogr_query_filter_methods.rb +8 -3
- data/lib/ogr/layer_mixins/ogr_sql_methods.rb +3 -3
- data/lib/ogr/spatial_reference.rb +12 -2
- data/lib/ogr/spatial_reference_extensions.rb +2 -26
- data/lib/ogr/spatial_reference_mixins/coordinate_system_getter_setters.rb +12 -5
- data/lib/ogr/spatial_reference_mixins/exporters.rb +2 -0
- data/lib/ogr/spatial_reference_mixins/importers.rb +6 -2
- data/lib/ogr/spatial_reference_mixins/morphers.rb +2 -0
- data/lib/ogr/spatial_reference_mixins/parameter_getter_setters.rb +2 -0
- data/lib/ogr/spatial_reference_mixins/type_checks.rb +2 -0
- data/lib/ogr/style_table.rb +2 -0
- data/lib/ogr/style_table_extensions.rb +2 -10
- data/lib/ogr/style_tool.rb +2 -0
- data/spec/ffi-gdal_spec.rb +2 -0
- data/spec/integration/gdal/color_table_info_spec.rb +2 -0
- data/spec/integration/gdal/dataset_info_spec.rb +15 -13
- data/spec/integration/gdal/driver_info_spec.rb +3 -1
- data/spec/integration/gdal/geo_transform_info_spec.rb +2 -0
- data/spec/integration/gdal/gridder_spec.rb +2 -0
- data/spec/integration/gdal/raster_attribute_table_info_spec.rb +2 -0
- data/spec/integration/gdal/raster_band_algorithms_spec.rb +2 -0
- data/spec/integration/gdal/raster_band_info_spec.rb +37 -15
- data/spec/integration/ogr/layer_spec.rb +2 -6
- data/spec/spec_helper.rb +3 -1
- data/spec/support/images/123.tiff +0 -0
- data/spec/support/integration_help.rb +2 -0
- data/spec/support/shared_contexts.rb +2 -0
- data/spec/support/shared_examples/gdal/major_object_examples.rb +2 -0
- data/spec/support/shared_examples/ogr/{a_25D_geometry.rb → a_25d_geometry.rb} +2 -0
- data/spec/support/shared_examples/ogr/a_container_geometry.rb +2 -0
- data/spec/support/shared_examples/ogr/a_geometry.rb +3 -1
- data/spec/support/shared_examples/ogr/a_line_string.rb +2 -0
- data/spec/unit/ext/error_symbols_spec.rb +2 -0
- data/spec/unit/ext/numeric_as_data_type_spec.rb +2 -0
- data/spec/unit/ffi/gdal_spec.rb +3 -0
- data/spec/unit/gdal/color_entry_spec.rb +2 -0
- data/spec/unit/gdal/color_interpretation_spec.rb +2 -0
- data/spec/unit/gdal/color_table_mixins/extensions_spec.rb +2 -0
- data/spec/unit/gdal/color_table_spec.rb +2 -0
- data/spec/unit/gdal/data_type_spec.rb +2 -0
- data/spec/unit/gdal/dataset_mixins/warp_methods_spec.rb +55 -0
- data/spec/unit/gdal/dataset_spec.rb +2 -0
- data/spec/unit/gdal/driver_mixins/extensions_spec.rb +2 -0
- data/spec/unit/gdal/driver_spec.rb +2 -0
- data/spec/unit/gdal/environment_methods_spec.rb +2 -0
- data/spec/unit/gdal/geo_transform_mixins/extensions_spec.rb +2 -0
- data/spec/unit/gdal/geo_transform_spec.rb +2 -13
- data/spec/unit/gdal/grid_spec.rb +10 -0
- data/spec/unit/gdal/gridder/point_extracting_spec.rb +2 -0
- data/spec/unit/gdal/gridder_options_spec.rb +2 -0
- data/spec/unit/gdal/gridder_spec.rb +42 -0
- data/spec/unit/gdal/internal_helpers_spec.rb +2 -0
- data/spec/unit/gdal/major_object_spec.rb +2 -0
- data/spec/unit/gdal/options_spec.rb +28 -1
- data/spec/unit/gdal/raster_attribute_table_spec.rb +2 -0
- data/spec/unit/gdal/raster_band_classifier_spec.rb +43 -5
- data/spec/unit/gdal/raster_band_mixins/extensions_spec.rb +2 -0
- data/spec/unit/gdal/raster_band_mixins/io_extensions_spec.rb +2 -0
- data/spec/unit/gdal/raster_band_spec.rb +2 -0
- data/spec/unit/gdal/rpc_info_spec.rb +2 -0
- data/spec/unit/gdal/version_info_spec.rb +2 -0
- data/spec/unit/gdal/virtual_dataset_spec.rb +2 -0
- data/spec/unit/gdal/warp_operation_spec.rb +2 -0
- data/spec/unit/gdal/warp_options_spec.rb +338 -0
- data/spec/unit/ogr/coordinate_transformation_spec.rb +2 -0
- data/spec/unit/ogr/data_source_mixins/capability_methods_spec.rb +2 -0
- data/spec/unit/ogr/data_source_spec.rb +2 -0
- data/spec/unit/ogr/driver_mixins/capability_methods_spec.rb +2 -0
- data/spec/unit/ogr/driver_spec.rb +3 -1
- data/spec/unit/ogr/envelope_spec.rb +2 -0
- data/spec/unit/ogr/feature_definition_spec.rb +2 -19
- data/spec/unit/ogr/feature_extensions_spec.rb +3 -1
- data/spec/unit/ogr/feature_spec.rb +3 -3
- data/spec/unit/ogr/field_definition_spec.rb +2 -19
- data/spec/unit/ogr/field_spec.rb +3 -1
- data/spec/unit/ogr/geometries/geometry_collection_25d_spec.rb +2 -0
- data/spec/unit/ogr/geometries/geometry_collection_spec.rb +2 -0
- data/spec/unit/ogr/geometries/line_string_25d_spec.rb +2 -0
- data/spec/unit/ogr/geometries/line_string_spec.rb +2 -0
- data/spec/unit/ogr/geometries/linear_ring_spec.rb +2 -0
- data/spec/unit/ogr/geometries/multi_line_string_25d_spec.rb +2 -0
- data/spec/unit/ogr/geometries/multi_line_string_spec.rb +2 -0
- data/spec/unit/ogr/geometries/multi_point_25d_spec.rb +2 -0
- data/spec/unit/ogr/geometries/multi_point_spec.rb +2 -0
- data/spec/unit/ogr/geometries/multi_polygon_25d_spec.rb +2 -0
- data/spec/unit/ogr/geometries/multi_polygon_spec.rb +2 -0
- data/spec/unit/ogr/geometries/none_geometry_spec.rb +2 -0
- data/spec/unit/ogr/geometries/point_25d_spec.rb +2 -0
- data/spec/unit/ogr/geometries/point_spec.rb +2 -0
- data/spec/unit/ogr/geometries/polygon_25d_spec.rb +2 -0
- data/spec/unit/ogr/geometries/polygon_spec.rb +2 -0
- data/spec/unit/ogr/geometries/unknown_geometry_spec.rb +2 -0
- data/spec/unit/ogr/geometry_field_definition_spec.rb +2 -16
- data/spec/unit/ogr/geometry_spec.rb +2 -0
- data/spec/unit/ogr/internal_helpers_spec.rb +2 -0
- data/spec/unit/ogr/layer_mixins/capability_methods_spec.rb +2 -0
- data/spec/unit/ogr/layer_mixins/ogr_feature_methods_spec.rb +2 -0
- data/spec/unit/ogr/layer_mixins/ogr_field_methods_spec.rb +2 -0
- data/spec/unit/ogr/layer_mixins/ogr_layer_method_methods_spec.rb +2 -0
- data/spec/unit/ogr/layer_mixins/ogr_query_filter_methods_spec.rb +2 -0
- data/spec/unit/ogr/layer_mixins/ogr_sql_methods_spec.rb +2 -0
- data/spec/unit/ogr/layer_spec.rb +2 -0
- data/spec/unit/ogr/spatial_reference_mixins/coordinate_system_getter_setters_spec.rb +2 -0
- data/spec/unit/ogr/spatial_reference_mixins/exporters_spec.rb +19 -15
- data/spec/unit/ogr/spatial_reference_mixins/importers_spec.rb +2 -0
- data/spec/unit/ogr/spatial_reference_mixins/morphers_spec.rb +9 -7
- data/spec/unit/ogr/spatial_reference_mixins/parameter_getter_setters_spec.rb +2 -0
- data/spec/unit/ogr/spatial_reference_mixins/type_checks_spec.rb +2 -0
- data/spec/unit/ogr/spatial_reference_spec.rb +4 -2
- data/spec/unit/ogr/style_table_spec.rb +2 -26
- data/spec/unit/ogr/style_tool_spec.rb +2 -0
- data/spec/unit/version_info_spec.rb +2 -0
- metadata +47 -15
- data/lib/ogr/field_definition_extensions.rb +0 -22
- data/lib/ogr/geometry_field_definition_extensions.rb +0 -19
data/lib/ogr/geometries/point.rb
CHANGED
data/lib/ogr/geometry.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative '../ogr'
|
2
4
|
require_relative 'geometry_mixins/extensions'
|
3
5
|
require_relative '../gdal'
|
@@ -240,7 +242,6 @@ module OGR
|
|
240
242
|
end
|
241
243
|
|
242
244
|
# @return [Fixnum]
|
243
|
-
# @todo This regularly crashes, so disabling it.
|
244
245
|
def centroid
|
245
246
|
point = is_3d? ? OGR::Point25D.new : OGR::Point.new
|
246
247
|
|
@@ -618,9 +619,7 @@ module OGR
|
|
618
619
|
|
619
620
|
linear_ring = OGR::LinearRing.new
|
620
621
|
|
621
|
-
if line_string.spatial_reference
|
622
|
-
linear_ring.spatial_reference = line_string.spatial_reference.clone
|
623
|
-
end
|
622
|
+
linear_ring.spatial_reference = line_string.spatial_reference.clone if line_string.spatial_reference
|
624
623
|
|
625
624
|
linear_ring.import_from_wkt(line_string.to_wkt.tr('LINESTRING', 'LINEARRING'))
|
626
625
|
linear_ring.close_rings! if close_rings
|
@@ -1,9 +1,7 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module OGR
|
4
4
|
class GeometryFieldDefinition
|
5
|
-
include GeometryFieldDefinitionExtensions
|
6
|
-
|
7
5
|
# @return [FFI::Pointer]
|
8
6
|
attr_reader :c_pointer
|
9
7
|
|
@@ -83,7 +81,8 @@ module OGR
|
|
83
81
|
|
84
82
|
FFI::OGR::API.OGR_GFld_SetSpatialRef(
|
85
83
|
@c_pointer,
|
86
|
-
spatial_ref_ptr
|
84
|
+
spatial_ref_ptr
|
85
|
+
)
|
87
86
|
end
|
88
87
|
|
89
88
|
# @return [Boolean]
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'json'
|
2
4
|
|
3
5
|
module OGR
|
@@ -7,18 +9,18 @@ module OGR
|
|
7
9
|
def utm_zone
|
8
10
|
return unless spatial_reference
|
9
11
|
|
10
|
-
if spatial_reference.authority_code == '4326'
|
11
|
-
|
12
|
+
if spatial_reference.authority_code == '4326'
|
13
|
+
self_as4326 = self
|
12
14
|
else
|
13
|
-
|
14
|
-
|
15
|
+
self_as4326 = dup
|
16
|
+
self_as4326.transform_to!(OGR::SpatialReference.new_from_epsg(4326))
|
15
17
|
end
|
16
18
|
|
17
|
-
|
19
|
+
self_as4326 = self_as4326.buffer(0) unless self_as4326.valid?
|
18
20
|
|
19
|
-
return unless
|
21
|
+
return unless self_as4326.point_on_surface.x
|
20
22
|
|
21
|
-
((
|
23
|
+
((self_as4326.point_on_surface.x + 180) / 6.to_f).floor + 1
|
22
24
|
end
|
23
25
|
|
24
26
|
# @return [Boolean]
|
@@ -53,35 +55,6 @@ module OGR
|
|
53
55
|
!valid?
|
54
56
|
end
|
55
57
|
|
56
|
-
# @return [Hash]
|
57
|
-
def as_json(options = nil)
|
58
|
-
json = {
|
59
|
-
coordinate_dimension: coordinate_dimension,
|
60
|
-
geometry_count: geometry_count,
|
61
|
-
dimension: dimension,
|
62
|
-
is_empty: empty?,
|
63
|
-
is_ring: ring?,
|
64
|
-
is_simple: simple?,
|
65
|
-
is_valid: valid?,
|
66
|
-
name: name,
|
67
|
-
point_count: point_count,
|
68
|
-
spatial_reference: spatial_reference.nil? ? nil : spatial_reference.as_json(options),
|
69
|
-
type: type_to_name,
|
70
|
-
wkb_size: wkb_size
|
71
|
-
}
|
72
|
-
|
73
|
-
json[:area] = area if respond_to? :area
|
74
|
-
json[:length] = length if respond_to? :length
|
75
|
-
json[:points] = points if respond_to? :points
|
76
|
-
|
77
|
-
json
|
78
|
-
end
|
79
|
-
|
80
|
-
# @return [String]
|
81
|
-
def to_json(options = nil)
|
82
|
-
as_json(options).to_json
|
83
|
-
end
|
84
|
-
|
85
58
|
def collection?
|
86
59
|
false
|
87
60
|
end
|
@@ -97,9 +70,7 @@ module OGR
|
|
97
70
|
# field = FieldDefinition.new('Name', :OFTString)
|
98
71
|
# field.width = 32
|
99
72
|
|
100
|
-
unless layer
|
101
|
-
raise OGR::InvalidLayer, "Unable to create layer '#{layer_name}'."
|
102
|
-
end
|
73
|
+
raise OGR::InvalidLayer, "Unable to create layer '#{layer_name}'." unless layer
|
103
74
|
|
104
75
|
feature = layer.create_feature(layer_name)
|
105
76
|
feature.geometry = self
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module OGR
|
2
4
|
module GeometryTypes
|
3
5
|
module Curve
|
@@ -102,7 +104,7 @@ module OGR
|
|
102
104
|
y_buffer = FFI::MemoryPointer.new(:buffer_out, buffer_size)
|
103
105
|
z_buffer = FFI::MemoryPointer.new(:buffer_out, buffer_size) if coordinate_dimension == 3
|
104
106
|
|
105
|
-
FFI::OGR::API.OGR_G_GetPoints(@c_pointer,
|
107
|
+
num_points = FFI::OGR::API.OGR_G_GetPoints(@c_pointer,
|
106
108
|
x_buffer, x_stride, y_buffer,
|
107
109
|
y_stride, z_buffer, z_stride)
|
108
110
|
|
data/lib/ogr/internal_helpers.rb
CHANGED
data/lib/ogr/layer.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative '../ogr'
|
2
4
|
require_relative '../gdal'
|
3
5
|
require_relative 'layer_mixins/extensions'
|
@@ -20,7 +22,9 @@ module OGR
|
|
20
22
|
include LayerMixins::OGRQueryFilterMethods
|
21
23
|
include LayerMixins::OGRSQLMethods
|
22
24
|
|
23
|
-
|
25
|
+
FFI::OGR::Core::OGR_ALTER.constants.each do |_name, obj|
|
26
|
+
const_set(obj.ruby_name, obj.value.to_i(16))
|
27
|
+
end
|
24
28
|
|
25
29
|
# @return [FFI::Pointer] C pointer to the C Layer.
|
26
30
|
attr_reader :c_pointer
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'json'
|
2
4
|
|
3
5
|
module OGR
|
@@ -22,7 +24,7 @@ module OGR
|
|
22
24
|
|
23
25
|
begin
|
24
26
|
yield feature
|
25
|
-
rescue
|
27
|
+
rescue StandardError
|
26
28
|
feature.destroy!
|
27
29
|
raise
|
28
30
|
end
|
@@ -50,7 +52,7 @@ module OGR
|
|
50
52
|
|
51
53
|
begin
|
52
54
|
yield feature_ptr
|
53
|
-
rescue
|
55
|
+
rescue StandardError
|
54
56
|
FFI::OGR::API.OGR_F_Destroy(feature_ptr)
|
55
57
|
raise
|
56
58
|
end
|
@@ -66,7 +68,7 @@ module OGR
|
|
66
68
|
#
|
67
69
|
# @return [Array<OGR::Feature>]
|
68
70
|
def features
|
69
|
-
each_feature.map
|
71
|
+
each_feature.map(&:clone)
|
70
72
|
end
|
71
73
|
|
72
74
|
# @return [OGR::Polygon] A polygon derived from a LinearRing that connects
|
@@ -122,6 +124,10 @@ module OGR
|
|
122
124
|
x_ptr = FFI::MemoryPointer.new(:double)
|
123
125
|
y_ptr = FFI::MemoryPointer.new(:double)
|
124
126
|
|
127
|
+
# This block is intentionally long simply for the sake of performance.
|
128
|
+
# I've tried refactoring chunks of this out to separate methods and
|
129
|
+
# performance suffers greatly. Since this is a key part of gridding (at
|
130
|
+
# least at this point), it needs to be as fast as possible.
|
125
131
|
each_feature_pointer do |feature_ptr|
|
126
132
|
field_values = field_indices.map.with_index do |j, attribute_index|
|
127
133
|
FFI::OGR::API.send("OGR_F_GetFieldAs#{with_attributes.values[attribute_index].capitalize}", feature_ptr, j)
|
@@ -229,30 +235,6 @@ module OGR
|
|
229
235
|
found_z_geom
|
230
236
|
end
|
231
237
|
|
232
|
-
# @return [Hash]
|
233
|
-
def as_json(options = nil)
|
234
|
-
{
|
235
|
-
layer: {
|
236
|
-
extent: extent.as_json(options),
|
237
|
-
feature_count: feature_count,
|
238
|
-
feature_definition: feature_definition.as_json(options),
|
239
|
-
features: each_feature.map { |f| f.as_json(options) },
|
240
|
-
fid_column: fid_column,
|
241
|
-
geometry_column: geometry_column,
|
242
|
-
geometry_type: geometry_type,
|
243
|
-
name: name,
|
244
|
-
spatial_reference: spatial_reference ? spatial_reference.as_json(options) : nil,
|
245
|
-
style_table: style_table ? style_table.as_json(options) : nil
|
246
|
-
},
|
247
|
-
metadata: nil # all_metadata
|
248
|
-
}
|
249
|
-
end
|
250
|
-
|
251
|
-
# @return [String]
|
252
|
-
def to_json(options = nil)
|
253
|
-
as_json(options).to_json
|
254
|
-
end
|
255
|
-
|
256
238
|
private
|
257
239
|
|
258
240
|
# @param geometry_ptr [FFI::Pointer]
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module OGR
|
2
4
|
module LayerMixins
|
3
5
|
module OGRFeatureMethods
|
@@ -23,9 +25,7 @@ module OGR
|
|
23
25
|
# @param feature [OGR::Feature] [description]
|
24
26
|
# @return [Boolean]
|
25
27
|
def create_feature(feature)
|
26
|
-
unless can_sequential_write?
|
27
|
-
raise OGR::UnsupportedOperation, 'This layer does not support feature creation.'
|
28
|
-
end
|
28
|
+
raise OGR::UnsupportedOperation, 'This layer does not support feature creation.' unless can_sequential_write?
|
29
29
|
|
30
30
|
ogr_err = FFI::OGR::API.OGR_L_CreateFeature(@c_pointer, feature.c_pointer)
|
31
31
|
|
@@ -39,9 +39,7 @@ module OGR
|
|
39
39
|
# @raise [OGR::Failure] When trying to delete a feature with an ID that
|
40
40
|
# does not exist.
|
41
41
|
def delete_feature(feature_id)
|
42
|
-
unless can_delete_feature?
|
43
|
-
raise OGR::UnsupportedOperation, 'This layer does not support feature deletion.'
|
44
|
-
end
|
42
|
+
raise OGR::UnsupportedOperation, 'This layer does not support feature deletion.' unless can_delete_feature?
|
45
43
|
|
46
44
|
ogr_err = FFI::OGR::API.OGR_L_DeleteFeature(@c_pointer, feature_id)
|
47
45
|
|
@@ -61,9 +59,7 @@ module OGR
|
|
61
59
|
#
|
62
60
|
# @param new_feature [OGR::Feature, FFI::Pointer]
|
63
61
|
def feature=(new_feature)
|
64
|
-
unless can_random_write?
|
65
|
-
raise OGR::UnsupportedOperation, '#feature= not supported by this Layer'
|
66
|
-
end
|
62
|
+
raise OGR::UnsupportedOperation, '#feature= not supported by this Layer' unless can_random_write?
|
67
63
|
|
68
64
|
new_feature_ptr = GDAL._pointer(OGR::Feature, new_feature)
|
69
65
|
raise OGR::InvalidFeature if new_feature_ptr.nil? || new_feature_ptr.null?
|
@@ -77,9 +73,7 @@ module OGR
|
|
77
73
|
# be <= +feature_count+, but no checking is done to ensure.
|
78
74
|
# @return [OGR::Feature, nil]
|
79
75
|
def feature(index)
|
80
|
-
unless can_random_read?
|
81
|
-
raise OGR::UnsupportedOperation, '#feature(index) not supported by this Layer'
|
82
|
-
end
|
76
|
+
raise OGR::UnsupportedOperation, '#feature(index) not supported by this Layer' unless can_random_read?
|
83
77
|
|
84
78
|
feature_pointer = FFI::OGR::API.OGR_L_GetFeature(@c_pointer, index)
|
85
79
|
return nil if feature_pointer.null?
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module OGR
|
2
4
|
module LayerMixins
|
3
5
|
module OGRFieldMethods
|
@@ -10,9 +12,7 @@ module OGR
|
|
10
12
|
# different form, depending on the limitations of the format driver.
|
11
13
|
# @return [Boolean]
|
12
14
|
def create_field(field_definition, approx_ok = false)
|
13
|
-
unless can_create_field?
|
14
|
-
raise OGR::UnsupportedOperation, 'This layer does not support field creation.'
|
15
|
-
end
|
15
|
+
raise OGR::UnsupportedOperation, 'This layer does not support field creation.' unless can_create_field?
|
16
16
|
|
17
17
|
field_definition_ptr = GDAL._pointer(OGR::FieldDefinition, field_definition)
|
18
18
|
ogr_err = FFI::OGR::API.OGR_L_CreateField(@c_pointer, field_definition_ptr, approx_ok)
|
@@ -24,9 +24,7 @@ module OGR
|
|
24
24
|
#
|
25
25
|
# @return +true+ if successful, otherwise raises an OGR exception.
|
26
26
|
def delete_field(field_id)
|
27
|
-
unless can_delete_field?
|
28
|
-
raise OGR::UnsupportedOperation, 'This driver does not support field deletion.'
|
29
|
-
end
|
27
|
+
raise OGR::UnsupportedOperation, 'This driver does not support field deletion.' unless can_delete_field?
|
30
28
|
|
31
29
|
ogr_err = FFI::OGR::API.OGR_L_DeleteField(@c_pointer, field_id)
|
32
30
|
|
@@ -37,9 +35,7 @@ module OGR
|
|
37
35
|
# which they should be reordered. I.e. [0, 2, 3, 1, 4].
|
38
36
|
# @return [Boolean]
|
39
37
|
def reorder_fields(*new_order)
|
40
|
-
unless can_reorder_fields?
|
41
|
-
raise OGR::UnsupportedOperation, 'This driver does not support field reordering.'
|
42
|
-
end
|
38
|
+
raise OGR::UnsupportedOperation, 'This driver does not support field reordering.' unless can_reorder_fields?
|
43
39
|
|
44
40
|
return false if new_order.empty?
|
45
41
|
return false if new_order.any? { |i| i > feature_definition.field_count }
|
@@ -56,9 +52,7 @@ module OGR
|
|
56
52
|
# @param old_position [Fixnum]
|
57
53
|
# @param new_position [Fixnum]
|
58
54
|
def reorder_field(old_position, new_position)
|
59
|
-
unless can_reorder_fields?
|
60
|
-
raise OGR::UnsupportedOperation, 'This driver does not support field reordering.'
|
61
|
-
end
|
55
|
+
raise OGR::UnsupportedOperation, 'This driver does not support field reordering.' unless can_reorder_fields?
|
62
56
|
|
63
57
|
ogr_err = FFI::OGR::API.OGR_L_ReorderField(@c_pointer, old_position, new_position)
|
64
58
|
|
@@ -81,7 +75,8 @@ module OGR
|
|
81
75
|
@c_pointer,
|
82
76
|
field_index,
|
83
77
|
new_field_definition_ptr,
|
84
|
-
flags
|
78
|
+
flags
|
79
|
+
)
|
85
80
|
|
86
81
|
ogr_err.handle_result
|
87
82
|
end
|
@@ -115,7 +110,8 @@ module OGR
|
|
115
110
|
ogr_err = FFI::OGR::API.OGR_L_CreateGeomField(
|
116
111
|
@c_pointer,
|
117
112
|
geometry_field_definition_ptr,
|
118
|
-
approx_ok
|
113
|
+
approx_ok
|
114
|
+
)
|
119
115
|
|
120
116
|
ogr_err.handle_result
|
121
117
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module OGR
|
2
4
|
module LayerMixins
|
3
5
|
module OGRQueryFilterMethods
|
@@ -29,7 +31,8 @@ module OGR
|
|
29
31
|
geometry_ptr = GDAL._pointer(OGR::Geometry, geometry)
|
30
32
|
|
31
33
|
FFI::OGR::API.OGR_L_SetSpatialFilterEx(
|
32
|
-
@c_pointer, geometry_field_index, geometry_ptr
|
34
|
+
@c_pointer, geometry_field_index, geometry_ptr
|
35
|
+
)
|
33
36
|
end
|
34
37
|
|
35
38
|
# Only features that geometrically intersect the given rectangle will be
|
@@ -47,7 +50,8 @@ module OGR
|
|
47
50
|
min_x,
|
48
51
|
min_y,
|
49
52
|
max_x,
|
50
|
-
max_y
|
53
|
+
max_y
|
54
|
+
)
|
51
55
|
end
|
52
56
|
|
53
57
|
# Only features that geometrically intersect the given rectangle will be
|
@@ -68,7 +72,8 @@ module OGR
|
|
68
72
|
min_x,
|
69
73
|
min_y,
|
70
74
|
max_x,
|
71
|
-
max_y
|
75
|
+
max_y
|
76
|
+
)
|
72
77
|
end
|
73
78
|
|
74
79
|
# Sets the attribute query string to be used when fetching Features using
|