proj4rb 4.1.0 → 4.1.1

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.
data/proj4rb.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = 'proj4rb'
3
- spec.version = '4.1.0'
3
+ spec.version = '4.1.1'
4
4
  spec.summary = 'Ruby bindings for the Proj coordinate transformation library'
5
5
  spec.description = <<-EOF
6
6
  Ruby bindings for the Proj coordinate transformation library
@@ -3,27 +3,4 @@ require 'minitest/autorun'
3
3
  require 'proj'
4
4
 
5
5
  class AbstractTest < Minitest::Test
6
- def self.proj7?
7
- Proj::Api::PROJ_VERSION >= Gem::Version.new("7.0.0")
8
- end
9
-
10
- def self.proj8?
11
- Proj::Api::PROJ_VERSION >= Gem::Version.new("8.0.0")
12
- end
13
-
14
- def self.proj9?
15
- Proj::Api::PROJ_VERSION >= Gem::Version.new("9.0.0")
16
- end
17
-
18
- def proj7?
19
- self.class.proj7?
20
- end
21
-
22
- def proj8?
23
- self.class.proj8?
24
- end
25
-
26
- def proj9?
27
- self.class.proj9?
28
- end
29
6
  end
@@ -31,8 +31,8 @@ class ConversionTest < AbstractTest
31
31
 
32
32
  inverse = operation.create_inverse
33
33
  proj_string = inverse.to_proj_string(:PJ_PROJ_5, multiline: true, indentation_width: 4, max_line_length: 40)
34
-
35
- expected = if proj7?
34
+
35
+ expected = if Proj::Api::PROJ_VERSION >= '7.0.0'
36
36
  <<~EOS
37
37
  +proj=pipeline
38
38
  +step +proj=axisswap +order=2,1
@@ -127,7 +127,7 @@ class ConversionTest < AbstractTest
127
127
  conversion.grid(-1)
128
128
  end
129
129
 
130
- if proj9?
130
+ if Proj::Api::PROJ_VERSION >= '9.0.0'
131
131
  assert_equal("File not found or invalid", error.to_s)
132
132
  else
133
133
  assert_equal("Unknown error (code 4096)", error.to_s)
@@ -141,12 +141,12 @@ class ConversionTest < AbstractTest
141
141
  grid = conversion.grid(0)
142
142
 
143
143
  assert_equal("ca_nrc_ntv1_can.tif", grid.name)
144
- assert_match(/ntv1_can/, grid.full_name)
145
144
  assert(grid.package_name.empty?)
146
145
  assert_equal("https://cdn.proj.org/ca_nrc_ntv1_can.tif", grid.url)
147
146
  assert(grid.downloadable?)
148
147
  assert(grid.open_license?)
149
- assert(grid.available?)
148
+ #assert_match(/ntv1_can/, grid.full_name)
149
+ #assert(grid.available?)
150
150
  end
151
151
 
152
152
  def test_xy_dist
@@ -275,7 +275,7 @@ class ConversionTest < AbstractTest
275
275
  assert_in_delta(1141263.01116045, coordinate_2.y)
276
276
  end
277
277
 
278
- if proj9?
278
+ if Proj::Api::PROJ_VERSION >= '9.0.0'
279
279
  def test_last_used_operation
280
280
  wkt = <<~EOS
281
281
  CONVERSION["UTM zone 31N",
@@ -331,11 +331,11 @@ class ConversionTest < AbstractTest
331
331
  prime_meridian_name: "Greenwich", prime_meridian_offset: 0.0, pm_angular_units: "Degree", pm_angular_units_conv: 0.0174532925199433,
332
332
  coordinate_system: coordinate_system)
333
333
 
334
- mercator = Proj::Projection.mercator_variant_a(context, center_lat: 0, center_long: 1,
334
+ mercator = Proj::Projection.mercator_variant_a(context, center_latitude: 0, center_longitude: 1,
335
335
  scale: 0.99,
336
336
  false_easting: 2, false_northing: 3,
337
- ang_unit_name: "Degree", ang_unit_conv_factor: 0.0174532925199433,
338
- linear_unit_name: "Metre", linear_unit_conv_factor: 1.0)
337
+ angular_unit_name: "Degree", angular_unit_conversion_factor: 0.0174532925199433,
338
+ linear_unit_name: "Metre", linear_unit_conversion_factor: 1.0)
339
339
 
340
340
  cartesian = Proj::CoordinateSystem.create_cartesian_2d(context, :PJ_CART2D_EASTING_NORTHING)
341
341
 
data/test/crs_test.rb CHANGED
@@ -505,9 +505,19 @@ class CrsTest < AbstractTest
505
505
 
506
506
  def test_to_json
507
507
  crs = Proj::Crs.new('EPSG:26915')
508
+
509
+ schema_version = case
510
+ when Proj::Api::PROJ_VERSION >= '9.0.0'
511
+ 'v0.7'
512
+ when Proj::Api::PROJ_VERSION >= '9.3.0'
513
+ 'v0.5'
514
+ else
515
+ 'v0.4'
516
+ end
517
+
508
518
  expected = <<~EOS
509
519
  {
510
- "$schema": "https://proj.org/schemas/#{proj9? ? 'v0.5' : 'v0.4'}/projjson.schema.json",
520
+ "$schema": "https://proj.org/schemas/#{schema_version}/projjson.schema.json",
511
521
  "type": "ProjectedCRS",
512
522
  "name": "NAD83 / UTM zone 15N",
513
523
  "base_crs": {
@@ -822,7 +832,7 @@ class CrsTest < AbstractTest
822
832
  crs = Proj::Crs.create("EPSG:4326", context)
823
833
 
824
834
  conversion = Proj::Projection.pole_rotation_grib_convention(context, south_pole_lat_in_unrotated_crs: 2, south_pole_long_in_unrotated_crs: 3,
825
- axis_rotation: 4, ang_unit_name: "Degree", ang_unit_conv_factor: 0.0174532925199433)
835
+ axis_rotation: 4, angular_unit_name: "Degree", angular_unit_conversion_factor: 0.0174532925199433)
826
836
 
827
837
  coordinate_system = crs.coordinate_system
828
838
 
@@ -922,7 +932,7 @@ class CrsTest < AbstractTest
922
932
  crses = Proj::Crs.query_geodetic_from_datum(context, datum_auth_name: "EPSG", datum_code: "6326")
923
933
 
924
934
  expected = case
925
- when proj9?
935
+ when Proj::Api::PROJ_VERSION >= '9.0.0'
926
936
  12
927
937
  else
928
938
  11
@@ -49,9 +49,15 @@ class DatabaseTest < AbstractTest
49
49
  end
50
50
 
51
51
  def test_codes
52
- types_with_no_codes = [:PJ_TYPE_TEMPORAL_CRS, :PJ_TYPE_BOUND_CRS, :PJ_TYPE_UNKNOWN, :PJ_TYPE_ENGINEERING_CRS,
52
+ if Proj::Api::PROJ_VERSION >= '9.3.0'
53
+ types_with_no_codes = [:PJ_TYPE_TEMPORAL_CRS, :PJ_TYPE_BOUND_CRS, :PJ_TYPE_UNKNOWN, :PJ_TYPE_ENGINEERING_CRS,
53
54
  :PJ_TYPE_TEMPORAL_DATUM, :PJ_TYPE_ENGINEERING_DATUM, :PJ_TYPE_PARAMETRIC_DATUM,
54
- :PJ_TYPE_OTHER_COORDINATE_OPERATION]
55
+ :PJ_TYPE_OTHER_COORDINATE_OPERATION, :PJ_TYPE_DERIVED_PROJECTED_CRS, :PJ_TYPE_COORDINATE_METADATA]
56
+ else
57
+ types_with_no_codes = [:PJ_TYPE_TEMPORAL_CRS, :PJ_TYPE_BOUND_CRS, :PJ_TYPE_UNKNOWN, :PJ_TYPE_ENGINEERING_CRS,
58
+ :PJ_TYPE_TEMPORAL_DATUM, :PJ_TYPE_ENGINEERING_DATUM, :PJ_TYPE_PARAMETRIC_DATUM,
59
+ :PJ_TYPE_OTHER_COORDINATE_OPERATION]
60
+ end
55
61
 
56
62
  database = Proj::Database.new(Proj::Context.current)
57
63
 
@@ -97,10 +103,12 @@ class DatabaseTest < AbstractTest
97
103
  crs_infos = database.crs_info
98
104
 
99
105
  expected = case
100
- when proj9?
101
- 13107
102
- else
103
- 12609
106
+ when Proj::Api::PROJ_VERSION >= '9.3.0'
107
+ 13434
108
+ when Proj::Api::PROJ_VERSION >= '9.0.0'
109
+ 13107
110
+ else
111
+ 12609
104
112
  end
105
113
  assert_equal(expected, crs_infos.count)
106
114
 
@@ -125,10 +133,12 @@ class DatabaseTest < AbstractTest
125
133
  crs_infos = database.crs_info("EPSG")
126
134
 
127
135
  expected = case
128
- when proj9?
129
- 7251
130
- else
131
- 7056
136
+ when Proj::Api::PROJ_VERSION >= '9.3.0'
137
+ 7477
138
+ when Proj::Api::PROJ_VERSION >= '9.0.0'
139
+ 7251
140
+ else
141
+ 7056
132
142
  end
133
143
  assert_equal(expected, crs_infos.count)
134
144
  end
@@ -140,10 +150,12 @@ class DatabaseTest < AbstractTest
140
150
  crs_infos = database.crs_info("EPSG", params)
141
151
 
142
152
  expected = case
143
- when proj9?
144
- 943
145
- else
146
- 930
153
+ when Proj::Api::PROJ_VERSION >= '9.3.0'
154
+ 997
155
+ when Proj::Api::PROJ_VERSION >= '9.0.0'
156
+ 943
157
+ else
158
+ 930
147
159
  end
148
160
 
149
161
  assert_equal(expected, crs_infos.count)
@@ -156,10 +168,12 @@ class DatabaseTest < AbstractTest
156
168
  crs_infos = database.crs_info("EPSG", params)
157
169
 
158
170
  expected = case
159
- when proj9?
160
- 5689
161
- else
162
- 5534
171
+ when Proj::Api::PROJ_VERSION >= '9.3.0'
172
+ 5839
173
+ when Proj::Api::PROJ_VERSION >= '9.0.0'
174
+ 5689
175
+ else
176
+ 5534
163
177
  end
164
178
 
165
179
  assert_equal(expected, crs_infos.count)
@@ -176,7 +190,15 @@ class DatabaseTest < AbstractTest
176
190
  params.north_lat_degree = 49.1
177
191
 
178
192
  crs_infos = database.crs_info("EPSG", params)
179
- assert_equal(35, crs_infos.count)
193
+
194
+ expected = case
195
+ when Proj::Api::PROJ_VERSION >= '9.3.0'
196
+ 37
197
+ else
198
+ 35
199
+ end
200
+
201
+ assert_equal(expected, crs_infos.count)
180
202
  end
181
203
 
182
204
  def test_crs_info_bounds_exclusive
@@ -191,7 +213,15 @@ class DatabaseTest < AbstractTest
191
213
  params.crs_area_of_use_contains_bbox = 0
192
214
 
193
215
  crs_infos = database.crs_info("EPSG", params)
194
- assert_equal(38, crs_infos.count)
216
+
217
+ expected = case
218
+ when Proj::Api::PROJ_VERSION >= '9.3.0'
219
+ 40
220
+ else
221
+ 38
222
+ end
223
+
224
+ assert_equal(expected, crs_infos.count)
195
225
  end
196
226
 
197
227
  def test_crs_info_celestial_body
@@ -201,10 +231,12 @@ class DatabaseTest < AbstractTest
201
231
  crs_infos = database.crs_info("EPSG", params)
202
232
 
203
233
  expected = case
204
- when proj9?
205
- 6723
206
- else
207
- 6532
234
+ when Proj::Api::PROJ_VERSION >= '9.3.0'
235
+ 6951
236
+ when Proj::Api::PROJ_VERSION >= '9.0.0'
237
+ 6723
238
+ else
239
+ 6532
208
240
  end
209
241
 
210
242
  assert_equal(expected, crs_infos.count)
@@ -237,7 +269,7 @@ class DatabaseTest < AbstractTest
237
269
  bodies = database.celestial_bodies
238
270
 
239
271
  expected = case
240
- when proj9?
272
+ when Proj::Api::PROJ_VERSION >= '9.0.0'
241
273
  176
242
274
  else
243
275
  170
@@ -255,7 +287,7 @@ class DatabaseTest < AbstractTest
255
287
  bodies = database.celestial_bodies('ESRI')
256
288
 
257
289
  expected = case
258
- when proj9?
290
+ when Proj::Api::PROJ_VERSION >= '9.0.0'
259
291
  78
260
292
  else
261
293
  72
@@ -349,7 +381,7 @@ class DatabaseTest < AbstractTest
349
381
  refute(name)
350
382
  end
351
383
 
352
- if proj7?
384
+ if Proj::Api::PROJ_VERSION >= '7.0.0'
353
385
  # This test causes a segmentation fault on proj6
354
386
  def test_metadata_invalid
355
387
  database = Proj::Database.new(Proj::Context.current)
@@ -51,20 +51,24 @@ class OperationFactoryContextTest < AbstractTest
51
51
  index = operations.suggested_operation(:PJ_FWD, coord)
52
52
 
53
53
  expected = case
54
- when proj9?
55
- 2
56
- else
57
- 7
54
+ when Proj::Api::PROJ_VERSION >= '9.3.0'
55
+ 3
56
+ when Proj::Api::PROJ_VERSION >= '9.0.0'
57
+ 2
58
+ else
59
+ 7
58
60
  end
59
61
  assert_equal(expected, index)
60
62
 
61
63
  operation = operations[index]
62
64
 
63
65
  expected = case
64
- when proj9?
65
- "NAD27 to NAD83 (1)"
66
- else
67
- "Ballpark geographic offset from NAD27 to NAD83"
66
+ when Proj::Api::PROJ_VERSION >= '9.3.0'
67
+ "NAD27 to NAD83 (7)"
68
+ when Proj::Api::PROJ_VERSION >= '9.0.0'
69
+ "NAD27 to NAD83 (1)"
70
+ else
71
+ "Ballpark geographic offset from NAD27 to NAD83"
68
72
  end
69
73
 
70
74
  assert_equal(expected, operation.name)
@@ -191,7 +195,7 @@ class OperationFactoryContextTest < AbstractTest
191
195
  assert_equal(5, operations.count)
192
196
  end
193
197
 
194
- if proj9?
198
+ if Proj::Api::PROJ_VERSION >= '9.0.0'
195
199
  def test_set_area_of_interest_name
196
200
  context = Proj::Context.new
197
201
  factory_context = Proj::OperationFactoryContext.new(context)
@@ -19,20 +19,20 @@ class PjObjectTest < AbstractTest
19
19
  def test_equivalent
20
20
  from_epsg = Proj::PjObject.create_from_database("EPSG", "7844", :PJ_CATEGORY_CRS)
21
21
  from_wkt = Proj::PjObject.create_from_wkt(<<~EOS)
22
- GEOGCRS["GDA2020",
23
- DATUM["GDA2020",
24
- ELLIPSOID["GRS_1980",6378137,298.257222101,
25
- LENGTHUNIT["metre",1]]],
26
- PRIMEM["Greenwich",0,
27
- ANGLEUNIT["Degree",0.0174532925199433]],
28
- CS[ellipsoidal,2],
29
- AXIS["geodetic latitude (Lat)",north,
30
- ORDER[1],
31
- ANGLEUNIT["degree",0.0174532925199433]],
32
- AXIS["geodetic longitude (Lon)",east,
33
- ORDER[2],
34
- ANGLEUNIT["degree",0.0174532925199433]]]"
35
- EOS
22
+ GEOGCRS["GDA2020",
23
+ DATUM["GDA2020",
24
+ ELLIPSOID["GRS_1980",6378137,298.257222101,
25
+ LENGTHUNIT["metre",1]]],
26
+ PRIMEM["Greenwich",0,
27
+ ANGLEUNIT["Degree",0.0174532925199433]],
28
+ CS[ellipsoidal,2],
29
+ AXIS["geodetic latitude (Lat)",north,
30
+ ORDER[1],
31
+ ANGLEUNIT["degree",0.0174532925199433]],
32
+ AXIS["geodetic longitude (Lon)",east,
33
+ ORDER[2],
34
+ ANGLEUNIT["degree",0.0174532925199433]]]"
35
+ EOS
36
36
 
37
37
  assert(from_epsg.equivalent_to?(from_wkt, :PJ_COMP_EQUIVALENT))
38
38
  end
@@ -136,7 +136,15 @@ class PjObjectTest < AbstractTest
136
136
  objects = Proj::PjObject.create_from_name("WGS 84", context, approximate_match: true,
137
137
  types: [:PJ_TYPE_GEODETIC_CRS, :PJ_TYPE_PROJECTED_CRS])
138
138
 
139
- expected = proj9? ? 442 : 440
139
+ expected = case
140
+ when Proj::Api::PROJ_VERSION >= '9.3.0'
141
+ 443
142
+ when Proj::Api::PROJ_VERSION >= '9.0.0'
143
+ 442
144
+ else
145
+ 440
146
+ end
147
+
140
148
  assert_equal(expected, objects.size)
141
149
  end
142
150
 
@@ -149,23 +157,23 @@ class PjObjectTest < AbstractTest
149
157
 
150
158
  def test_deprecated_true
151
159
  wkt = <<~EOS
152
- GEOGCRS["SAD69 (deprecated)",
153
- DATUM["South_American_Datum_1969",
154
- ELLIPSOID["GRS 1967",6378160,298.247167427,
155
- LENGTHUNIT["metre",1,
156
- ID["EPSG",9001]]]],
157
- PRIMEM["Greenwich",0,
160
+ GEOGCRS["SAD69 (deprecated)",
161
+ DATUM["South_American_Datum_1969",
162
+ ELLIPSOID["GRS 1967",6378160,298.247167427,
163
+ LENGTHUNIT["metre",1,
164
+ ID["EPSG",9001]]]],
165
+ PRIMEM["Greenwich",0,
166
+ ANGLEUNIT["degree",0.0174532925199433,
167
+ ID["EPSG",9122]]],
168
+ CS[ellipsoidal,2],
169
+ AXIS["latitude",north,
170
+ ORDER[1],
158
171
  ANGLEUNIT["degree",0.0174532925199433,
159
172
  ID["EPSG",9122]]],
160
- CS[ellipsoidal,2],
161
- AXIS["latitude",north,
162
- ORDER[1],
163
- ANGLEUNIT["degree",0.0174532925199433,
164
- ID["EPSG",9122]]],
165
- AXIS["longitude",east,
166
- ORDER[2],
167
- ANGLEUNIT["degree",0.0174532925199433,
168
- ID["EPSG",9122]]]]
173
+ AXIS["longitude",east,
174
+ ORDER[2],
175
+ ANGLEUNIT["degree",0.0174532925199433,
176
+ ID["EPSG",9122]]]]
169
177
  EOS
170
178
 
171
179
  crs = Proj::Crs.create(wkt)