proj4rb 4.0.0 → 4.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/lib/proj/session.rb CHANGED
@@ -2,6 +2,7 @@ module Proj
2
2
  class Session
3
3
  attr_reader :context
4
4
 
5
+ # @!visibility private
5
6
  def self.finalize(context, pointer)
6
7
  proc do
7
8
  Api.proj_insert_object_session_destroy(context, pointer)
@@ -24,7 +25,7 @@ module Proj
24
25
  # @param authority [String] - Authority name into which the object will be inserted. Must not be nil
25
26
  # @param code [Integer] - Code with which the object will be inserted.Must not be nil
26
27
  # @param numeric_codes [Boolean] - Whether intermediate objects that can be created should use numeric codes (true), or may be alphanumeric (false)
27
- # @param allowed_authorities [Array[String]] - Authorities to which intermediate objects are allowed to refer to. "authority" will be implicitly added to it.
28
+ # @param allowed_authorities [Array<String>] - Authorities to which intermediate objects are allowed to refer to. "authority" will be implicitly added to it.
28
29
  #
29
30
  # @return [Strings] - List of insert statements
30
31
  def get_insert_statements(object, authority, code, numeric_codes = false, allowed_authorities = nil)
@@ -1,5 +1,5 @@
1
1
  module Proj
2
- # Transformations are {CoordinateOperationMix coordinate operations} that
2
+ # Transformations are {CoordinateOperationMixin coordinate operations} that
3
3
  # convert {Coordinate coordinates} from one {Crs} to another.
4
4
  # In Proj they are defined as operations that exert a change in reference frame
5
5
  # while {Conversion conversions } do not.
@@ -19,7 +19,7 @@ module Proj
19
19
  # @param method_auth_name [String] Method authority name. Default is nil.
20
20
  # @param method_code [String] Method code. Default is nil.
21
21
  # @param params [Array<Parameter>] Parameter descriptions
22
- # @param accuracy [Double] Accuracy of the transformation in meters. A negative value means unknown.
22
+ # @param accuracy [Float] Accuracy of the transformation in meters. A negative value means unknown.
23
23
  #
24
24
  # @return [Transformation]
25
25
  def self.create(context, name: nil, auth_name: nil, code: nil,
@@ -58,8 +58,8 @@ module Proj
58
58
  # @see https://proj.org/development/reference/functions.html#c.proj_create_crs_to_crs_from_pj
59
59
  # @see https://proj.org/development/reference/functions.html#c.proj_create_crs_to_crs proj_create_crs_to_crs
60
60
  #
61
- # @param source [Crs | String] The source Crs. See the Crs documentation for the string format
62
- # @param target [Crs | String] The target Crs. See the Crs documentation for the string format
61
+ # @param source [Crs, String] The source Crs. See the Crs documentation for the string format
62
+ # @param target [Crs, String] The target Crs. See the Crs documentation for the string format
63
63
  # @param area [Area] If an area is specified a more accurate transformation between two given systems can be chosen
64
64
  # @param context [Context]
65
65
  # @param authority [String] Restricts the authority of coordinate operations looked up in the database
data/lib/proj/unit.rb CHANGED
@@ -79,7 +79,7 @@ module Proj
79
79
  self.code == other.code
80
80
  end
81
81
 
82
- def type
82
+ def unit_type
83
83
  case self.category
84
84
  when "linear"
85
85
  :PJ_UT_LINEAR
data/lib/proj.rb CHANGED
@@ -40,6 +40,8 @@ module Proj
40
40
  # Returns information about the Proj library
41
41
  #
42
42
  # @see https://proj.org/development/reference/functions.html#c.proj_info proj_info
43
+ #
44
+ # @return [PJ_INFO]
43
45
  def self.info
44
46
  Api.proj_info
45
47
  end
@@ -47,6 +49,8 @@ module Proj
47
49
  # Returns the Proj version
48
50
  #
49
51
  # @see https://proj.org/development/reference/functions.html#c.proj_info proj_info
52
+ #
53
+ # @return [String]
50
54
  def self.version
51
55
  self.info[:version]
52
56
  end
@@ -55,7 +59,7 @@ module Proj
55
59
  #
56
60
  # @see https://proj.org/development/reference/functions.html#c.proj_info proj_info
57
61
  #
58
- # @return Array<string> List of search paths
62
+ # @return [Array<String>] List of search paths
59
63
  def self.search_paths
60
64
  self.info[:searchpath].split(";")
61
65
  end
@@ -75,9 +79,9 @@ module Proj
75
79
  #
76
80
  # see https://proj.org/development/reference/functions.html#c.proj_torad proj_torad
77
81
  #
78
- # @param value [Double] Value in degrees to convert
82
+ # @param value [Float] Value in degrees to convert
79
83
  #
80
- # @return [Double]
84
+ # @return [Float]
81
85
  def self.degrees_to_radians(value)
82
86
  Api.proj_torad(value)
83
87
  end
@@ -86,9 +90,9 @@ module Proj
86
90
  #
87
91
  # see https://proj.org/development/reference/functions.html#c.proj_todeg proj_todeg
88
92
  #
89
- # @param value [Double] Value in radians to convert
93
+ # @param value [Float] Value in radians to convert
90
94
  #
91
- # @return [Double]
95
+ # @return [Float]
92
96
  def self.radians_to_degrees(value)
93
97
  Api.proj_todeg(value)
94
98
  end
@@ -99,7 +103,7 @@ module Proj
99
103
  #
100
104
  # @param value [String] Value to be converted to radians
101
105
  #
102
- # @return [Double]
106
+ # @return [Float]
103
107
  def self.degrees_minutes_seconds_to_radians(value)
104
108
  ptr = FFI::MemoryPointer.new(:string)
105
109
  Api.proj_dmstor(value, ptr)
@@ -110,7 +114,7 @@ module Proj
110
114
  # @see https://proj.org/development/reference/functions.html#c.proj_rtodms proj_rtodms
111
115
  # @see https://proj.org/development/reference/functions.html#c.proj_rtodms2 proj_rtodms2
112
116
  #
113
- # @param value [Double] Value to be converted in radians
117
+ # @param value [Float] Value to be converted in radians
114
118
  # @param positive [String] Character denoting positive direction, typically 'N' or 'E'. Default 'N'
115
119
  # @param negative [String] Character denoting negative direction, typically 'S' or 'W'. Default 'S'
116
120
  #
data/proj4rb.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = 'proj4rb'
3
- spec.version = '4.0.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",
@@ -326,16 +326,16 @@ class ConversionTest < AbstractTest
326
326
  context = Proj::Context.new
327
327
  coordinate_system = Proj::CoordinateSystem.create_ellipsoidal_2d(:PJ_ELLPS2D_LONGITUDE_LATITUDE, context)
328
328
 
329
- crs = Proj::Crs.create_geographic(context, name: "WGS 84", datum_name: "World Geodetic System 1984", ellps_name: "WGS 84",
329
+ crs = Proj::Crs.create_geographic(context, name: "WGS 84", datum_name: "World Geodetic System 1984", ellipsoid_name: "WGS 84",
330
330
  semi_major_meter: 6378137, inv_flattening: 298.257223563,
331
- prime_meridian_name: "Greenwich", prime_meridian_offset: 0.0, pm_angular_units: "Degree", pm_units_conv: 0.0174532925199433,
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
 
@@ -8,9 +8,9 @@ class CoordinateSystemTest < AbstractTest
8
8
  crs = Proj::Crs.new('EPSG:4326', context)
9
9
  cs = crs.coordinate_system
10
10
  axes = cs.axes
11
- cs = Proj::CoordinateSystem.create(cs.type, axes, context)
11
+ cs = Proj::CoordinateSystem.create(cs.cs_type, axes, context)
12
12
  assert_equal(2, cs.axis_count)
13
- assert_equal(:PJ_CS_TYPE_ELLIPSOIDAL, cs.type)
13
+ assert_equal(:PJ_CS_TYPE_ELLIPSOIDAL, cs.cs_type)
14
14
  assert_equal(:PJ_TYPE_UNKNOWN, cs.proj_type)
15
15
  refute(cs.auth_name)
16
16
  refute(cs.id_code)
@@ -20,7 +20,7 @@ class CoordinateSystemTest < AbstractTest
20
20
  context = Proj::Context.new
21
21
  cs = Proj::CoordinateSystem.create_ellipsoidal_2d(:PJ_ELLPS2D_LONGITUDE_LATITUDE, context)
22
22
  assert_equal(2, cs.axis_count)
23
- assert_equal(:PJ_CS_TYPE_ELLIPSOIDAL, cs.type)
23
+ assert_equal(:PJ_CS_TYPE_ELLIPSOIDAL, cs.cs_type)
24
24
  assert_equal(:PJ_TYPE_UNKNOWN, cs.proj_type)
25
25
  refute(cs.auth_name)
26
26
  refute(cs.id_code)
@@ -30,7 +30,7 @@ class CoordinateSystemTest < AbstractTest
30
30
  context = Proj::Context.new
31
31
  cs = Proj::CoordinateSystem.create_ellipsoidal_3d(:PJ_ELLPS3D_LATITUDE_LONGITUDE_HEIGHT, context)
32
32
  assert_equal(3, cs.axis_count)
33
- assert_equal(:PJ_CS_TYPE_ELLIPSOIDAL, cs.type)
33
+ assert_equal(:PJ_CS_TYPE_ELLIPSOIDAL, cs.cs_type)
34
34
  assert_equal(:PJ_TYPE_UNKNOWN, cs.proj_type)
35
35
 
36
36
  axis = cs.axis_info(0)
@@ -54,7 +54,7 @@ class CoordinateSystemTest < AbstractTest
54
54
  horizontal_angular_unit_name: "foo", horizontal_angular_unit_conv_factor: 0.5,
55
55
  vertical_linear_unit_name: "bar", vertical_linear_unit_conv_factor: 0.6)
56
56
  assert_equal(3, cs.axis_count)
57
- assert_equal(:PJ_CS_TYPE_ELLIPSOIDAL, cs.type)
57
+ assert_equal(:PJ_CS_TYPE_ELLIPSOIDAL, cs.cs_type)
58
58
  assert_equal(:PJ_TYPE_UNKNOWN, cs.proj_type)
59
59
 
60
60
  axis = cs.axis_info(0)
@@ -83,7 +83,7 @@ class CoordinateSystemTest < AbstractTest
83
83
  context = Proj::Context.new
84
84
  coordinate_system = Proj::CoordinateSystem.create_cartesian_2d(context, :PJ_CART2D_EASTING_NORTHING)
85
85
  assert_equal(2, coordinate_system.axis_count)
86
- assert_equal(:PJ_CS_TYPE_CARTESIAN, coordinate_system.type)
86
+ assert_equal(:PJ_CS_TYPE_CARTESIAN, coordinate_system.cs_type)
87
87
  assert_equal(:PJ_TYPE_UNKNOWN, coordinate_system.proj_type)
88
88
  end
89
89
 
@@ -91,7 +91,7 @@ class CoordinateSystemTest < AbstractTest
91
91
  crs = Proj::Crs.new('EPSG:4326')
92
92
  cs = crs.coordinate_system
93
93
  refute(cs.name)
94
- assert_equal(:PJ_CS_TYPE_ELLIPSOIDAL, cs.type)
94
+ assert_equal(:PJ_CS_TYPE_ELLIPSOIDAL, cs.cs_type)
95
95
  assert_equal(:PJ_TYPE_UNKNOWN, cs.proj_type)
96
96
  assert_equal("EPSG", cs.auth_name)
97
97
  assert_equal("6422", cs.id_code)
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": {
@@ -702,9 +712,9 @@ class CrsTest < AbstractTest
702
712
  context = Proj::Context.new
703
713
  coordinate_system = Proj::CoordinateSystem.create_ellipsoidal_2d(:PJ_ELLPS2D_LATITUDE_LONGITUDE, context)
704
714
 
705
- crs = Proj::Crs.create_geographic(context, name: "WGS 84", datum_name: "World Geodetic System 1984", ellps_name: "WGS 84",
715
+ crs = Proj::Crs.create_geographic(context, name: "WGS 84", datum_name: "World Geodetic System 1984", ellipsoid_name: "WGS 84",
706
716
  semi_major_meter: 6378137, inv_flattening: 298.257223563,
707
- prime_meridian_name: "Greenwich", prime_meridian_offset: 0.0, pm_angular_units: "Degree", pm_units_conv: 0.0174532925199433,
717
+ prime_meridian_name: "Greenwich", prime_meridian_offset: 0.0, pm_angular_units: "Degree", pm_angular_units_conv: 0.0174532925199433,
708
718
  coordinate_system: coordinate_system)
709
719
 
710
720
  crs_2 = Proj::Crs.create_from_database("EPSG", "4326", :PJ_CATEGORY_CRS)
@@ -720,7 +730,7 @@ class CrsTest < AbstractTest
720
730
 
721
731
  def test_geocentric
722
732
  context = Proj::Context.new
723
- crs = Proj::Crs.create_geocentric(context, name: "WGS 84", datum_name: "World Geodetic System 1984", ellps_name: "WGS 84",
733
+ crs = Proj::Crs.create_geocentric(context, name: "WGS 84", datum_name: "World Geodetic System 1984", ellipsoid_name: "WGS 84",
724
734
  semi_major_meter: 6378137, inv_flattening: 298.257223563,
725
735
  prime_meridian_name: "Greenwich", prime_meridian_offset: 0.0,
726
736
  angular_units: "Degree", angular_units_conv: 0.0174532925199433,
@@ -732,7 +742,7 @@ class CrsTest < AbstractTest
732
742
 
733
743
  def test_geocentric_datum
734
744
  context = Proj::Context.new
735
- crs = Proj::Crs.create_geocentric(context, name: "WGS 84", datum_name: "World Geodetic System 1984", ellps_name: "WGS 84",
745
+ crs = Proj::Crs.create_geocentric(context, name: "WGS 84", datum_name: "World Geodetic System 1984", ellipsoid_name: "WGS 84",
736
746
  semi_major_meter: 6378137, inv_flattening: 298.257223563,
737
747
  prime_meridian_name: "Greenwich", prime_meridian_offset: 0.0,
738
748
  angular_units: "Degree", angular_units_conv: 0.0174532925199433,
@@ -791,9 +801,9 @@ class CrsTest < AbstractTest
791
801
  context = Proj::Context.new
792
802
  coordinate_system = Proj::CoordinateSystem.create_ellipsoidal_2d(:PJ_ELLPS2D_LONGITUDE_LATITUDE, context)
793
803
 
794
- horizontal_crs = Proj::Crs.create_geographic(context, name: "WGS 84", datum_name: "World Geodetic System 1984", ellps_name: "WGS 84",
804
+ horizontal_crs = Proj::Crs.create_geographic(context, name: "WGS 84", datum_name: "World Geodetic System 1984", ellipsoid_name: "WGS 84",
795
805
  semi_major_meter: 6378137, inv_flattening: 298.257223563,
796
- prime_meridian_name: "Greenwich", prime_meridian_offset: 0.0, pm_angular_units: "Degree", pm_units_conv: 0.0174532925199433,
806
+ prime_meridian_name: "Greenwich", prime_meridian_offset: 0.0, pm_angular_units: "Degree", pm_angular_units_conv: 0.0174532925199433,
797
807
  coordinate_system: coordinate_system)
798
808
 
799
809
  vertical_crs = Proj::Crs.create_vertical(context, name: "myVertCRS",
@@ -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
 
@@ -860,9 +870,9 @@ class CrsTest < AbstractTest
860
870
 
861
871
  coordinate_system = Proj::CoordinateSystem.create_ellipsoidal_2d(:PJ_ELLPS2D_LONGITUDE_LATITUDE, context)
862
872
  crs = Proj::Crs.create_geographic(context, name: "WGS 84", datum_name: "World Geodetic System 1984",
863
- ellps_name: "WGS 84", semi_major_meter: 6378137, inv_flattening: 298.257223563,
873
+ ellipsoid_name: "WGS 84", semi_major_meter: 6378137, inv_flattening: 298.257223563,
864
874
  prime_meridian_name: "Greenwich", prime_meridian_offset: 0.0,
865
- pm_angular_units: "Degree", pm_units_conv: 0.0174532925199433,
875
+ pm_angular_units: "Degree", pm_angular_units_conv: 0.0174532925199433,
866
876
  coordinate_system: coordinate_system)
867
877
 
868
878
  cartesian = Proj::CoordinateSystem.create_cartesian_2d(context, :PJ_CART2D_EASTING_NORTHING)
@@ -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
@@ -940,9 +950,9 @@ class CrsTest < AbstractTest
940
950
  context = Proj::Context.new
941
951
  coordinate_system = Proj::CoordinateSystem.create_ellipsoidal_2d(:PJ_ELLPS2D_LATITUDE_LONGITUDE, context)
942
952
 
943
- crs = Proj::Crs.create_geographic(context, name: "WGS 84", datum_name: "World Geodetic System 1984", ellps_name: "WGS 84",
953
+ crs = Proj::Crs.create_geographic(context, name: "WGS 84", datum_name: "World Geodetic System 1984", ellipsoid_name: "WGS 84",
944
954
  semi_major_meter: 6378137, inv_flattening: 298.257223563,
945
- prime_meridian_name: "Greenwich", prime_meridian_offset: 0.0, pm_angular_units: "Degree", pm_units_conv: 0.0174532925199433,
955
+ prime_meridian_name: "Greenwich", prime_meridian_offset: 0.0, pm_angular_units: "Degree", pm_angular_units_conv: 0.0174532925199433,
946
956
  coordinate_system: coordinate_system)
947
957
  assert_equal("WGS 84", crs.name)
948
958
 
@@ -955,9 +965,9 @@ class CrsTest < AbstractTest
955
965
  context = Proj::Context.new
956
966
  coordinate_system = Proj::CoordinateSystem.create_ellipsoidal_2d(:PJ_ELLPS2D_LATITUDE_LONGITUDE, context)
957
967
 
958
- crs = Proj::Crs.create_geographic(context, name: "WGS 84", datum_name: "World Geodetic System 1984", ellps_name: "WGS 84",
968
+ crs = Proj::Crs.create_geographic(context, name: "WGS 84", datum_name: "World Geodetic System 1984", ellipsoid_name: "WGS 84",
959
969
  semi_major_meter: 6378137, inv_flattening: 298.257223563,
960
- prime_meridian_name: "Greenwich", prime_meridian_offset: 0.0, pm_angular_units: "Degree", pm_units_conv: 0.0174532925199433,
970
+ prime_meridian_name: "Greenwich", prime_meridian_offset: 0.0, pm_angular_units: "Degree", pm_angular_units_conv: 0.0174532925199433,
961
971
  coordinate_system: coordinate_system)
962
972
  refute(crs.auth)
963
973
 
@@ -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
 
@@ -108,7 +116,7 @@ class DatabaseTest < AbstractTest
108
116
  assert_equal("EPSG", crs_info.auth_name)
109
117
  assert_equal("2000", crs_info.code)
110
118
  assert_equal("Anguilla 1957 / British West Indies Grid", crs_info.name)
111
- assert_equal(:PJ_TYPE_PROJECTED_CRS, crs_info.type)
119
+ assert_equal(:PJ_TYPE_PROJECTED_CRS, crs_info.crs_type)
112
120
  refute(crs_info.deprecated)
113
121
  assert(crs_info.bbox_valid)
114
122
  assert_equal(-63.22, crs_info.west_lon_degree)
@@ -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)