ffi-gdal 0.0.4 → 1.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (138) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +7 -1
  3. data/Rakefile +12 -1
  4. data/TODO.md +11 -0
  5. data/ffi-gdal.gemspec +2 -2
  6. data/lib/ext/error_symbols.rb +59 -0
  7. data/lib/ext/float_ext.rb +15 -0
  8. data/lib/ext/narray_ext.rb +16 -0
  9. data/lib/ext/to_bool.rb +2 -0
  10. data/lib/ffi-gdal.rb +139 -4
  11. data/lib/ffi/{gdal/cpl_conv.rb → cpl/conv_h.rb} +2 -3
  12. data/lib/ffi/{gdal/cpl_error.rb → cpl/error_h.rb} +1 -25
  13. data/lib/ffi/cpl/minixml_h.rb +14 -0
  14. data/lib/ffi/{gdal/cpl_string.rb → cpl/string_h.rb} +0 -25
  15. data/lib/ffi/{gdal/cpl_vsi.rb → cpl/vsi_h.rb} +0 -0
  16. data/lib/ffi/cpl/xml_node.rb +13 -0
  17. data/lib/ffi/gdal.rb +57 -593
  18. data/lib/ffi/gdal/alg_h.rb +127 -0
  19. data/lib/ffi/gdal/gdal_grid_data_metrics_options.rb +14 -0
  20. data/lib/ffi/gdal/gdal_grid_inverse_distance_to_a_power_options.rb +19 -0
  21. data/lib/ffi/gdal/gdal_grid_moving_average_options.rb +14 -0
  22. data/lib/ffi/gdal/gdal_grid_nearest_neighbor_options.rb +13 -0
  23. data/lib/ffi/gdal/gdal_h.rb +683 -0
  24. data/lib/ffi/gdal/gdal_rpc_info.rb +27 -0
  25. data/lib/ffi/gdal/gdal_transformer_info.rb +14 -0
  26. data/lib/ffi/gdal/gdal_warp_options.rb +43 -0
  27. data/lib/ffi/gdal/grid_h.rb +51 -0
  28. data/lib/ffi/gdal/version.rb +1 -1
  29. data/lib/ffi/gdal/warper_h.rb +48 -0
  30. data/lib/ffi/ogr.rb +12 -0
  31. data/lib/ffi/ogr/api_h.rb +553 -0
  32. data/lib/ffi/ogr/core_h.rb +148 -0
  33. data/lib/ffi/ogr/featurestyle_h.rb +22 -0
  34. data/lib/ffi/ogr/geocoding_h.rb +21 -0
  35. data/lib/ffi/ogr/ogr_contour_writer_info.rb +14 -0
  36. data/lib/ffi/ogr/ogr_envelope.rb +12 -0
  37. data/lib/ffi/ogr/ogr_envelope_3d.rb +14 -0
  38. data/lib/ffi/ogr/ogr_field.rb +50 -0
  39. data/lib/ffi/ogr/ogr_style_param.rb +12 -0
  40. data/lib/ffi/ogr/ogr_style_value.rb +13 -0
  41. data/lib/ffi/ogr/srs_api_h.rb +325 -0
  42. data/lib/gdal/color_entry.rb +47 -0
  43. data/lib/gdal/color_entry_extensions.rb +30 -0
  44. data/lib/gdal/color_interpretation.rb +15 -0
  45. data/lib/gdal/color_table.rb +146 -0
  46. data/lib/gdal/color_table_extensions.rb +47 -0
  47. data/lib/gdal/color_table_types/cmyk.rb +25 -0
  48. data/lib/gdal/color_table_types/gray.rb +9 -0
  49. data/lib/gdal/color_table_types/hls.rb +21 -0
  50. data/lib/gdal/color_table_types/rgb.rb +25 -0
  51. data/lib/gdal/data_type.rb +38 -0
  52. data/lib/gdal/dataset.rb +437 -0
  53. data/lib/gdal/dataset_extensions.rb +496 -0
  54. data/lib/gdal/driver.rb +244 -0
  55. data/lib/gdal/driver_extensions.rb +56 -0
  56. data/lib/gdal/environment_methods.rb +43 -0
  57. data/lib/{ffi-gdal → gdal}/exceptions.rb +4 -1
  58. data/lib/gdal/geo_transform.rb +188 -0
  59. data/lib/gdal/geo_transform_extensions.rb +90 -0
  60. data/lib/gdal/logger.rb +7 -0
  61. data/lib/{ffi-gdal → gdal}/major_object.rb +15 -14
  62. data/lib/gdal/options.rb +49 -0
  63. data/lib/gdal/raster_attribute_table.rb +185 -0
  64. data/lib/gdal/raster_attribute_table_extensions.rb +40 -0
  65. data/lib/{ffi-gdal → gdal}/raster_band.rb +227 -99
  66. data/lib/gdal/raster_band_extensions.rb +198 -0
  67. data/lib/{ffi-gdal → gdal}/version_info.rb +8 -0
  68. data/lib/gdal/warp_operation.rb +96 -0
  69. data/lib/ogr/coordinate_transformation.rb +108 -0
  70. data/lib/ogr/data_source.rb +172 -0
  71. data/lib/ogr/data_source_extensions.rb +32 -0
  72. data/lib/ogr/driver.rb +119 -0
  73. data/lib/ogr/envelope.rb +80 -0
  74. data/lib/ogr/envelope_extensions.rb +92 -0
  75. data/lib/ogr/exceptions.rb +35 -0
  76. data/lib/ogr/feature.rb +212 -0
  77. data/lib/ogr/feature_definition.rb +120 -0
  78. data/lib/ogr/feature_definition_extensions.rb +36 -0
  79. data/lib/ogr/feature_extensions.rb +31 -0
  80. data/lib/ogr/field.rb +91 -0
  81. data/lib/ogr/field_extensions.rb +23 -0
  82. data/lib/ogr/geocoding_session.rb +84 -0
  83. data/lib/ogr/geometry.rb +617 -0
  84. data/lib/ogr/geometry_extensions.rb +60 -0
  85. data/lib/ogr/geometry_types/collection.rb +45 -0
  86. data/lib/ogr/geometry_types/curve.rb +120 -0
  87. data/lib/ogr/geometry_types/surface.rb +20 -0
  88. data/lib/ogr/layer.rb +226 -0
  89. data/lib/ogr/layer_extensions.rb +55 -0
  90. data/lib/ogr/line_string.rb +7 -0
  91. data/lib/ogr/linear_ring.rb +6 -0
  92. data/lib/ogr/multi_line_string.rb +9 -0
  93. data/lib/ogr/multi_point.rb +7 -0
  94. data/lib/ogr/multi_polygon.rb +14 -0
  95. data/lib/ogr/point.rb +89 -0
  96. data/lib/ogr/polygon.rb +9 -0
  97. data/lib/ogr/spatial_reference.rb +723 -0
  98. data/lib/ogr/spatial_reference_extensions.rb +32 -0
  99. data/lib/ogr/style_table.rb +17 -0
  100. data/lib/ogr/style_table_extensions.rb +16 -0
  101. data/spec/{ffi-gdal/integration → integration}/color_table_info_spec.rb +1 -1
  102. data/spec/{ffi-gdal/integration → integration}/dataset_info_spec.rb +0 -0
  103. data/spec/{ffi-gdal/integration → integration}/driver_info_spec.rb +1 -1
  104. data/spec/{ffi-gdal/integration → integration}/geo_transform_info_spec.rb +0 -0
  105. data/spec/{ffi-gdal/integration → integration}/raster_attribute_table_info_spec.rb +1 -1
  106. data/spec/{ffi-gdal/integration → integration}/raster_band_info_spec.rb +5 -5
  107. data/spec/spec_helper.rb +4 -1
  108. data/spec/support/shapefiles/states_21basic/states.prj +1 -0
  109. data/spec/support/shapefiles/states_21basic/states.sbn +0 -0
  110. data/spec/support/shapefiles/states_21basic/states.sbx +0 -0
  111. data/spec/support/shapefiles/states_21basic/states.shp +0 -0
  112. data/spec/support/worldfiles/SR_50M/SR_50M.VERSION.txt +1 -0
  113. data/spec/support/worldfiles/SR_50M/SR_50M.prj +1 -0
  114. data/spec/support/worldfiles/SR_50M/SR_50M.tfw +6 -0
  115. data/spec/{ext/cpl_error_symbols_spec.rb → unit/ext/error_symbols_spec.rb} +1 -1
  116. data/spec/unit/gdal/color_table_spec.rb +146 -0
  117. data/spec/unit/ogr/layer_spec.rb +97 -0
  118. data/spec/unit/ogr/linear_ring_spec.rb +111 -0
  119. data/spec/unit/ogr/point_spec.rb +321 -0
  120. data/spec/{ffi-gdal/unit → unit}/version_info_spec.rb +1 -1
  121. data/testing_gdal.rb +168 -0
  122. data/testing_gdalwarp.rb +91 -0
  123. data/testing_layer_to_layer.rb +35 -0
  124. data/testing_ndvi.rb +76 -0
  125. data/testing_nir.rb +77 -0
  126. data/testing_ogr.rb +63 -0
  127. metadata +167 -59
  128. data/lib/ext/cpl_error_symbols.rb +0 -37
  129. data/lib/ffi-gdal/color_table.rb +0 -59
  130. data/lib/ffi-gdal/dataset.rb +0 -359
  131. data/lib/ffi-gdal/driver.rb +0 -151
  132. data/lib/ffi-gdal/geo_transform.rb +0 -137
  133. data/lib/ffi-gdal/raster_attribute_table.rb +0 -78
  134. data/lib/ffi/gdal/ogr_api.rb +0 -21
  135. data/lib/ffi/gdal/ogr_core.rb +0 -195
  136. data/lib/ffi/gdal/ogr_srs_api.rb +0 -44
  137. data/meow.rb +0 -144
  138. data/rubby.rb +0 -224
@@ -0,0 +1,32 @@
1
+ require 'json'
2
+
3
+ module OGR
4
+ module SpatialReferenceExtensions
5
+
6
+ # @return [Hash]
7
+ def as_json
8
+ {
9
+ angular_units: angular_units,
10
+ epsg_treats_as_lat_long: epsg_treats_as_lat_long?,
11
+ epsg_treats_as_northing_easting: epsg_treats_as_northing_easting?,
12
+ is_compound: compound?,
13
+ is_geocentric: geocentric?,
14
+ is_geographic: geographic?,
15
+ is_local: local?,
16
+ is_projected: projected?,
17
+ is_vertical: vertical?,
18
+ linear_units: linear_units,
19
+ prime_meridian: prime_meridian,
20
+ semi_major: semi_major,
21
+ semi_minor: semi_minor,
22
+ spheroid_inverse_flattening: spheroid_inverse_flattening,
23
+ utm_zone: utm_zone
24
+ }
25
+ end
26
+
27
+ # @return [String]
28
+ def to_json
29
+ as_json.to_json
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,17 @@
1
+ require_relative '../ffi/ogr'
2
+ require_relative 'style_table_extensions'
3
+
4
+ module OGR
5
+ class StyleTable
6
+ include StyleTableExtensions
7
+
8
+ # @param style_table [OGR::StyleTable, FFI::Pointer]
9
+ def initialize(style_table)
10
+ @ogr_style_table_pointer = GDAL._pointer(OGR::StyleTable, style_table)
11
+ end
12
+
13
+ def c_pointer
14
+ @ogr_style_table_pointer
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,16 @@
1
+ require 'json'
2
+
3
+ module OGR
4
+ module StyleTableExtensions
5
+
6
+ # @return [String]
7
+ def as_json
8
+ 'StyleTable interface not yet wrapped with ffi-ruby'
9
+ end
10
+
11
+ # @return [String]
12
+ def to_json
13
+ as_json.to_json
14
+ end
15
+ end
16
+ end
@@ -13,7 +13,7 @@ TIF_FILES.each do |file|
13
13
 
14
14
  # TODO: Test against each raster band
15
15
  subject do
16
- band = GDAL::RasterBand.new(dataset.c_pointer, band_id: 1)
16
+ band = dataset.raster_band(1)
17
17
  band.color_table
18
18
  end
19
19
 
@@ -5,7 +5,7 @@ require 'ffi-gdal'
5
5
  TIF_FILES.each do |file|
6
6
  describe 'Driver Info' do
7
7
  subject do
8
- GDAL::Driver.new(file_path: file)
8
+ GDAL::Driver.open_by_file(file)
9
9
  end
10
10
 
11
11
  it_behaves_like 'a major object'
@@ -12,7 +12,7 @@ TIF_FILES.each do |file|
12
12
  end
13
13
 
14
14
  subject do
15
- band = GDAL::RasterBand.new(dataset.c_pointer, band_id: 1)
15
+ band = dataset.raster_band(1)
16
16
  band.default_raster_attribute_table
17
17
  end
18
18
 
@@ -5,8 +5,8 @@ require 'ffi-gdal'
5
5
 
6
6
  TIF_FILES.each do |file|
7
7
  dataset = GDAL::Dataset.open(file, 'r')
8
- dataset.each_band do |band_under_test|
9
8
 
9
+ dataset.each_band do |band_under_test|
10
10
  describe "Raster Band Info" do
11
11
  after :suite do
12
12
  dataset.close
@@ -14,7 +14,7 @@ TIF_FILES.each do |file|
14
14
 
15
15
  # TODO: Test against each raster band
16
16
  subject do
17
- GDAL::RasterBand.new(dataset.c_pointer, raster_band_pointer: band_under_test.c_pointer)
17
+ GDAL::RasterBand.new(band_under_test.c_pointer)
18
18
  end
19
19
 
20
20
  it_behaves_like 'a major object'
@@ -37,10 +37,10 @@ TIF_FILES.each do |file|
37
37
  specify { expect(subject.access_flag).to eq :GA_ReadOnly }
38
38
  end
39
39
 
40
- describe '#band_number' do
40
+ describe '#number' do
41
41
  it 'is a non-zero Integer' do
42
- expect(subject.band_number).to be_a Fixnum
43
- expect(subject.band_number).to be > 0
42
+ expect(subject.number).to be_a Fixnum
43
+ expect(subject.number).to be > 0
44
44
  end
45
45
  end
46
46
 
data/spec/spec_helper.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  $:.unshift File.expand_path('../lib', __FILE__)
2
- $:.unshift File.expand_path('../spec', __FILE__)
2
+ #$:.unshift File.expand_path('../spec', __FILE__)
3
+ require 'ffi-gdal'
3
4
 
4
5
  Dir['./spec/support/shared_examples/**/*.rb'].sort.each { |f| require f}
5
6
 
@@ -11,3 +12,5 @@ RSpec.configure do |config|
11
12
  # --seed 1234
12
13
  config.order = 'random'
13
14
  end
15
+
16
+ OGR::Geometry.logging_enabled = true
@@ -0,0 +1 @@
1
+ GEOGCS["GCS_North_American_1983",DATUM["D_North_American_1983",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]]
@@ -0,0 +1 @@
1
+ GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.017453292519943295]]
@@ -0,0 +1,6 @@
1
+ 0.03333333333333
2
+ 0.00000000000000
3
+ 0.00000000000000
4
+ -0.03333333333333
5
+ -179.98333333333333
6
+ 89.98333333333333
@@ -1,5 +1,5 @@
1
1
  require 'spec_helper'
2
- require 'ext/cpl_error_symbols'
2
+ require 'ext/error_symbols'
3
3
 
4
4
  describe Symbol do
5
5
  describe '#to_ruby' do
@@ -0,0 +1,146 @@
1
+ require 'spec_helper'
2
+
3
+
4
+ describe GDAL::ColorTable do
5
+ describe '.create' do
6
+ context 'with a valid PaletteInterpretation' do
7
+ it 'creates a new ColorTable' do
8
+ expect(described_class.create(:GPI_RGB)).to be_a(described_class)
9
+ end
10
+ end
11
+
12
+ context 'with an invalid PaletteInterpretation' do
13
+ it 'raises an ArgumentError' do
14
+ expect {
15
+ described_class.create(:MEOW)
16
+ }.to raise_exception(ArgumentError)
17
+ end
18
+ end
19
+ end
20
+
21
+ describe '#initialize' do
22
+ context ':GPI_RGB' do
23
+ it 'extends the new object with the ColorTableTypes::RGB module' do
24
+ expect_any_instance_of(described_class).to receive(:extend).
25
+ with(GDAL::ColorTableTypes::RGB)
26
+ described_class.create(:GPI_RGB)
27
+ end
28
+ end
29
+
30
+ context ':GPI_Gray' do
31
+ it 'extends the new object with the ColorTableTypes::Gray module' do
32
+ expect_any_instance_of(described_class).to receive(:extend).
33
+ with(GDAL::ColorTableTypes::Gray)
34
+ described_class.create(:GPI_Gray)
35
+ end
36
+ end
37
+
38
+ context ':GPI_CMYK' do
39
+ it 'extends the new object with the ColorTableTypes::CMYK module' do
40
+ expect_any_instance_of(described_class).to receive(:extend).
41
+ with(GDAL::ColorTableTypes::CMYK)
42
+ described_class.create(:GPI_CMYK)
43
+ end
44
+ end
45
+
46
+ context ':GPI_HLS' do
47
+ it 'extends the new object with the ColorTableTypes::HLS module' do
48
+ expect_any_instance_of(described_class).to receive(:extend).
49
+ with(GDAL::ColorTableTypes::HLS)
50
+ described_class.create(:GPI_HLS)
51
+ end
52
+ end
53
+ end
54
+
55
+ subject do
56
+ described_class.create(:GPI_RGB)
57
+ end
58
+
59
+ describe '#palette_interpretation' do
60
+ it 'equals the symbol that was given during .create' do
61
+ expect(subject.palette_interpretation).to eq :GPI_RGB
62
+ end
63
+ end
64
+
65
+ describe '#color_entry_count' do
66
+ it 'defaults to 0' do
67
+ expect(subject.color_entry_count).to be_zero
68
+ end
69
+ end
70
+
71
+ describe '#color_entry' do
72
+ context 'when no entries' do
73
+ it 'returns nil' do
74
+ expect(subject.color_entry(900)).to be_nil
75
+ end
76
+ end
77
+
78
+ context 'when entries' do
79
+ before do
80
+ subject.add_color_entry(0)
81
+ end
82
+
83
+ it 'returns the ColorEntry' do
84
+ expect(subject.color_entry(0)).to be_a GDAL::ColorEntry
85
+ end
86
+ end
87
+ end
88
+
89
+ describe '#color_entry_as_rgb' do
90
+ context 'when no entries' do
91
+ it 'returns nil' do
92
+ expect(subject.color_entry_as_rgb(900)).to be_nil
93
+ end
94
+ end
95
+
96
+ context 'when entries' do
97
+ before do
98
+ subject.add_color_entry(0)
99
+ end
100
+
101
+ it 'returns the ColorEntry' do
102
+ expect(subject.color_entry_as_rgb(0)).to be_a GDAL::ColorEntry
103
+ end
104
+ end
105
+ end
106
+
107
+ describe '#add_color_entry' do
108
+ context 'no values given' do
109
+ it 'creates and returns the entry' do
110
+ expect(subject.add_color_entry(0)).to be_a GDAL::ColorEntry
111
+ end
112
+ end
113
+
114
+ context 'all values given' do
115
+ it 'creates and returns the entry' do
116
+ expect(subject.add_color_entry(0, 75, 250, 255)).to be_a GDAL::ColorEntry
117
+ end
118
+ end
119
+
120
+ context 'bad values given' do
121
+ it 'creates and returns the entry' do
122
+ expect(subject.add_color_entry(0, 300, 250, 255)).to be_a GDAL::ColorEntry
123
+ end
124
+ end
125
+ end
126
+
127
+ describe '#create_color_ramp!' do
128
+ context 'no color entries' do
129
+ it 'returns nil' do
130
+ entry0 = GDAL::ColorEntry.new
131
+ entry1 = GDAL::ColorEntry.new
132
+ expect(subject.create_color_ramp!(0, entry0, 1, entry1)).to be_nil
133
+ end
134
+ end
135
+
136
+ context 'color entries that exist' do
137
+ it 'returns nil' do
138
+ entry0 = subject.add_color_entry(0, 0, 0, 0, 0)
139
+ entry1 = subject.add_color_entry(1, 10, 10, 10, 10)
140
+ entry2 = subject.add_color_entry(2, 100, 100, 100, 100)
141
+
142
+ expect(subject.create_color_ramp!(0, entry0, 2, entry2)).to be_nil
143
+ end
144
+ end
145
+ end
146
+ end
@@ -0,0 +1,97 @@
1
+ require 'spec_helper'
2
+
3
+ describe OGR::Layer do
4
+ let(:data_source) do
5
+ OGR::DataSource.open('spec/support/shapefiles/states_21basic/states.shp', 'r')
6
+ end
7
+
8
+ let(:layer0) do
9
+ data_source.layer(0)
10
+ end
11
+
12
+ subject do
13
+ layer0
14
+ end
15
+
16
+ describe '#name' do
17
+ subject { layer0.name }
18
+ it { is_expected.to eq 'states' }
19
+ end
20
+
21
+ describe '#geometry_type' do
22
+ subject { layer0.geometry_type }
23
+ it { is_expected.to eq :wkbPolygon }
24
+ end
25
+
26
+ describe '#feature_count' do
27
+ subject { layer0.feature_count }
28
+ it { is_expected.to eq 51 }
29
+ end
30
+
31
+ describe '#feature' do
32
+ subject { layer0.feature(0) }
33
+ it { is_expected.to be_a OGR::Feature }
34
+ end
35
+
36
+ describe '#next_feature' do
37
+ subject { layer0.next_feature }
38
+ it { is_expected.to be_a OGR::Feature }
39
+ end
40
+
41
+ describe '#features_read' do
42
+ subject { layer0.features_read }
43
+ it { is_expected.to be >= 0 }
44
+ end
45
+
46
+ describe '#features' do
47
+ subject { layer0.features }
48
+ it { is_expected.to be_an Array }
49
+ specify { expect(subject.first).to be_a OGR::Feature }
50
+ specify { expect(subject.size).to eq layer0.feature_count }
51
+ end
52
+
53
+ describe '#feature_definition' do
54
+ subject { layer0.feature_definition }
55
+ it { is_expected.to be_a OGR::FeatureDefinition }
56
+ end
57
+
58
+ describe '#spatial_reference' do
59
+ subject { layer0.spatial_reference }
60
+ it { is_expected.to be_a OGR::SpatialReference }
61
+ end
62
+
63
+ describe '#extent' do
64
+ subject { layer0.extent }
65
+ it { is_expected.to be_a OGR::Envelope }
66
+ end
67
+
68
+ describe '#fid_column' do
69
+ subject { layer0.fid_column }
70
+ it { is_expected.to be_a String }
71
+ it { is_expected.to be_empty }
72
+ end
73
+
74
+ describe '#geometry_column' do
75
+ subject { layer0.geometry_column }
76
+ it { is_expected.to be_a String }
77
+ it { is_expected.to be_empty }
78
+ end
79
+
80
+ describe '#style_table' do
81
+ subject { layer0.style_table }
82
+ it { is_expected.to be_nil }
83
+ end
84
+
85
+ describe '#geometry_from_extent' do
86
+ it 'is a Polygon' do
87
+ geometry = subject.geometry_from_extent
88
+ expect(geometry).to be_a OGR::Polygon
89
+ end
90
+ end
91
+
92
+ describe '#as_json' do
93
+ specify do
94
+ expect { subject.as_json }.to_not raise_exception
95
+ end
96
+ end
97
+ end
@@ -0,0 +1,111 @@
1
+ require 'spec_helper'
2
+
3
+ describe OGR::LinearRing do
4
+ let(:linear_ring) do
5
+ g = OGR::Geometry.create(:wkbLinearRing)
6
+ g.add_point(0, 0)
7
+ g.add_point(0, 10)
8
+ g.add_point(10, 10)
9
+ g.add_point(10, 0)
10
+ g.add_point(0, 0)
11
+
12
+ g
13
+ end
14
+
15
+ subject { linear_ring }
16
+
17
+ describe '#closed' do
18
+ it { is_expected.to be_closed }
19
+ end
20
+
21
+ describe '#dimension' do
22
+ subject { linear_ring.dimension }
23
+ it { is_expected.to eq 1 }
24
+ end
25
+
26
+ describe '#coordinate_dimension' do
27
+ subject { linear_ring.coordinate_dimension }
28
+ it { is_expected.to eq 2 }
29
+ end
30
+
31
+ describe '#envelope' do
32
+ subject { linear_ring.envelope }
33
+ it { is_expected.to be_a OGR::Envelope }
34
+ end
35
+
36
+ describe '#type' do
37
+ subject { linear_ring.type }
38
+ it { is_expected.to eq :wkbLineString }
39
+ end
40
+
41
+ describe '#type_to_name' do
42
+ subject { linear_ring.type }
43
+ it { is_expected.to eq :wkbLineString }
44
+ end
45
+
46
+ describe '#name' do
47
+ subject { linear_ring.name }
48
+ it { is_expected.to eq 'LINEARRING' }
49
+ end
50
+
51
+ describe '#count' do
52
+ subject { linear_ring.count }
53
+ it { is_expected.to be_zero }
54
+ end
55
+
56
+ describe '#point_count' do
57
+ subject { linear_ring.point_count }
58
+ it { is_expected.to eq 5 }
59
+ end
60
+
61
+ describe '#intersects?' do
62
+ context 'other geometry is a point' do
63
+ context 'inside the ring' do
64
+ let(:other_geometry) do
65
+ OGR::Geometry.create_from_wkt('POINT (0 1)')
66
+ end
67
+
68
+ subject { linear_ring.intersects?(other_geometry) }
69
+ it { is_expected.to eq false }
70
+ end
71
+
72
+ context 'on a vertex of the ring' do
73
+ let(:other_geometry) do
74
+ OGR::Geometry.create_from_wkt('POINT (0 0)')
75
+ end
76
+
77
+ subject { linear_ring.intersects?(other_geometry) }
78
+ it { is_expected.to eq false }
79
+ end
80
+ end
81
+
82
+ context 'other geometry is a line string' do
83
+ context 'outside the ring' do
84
+ let(:other_geometry) do
85
+ OGR::Geometry.create_from_wkt('LINESTRING (100 100, 200 200)')
86
+ end
87
+
88
+ subject { linear_ring.intersects?(other_geometry) }
89
+ it { is_expected.to eq false }
90
+ end
91
+
92
+ context 'ends on a vertex' do
93
+ let(:other_geometry) do
94
+ OGR::Geometry.create_from_wkt('LINESTRING (50 50, 0 0)')
95
+ end
96
+
97
+ subject { linear_ring.intersects?(other_geometry) }
98
+ it { is_expected.to eq false }
99
+ end
100
+
101
+ context 'passes across the boundary' do
102
+ let(:other_geometry) do
103
+ OGR::Geometry.create_from_wkt('LINESTRING (15 5, 5 5)')
104
+ end
105
+
106
+ subject { linear_ring.intersects?(other_geometry) }
107
+ it { is_expected.to eq false }
108
+ end
109
+ end
110
+ end
111
+ end