ffi-gdal 1.0.0.beta3 → 1.0.0.beta4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/.rubocop.yml +62 -0
- data/Gemfile +1 -1
- data/History.md +53 -28
- data/README.md +6 -0
- data/Rakefile +23 -1
- data/examples/extract_and_colorize.rb +21 -22
- data/examples/geometries.rb +2 -2
- data/examples/gridding.rb +106 -0
- data/examples/ogr_layer_to_layer.rb +1 -1
- data/examples/points.txt +127 -0
- data/examples/testing_gdal.rb +3 -4
- data/ffi-gdal.gemspec +3 -2
- data/lib/ext/error_symbols.rb +2 -57
- data/lib/ext/ffi_library_function_checks.rb +26 -0
- data/lib/ext/float_ext.rb +2 -2
- data/lib/ext/narray_ext.rb +2 -0
- data/lib/ext/numeric_as_data_type.rb +19 -0
- data/lib/ext/to_bool.rb +4 -4
- data/lib/ffi/cpl/conv.rb +132 -0
- data/lib/ffi/cpl/error.rb +67 -0
- data/lib/ffi/cpl/hash_set.rb +39 -0
- data/lib/ffi/cpl/http.rb +25 -0
- data/lib/ffi/cpl/http_result.rb +18 -0
- data/lib/ffi/cpl/list.rb +38 -0
- data/lib/ffi/cpl/mime_part.rb +11 -0
- data/lib/ffi/cpl/minixml.rb +47 -0
- data/lib/ffi/cpl/port.rb +23 -0
- data/lib/ffi/cpl/quad_tree.rb +51 -0
- data/lib/ffi/{ogr/ogr_envelope.rb → cpl/rect_obj.rb} +3 -3
- data/lib/ffi/cpl/string.rb +95 -0
- data/lib/ffi/cpl/vsi.rb +115 -0
- data/lib/ffi/cpl/xml_node.rb +6 -6
- data/lib/ffi/gdal/alg.rb +385 -0
- data/lib/ffi/gdal/{gdal_color_entry.rb → color_entry.rb} +1 -2
- data/lib/ffi/gdal/exceptions.rb +6 -0
- data/lib/ffi/gdal/{gdal_gcp.rb → gcp.rb} +1 -3
- data/lib/ffi/gdal/{gdal_h.rb → gdal.rb} +253 -252
- data/lib/ffi/gdal/grid.rb +58 -0
- data/lib/ffi/gdal/{gdal_grid_data_metrics_options.rb → grid_data_metrics_options.rb} +1 -2
- data/lib/ffi/gdal/{gdal_grid_inverse_distance_to_a_power_options.rb → grid_inverse_distance_to_a_power_options.rb} +1 -2
- data/lib/ffi/gdal/{gdal_grid_moving_average_options.rb → grid_moving_average_options.rb} +1 -2
- data/lib/ffi/gdal/{gdal_grid_nearest_neighbor_options.rb → grid_nearest_neighbor_options.rb} +1 -2
- data/lib/ffi/gdal/matching.rb +20 -0
- data/lib/ffi/gdal/{gdal_rpc_info.rb → rpc_info.rb} +1 -2
- data/lib/ffi/gdal/{gdal_transformer_info.rb → transformer_info.rb} +1 -2
- data/lib/ffi/gdal/version.rb +1 -1
- data/lib/ffi/gdal/vrt.rb +92 -0
- data/lib/ffi/gdal/{gdal_warp_options.rb → warp_options.rb} +8 -4
- data/lib/ffi/gdal/warper.rb +70 -0
- data/lib/ffi/gdal.rb +56 -69
- data/lib/ffi/ogr/api.rb +567 -0
- data/lib/ffi/ogr/{ogr_contour_writer_info.rb → contour_writer_info.rb} +2 -3
- data/lib/ffi/ogr/core.rb +181 -0
- data/lib/ffi/ogr/envelope.rb +12 -0
- data/lib/ffi/ogr/{ogr_envelope_3d.rb → envelope_3d.rb} +2 -2
- data/lib/ffi/ogr/featurestyle.rb +29 -0
- data/lib/ffi/ogr/field.rb +63 -0
- data/lib/ffi/ogr/geocoding.rb +30 -0
- data/lib/ffi/ogr/srs_api.rb +407 -0
- data/lib/ffi/ogr/style_param.rb +13 -0
- data/lib/ffi/ogr/{ogr_style_value.rb → style_value.rb} +4 -3
- data/lib/ffi/ogr.rb +7 -7
- data/lib/ffi-gdal.rb +7 -145
- data/lib/gdal/color_entry.rb +18 -14
- data/lib/gdal/color_entry_mixins/extensions.rb +32 -0
- data/lib/gdal/color_interpretation.rb +2 -2
- data/lib/gdal/color_table.rb +37 -32
- data/lib/gdal/color_table_mixins/extensions.rb +48 -0
- data/lib/gdal/cpl_error_handler.rb +119 -0
- data/lib/gdal/data_type.rb +7 -7
- data/lib/gdal/dataset.rb +131 -238
- data/lib/gdal/dataset_mixins/algorithm_methods.rb +182 -0
- data/lib/gdal/dataset_mixins/extensions.rb +542 -0
- data/lib/gdal/dataset_mixins/matching.rb +26 -0
- data/lib/gdal/driver.rb +68 -92
- data/lib/gdal/driver_mixins/extensions.rb +93 -0
- data/lib/gdal/exceptions.rb +32 -4
- data/lib/gdal/geo_transform.rb +63 -43
- data/lib/gdal/geo_transform_mixins/extensions.rb +57 -0
- data/lib/gdal/grid.rb +144 -0
- data/lib/gdal/grid_types/data_metrics_base.rb +14 -0
- data/lib/gdal/grid_types/inverse_distance_to_a_power.rb +19 -0
- data/lib/gdal/grid_types/metric_average_distance.rb +12 -0
- data/lib/gdal/grid_types/metric_average_distance_pts.rb +12 -0
- data/lib/gdal/grid_types/metric_count.rb +12 -0
- data/lib/gdal/grid_types/metric_maximum.rb +12 -0
- data/lib/gdal/grid_types/metric_minimum.rb +12 -0
- data/lib/gdal/grid_types/metric_range.rb +12 -0
- data/lib/gdal/grid_types/moving_average.rb +19 -0
- data/lib/gdal/grid_types/nearest_neighbor.rb +19 -0
- data/lib/gdal/grid_types.rb +22 -0
- data/lib/gdal/internal_helpers.rb +94 -0
- data/lib/gdal/major_object.rb +4 -7
- data/lib/gdal/options.rb +14 -7
- data/lib/gdal/raster_attribute_table.rb +38 -47
- data/lib/gdal/raster_attribute_table_mixins/extensions.rb +41 -0
- data/lib/gdal/raster_band.rb +193 -227
- data/lib/gdal/raster_band_classifier.rb +107 -0
- data/lib/gdal/raster_band_mixins/algorithm_methods.rb +292 -0
- data/lib/gdal/raster_band_mixins/extensions.rb +238 -0
- data/lib/gdal/rpc_info.rb +35 -0
- data/lib/gdal/transformer.rb +15 -0
- data/lib/gdal/transformers/approximate_transformer.rb +48 -0
- data/lib/gdal/transformers/base_general_image_projection_transformer.rb +45 -0
- data/lib/gdal/transformers/gcp_transformer.rb +55 -0
- data/lib/gdal/transformers/general_image_projection_transformer.rb +31 -0
- data/lib/gdal/transformers/general_image_projection_transformer2.rb +52 -0
- data/lib/gdal/transformers/general_image_projection_transformer3.rb +25 -0
- data/lib/gdal/transformers/geolocation_transformer.rb +42 -0
- data/lib/gdal/transformers/reprojection_transformer.rb +39 -0
- data/lib/gdal/transformers/rpc_transformer.rb +56 -0
- data/lib/gdal/transformers/tps_transformer.rb +40 -0
- data/lib/gdal/virtual_dataset.rb +96 -0
- data/lib/gdal/warp_operation.rb +20 -23
- data/lib/gdal.rb +17 -0
- data/lib/ogr/coordinate_transformation.rb +16 -41
- data/lib/ogr/data_source.rb +103 -58
- data/lib/ogr/data_source_extensions.rb +5 -6
- data/lib/ogr/data_source_mixins/capability_methods.rb +27 -0
- data/lib/ogr/driver.rb +61 -33
- data/lib/ogr/driver_mixins/capability_methods.rb +16 -0
- data/lib/ogr/envelope.rb +29 -18
- data/lib/ogr/envelope_extensions.rb +70 -49
- data/lib/ogr/error_handling.rb +46 -0
- data/lib/ogr/exceptions.rb +58 -12
- data/lib/ogr/feature.rb +334 -86
- data/lib/ogr/feature_definition.rb +94 -51
- data/lib/ogr/feature_definition_extensions.rb +36 -13
- data/lib/ogr/feature_extensions.rb +62 -11
- data/lib/ogr/field.rb +175 -54
- data/lib/ogr/field_definition.rb +110 -0
- data/lib/ogr/{field_extensions.rb → field_definition_extensions.rb} +4 -5
- data/lib/ogr/{geocoding_session.rb → geocoder.rb} +14 -13
- data/lib/ogr/geometries/geometry_collection.rb +13 -0
- data/lib/ogr/geometries/line_string.rb +35 -0
- data/lib/ogr/geometries/linear_ring.rb +11 -0
- data/lib/ogr/geometries/multi_line_string.rb +16 -0
- data/lib/ogr/geometries/multi_point.rb +14 -0
- data/lib/ogr/geometries/multi_polygon.rb +21 -0
- data/lib/ogr/geometries/none_geometry.rb +13 -0
- data/lib/ogr/geometries/point.rb +65 -0
- data/lib/ogr/geometries/point_extensions.rb +32 -0
- data/lib/ogr/geometries/polygon.rb +14 -0
- data/lib/ogr/geometries/unknown_geometry.rb +10 -0
- data/lib/ogr/geometry.rb +270 -242
- data/lib/ogr/geometry_extensions.rb +8 -9
- data/lib/ogr/geometry_field_definition.rb +99 -0
- data/lib/ogr/geometry_field_definition_extensions.rb +19 -0
- data/lib/ogr/geometry_types/container.rb +75 -0
- data/lib/ogr/geometry_types/curve.rb +25 -28
- data/lib/ogr/geometry_types/surface.rb +13 -4
- data/lib/ogr/internal_helpers.rb +57 -0
- data/lib/ogr/layer.rb +60 -181
- data/lib/ogr/layer_mixins/capability_methods.rb +102 -0
- data/lib/ogr/layer_mixins/extensions.rb +59 -0
- data/lib/ogr/layer_mixins/ogr_feature_methods.rb +127 -0
- data/lib/ogr/layer_mixins/ogr_field_methods.rb +143 -0
- data/lib/ogr/layer_mixins/ogr_layer_method_methods.rb +163 -0
- data/lib/ogr/layer_mixins/ogr_query_filter_methods.rb +89 -0
- data/lib/ogr/layer_mixins/ogr_sql_methods.rb +48 -0
- data/lib/ogr/spatial_reference.rb +108 -589
- data/lib/ogr/spatial_reference_extensions.rb +29 -3
- data/lib/ogr/spatial_reference_mixins/coordinate_system_getter_setters.rb +494 -0
- data/lib/ogr/spatial_reference_mixins/exporters.rb +134 -0
- data/lib/ogr/spatial_reference_mixins/importers.rb +243 -0
- data/lib/ogr/spatial_reference_mixins/morphers.rb +25 -0
- data/lib/ogr/spatial_reference_mixins/parameter_getter_setters.rb +122 -0
- data/lib/ogr/spatial_reference_mixins/type_checks.rb +62 -0
- data/lib/ogr/style_table.rb +53 -5
- data/lib/ogr/style_table_extensions.rb +21 -5
- data/lib/ogr/style_tool.rb +118 -0
- data/lib/ogr.rb +8 -0
- data/spec/ffi-gdal_spec.rb +1 -2
- data/spec/integration/{color_table_info_spec.rb → gdal/color_table_info_spec.rb} +12 -12
- data/spec/integration/{dataset_info_spec.rb → gdal/dataset_info_spec.rb} +2 -6
- data/spec/integration/{driver_info_spec.rb → gdal/driver_info_spec.rb} +5 -5
- data/spec/integration/{geo_transform_info_spec.rb → gdal/geo_transform_info_spec.rb} +1 -14
- data/spec/integration/{raster_attribute_table_info_spec.rb → gdal/raster_attribute_table_info_spec.rb} +1 -2
- data/spec/integration/{raster_band_info_spec.rb → gdal/raster_band_info_spec.rb} +30 -42
- data/spec/integration/ogr/layer_spec.rb +97 -0
- data/spec/spec_helper.rb +94 -5
- data/spec/support/integration_help.rb +1 -0
- data/spec/support/shared_contexts.rb +26 -0
- data/spec/support/shared_examples/{major_object_examples.rb → gdal/major_object_examples.rb} +5 -5
- data/spec/support/shared_examples/ogr/a_25D_geometry.rb +7 -0
- data/spec/support/shared_examples/ogr/a_container_geometry.rb +47 -0
- data/spec/support/shared_examples/ogr/a_geometry.rb +404 -0
- data/spec/support/shared_examples/ogr/a_line_string.rb +16 -0
- data/spec/support/test_style_table.txt +3 -0
- data/spec/unit/ext/error_symbols_spec.rb +41 -53
- data/spec/unit/ext/numeric_as_data_type_spec.rb +113 -0
- data/spec/unit/ffi/gdal_spec.rb +70 -0
- data/spec/unit/gdal/color_entry_spec.rb +5 -0
- data/spec/unit/gdal/color_interpretation_spec.rb +5 -0
- data/spec/unit/gdal/{color_table_extensions_spec.rb → color_table_mixins/extensions_spec.rb} +3 -3
- data/spec/unit/gdal/color_table_spec.rb +14 -16
- data/spec/unit/gdal/data_type_spec.rb +10 -17
- data/spec/unit/gdal/dataset_spec.rb +4 -7
- data/spec/unit/gdal/driver_mixins/extensions_spec.rb +22 -0
- data/spec/unit/gdal/driver_spec.rb +49 -0
- data/spec/unit/gdal/environment_methods_spec.rb +6 -0
- data/spec/unit/gdal/geo_transform_spec.rb +276 -0
- data/spec/unit/gdal/grid_spec.rb +5 -0
- data/spec/unit/gdal/internal_helpers_spec.rb +112 -0
- data/spec/unit/gdal/major_object_spec.rb +6 -0
- data/spec/unit/gdal/options_spec.rb +5 -0
- data/spec/unit/gdal/raster_attribute_table_spec.rb +5 -0
- data/spec/unit/gdal/raster_band_classifier_spec.rb +134 -0
- data/spec/unit/gdal/raster_band_spec.rb +5 -0
- data/spec/unit/gdal/rpc_info_spec.rb +5 -0
- data/spec/unit/gdal/version_info_spec.rb +6 -0
- data/spec/unit/gdal/virtual_dataset_spec.rb +32 -0
- data/spec/unit/gdal/warp_operation_spec.rb +5 -0
- data/spec/unit/ogr/data_source_mixins/capability_methods_spec.rb +30 -0
- data/spec/unit/ogr/data_source_spec.rb +209 -0
- data/spec/unit/ogr/driver_mixins/capability_methods_spec.rb +18 -0
- data/spec/unit/ogr/driver_spec.rb +150 -0
- data/spec/unit/ogr/envelope_spec.rb +322 -0
- data/spec/unit/ogr/feature_definition_spec.rb +313 -0
- data/spec/unit/ogr/feature_spec.rb +379 -0
- data/spec/unit/ogr/field_definition_spec.rb +135 -0
- data/spec/unit/ogr/field_spec.rb +193 -0
- data/spec/unit/ogr/geometries/geometry_collection_spec.rb +186 -0
- data/spec/unit/ogr/geometries/line_string_spec.rb +105 -0
- data/spec/unit/ogr/{linear_ring_spec.rb → geometries/linear_ring_spec.rb} +10 -31
- data/spec/unit/ogr/geometries/multi_line_string_spec.rb +14 -0
- data/spec/unit/ogr/geometries/multi_point_spec.rb +14 -0
- data/spec/unit/ogr/geometries/multi_polygon_spec.rb +41 -0
- data/spec/unit/ogr/geometries/none_geometry_spec.rb +12 -0
- data/spec/unit/ogr/{point_spec.rb → geometries/point_spec.rb} +19 -25
- data/spec/unit/ogr/geometries/polygon_spec.rb +17 -0
- data/spec/unit/ogr/geometries/unknown_geometry_spec.rb +10 -0
- data/spec/unit/ogr/geometry_field_definition_spec.rb +87 -0
- data/spec/unit/ogr/geometry_spec.rb +542 -0
- data/spec/unit/ogr/internal_helpers_spec.rb +57 -0
- data/spec/unit/ogr/layer_mixins/capability_methods_spec.rb +88 -0
- data/spec/unit/ogr/layer_mixins/ogr_feature_methods_spec.rb +145 -0
- data/spec/unit/ogr/layer_mixins/ogr_field_methods_spec.rb +432 -0
- data/spec/unit/ogr/layer_mixins/ogr_layer_method_methods_spec.rb +20 -0
- data/spec/unit/ogr/layer_mixins/ogr_query_filter_methods_spec.rb +42 -0
- data/spec/unit/ogr/layer_mixins/ogr_sql_methods_spec.rb +12 -0
- data/spec/unit/ogr/layer_spec.rb +66 -67
- data/spec/unit/ogr/spatial_reference_mixins/coordinate_system_getter_setters_spec.rb +46 -0
- data/spec/unit/ogr/spatial_reference_mixins/exporters_spec.rb +139 -0
- data/spec/unit/ogr/spatial_reference_mixins/importers_spec.rb +38 -0
- data/spec/unit/ogr/spatial_reference_mixins/morphers_spec.rb +36 -0
- data/spec/unit/ogr/spatial_reference_mixins/parameter_getter_setters_spec.rb +102 -0
- data/spec/unit/ogr/spatial_reference_mixins/type_checks_spec.rb +157 -0
- data/spec/unit/ogr/spatial_reference_spec.rb +42 -0
- data/spec/unit/ogr/style_table_spec.rb +132 -0
- data/spec/unit/ogr/style_tool_spec.rb +157 -0
- data/spec/unit/version_info_spec.rb +1 -1
- metadata +285 -75
- data/lib/ffi/cpl/conv_h.rb +0 -143
- data/lib/ffi/cpl/error_h.rb +0 -63
- data/lib/ffi/cpl/minixml_h.rb +0 -14
- data/lib/ffi/cpl/string_h.rb +0 -81
- data/lib/ffi/cpl/vsi_h.rb +0 -112
- data/lib/ffi/gdal/alg_h.rb +0 -127
- data/lib/ffi/gdal/grid_h.rb +0 -51
- data/lib/ffi/gdal/warper_h.rb +0 -48
- data/lib/ffi/ogr/api_h.rb +0 -553
- data/lib/ffi/ogr/core_h.rb +0 -148
- data/lib/ffi/ogr/featurestyle_h.rb +0 -22
- data/lib/ffi/ogr/geocoding_h.rb +0 -21
- data/lib/ffi/ogr/ogr_field.rb +0 -50
- data/lib/ffi/ogr/ogr_style_param.rb +0 -12
- data/lib/ffi/ogr/srs_api_h.rb +0 -325
- data/lib/gdal/color_entry_extensions.rb +0 -30
- data/lib/gdal/color_table_extensions.rb +0 -47
- data/lib/gdal/dataset_extensions.rb +0 -496
- data/lib/gdal/driver_extensions.rb +0 -56
- data/lib/gdal/geo_transform_extensions.rb +0 -90
- data/lib/gdal/raster_attribute_table_extensions.rb +0 -40
- data/lib/gdal/raster_band_extensions.rb +0 -198
- data/lib/ogr/geometry_types/collection.rb +0 -45
- data/lib/ogr/layer_extensions.rb +0 -55
- data/lib/ogr/line_string.rb +0 -7
- data/lib/ogr/linear_ring.rb +0 -6
- data/lib/ogr/multi_line_string.rb +0 -9
- data/lib/ogr/multi_point.rb +0 -7
- data/lib/ogr/multi_polygon.rb +0 -14
- data/lib/ogr/point.rb +0 -89
- data/lib/ogr/polygon.rb +0 -9
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'ogr/geometry'
|
3
|
+
|
4
|
+
RSpec.describe OGR::MultiPolygon do
|
5
|
+
it_behaves_like 'a geometry' do
|
6
|
+
let(:geometry) { described_class.new }
|
7
|
+
end
|
8
|
+
|
9
|
+
it_behaves_like 'a container geometry' do
|
10
|
+
let(:child_geometry) { OGR::Polygon.new }
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '#to_polygon' do
|
14
|
+
subject { OGR::Geometry.create_from_wkt(wkt) }
|
15
|
+
|
16
|
+
let(:wkt) do
|
17
|
+
'MULTIPOLYGON(((0 0,0 1,1 1,0 0)),((0 0,1 1,1 0,0 0)))'
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'returns a Polygon' do
|
21
|
+
expect(subject.to_polygon).to be_a OGR::Polygon
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#union_cascaded' do
|
26
|
+
subject { OGR::Geometry.create_from_wkt(wkt) }
|
27
|
+
|
28
|
+
let(:wkt) do
|
29
|
+
'MULTIPOLYGON(((0 0,0 1,1 1,0 0)),((0 0,1 1,1 0,0 0)))'
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'returns a Geometry' do
|
33
|
+
expect(subject.union_cascaded).to be_a OGR::Polygon
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'does a union on the geometry' do
|
37
|
+
expect(subject.union_cascaded.to_wkt).
|
38
|
+
to eq 'POLYGON ((0 0,0 1,1 1,1 0,0 0))'
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'ogr/geometry'
|
3
|
+
|
4
|
+
RSpec.describe OGR::NoneGeometry do
|
5
|
+
skip 'Not sure how to instantiate one of these'
|
6
|
+
|
7
|
+
it 'can be created from a pointer to a geometry' do
|
8
|
+
geom_ptr = FFI::OGR::API.OGR_G_CreateGeometry(:wkbPoint)
|
9
|
+
geom = described_class.new(geom_ptr)
|
10
|
+
expect(geom).to be_a OGR::NoneGeometry
|
11
|
+
end
|
12
|
+
end
|
@@ -1,16 +1,16 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
require 'ogr/geometry'
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
subject { described_class.create_from_wkt(wkt) }
|
4
|
+
RSpec.describe OGR::Point do
|
5
|
+
subject { OGR::Geometry.create_from_wkt(wkt) }
|
6
6
|
let(:wkt) { 'POINT (1 2)' }
|
7
7
|
|
8
8
|
let(:another_point) do
|
9
|
-
|
9
|
+
OGR::Geometry.create_from_wkt('POINT (2 3)')
|
10
10
|
end
|
11
11
|
|
12
12
|
let(:same_point) do
|
13
|
-
|
13
|
+
OGR::Geometry.create_from_wkt(wkt)
|
14
14
|
end
|
15
15
|
|
16
16
|
describe '#dimension' do
|
@@ -40,20 +40,14 @@ describe OGR::Point do
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
-
describe '#
|
44
|
-
specify { expect(subject.
|
43
|
+
describe '#geometry_count' do
|
44
|
+
specify { expect(subject.geometry_count).to be_zero }
|
45
45
|
end
|
46
46
|
|
47
47
|
describe '#point_count' do
|
48
48
|
specify { expect(subject.point_count).to eq 1 }
|
49
49
|
end
|
50
50
|
|
51
|
-
# describe '#centroid' do
|
52
|
-
# it 'returns 0' do
|
53
|
-
# expect(subject.centroid.point).to eq(subject.point)
|
54
|
-
# end
|
55
|
-
# end
|
56
|
-
#
|
57
51
|
describe '#equals?' do
|
58
52
|
context 'a point with same coordinates' do
|
59
53
|
it 'returns true' do
|
@@ -217,27 +211,27 @@ describe OGR::Point do
|
|
217
211
|
|
218
212
|
describe '#set_point' do
|
219
213
|
it 'changes the x & y values' do
|
220
|
-
expect
|
214
|
+
expect do
|
221
215
|
subject.set_point(5, 6)
|
222
|
-
|
216
|
+
end.to change { subject.points }.
|
223
217
|
from([[1, 2]]).to([[5.0, 6.0, 0.0]])
|
224
218
|
end
|
225
219
|
end
|
226
220
|
|
227
221
|
describe '#add_point' do
|
228
222
|
it 'changes the x & y values' do
|
229
|
-
expect
|
223
|
+
expect do
|
230
224
|
subject.add_point(5, 6)
|
231
|
-
|
225
|
+
end.to change { subject.points }.
|
232
226
|
from([[1, 2]]).to([[5.0, 6.0, 0.0]])
|
233
227
|
end
|
234
228
|
end
|
235
229
|
|
236
230
|
describe '#empty!' do
|
237
231
|
it 'clears the point' do
|
238
|
-
expect
|
232
|
+
expect do
|
239
233
|
subject.empty!
|
240
|
-
|
234
|
+
end.to change { subject.points }.
|
241
235
|
from([[1, 2]]).to([[]])
|
242
236
|
end
|
243
237
|
end
|
@@ -250,8 +244,8 @@ describe OGR::Point do
|
|
250
244
|
specify { expect(subject.coordinate_dimension).to eq 0 }
|
251
245
|
end
|
252
246
|
|
253
|
-
describe '#
|
254
|
-
specify { expect(subject.
|
247
|
+
describe '#geometry_count' do
|
248
|
+
specify { expect(subject.geometry_count).to be_zero }
|
255
249
|
end
|
256
250
|
|
257
251
|
describe '#point_count' do
|
@@ -296,18 +290,18 @@ describe OGR::Point do
|
|
296
290
|
|
297
291
|
describe '#set_point' do
|
298
292
|
it 'changes the x & y values' do
|
299
|
-
expect
|
293
|
+
expect do
|
300
294
|
subject.set_point(5, 6)
|
301
|
-
|
295
|
+
end.to change { subject.points }.
|
302
296
|
from([[]]).to([[5.0, 6.0, 0.0]])
|
303
297
|
end
|
304
298
|
end
|
305
299
|
|
306
300
|
describe '#add_point' do
|
307
301
|
it 'changes the x & y values' do
|
308
|
-
expect
|
302
|
+
expect do
|
309
303
|
subject.add_point(5, 6)
|
310
|
-
|
304
|
+
end.to change { subject.points }.
|
311
305
|
from([[]]).to([[5.0, 6.0, 0.0]])
|
312
306
|
end
|
313
307
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'ogr/geometry'
|
3
|
+
|
4
|
+
RSpec.describe OGR::Polygon do
|
5
|
+
subject(:polygon) { OGR::Geometry.create_from_wkt(wkt) }
|
6
|
+
let(:wkt) { 'POLYGON((100 100, 200 200, 300 300))' }
|
7
|
+
|
8
|
+
it_behaves_like 'a geometry' do
|
9
|
+
let(:geometry) { polygon }
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '#to_multi_polygon' do
|
13
|
+
it 'returns a MultiPolygon' do
|
14
|
+
expect(subject.to_multi_polygon).to be_a OGR::MultiPolygon
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'ogr/geometry'
|
3
|
+
|
4
|
+
RSpec.describe OGR::UnknownGeometry do
|
5
|
+
it 'can be created from a pointer to a geometry' do
|
6
|
+
geom_ptr = FFI::OGR::API.OGR_G_CreateGeometry(:wkbPoint)
|
7
|
+
geom = described_class.new(geom_ptr)
|
8
|
+
expect(geom).to be_a OGR::UnknownGeometry
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'ogr/geometry_field_definition'
|
3
|
+
require 'ogr/spatial_reference'
|
4
|
+
|
5
|
+
RSpec.describe OGR::GeometryFieldDefinition do
|
6
|
+
subject(:geometry_field_definition) { described_class.new('test gfld') }
|
7
|
+
|
8
|
+
describe '#destroy!' do
|
9
|
+
it 'sets the c_pointer to nil' do
|
10
|
+
subject.destroy!
|
11
|
+
expect(subject.instance_variable_get(:@geometry_field_definition_pointer)).
|
12
|
+
to be_nil
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '#name' do
|
17
|
+
it 'returns the name' do
|
18
|
+
expect(subject.name).to eq 'test gfld'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '#name= + #name' do
|
23
|
+
it 'assigns a new name' do
|
24
|
+
subject.name = 'bobo'
|
25
|
+
expect(subject.name).to eq 'bobo'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe '#type' do
|
30
|
+
it 'returns the type' do
|
31
|
+
expect(subject.type).to eq :wkbUnknown
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '#type= + #type' do
|
36
|
+
it 'assigns a new type' do
|
37
|
+
subject.type = :wkbPolygon
|
38
|
+
expect(subject.type).to eq :wkbPolygon
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '#spatial_reference' do
|
43
|
+
context 'default' do
|
44
|
+
subject { geometry_field_definition.spatial_reference }
|
45
|
+
it { is_expected.to be_nil }
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe '#spatial_reference= + #spatial_reference' do
|
50
|
+
it 'assigns the new SpatialReference' do
|
51
|
+
new_spatial_reference = OGR::SpatialReference.new_from_epsg 4326
|
52
|
+
subject.spatial_reference = new_spatial_reference
|
53
|
+
expect(subject.spatial_reference.authority_code.to_i).to eq 4326
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe '#ignored?' do
|
58
|
+
context 'default' do
|
59
|
+
it { is_expected.to_not be_ignored }
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe '#ignore=' do
|
64
|
+
context 'setting to true' do
|
65
|
+
it 'sets the value to true' do
|
66
|
+
subject.ignore = true
|
67
|
+
expect(subject).to be_ignored
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe '#as_json' do
|
73
|
+
it 'returns a Hash of attributes' do
|
74
|
+
expect(subject.as_json). to eq(
|
75
|
+
is_ignored: false,
|
76
|
+
name: 'test gfld',
|
77
|
+
spatial_reference: nil,
|
78
|
+
type: :wkbUnknown
|
79
|
+
)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
describe '#to_json' do
|
84
|
+
subject { geometry_field_definition.to_json }
|
85
|
+
it { is_expected.to be_a String }
|
86
|
+
end
|
87
|
+
end
|