ffi-gdal 1.0.0.beta16 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.dockerignore +17 -0
- data/.github/workflows/codacy.yml +61 -0
- data/.github/workflows/codeql.yml +74 -0
- data/.github/workflows/continuous-integration.yml +36 -0
- data/.github/workflows/dependency-review.yml +20 -0
- data/.github/workflows/specs-in-docker.yml +27 -0
- data/.gitignore +3 -0
- data/.rspec +1 -0
- data/.rubocop.yml +10 -80
- data/.rubocop_todo.yml +23 -40
- data/.ruby-version +1 -1
- data/Changelog-0.x.md +512 -0
- data/Changelog.md +12 -0
- data/Dockerfile.gdal2 +110 -0
- data/Dockerfile.gdal3 +73 -0
- data/README.md +25 -14
- data/Rakefile +0 -8
- data/Tiltfile +91 -0
- data/bin/bundle +123 -0
- data/bin/docker-clean +8 -0
- data/bin/rake +29 -0
- data/bin/rspec +29 -0
- data/bin/rubocop +29 -0
- data/docker-compose.yml +25 -0
- data/examples/extract_and_colorize.rb +0 -13
- data/examples/geometries.rb +14 -14
- data/examples/ogr_layer_to_layer.rb +1 -3
- data/examples/raster_erasing.rb +1 -0
- data/examples/remove_small_polygons.rb +1 -1
- data/examples/testing_gdal.rb +20 -17
- data/examples/warping.rb +9 -7
- data/ffi-gdal.gemspec +12 -6
- data/lib/ext/ffi_library_function_checks.rb +2 -2
- data/lib/ext/to_bool.rb +5 -3
- data/lib/ffi/cpl/conv.rb +27 -25
- data/lib/ffi/cpl/error.rb +19 -20
- data/lib/ffi/cpl/hash_set.rb +4 -4
- data/lib/ffi/cpl/http.rb +3 -3
- data/lib/ffi/cpl/http_result.rb +8 -8
- data/lib/ffi/cpl/list.rb +1 -1
- data/lib/ffi/cpl/mime_part.rb +2 -2
- data/lib/ffi/cpl/minixml.rb +7 -7
- data/lib/ffi/cpl/progress.rb +8 -8
- data/lib/ffi/cpl/quad_tree.rb +14 -14
- data/lib/ffi/cpl/rect_obj.rb +3 -3
- data/lib/ffi/cpl/string.rb +17 -20
- data/lib/ffi/cpl/vsi.rb +13 -13
- data/lib/ffi/cpl/xml_node.rb +3 -3
- data/lib/ffi/extensions/gdal/extensions/all.rb +4 -0
- data/lib/ffi/extensions/gdal/extensions/version.rb +9 -0
- data/lib/ffi/extensions/gdal/extensions.rb +12 -0
- data/lib/ffi/extensions/rttopo/gbox.rb +19 -0
- data/lib/ffi/extensions/rttopo/geom.rb +16 -0
- data/lib/ffi/extensions/rttopo.rb +41 -0
- data/lib/ffi/gdal/alg.rb +277 -277
- data/lib/ffi/gdal/color_entry.rb +3 -3
- data/lib/ffi/gdal/gcp.rb +6 -6
- data/lib/ffi/gdal/gdal.rb +349 -349
- data/lib/ffi/gdal/grid.rb +134 -134
- data/lib/ffi/gdal/grid_data_metrics_options.rb +4 -4
- data/lib/ffi/gdal/grid_inverse_distance_to_a_power_options.rb +9 -9
- data/lib/ffi/gdal/grid_moving_average_options.rb +4 -4
- data/lib/ffi/gdal/grid_nearest_neighbor_options.rb +3 -3
- data/lib/ffi/gdal/matching.rb +3 -3
- data/lib/ffi/gdal/rpc_info.rb +17 -17
- data/lib/ffi/gdal/transformer_info.rb +4 -4
- data/lib/ffi/gdal/version.rb +1 -1
- data/lib/ffi/gdal/vrt.rb +39 -39
- data/lib/ffi/gdal/warp_options.rb +34 -34
- data/lib/ffi/gdal/warper.rb +90 -90
- data/lib/ffi/gdal.rb +2 -31
- data/lib/ffi/ogr/api.rb +175 -167
- data/lib/ffi/ogr/contour_writer_info.rb +4 -4
- data/lib/ffi/ogr/core.rb +107 -107
- data/lib/ffi/ogr/envelope.rb +3 -3
- data/lib/ffi/ogr/envelope_3d.rb +5 -5
- data/lib/ffi/ogr/featurestyle.rb +3 -3
- data/lib/ffi/ogr/field.rb +22 -22
- data/lib/ffi/ogr/geocoding.rb +4 -4
- data/lib/ffi/ogr/srs_api.rb +154 -155
- data/lib/ffi/ogr/style_param.rb +3 -3
- data/lib/ffi/ogr/style_value.rb +4 -4
- data/lib/gdal/color_entry.rb +1 -5
- data/lib/gdal/color_interpretation.rb +7 -3
- data/lib/gdal/color_table.rb +46 -27
- data/lib/gdal/cpl_error_handler.rb +26 -6
- data/lib/gdal/data_type.rb +10 -3
- data/lib/gdal/dataset.rb +171 -85
- data/lib/gdal/dataset_mixins/algorithm_methods.rb +44 -44
- data/lib/gdal/dataset_mixins/matching.rb +1 -1
- data/lib/gdal/dataset_mixins/warp_methods.rb +4 -2
- data/lib/gdal/driver.rb +38 -21
- data/lib/gdal/environment_methods.rb +6 -6
- data/lib/gdal/extensions/all.rb +3 -0
- data/lib/gdal/{color_entry_mixins → extensions/color_entry}/extensions.rb +4 -1
- data/lib/gdal/{color_table_mixins → extensions/color_table}/extensions.rb +3 -0
- data/lib/gdal/extensions/dataset/extensions.rb +205 -0
- data/lib/gdal/{driver_mixins → extensions/driver}/extensions.rb +6 -2
- data/lib/gdal/{geo_transform_mixins → extensions/geo_transform}/extensions.rb +10 -8
- data/lib/gdal/{gridder → extensions/gridder}/point_extracting.rb +7 -5
- data/lib/gdal/{gridder.rb → extensions/gridder.rb} +33 -33
- data/lib/gdal/{gridder_options.rb → extensions/gridder_options.rb} +13 -14
- data/lib/gdal/{raster_attribute_table_mixins → extensions/raster_attribute_table}/extensions.rb +8 -6
- data/lib/gdal/{raster_band_mixins → extensions/raster_band}/algorithm_extensions.rb +8 -6
- data/lib/gdal/{raster_band_mixins → extensions/raster_band}/coloring_extensions.rb +6 -4
- data/lib/gdal/{raster_band_mixins → extensions/raster_band}/extensions.rb +9 -5
- data/lib/gdal/{raster_band_mixins → extensions/raster_band}/io_extensions.rb +18 -14
- data/lib/gdal/{raster_band_classifier.rb → extensions/raster_band_classifier.rb} +3 -5
- data/lib/gdal/geo_transform.rb +1 -6
- data/lib/gdal/grid.rb +3 -2
- data/lib/gdal/grid_algorithms.rb +9 -9
- data/lib/gdal/internal_helpers.rb +46 -9
- data/lib/gdal/major_object.rb +11 -3
- data/lib/gdal/options.rb +26 -32
- data/lib/gdal/raster_attribute_table.rb +63 -37
- data/lib/gdal/raster_band.rb +164 -116
- data/lib/gdal/raster_band_mixins/algorithm_methods.rb +26 -25
- data/lib/gdal/rpc_info.rb +3 -2
- data/lib/gdal/transformers/approximate_transformer.rb +12 -3
- data/lib/gdal/transformers/base_general_image_projection_transformer.rb +15 -2
- data/lib/gdal/transformers/gcp_transformer.rb +27 -19
- data/lib/gdal/transformers/general_image_projection_transformer.rb +8 -6
- data/lib/gdal/transformers/general_image_projection_transformer2.rb +9 -6
- data/lib/gdal/transformers/general_image_projection_transformer3.rb +6 -2
- data/lib/gdal/transformers/geolocation_transformer.rb +12 -4
- data/lib/gdal/transformers/reprojection_transformer.rb +11 -3
- data/lib/gdal/transformers/rpc_transformer.rb +11 -2
- data/lib/gdal/transformers/tps_transformer.rb +12 -4
- data/lib/gdal/version_info.rb +2 -2
- data/lib/gdal/virtual_dataset.rb +2 -0
- data/lib/gdal/warp_operation.rb +65 -54
- data/lib/gdal/warp_options.rb +9 -11
- data/lib/ogr/coordinate_transformation.rb +23 -9
- data/lib/ogr/data_source.rb +68 -37
- data/lib/ogr/driver.rb +18 -17
- data/lib/ogr/envelope.rb +0 -3
- data/lib/ogr/error_handling.rb +22 -24
- data/lib/ogr/extensions/all.rb +3 -0
- data/lib/ogr/{data_source_mixins → extensions/data_source}/capability_methods.rb +2 -0
- data/lib/ogr/extensions/data_source/data_source_extensions.rb +16 -0
- data/lib/ogr/{driver_mixins → extensions/driver}/capability_methods.rb +5 -1
- data/lib/ogr/extensions/envelope/extensions.rb +114 -0
- data/lib/ogr/extensions/feature/extensions.rb +87 -0
- data/lib/ogr/extensions/feature_definition/extensions.rb +43 -0
- data/lib/ogr/extensions/geometries/point/extensions.rb +19 -0
- data/lib/ogr/extensions/geometry/container_mixins.rb +56 -0
- data/lib/ogr/extensions/geometry/ewkb_io_extensions.rb +44 -0
- data/lib/ogr/extensions/geometry/ewkb_record.rb +94 -0
- data/lib/ogr/{geometry_mixins → extensions/geometry}/extensions.rb +16 -9
- data/lib/ogr/extensions/geometry/rttopo_extensions.rb +48 -0
- data/lib/ogr/extensions/geometry/wkb_record.rb +63 -0
- data/lib/ogr/extensions/geometry_types/curve/extensions.rb +68 -0
- data/lib/ogr/{layer_mixins → extensions/layer}/capability_methods.rb +4 -0
- data/lib/ogr/{layer_mixins → extensions/layer}/extensions.rb +11 -6
- data/lib/ogr/extensions/spatial_reference/extensions.rb +38 -0
- data/lib/ogr/extensions/spatial_reference/initializers.rb +138 -0
- data/lib/ogr/extensions/style_table/extensions.rb +31 -0
- data/lib/ogr/feature.rb +173 -88
- data/lib/ogr/feature_definition.rb +53 -45
- data/lib/ogr/field.rb +17 -19
- data/lib/ogr/field_definition.rb +30 -18
- data/lib/ogr/geocoder.rb +11 -4
- data/lib/ogr/geometries/line_string.rb +1 -0
- data/lib/ogr/geometries/line_string_25d.rb +0 -9
- data/lib/ogr/geometries/linear_ring.rb +2 -2
- data/lib/ogr/geometries/point.rb +0 -9
- data/lib/ogr/geometry.rb +116 -49
- data/lib/ogr/geometry_field_definition.rb +31 -15
- data/lib/ogr/geometry_types/container.rb +26 -28
- data/lib/ogr/geometry_types/curve.rb +5 -61
- data/lib/ogr/geometry_types/surface.rb +1 -1
- data/lib/ogr/internal_helpers.rb +2 -2
- data/lib/ogr/layer.rb +12 -10
- data/lib/ogr/layer_mixins/ogr_feature_methods.rb +39 -27
- data/lib/ogr/layer_mixins/ogr_field_methods.rb +66 -50
- data/lib/ogr/layer_mixins/ogr_layer_method_methods.rb +17 -8
- data/lib/ogr/layer_mixins/ogr_query_filter_methods.rb +7 -6
- data/lib/ogr/layer_mixins/ogr_sql_methods.rb +15 -7
- data/lib/ogr/spatial_reference.rb +79 -42
- data/lib/ogr/spatial_reference_mixins/coordinate_system_getter_setters.rb +149 -118
- data/lib/ogr/spatial_reference_mixins/exporters.rb +87 -51
- data/lib/ogr/spatial_reference_mixins/importers.rb +88 -43
- data/lib/ogr/spatial_reference_mixins/morphers.rb +12 -8
- data/lib/ogr/spatial_reference_mixins/parameter_getter_setters.rb +27 -13
- data/lib/ogr/style_table.rb +15 -5
- data/lib/ogr/style_tool.rb +29 -15
- data/lib/ogr.rb +1 -0
- data/rakelib/docker.rake +10 -0
- data/sorbet/rbi/hidden-definitions/errors.txt +21790 -0
- data/tilt/gdal2.yml +22 -0
- data/tilt/gdal3.yml +22 -0
- metadata +116 -280
- data/History.md +0 -360
- data/lib/ext/error_symbols.rb +0 -7
- data/lib/gdal/dataset_mixins/extensions.rb +0 -380
- data/lib/gdal/merger.rb +0 -132
- data/lib/ogr/data_source_extensions.rb +0 -10
- data/lib/ogr/envelope_extensions.rb +0 -110
- data/lib/ogr/feature_definition_extensions.rb +0 -39
- data/lib/ogr/feature_extensions.rb +0 -87
- data/lib/ogr/geometry_mixins/container_mixins.rb +0 -25
- data/lib/ogr/spatial_reference_extensions.rb +0 -34
- data/lib/ogr/style_table_extensions.rb +0 -26
- data/spec/ffi-gdal_spec.rb +0 -24
- data/spec/integration/gdal/color_table_info_spec.rb +0 -78
- data/spec/integration/gdal/dataset_info_spec.rb +0 -342
- data/spec/integration/gdal/driver_info_spec.rb +0 -170
- data/spec/integration/gdal/geo_transform_info_spec.rb +0 -226
- data/spec/integration/gdal/gridder_spec.rb +0 -331
- data/spec/integration/gdal/raster_attribute_table_info_spec.rb +0 -229
- data/spec/integration/gdal/raster_band_algorithms_spec.rb +0 -35
- data/spec/integration/gdal/raster_band_info_spec.rb +0 -320
- data/spec/integration/ogr/layer_spec.rb +0 -95
- data/spec/spec_helper.rb +0 -116
- data/spec/support/images/123.tiff +0 -0
- data/spec/support/images/osgeo/gdal/data/hfa/float-rle.img +0 -0
- data/spec/support/images/osgeo/geotiff/GeogToWGS84GeoKey/GeogToWGS84GeoKey5.lgo +0 -31
- data/spec/support/images/osgeo/geotiff/GeogToWGS84GeoKey/GeogToWGS84GeoKey5.tif +0 -0
- data/spec/support/images/osgeo/geotiff/GeogToWGS84GeoKey/GeogToWGS84GeoKey5.tif.msk +0 -0
- data/spec/support/images/osgeo/geotiff/GeogToWGS84GeoKey/GeogToWGS84GeoKey5.txt +0 -10
- data/spec/support/images/osgeo/geotiff/gdal_eg/cea.tif +0 -0
- data/spec/support/images/osgeo/geotiff/gdal_eg/cea.txt +0 -84
- data/spec/support/images/osgeo/geotiff/zi_imaging/image0.lgo +0 -45
- data/spec/support/images/osgeo/geotiff/zi_imaging/image0.tif +0 -0
- data/spec/support/integration_help.rb +0 -34
- data/spec/support/shapefiles/states_21basic/states.dbf +0 -0
- data/spec/support/shapefiles/states_21basic/states.prj +0 -1
- data/spec/support/shapefiles/states_21basic/states.sbn +0 -0
- data/spec/support/shapefiles/states_21basic/states.sbx +0 -0
- data/spec/support/shapefiles/states_21basic/states.shp +0 -0
- data/spec/support/shapefiles/states_21basic/states.shp.xml +0 -3
- data/spec/support/shapefiles/states_21basic/states.shx +0 -0
- data/spec/support/shared_contexts.rb +0 -28
- data/spec/support/shared_examples/gdal/major_object_examples.rb +0 -55
- data/spec/support/shared_examples/ogr/a_25d_geometry.rb +0 -9
- data/spec/support/shared_examples/ogr/a_container_geometry.rb +0 -49
- data/spec/support/shared_examples/ogr/a_geometry.rb +0 -406
- data/spec/support/shared_examples/ogr/a_line_string.rb +0 -18
- data/spec/support/test_style_table.txt +0 -3
- data/spec/support/worldfiles/SR_50M/SR_50M.VERSION.txt +0 -1
- data/spec/support/worldfiles/SR_50M/SR_50M.prj +0 -1
- data/spec/support/worldfiles/SR_50M/SR_50M.tfw +0 -6
- data/spec/support/worldfiles/SR_50M/SR_50M.tif +0 -0
- data/spec/unit/ext/error_symbols_spec.rb +0 -69
- data/spec/unit/ext/numeric_as_data_type_spec.rb +0 -115
- data/spec/unit/ffi/gdal_spec.rb +0 -73
- data/spec/unit/gdal/color_entry_spec.rb +0 -8
- data/spec/unit/gdal/color_interpretation_spec.rb +0 -8
- data/spec/unit/gdal/color_table_mixins/extensions_spec.rb +0 -62
- data/spec/unit/gdal/color_table_spec.rb +0 -146
- data/spec/unit/gdal/data_type_spec.rb +0 -74
- data/spec/unit/gdal/dataset_mixins/warp_methods_spec.rb +0 -55
- data/spec/unit/gdal/dataset_spec.rb +0 -148
- data/spec/unit/gdal/driver_mixins/extensions_spec.rb +0 -24
- data/spec/unit/gdal/driver_spec.rb +0 -51
- data/spec/unit/gdal/environment_methods_spec.rb +0 -8
- data/spec/unit/gdal/geo_transform_mixins/extensions_spec.rb +0 -69
- data/spec/unit/gdal/geo_transform_spec.rb +0 -265
- data/spec/unit/gdal/grid_spec.rb +0 -98
- data/spec/unit/gdal/gridder/point_extracting_spec.rb +0 -101
- data/spec/unit/gdal/gridder_options_spec.rb +0 -185
- data/spec/unit/gdal/gridder_spec.rb +0 -182
- data/spec/unit/gdal/internal_helpers_spec.rb +0 -278
- data/spec/unit/gdal/major_object_spec.rb +0 -10
- data/spec/unit/gdal/options_spec.rb +0 -33
- data/spec/unit/gdal/raster_attribute_table_spec.rb +0 -7
- data/spec/unit/gdal/raster_band_classifier_spec.rb +0 -260
- data/spec/unit/gdal/raster_band_mixins/extensions_spec.rb +0 -73
- data/spec/unit/gdal/raster_band_mixins/io_extensions_spec.rb +0 -135
- data/spec/unit/gdal/raster_band_spec.rb +0 -8
- data/spec/unit/gdal/rpc_info_spec.rb +0 -8
- data/spec/unit/gdal/version_info_spec.rb +0 -10
- data/spec/unit/gdal/virtual_dataset_spec.rb +0 -34
- data/spec/unit/gdal/warp_operation_spec.rb +0 -8
- data/spec/unit/gdal/warp_options_spec.rb +0 -338
- data/spec/unit/ogr/coordinate_transformation_spec.rb +0 -104
- data/spec/unit/ogr/data_source_mixins/capability_methods_spec.rb +0 -32
- data/spec/unit/ogr/data_source_spec.rb +0 -223
- data/spec/unit/ogr/driver_mixins/capability_methods_spec.rb +0 -20
- data/spec/unit/ogr/driver_spec.rb +0 -152
- data/spec/unit/ogr/envelope_spec.rb +0 -324
- data/spec/unit/ogr/feature_definition_spec.rb +0 -296
- data/spec/unit/ogr/feature_extensions_spec.rb +0 -90
- data/spec/unit/ogr/feature_spec.rb +0 -363
- data/spec/unit/ogr/field_definition_spec.rb +0 -118
- data/spec/unit/ogr/field_spec.rb +0 -195
- data/spec/unit/ogr/geometries/geometry_collection_25d_spec.rb +0 -25
- data/spec/unit/ogr/geometries/geometry_collection_spec.rb +0 -188
- data/spec/unit/ogr/geometries/line_string_25d_spec.rb +0 -25
- data/spec/unit/ogr/geometries/line_string_spec.rb +0 -107
- data/spec/unit/ogr/geometries/linear_ring_spec.rb +0 -92
- data/spec/unit/ogr/geometries/multi_line_string_25d_spec.rb +0 -25
- data/spec/unit/ogr/geometries/multi_line_string_spec.rb +0 -16
- data/spec/unit/ogr/geometries/multi_point_25d_spec.rb +0 -25
- data/spec/unit/ogr/geometries/multi_point_spec.rb +0 -16
- data/spec/unit/ogr/geometries/multi_polygon_25d_spec.rb +0 -25
- data/spec/unit/ogr/geometries/multi_polygon_spec.rb +0 -43
- data/spec/unit/ogr/geometries/none_geometry_spec.rb +0 -14
- data/spec/unit/ogr/geometries/point_25d_spec.rb +0 -25
- data/spec/unit/ogr/geometries/point_spec.rb +0 -307
- data/spec/unit/ogr/geometries/polygon_25d_spec.rb +0 -25
- data/spec/unit/ogr/geometries/polygon_spec.rb +0 -19
- data/spec/unit/ogr/geometries/unknown_geometry_spec.rb +0 -12
- data/spec/unit/ogr/geometry_field_definition_spec.rb +0 -73
- data/spec/unit/ogr/geometry_spec.rb +0 -711
- data/spec/unit/ogr/internal_helpers_spec.rb +0 -70
- data/spec/unit/ogr/layer_mixins/capability_methods_spec.rb +0 -90
- data/spec/unit/ogr/layer_mixins/ogr_feature_methods_spec.rb +0 -155
- data/spec/unit/ogr/layer_mixins/ogr_field_methods_spec.rb +0 -434
- data/spec/unit/ogr/layer_mixins/ogr_layer_method_methods_spec.rb +0 -22
- data/spec/unit/ogr/layer_mixins/ogr_query_filter_methods_spec.rb +0 -44
- data/spec/unit/ogr/layer_mixins/ogr_sql_methods_spec.rb +0 -14
- data/spec/unit/ogr/layer_spec.rb +0 -98
- data/spec/unit/ogr/spatial_reference_mixins/coordinate_system_getter_setters_spec.rb +0 -48
- data/spec/unit/ogr/spatial_reference_mixins/exporters_spec.rb +0 -151
- data/spec/unit/ogr/spatial_reference_mixins/importers_spec.rb +0 -40
- data/spec/unit/ogr/spatial_reference_mixins/morphers_spec.rb +0 -38
- data/spec/unit/ogr/spatial_reference_mixins/parameter_getter_setters_spec.rb +0 -105
- data/spec/unit/ogr/spatial_reference_mixins/type_checks_spec.rb +0 -159
- data/spec/unit/ogr/spatial_reference_spec.rb +0 -44
- data/spec/unit/ogr/style_table_spec.rb +0 -108
- data/spec/unit/ogr/style_tool_spec.rb +0 -159
- data/spec/unit/version_info_spec.rb +0 -50
@@ -1,151 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
require 'ogr/spatial_reference'
|
5
|
-
|
6
|
-
RSpec.describe OGR::SpatialReference do
|
7
|
-
describe '#to_erm' do
|
8
|
-
context 'known projection' do
|
9
|
-
subject { described_class.new_from_epsg(4322) }
|
10
|
-
|
11
|
-
it 'returns a Hash' do
|
12
|
-
expect(subject.to_erm).to eq(projection_name: 'GEODETIC', datum_name: 'WGS72DOD', units: 'METERS')
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
context 'empty SRS' do
|
17
|
-
it 'raises an OGR::NotEnoughData' do
|
18
|
-
expect { subject.to_erm }.to raise_exception OGR::NotEnoughData
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
describe '#to_mapinfo' do
|
24
|
-
context 'known projection' do
|
25
|
-
subject { described_class.new_from_epsg(4322) }
|
26
|
-
|
27
|
-
it 'returns a populated array' do
|
28
|
-
pending 'Understanding how to make it work'
|
29
|
-
expect(subject.to_mapinfo).to be_an Array
|
30
|
-
expect(subject.to_mapinfo).to_not be_empty
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
context 'empty SRS' do
|
35
|
-
it 'raises an OGR::NotEnoughData' do
|
36
|
-
pending 'Understanding how to make it work'
|
37
|
-
|
38
|
-
expect { subject.to_mapinfo }.to raise_exception OGR::NotEnoughData
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
describe '#to_pci' do
|
44
|
-
context 'known projection' do
|
45
|
-
subject { described_class.new_from_epsg(4322) }
|
46
|
-
|
47
|
-
it 'returns a Hash' do
|
48
|
-
expect(subject.to_pci).to eq(
|
49
|
-
projection: 'LONG/LAT D001',
|
50
|
-
units: 'DEGREE',
|
51
|
-
projection_parameters: []
|
52
|
-
)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
context 'empty SRS' do
|
57
|
-
it 'returns default values' do
|
58
|
-
expect(subject.to_pci).to eq(
|
59
|
-
projection: 'LONG/LAT E012',
|
60
|
-
units: 'DEGREE',
|
61
|
-
projection_parameters: []
|
62
|
-
)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
describe '#to_proj4' do
|
68
|
-
context 'known projection' do
|
69
|
-
subject { described_class.new_from_epsg(4322) }
|
70
|
-
|
71
|
-
it 'returns a PROJ4 String' do
|
72
|
-
expect(subject.to_proj4).to eq('+proj=longlat +ellps=WGS72 +towgs84=0,0,4.5,0,0,0.554,0.2263 +no_defs ')
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
context 'empty SRS' do
|
77
|
-
it 'raises a GDAL::UnsupportedOperation' do
|
78
|
-
expect { subject.to_proj4 }.to raise_exception GDAL::UnsupportedOperation
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
describe '#to_wkt' do
|
84
|
-
context 'known projection' do
|
85
|
-
subject { described_class.new_from_epsg(4322) }
|
86
|
-
|
87
|
-
let(:expected_wkt) do
|
88
|
-
'GEOGCS["WGS 72",DATUM["WGS_1972",SPHEROID["WGS 72",6378135,298.26,' \
|
89
|
-
'AUTHORITY["EPSG","7043"]],TOWGS84[0,0,4.5,0,0,0.554,0.2263],' \
|
90
|
-
'AUTHORITY["EPSG","6322"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],' \
|
91
|
-
'UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],' \
|
92
|
-
'AUTHORITY["EPSG","4322"]]'
|
93
|
-
end
|
94
|
-
|
95
|
-
it 'returns a well-known text String' do
|
96
|
-
expect(subject.to_wkt).to eq(expected_wkt)
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
context 'empty SRS' do
|
101
|
-
it 'returns an empty String' do
|
102
|
-
expect(subject.to_wkt).to eq ''
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
describe '#to_pretty_wkt' do
|
108
|
-
context 'known projection' do
|
109
|
-
subject { described_class.new_from_epsg(4322) }
|
110
|
-
|
111
|
-
it 'returns a well-known text String' do
|
112
|
-
expect(subject.to_pretty_wkt).to eq <<~WKT.strip
|
113
|
-
GEOGCS["WGS 72",
|
114
|
-
DATUM["WGS_1972",
|
115
|
-
SPHEROID["WGS 72",6378135,298.26,
|
116
|
-
AUTHORITY["EPSG","7043"]],
|
117
|
-
TOWGS84[0,0,4.5,0,0,0.554,0.2263],
|
118
|
-
AUTHORITY["EPSG","6322"]],
|
119
|
-
PRIMEM["Greenwich",0,
|
120
|
-
AUTHORITY["EPSG","8901"]],
|
121
|
-
UNIT["degree",0.0174532925199433,
|
122
|
-
AUTHORITY["EPSG","9122"]],
|
123
|
-
AUTHORITY["EPSG","4322"]]
|
124
|
-
WKT
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
|
-
context 'empty SRS' do
|
129
|
-
it 'returns an empty String' do
|
130
|
-
expect(subject.to_pretty_wkt).to eq ''
|
131
|
-
end
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
describe '#to_xml' do
|
136
|
-
context 'known projection' do
|
137
|
-
subject { described_class.new_from_epsg(4322) }
|
138
|
-
|
139
|
-
it 'returns an XML string' do
|
140
|
-
pending 'Understanding how to make it work'
|
141
|
-
expect(subject.to_xml).to eq 'something'
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
context 'empty SRS' do
|
146
|
-
it 'raises an OGR::UnsupportedSRS' do
|
147
|
-
expect { subject.to_xml }.to raise_exception OGR::UnsupportedSRS
|
148
|
-
end
|
149
|
-
end
|
150
|
-
end
|
151
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
require 'ogr/spatial_reference'
|
5
|
-
|
6
|
-
RSpec.describe OGR::SpatialReference do
|
7
|
-
describe '#import_from_epsg' do
|
8
|
-
context 'valid code' do
|
9
|
-
it "updates self's info" do
|
10
|
-
expect do
|
11
|
-
subject.import_from_epsg(4326)
|
12
|
-
end.to change { subject.to_wkt.size }.from(0)
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'does not treat as lat/lon' do
|
16
|
-
subject.import_from_epsg(4326)
|
17
|
-
expect(subject.epsg_treats_as_lat_long?).to eq false
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
context 'invalid code' do
|
22
|
-
it 'raises a GDAL::UnsupportedOperation' do
|
23
|
-
expect { subject.import_from_epsg 1_231_234 }.to raise_exception GDAL::UnsupportedOperation
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
describe '#import_from_epsga' do
|
29
|
-
it "updates self's info" do
|
30
|
-
expect do
|
31
|
-
subject.import_from_epsga(4326)
|
32
|
-
end.to change { subject.to_wkt.size }.from(0)
|
33
|
-
end
|
34
|
-
|
35
|
-
it 'treats as lat/lon' do
|
36
|
-
subject.import_from_epsga(4326)
|
37
|
-
expect(subject.epsg_treats_as_lat_long?).to eq true
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
require 'ogr/spatial_reference'
|
5
|
-
|
6
|
-
RSpec.describe OGR::SpatialReference do
|
7
|
-
describe '#morph_to_esri!' do
|
8
|
-
subject { described_class.new_from_epsg 4326 }
|
9
|
-
|
10
|
-
it 'changes the SRS to ESRI' do
|
11
|
-
expect do
|
12
|
-
subject.morph_to_esri!
|
13
|
-
end.to(change { subject.to_wkt.size })
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
describe '#morph_from_esri!' do
|
18
|
-
let(:esri) do
|
19
|
-
<<-ESRI.strip
|
20
|
-
GEOGCS["GCS_North_American_1983",
|
21
|
-
DATUM["D_North_American_1983",
|
22
|
-
SPHEROID["GRS_1980",6378137,298.257222101]],
|
23
|
-
PRIMEM["Greenwich",0],
|
24
|
-
UNIT["Degree",0.0174532925199433]]
|
25
|
-
ESRI
|
26
|
-
end
|
27
|
-
|
28
|
-
subject { described_class.new_from_esri(esri) }
|
29
|
-
|
30
|
-
it 'changes the SRS to ESRI' do
|
31
|
-
pending 'Figure out why morphing does not change anything'
|
32
|
-
|
33
|
-
expect do
|
34
|
-
subject.morph_from_esri!
|
35
|
-
end.to(change { subject.to_wkt.size })
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
@@ -1,105 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
require 'ogr/spatial_reference'
|
5
|
-
|
6
|
-
RSpec.describe OGR::SpatialReference do
|
7
|
-
# Not sure why yet, but it seems I can only do angular unit setting with
|
8
|
-
# certain projections; 4326 is one of them.
|
9
|
-
describe '#set_angular_units + #angular_units' do
|
10
|
-
subject { OGR::SpatialReference.new_from_epsg(4326) }
|
11
|
-
|
12
|
-
context 'using a known label and value' do
|
13
|
-
it 'sets the new label and value' do
|
14
|
-
subject.set_angular_units(OGR::SpatialReference::RADIAN_LABEL, 1.0)
|
15
|
-
expect(subject.angular_units).to eq(unit_name: 'radian', value: 1.0)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
context 'using an unknown label and value' do
|
20
|
-
it 'sets the new label and value' do
|
21
|
-
subject.set_angular_units('Darrels', 25.6)
|
22
|
-
expect(subject.angular_units).to eq(unit_name: 'Darrels', value: 25.6)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
# Not sure why yet, but it seems I can only do angular unit setting with
|
28
|
-
# certain projections; 4326 is one of them.
|
29
|
-
describe '#angular_units= + #angular_units' do
|
30
|
-
subject { OGR::SpatialReference.new_from_epsg(4326) }
|
31
|
-
|
32
|
-
context 'using a known label' do
|
33
|
-
it 'sets the new label and value' do
|
34
|
-
subject.angular_units = :radian
|
35
|
-
expect(subject.angular_units).to eq(unit_name: 'radian', value: 1.0)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
context 'using an unknown label and value' do
|
40
|
-
it 'raises a NameError' do
|
41
|
-
expect { subject.angular_units = 'Darrels' }.to raise_exception NameError
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
# Not sure why yet, but it seems I can only do linear unit setting with
|
47
|
-
# certain projections; 4333 is one of them.
|
48
|
-
describe '#set_linear_units + #linear_units' do
|
49
|
-
subject { OGR::SpatialReference.new_from_epsg(4333) }
|
50
|
-
|
51
|
-
context 'using a known label and value' do
|
52
|
-
it 'sets the new label and value' do
|
53
|
-
subject.set_linear_units(OGR::SpatialReference::FOOT_LABEL, OGR::SpatialReference::METER_TO_FOOT)
|
54
|
-
expect(subject.linear_units).to eq(unit_name: 'Foot (International)', value: 0.3048)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
context 'using an unknown label and value' do
|
59
|
-
it 'sets the new label and value' do
|
60
|
-
subject.set_linear_units('Darrels', 25.6)
|
61
|
-
expect(subject.linear_units).to eq(unit_name: 'Darrels', value: 25.6)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
# Not sure why yet, but it seems I can only do linear unit setting with
|
67
|
-
# certain projections; 4333 is one of them.
|
68
|
-
describe '#set_linear_units_and_update_parameters + #linear_units' do
|
69
|
-
subject { OGR::SpatialReference.new_from_epsg(4333) }
|
70
|
-
|
71
|
-
context 'using a known label and value' do
|
72
|
-
it 'sets the new label and value' do
|
73
|
-
subject.set_linear_units_and_update_parameters(OGR::SpatialReference::FOOT_LABEL,
|
74
|
-
OGR::SpatialReference::METER_TO_FOOT)
|
75
|
-
expect(subject.linear_units).to eq(unit_name: 'Foot (International)', value: 0.3048)
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
context 'using an unknown label and value' do
|
80
|
-
it 'sets the new label and value' do
|
81
|
-
subject.set_linear_units('Darrels', 25.6)
|
82
|
-
expect(subject.linear_units).to eq(unit_name: 'Darrels', value: 25.6)
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
# Not sure why yet, but it seems I can only do linear unit setting with
|
88
|
-
# certain projections; 4333 is one of them.
|
89
|
-
describe '#linear_units= + #linear_units' do
|
90
|
-
subject { OGR::SpatialReference.new_from_epsg(4333) }
|
91
|
-
|
92
|
-
context 'using a known label' do
|
93
|
-
it 'sets the new label and value' do
|
94
|
-
subject.linear_units = :foot
|
95
|
-
expect(subject.linear_units).to eq(unit_name: 'Foot (International)', value: 0.3048)
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
context 'using an unknown label and value' do
|
100
|
-
it 'raises a NameError' do
|
101
|
-
expect { subject.linear_units = 'Darrels' }.to raise_exception NameError
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
@@ -1,159 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
require 'ogr/spatial_reference'
|
5
|
-
|
6
|
-
RSpec.describe OGR::SpatialReference do
|
7
|
-
describe '#geographic?' do
|
8
|
-
context 'root is a GEOGCS node' do
|
9
|
-
subject { described_class.new_from_epsg 4326 }
|
10
|
-
it { is_expected.to be_geographic }
|
11
|
-
end
|
12
|
-
|
13
|
-
context 'root is not a GEOGCS node' do
|
14
|
-
it { is_expected.to_not be_geographic }
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
describe '#local?' do
|
19
|
-
context 'root is a LOCAL_CS node' do
|
20
|
-
subject do
|
21
|
-
sr = described_class.new
|
22
|
-
sr.local_cs = 'bobby'
|
23
|
-
sr
|
24
|
-
end
|
25
|
-
|
26
|
-
it { is_expected.to be_local }
|
27
|
-
end
|
28
|
-
|
29
|
-
context 'root is not a LOCAL_CS node' do
|
30
|
-
it { is_expected.to_not be_local }
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
describe '#projected?' do
|
35
|
-
context 'contains a PROJCS node' do
|
36
|
-
subject do
|
37
|
-
sr = described_class.new
|
38
|
-
sr.proj_cs = 'bobby'
|
39
|
-
sr
|
40
|
-
end
|
41
|
-
|
42
|
-
it { is_expected.to be_projected }
|
43
|
-
end
|
44
|
-
|
45
|
-
context 'does not contain a PROJCS node' do
|
46
|
-
it { is_expected.to_not be_projected }
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
describe '#compound?' do
|
51
|
-
context 'contains a COMPD_CS node' do
|
52
|
-
subject do
|
53
|
-
sr = described_class.new_from_epsg(4326)
|
54
|
-
sr.set_vert_cs('darrel', 'bobby', 2005)
|
55
|
-
sr
|
56
|
-
end
|
57
|
-
|
58
|
-
it { is_expected.to be_compound }
|
59
|
-
end
|
60
|
-
|
61
|
-
context 'does not contain a COMPD_CS node' do
|
62
|
-
it { is_expected.to_not be_compound }
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
describe '#geocentric?' do
|
67
|
-
context 'contains a GEOCCS node' do
|
68
|
-
subject do
|
69
|
-
sr = described_class.new
|
70
|
-
sr.geoc_cs = 'bobby'
|
71
|
-
sr
|
72
|
-
end
|
73
|
-
|
74
|
-
it { is_expected.to be_geocentric }
|
75
|
-
end
|
76
|
-
|
77
|
-
context 'does not contain a GEOCCS node' do
|
78
|
-
it { is_expected.to_not be_geocentric }
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
describe '#vertical?' do
|
83
|
-
context 'contains a VERT_CS node' do
|
84
|
-
subject do
|
85
|
-
sr = described_class.new
|
86
|
-
sr.set_vert_cs('darrel', 'bobby', 2005)
|
87
|
-
sr
|
88
|
-
end
|
89
|
-
|
90
|
-
it { is_expected.to be_vertical }
|
91
|
-
end
|
92
|
-
|
93
|
-
context 'does not contain a VERT_CS node' do
|
94
|
-
it { is_expected.to_not be_vertical }
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
describe '#same?' do
|
99
|
-
context 'SpatialReferences describe the same system' do
|
100
|
-
subject { described_class.new_from_epsg(4322) }
|
101
|
-
let(:other) { described_class.new_from_epsg(4322) }
|
102
|
-
it('returns true') { expect(subject.same?(other)).to eq true }
|
103
|
-
end
|
104
|
-
|
105
|
-
context 'SpatialReferences describe different systems' do
|
106
|
-
subject { described_class.new_from_epsg(4322) }
|
107
|
-
let(:other) { described_class.new_from_epsg(4326) }
|
108
|
-
it('returns false') { expect(subject.same?(other)).to eq false }
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
describe '#geog_cs_is_same?' do
|
113
|
-
context 'SpatialReferences describe the same GEOGCS system' do
|
114
|
-
subject { described_class.new_from_epsg(4322) }
|
115
|
-
let(:other) { described_class.new_from_epsg(4322) }
|
116
|
-
it('returns true') { expect(subject.geog_cs_is_same?(other)).to eq true }
|
117
|
-
end
|
118
|
-
|
119
|
-
context 'SpatialReferences describe different systems' do
|
120
|
-
subject { described_class.new_from_epsg(4322) }
|
121
|
-
let(:other) { described_class.new_from_epsg(4326) }
|
122
|
-
it('returns false') { expect(subject.geog_cs_is_same?(other)).to eq false }
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
describe '#vert_cs_is_same?' do
|
127
|
-
context 'SpatialReferences describe the same VERT_CS system' do
|
128
|
-
subject do
|
129
|
-
sr = described_class.new
|
130
|
-
sr.set_vert_cs('one', 'things', 2005)
|
131
|
-
sr
|
132
|
-
end
|
133
|
-
|
134
|
-
let(:other) do
|
135
|
-
sr = described_class.new
|
136
|
-
sr.set_vert_cs('one', 'things', 2005)
|
137
|
-
sr
|
138
|
-
end
|
139
|
-
|
140
|
-
it('returns true') { expect(subject.vert_cs_is_same?(other)).to eq true }
|
141
|
-
end
|
142
|
-
|
143
|
-
context 'SpatialReferences describe different systems' do
|
144
|
-
subject do
|
145
|
-
sr = described_class.new
|
146
|
-
sr.set_vert_cs('one', 'things', 2005)
|
147
|
-
sr
|
148
|
-
end
|
149
|
-
|
150
|
-
let(:other) do
|
151
|
-
sr = described_class.new
|
152
|
-
sr.set_vert_cs('two', 'other things', 2006)
|
153
|
-
sr
|
154
|
-
end
|
155
|
-
|
156
|
-
it('returns false') { expect(subject.vert_cs_is_same?(other)).to eq false }
|
157
|
-
end
|
158
|
-
end
|
159
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
require 'ogr/spatial_reference'
|
5
|
-
|
6
|
-
RSpec.describe OGR::SpatialReference do
|
7
|
-
describe '.projection_methods' do
|
8
|
-
context 'strip underscores' do
|
9
|
-
subject { described_class.projection_methods(true) }
|
10
|
-
|
11
|
-
it 'returns an Array of Strings' do
|
12
|
-
expect(subject).to be_an Array
|
13
|
-
expect(subject.first).to be_a String
|
14
|
-
end
|
15
|
-
|
16
|
-
it 'has Strings with no underscores' do
|
17
|
-
expect(subject).to(satisfy { |v| !v.include?('_') })
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
context 'not strip underscores' do
|
22
|
-
subject { described_class.projection_methods(false) }
|
23
|
-
|
24
|
-
it 'returns an Array of Strings' do
|
25
|
-
expect(subject).to be_an Array
|
26
|
-
expect(subject.first).to be_a String
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'has Strings with underscores' do
|
30
|
-
expect(subject).to(satisfy { |v| !v.include?(' ') })
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
describe '#copy_geog_cs_from' do
|
36
|
-
let(:other_srs) { OGR::SpatialReference.new_from_epsg(4326) }
|
37
|
-
|
38
|
-
it 'copies the info over' do
|
39
|
-
expect(subject.to_wkt).to be_empty
|
40
|
-
subject.copy_geog_cs_from(other_srs)
|
41
|
-
expect(subject.to_wkt).to eq other_srs.to_wkt
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
@@ -1,108 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
require 'ogr/style_table'
|
5
|
-
|
6
|
-
RSpec.describe OGR::StyleTable do
|
7
|
-
describe '#destroy!' do
|
8
|
-
it 'cleans up the pointer and sets it to nil' do
|
9
|
-
subject.destroy!
|
10
|
-
expect(subject.instance_variable_get(:@c_pointer)).to be_nil
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
describe '#add_style + #find' do
|
15
|
-
it '#add_style returns true' do
|
16
|
-
expect(subject.add_style('test style', '#ffffff')).to eq true
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
describe '#add_style + #find' do
|
21
|
-
it 'adds the style to the table' do
|
22
|
-
subject.add_style('test style', '#ffffff')
|
23
|
-
expect(subject.find('test style')).to eq '#ffffff'
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe '#next_style + #last_style_name' do
|
28
|
-
context 'without styles' do
|
29
|
-
context 'after calling #next_style' do
|
30
|
-
it '#last_style_name returns an empty string' do
|
31
|
-
subject.next_style
|
32
|
-
expect(subject.last_style_name).to be_empty
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
context 'with styles' do
|
38
|
-
subject do
|
39
|
-
st = described_class.new
|
40
|
-
st.add_style('test style', '12345')
|
41
|
-
st
|
42
|
-
end
|
43
|
-
|
44
|
-
context 'without calling #next_style' do
|
45
|
-
it '#last_style_name returns an empty string' do
|
46
|
-
expect(subject.last_style_name).to be_empty
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
context 'after calling #next_style' do
|
51
|
-
it '#last_style_name returns the name of the last style' do
|
52
|
-
subject.next_style
|
53
|
-
expect(subject.last_style_name).to eq 'test style'
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
describe '#load!' do
|
60
|
-
context 'file exists' do
|
61
|
-
let(:file_path) do
|
62
|
-
'spec/support/test_style_table.txt'
|
63
|
-
end
|
64
|
-
|
65
|
-
it 'returns true and imports the styles from the file' do
|
66
|
-
expect(subject.load!(file_path)).to eq true
|
67
|
-
expect(subject.find('meow things')).to eq 'Meow'
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
context 'file does not exist' do
|
72
|
-
it 'raises a GDAL::OpenFailure' do
|
73
|
-
expect do
|
74
|
-
subject.load!('blargh')
|
75
|
-
end.to raise_exception GDAL::OpenFailure
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
describe '#reset_style_string_reading' do
|
81
|
-
subject do
|
82
|
-
st = described_class.new
|
83
|
-
st.add_style('style1', '12345')
|
84
|
-
st.add_style('style2', '67890')
|
85
|
-
st
|
86
|
-
end
|
87
|
-
|
88
|
-
it 'returns the #next_style back to the first style' do
|
89
|
-
subject.next_style
|
90
|
-
subject.next_style
|
91
|
-
subject.reset_style_string_reading
|
92
|
-
expect(subject.next_style).to eq '12345'
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
describe '#styles' do
|
97
|
-
subject do
|
98
|
-
st = described_class.new
|
99
|
-
st.add_style('style1', '12345')
|
100
|
-
st.add_style('style2', '67890')
|
101
|
-
st
|
102
|
-
end
|
103
|
-
|
104
|
-
it 'returns the styles as a Hash' do
|
105
|
-
expect(subject.styles).to eq('style1' => '12345', 'style2' => '67890')
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|