proj4rb 3.0.0 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog +26 -15
  3. data/README.rdoc +82 -44
  4. data/Rakefile +27 -27
  5. data/lib/api/api.rb +96 -118
  6. data/lib/api/api_5_0.rb +331 -300
  7. data/lib/api/api_5_1.rb +6 -6
  8. data/lib/api/api_5_2.rb +4 -4
  9. data/lib/api/api_6_0.rb +116 -14
  10. data/lib/api/api_6_1.rb +4 -4
  11. data/lib/api/api_6_2.rb +9 -6
  12. data/lib/api/api_6_3.rb +6 -0
  13. data/lib/api/api_7_0.rb +68 -0
  14. data/lib/api/api_7_1.rb +73 -0
  15. data/lib/api/api_7_2.rb +14 -0
  16. data/lib/api/api_8_0.rb +6 -0
  17. data/lib/api/api_8_1.rb +24 -0
  18. data/lib/api/api_8_2.rb +6 -0
  19. data/lib/api/api_9_1.rb +7 -0
  20. data/lib/api/api_9_2.rb +9 -0
  21. data/lib/api/api_experimental.rb +196 -0
  22. data/lib/proj/area.rb +73 -32
  23. data/lib/proj/axis_info.rb +44 -0
  24. data/lib/proj/bounds.rb +13 -0
  25. data/lib/proj/context.rb +174 -28
  26. data/lib/proj/conversion.rb +92 -0
  27. data/lib/proj/coordinate.rb +281 -197
  28. data/lib/proj/coordinate_operation_mixin.rb +381 -0
  29. data/lib/proj/coordinate_system.rb +137 -0
  30. data/lib/proj/crs.rb +672 -204
  31. data/lib/proj/crs_info.rb +47 -0
  32. data/lib/proj/database.rb +305 -0
  33. data/lib/proj/datum.rb +32 -0
  34. data/lib/proj/datum_ensemble.rb +34 -0
  35. data/lib/proj/ellipsoid.rb +77 -41
  36. data/lib/proj/error.rb +62 -9
  37. data/lib/proj/file_api.rb +166 -0
  38. data/lib/proj/grid.rb +121 -0
  39. data/lib/proj/grid_cache.rb +64 -0
  40. data/lib/proj/grid_info.rb +19 -0
  41. data/lib/proj/network_api.rb +92 -0
  42. data/lib/proj/operation.rb +42 -42
  43. data/lib/proj/operation_factory_context.rb +136 -0
  44. data/lib/proj/parameter.rb +38 -0
  45. data/lib/proj/parameters.rb +106 -0
  46. data/lib/proj/pj_object.rb +670 -80
  47. data/lib/proj/pj_objects.rb +44 -0
  48. data/lib/proj/prime_meridian.rb +65 -39
  49. data/lib/proj/projection.rb +698 -207
  50. data/lib/proj/session.rb +46 -0
  51. data/lib/proj/strings.rb +32 -0
  52. data/lib/proj/transformation.rb +101 -60
  53. data/lib/proj/unit.rb +108 -53
  54. data/lib/proj.rb +110 -9
  55. data/proj4rb.gemspec +5 -5
  56. data/test/abstract_test.rb +23 -1
  57. data/test/context_test.rb +172 -82
  58. data/test/conversion_test.rb +368 -0
  59. data/test/coordinate_system_test.rb +144 -0
  60. data/test/crs_test.rb +770 -71
  61. data/test/database_test.rb +360 -0
  62. data/test/datum_ensemble_test.rb +65 -0
  63. data/test/datum_test.rb +55 -0
  64. data/test/ellipsoid_test.rb +64 -18
  65. data/test/file_api_test.rb +66 -0
  66. data/test/grid_cache_test.rb +72 -0
  67. data/test/grid_test.rb +141 -0
  68. data/test/network_api_test.rb +45 -0
  69. data/test/operation_factory_context_test.rb +201 -0
  70. data/test/parameters_test.rb +40 -0
  71. data/test/pj_object_test.rb +179 -0
  72. data/test/prime_meridian_test.rb +76 -0
  73. data/test/proj_test.rb +46 -4
  74. data/test/projection_test.rb +646 -222
  75. data/test/session_test.rb +78 -0
  76. data/test/transformation_test.rb +149 -7
  77. data/test/unit_test.rb +57 -28
  78. metadata +51 -13
  79. data/lib/api/api_4_9.rb +0 -31
  80. data/lib/proj/config.rb +0 -70
  81. data/lib/proj/point.rb +0 -72
  82. data/test/prime_meridians_test.rb +0 -33
@@ -0,0 +1,78 @@
1
+ # encoding: UTF-8
2
+
3
+ require_relative './abstract_test'
4
+
5
+ class SessionTest < AbstractTest
6
+ def teardown
7
+ GC.start
8
+ end
9
+
10
+ def create_crs
11
+ Proj::Crs.new(<<~EOS, Proj::Context.new)
12
+ GEOGCRS["myGDA2020",
13
+ DATUM["GDA2020",
14
+ ELLIPSOID["GRS_1980",6378137,298.257222101,
15
+ LENGTHUNIT["metre",1]]],
16
+ PRIMEM["Greenwich",0,
17
+ ANGLEUNIT["Degree",0.0174532925199433]],
18
+ CS[ellipsoidal,2],
19
+ AXIS["geodetic latitude (Lat)",north,
20
+ ORDER[1],
21
+ ANGLEUNIT["degree",0.0174532925199433]],
22
+ AXIS["geodetic longitude (Lon)",east,
23
+ ORDER[2],
24
+ ANGLEUNIT["degree",0.0174532925199433]]]
25
+ EOS
26
+ end
27
+
28
+ def test_create_session
29
+ session = Proj::Session.new
30
+ assert(session)
31
+ end
32
+
33
+ def test_finalize
34
+ 100.times do
35
+ crs = Proj::Session.new(Proj::Context.new)
36
+ assert(crs.to_ptr)
37
+ GC.start
38
+ end
39
+ assert(true)
40
+ end
41
+
42
+ def test_insert_statements
43
+ crs = create_crs
44
+ session = Proj::Session.new(crs.context)
45
+ statements = session.get_insert_statements(crs, "HOBU", "XXXX")
46
+ assert_equal(4, statements.count)
47
+
48
+ expected = "INSERT INTO geodetic_datum VALUES('HOBU','GEODETIC_DATUM_XXXX','GDA2020','','EPSG','7019','EPSG','8901',NULL,NULL,NULL,NULL,0);"
49
+ assert_equal(expected, statements[0])
50
+ end
51
+
52
+ def test_insert_statements_empty_authorities
53
+ crs = create_crs
54
+
55
+ session = Proj::Session.new(crs.context)
56
+ statements = session.get_insert_statements(crs, "HOBU", "XXXX", false, [])
57
+ assert_equal(6, statements.count)
58
+ end
59
+
60
+ def test_insert_statements_authorities_proj
61
+ crs = create_crs
62
+
63
+ session = Proj::Session.new(crs.context)
64
+ statements = session.get_insert_statements(crs, "HOBU", "XXXX", false, ['EPSG'])
65
+ assert_equal(4, statements.count)
66
+ end
67
+
68
+ def test_insert_twice
69
+ crs = create_crs
70
+
71
+ session = Proj::Session.new(crs.context)
72
+ statements = session.get_insert_statements(crs, "HOBU", "XXXX")
73
+ assert_equal(4, statements.count)
74
+
75
+ statements = session.get_insert_statements(crs, "HOBU", "XXXX")
76
+ assert_equal(0, statements.count)
77
+ end
78
+ end
@@ -3,23 +3,76 @@
3
3
  require_relative './abstract_test'
4
4
 
5
5
  class TransformationTest < AbstractTest
6
- PRECISION = 0.5
6
+ PRECISION = 1.5
7
7
 
8
8
  def setup
9
- @crs_wgs84 = Proj::Crs.new('epsg:4326')
10
- @crs_gk = Proj::Crs.new('epsg:31467')
9
+ @crs_wgs84 = Proj::Crs.new('EPSG:4326')
10
+ @crs_gk = Proj::Crs.new('EPSG:31467')
11
11
  end
12
12
 
13
13
  def test_create_from_strings
14
- transform = Proj::Transformation.new('epsg:31467', 'epsg:4326')
14
+ transform = Proj::Transformation.new('EPSG:31467', 'EPSG:4326')
15
15
  assert(transform.info)
16
16
  end
17
17
 
18
- def test_create_crs
18
+ def test_create_from_crs
19
19
  transform = Proj::Transformation.new(@crs_wgs84, @crs_gk)
20
20
  assert(transform.info)
21
21
  end
22
22
 
23
+ def test_create
24
+ context = Proj::Context.new
25
+ coordinate_system = Proj::CoordinateSystem.create_ellipsoidal_2d(:PJ_ELLPS2D_LONGITUDE_LATITUDE, context)
26
+ source_crs = Proj::Crs.create_geographic(context,
27
+ name: "Source CRS",
28
+ datum_name: "World Geodetic System 1984",
29
+ ellps_name: "WGS 84",
30
+ semi_major_meter: 6378137,
31
+ inv_flattening: 298.257223563,
32
+ prime_meridian_name: "Greenwich",
33
+ prime_meridian_offset: 0.0,
34
+ pm_angular_units: "Degree",
35
+ pm_units_conv: 0.0174532925199433,
36
+ coordinate_system: coordinate_system)
37
+
38
+ target_crs = Proj::Crs.create_geographic(context,
39
+ name: "WGS 84",
40
+ datum_name: "World Geodetic System 1984",
41
+ ellps_name: "WGS 84",
42
+ semi_major_meter: 6378137,
43
+ inv_flattening: 298.257223563,
44
+ prime_meridian_name: "Greenwich",
45
+ prime_meridian_offset: 0.0,
46
+ pm_angular_units: "Degree",
47
+ pm_units_conv: 0.0174532925199433,
48
+ coordinate_system: coordinate_system)
49
+
50
+ interp_crs = Proj::Crs.create_geographic(context,
51
+ name: "Interpolation CRS",
52
+ datum_name: "World Geodetic System 1984",
53
+ ellps_name: "WGS 84",
54
+ semi_major_meter: 6378137,
55
+ inv_flattening: 298.257223563,
56
+ prime_meridian_name: "Greenwich",
57
+ prime_meridian_offset: 0.0,
58
+ pm_angular_units: "Degree",
59
+ pm_units_conv: 0.0174532925199433,
60
+ coordinate_system: coordinate_system)
61
+
62
+ param = Proj::Parameter.new(name: "param name", value: 0.99,
63
+ unit_conv_factor: 1.0, unit_type: :PJ_UT_SCALE)
64
+
65
+ transformation = Proj::Transformation.create(context, name: "transf", auth_name: "transf auth", code: "transf code",
66
+ source_crs: source_crs, target_crs: target_crs, interpolation_crs: interp_crs,
67
+ method_name: "method", method_auth_name: "method_auth", method_code: "1",
68
+ params: [param], accuracy: 0)
69
+
70
+ assert_equal(1, transformation.param_count)
71
+
72
+ assert(source_crs.equivalent_to?(transformation.source_crs, :PJ_COMP_STRICT))
73
+ assert(target_crs.equivalent_to?(transformation.target_crs, :PJ_COMP_STRICT))
74
+ end
75
+
23
76
  # echo "3458305 5428192" | cs2cs -f '%.10f' +init=epsg:31467 +to +init=epsg:4326 -
24
77
  def test_gk_to_wgs84_forward
25
78
  transform = Proj::Transformation.new(@crs_gk, @crs_wgs84)
@@ -37,7 +90,7 @@ class TransformationTest < AbstractTest
37
90
  from = Proj::Coordinate.new(lam: 48.9906726079, phi: 8.4302123334)
38
91
  to = transform.inverse(from)
39
92
 
40
- assert_in_delta(5428307, to.x, PRECISION)
93
+ assert_in_delta(5428306, to.x, PRECISION)
41
94
  assert_in_delta(3458375, to.y, PRECISION)
42
95
  assert_in_delta(0, to.z, PRECISION)
43
96
  assert_in_delta(0, to.t, PRECISION)
@@ -49,7 +102,7 @@ class TransformationTest < AbstractTest
49
102
  from = Proj::Coordinate.new(lam: 48.9906726079, phi: 8.4302123334)
50
103
  to = transform.forward(from)
51
104
 
52
- assert_in_delta(5428307, to.x, PRECISION)
105
+ assert_in_delta(5428306, to.x, PRECISION)
53
106
  assert_in_delta(3458375, to.y, PRECISION)
54
107
  assert_in_delta(0, to.z, PRECISION)
55
108
  assert_in_delta(0, to.t, PRECISION)
@@ -65,4 +118,93 @@ class TransformationTest < AbstractTest
65
118
  assert_in_delta(-5.1790915237, to.z, PRECISION)
66
119
  assert_in_delta(0, to.t, PRECISION)
67
120
  end
121
+
122
+ def test_with_area
123
+ area = Proj::Area.new(west_lon_degree: -114.1324, south_lat_degree: 49.5614,
124
+ east_lon_degree: 3.76488, north_lat_degree: 62.1463)
125
+ transformation = Proj::Transformation.new("EPSG:4277", "EPSG:4326", area: area)
126
+
127
+ coordinate1 = Proj::Coordinate.new(x: 50, y: -2, z: 0, t: Float::INFINITY)
128
+ coordinate2 = transformation.forward(coordinate1)
129
+
130
+ assert_in_delta(50.00065628, coordinate2.x, 1e-4)
131
+ assert_in_delta(-2.00133989, coordinate2.y, 1e-4)
132
+ end
133
+
134
+ def test_accuracy_filter
135
+ src = Proj::Crs.new("EPSG:4326")
136
+ dst = Proj::Crs.new("EPSG:4258")
137
+
138
+ error = assert_raises(Proj::Error) do
139
+ Proj::Transformation.new(src, dst, accuracy: 0.05)
140
+ end
141
+ assert_equal("No operation found matching criteria", error.to_s)
142
+ end
143
+
144
+ def test_ballpark_filter
145
+ src = Proj::Crs.new("EPSG:4267")
146
+ dst = Proj::Crs.new("EPSG:4258")
147
+
148
+ error = assert_raises(Proj::Error) do
149
+ Proj::Transformation.new(src, dst, allow_ballpark: false)
150
+ end
151
+ assert_equal("No operation found matching criteria", error.to_s)
152
+ end
153
+
154
+ if proj8?
155
+ def test_transform_bounds
156
+ transform = Proj::Transformation.new("EPSG:4326",
157
+ "+proj=laea +lat_0=45 +lon_0=-100 +x_0=0 +y_0=0 +a=6370997 +b=6370997 +units=m +no_defs")
158
+
159
+ start_bounds = Proj::Bounds.new(40, -120, 64, -80)
160
+ end_bounds = transform.transform_bounds(start_bounds, :PJ_FWD, 0)
161
+
162
+ assert_equal(-1684649.4133828662, end_bounds.xmin)
163
+ assert_equal(-350356.8137658477, end_bounds.ymin)
164
+ assert_equal(1684649.4133828674, end_bounds.xmax)
165
+ assert_equal(2234551.1855909275, end_bounds.ymax)
166
+ end
167
+
168
+ def test_transform_bounds_normalized
169
+ transform = Proj::Transformation.new("EPSG:4326",
170
+ "+proj=laea +lat_0=45 +lon_0=-100 +x_0=0 +y_0=0 +a=6370997 +b=6370997 +units=m +no_defs")
171
+
172
+ normalized = transform.normalize_for_visualization
173
+
174
+ start_bounds = Proj::Bounds.new(-120, 40, -80, 64)
175
+ end_bounds = normalized.transform_bounds(start_bounds, :PJ_FWD, 100)
176
+
177
+ assert_equal(-1684649.4133828662, end_bounds.xmin)
178
+ assert_equal(-555777.7923351025, end_bounds.ymin)
179
+ assert_equal(1684649.4133828674, end_bounds.xmax)
180
+ assert_equal(2234551.1855909275, end_bounds.ymax)
181
+ end
182
+
183
+ def test_transform_bounds_densify
184
+ transform = Proj::Transformation.new("EPSG:4326",
185
+ "+proj=laea +lat_0=45 +lon_0=-100 +x_0=0 +y_0=0 +a=6370997 +b=6370997 +units=m +no_defs")
186
+
187
+ start_bounds = Proj::Bounds.new(40, -120, 64, -80)
188
+ end_bounds = transform.transform_bounds(start_bounds, :PJ_FWD, 100)
189
+
190
+ assert_equal(-1684649.4133828662, end_bounds.xmin)
191
+ assert_equal(-555777.7923351025, end_bounds.ymin)
192
+ assert_equal(1684649.4133828674, end_bounds.xmax)
193
+ assert_equal(2234551.1855909275, end_bounds.ymax)
194
+ end
195
+
196
+ def test_instantiable
197
+ operation = Proj::Conversion.create_from_database("EPSG", "1671", :PJ_CATEGORY_COORDINATE_OPERATION)
198
+ assert(operation.instantiable?)
199
+ end
200
+
201
+ def test_steps_not_concatenated
202
+ operation = Proj::Conversion.create_from_database("EPSG", "8048", :PJ_CATEGORY_COORDINATE_OPERATION)
203
+ assert_instance_of(Proj::Transformation, operation)
204
+ assert_equal(:PJ_TYPE_TRANSFORMATION, operation.proj_type)
205
+
206
+ assert_equal(0, operation.step_count)
207
+ refute(operation.step(0))
208
+ end
209
+ end
68
210
  end
data/test/unit_test.rb CHANGED
@@ -4,44 +4,73 @@ require_relative './abstract_test'
4
4
 
5
5
  class UnitsTest < AbstractTest
6
6
  def test_get_all
7
- units = Proj::Unit.list.sort.collect {|unit| unit.id}
8
- assert(units.include?('deg'))
9
- assert(units.include?('km'))
10
- assert(units.include?('m'))
11
- assert(units.include?('yd'))
12
- assert(units.include?('us-mi'))
7
+ database = Proj::Database.new(Proj::Context.current)
8
+ units = database.units
9
+ assert_equal(91, units.count)
10
+
11
+ unit = units[0]
12
+ assert_instance_of(Proj::Unit, unit)
13
+ end
14
+
15
+ def test_builtin
16
+ units = Proj::Unit.built_in
17
+ assert_equal(24, units.count)
18
+
19
+ unit = units[0]
20
+ assert_instance_of(Proj::Unit, unit)
13
21
  end
14
22
 
15
23
  def test_linear_unit
16
- unit = Proj::Unit.get('km')
17
- assert_kind_of Proj::Unit, unit
18
- assert_equal('km', unit.id)
19
- assert_equal('km', unit.to_s)
20
- assert_equal('1000', unit.to_meter)
21
- assert_equal(1000.0, unit.factor)
22
- assert_equal('Kilometer', unit.name)
23
- assert_equal('#<Proj::Unit id="km", to_meter="1000", factor="1000.0", name="Kilometer">', unit.inspect)
24
+ database = Proj::Database.new(Proj::Context.current)
25
+ units = database.units(category: "linear")
26
+ assert_equal(52, units.count)
27
+
28
+ unit = units[0]
29
+ assert_instance_of(Proj::Unit, unit)
30
+ assert_equal('millimetre', unit.name)
31
+ assert_equal('millimetre', unit.to_s)
32
+ assert_equal('mm', unit.proj_short_name)
33
+ assert_equal(0.001, unit.conv_factor)
34
+ assert_equal('EPSG', unit.auth_name)
35
+ assert_equal('#<Proj::Unit authority="EPSG", code="1025", name="millimetre">', unit.inspect)
24
36
  end
25
37
 
26
38
  def test_angular_unit
27
- unit = Proj::Unit.get('deg')
28
- assert_kind_of Proj::Unit, unit
29
- assert_equal('deg', unit.id)
30
- assert_equal('deg', unit.to_s)
31
- assert_equal('0.017453292519943296', unit.to_meter)
32
- assert_equal(0.017453292519943295, unit.factor)
33
- assert_equal('Degree', unit.name)
34
- assert_equal('#<Proj::Unit id="deg", to_meter="0.017453292519943296", factor="0.017453292519943295", name="Degree">', unit.inspect)
39
+ database = Proj::Database.new(Proj::Context.current)
40
+ units = database.units(category: "angular")
41
+ assert_equal(22, units.count)
42
+
43
+ unit = units[0]
44
+ assert_equal('milliarc-second', unit.name)
45
+ assert_equal('milliarc-second', unit.to_s)
46
+ refute(unit.proj_short_name)
47
+ assert_in_delta(4.84813681109536e-09, unit.conv_factor, 0.0001)
48
+ assert_equal('EPSG', unit.auth_name)
49
+ assert_equal('#<Proj::Unit authority="EPSG", code="1031", name="milliarc-second">', unit.inspect)
35
50
  end
36
51
 
37
52
  def test_compare
38
- u1 = Proj::Unit.get('km')
39
- u2 = Proj::Unit.get('km')
40
- assert(u1 == u2)
53
+ database = Proj::Database.new(Proj::Context.current)
54
+ unit_1 = database.unit("EPSG", "9001")
55
+ unit_2 = database.unit("EPSG", "9001")
56
+ assert(unit_1 == unit_2)
41
57
  end
42
58
 
43
- def test_failed_get
44
- unit = Proj::Unit.get('foo')
45
- assert_nil unit
59
+ def test_category
60
+ database = Proj::Database.new(Proj::Context.current)
61
+
62
+ %w[linear linear_per_time angular angular_per_time scale scale_per_time time].each do |category|
63
+ units = database.units(category: category)
64
+ refute_empty(units)
65
+ end
66
+ end
67
+
68
+ def test_auth_name
69
+ database = Proj::Database.new(Proj::Context.current)
70
+
71
+ %w[EPSG PROJ].each do |auth_name|
72
+ units = database.units(auth_name: auth_name)
73
+ refute_empty(units)
74
+ end
46
75
  end
47
76
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: proj4rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Guilhem Vellut
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2021-09-27 00:00:00.000000000 Z
13
+ date: 2023-03-13 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: ffi
@@ -82,9 +82,7 @@ dependencies:
82
82
  - - ">="
83
83
  - !ruby/object:Gem::Version
84
84
  version: '0'
85
- description: " Proj4rb is a ruby binding for the Proj.4 Carthographic Projection
86
- library, that supports conversions between a very large number of geographic coordinate
87
- systems and datumspec.\n"
85
+ description: " Ruby bindings for the Proj coordinate transformation library\n"
88
86
  email:
89
87
  executables: []
90
88
  extensions: []
@@ -96,39 +94,79 @@ files:
96
94
  - README.rdoc
97
95
  - Rakefile
98
96
  - lib/api/api.rb
99
- - lib/api/api_4_9.rb
100
97
  - lib/api/api_5_0.rb
101
98
  - lib/api/api_5_1.rb
102
99
  - lib/api/api_5_2.rb
103
100
  - lib/api/api_6_0.rb
104
101
  - lib/api/api_6_1.rb
105
102
  - lib/api/api_6_2.rb
103
+ - lib/api/api_6_3.rb
104
+ - lib/api/api_7_0.rb
105
+ - lib/api/api_7_1.rb
106
+ - lib/api/api_7_2.rb
107
+ - lib/api/api_8_0.rb
108
+ - lib/api/api_8_1.rb
109
+ - lib/api/api_8_2.rb
110
+ - lib/api/api_9_1.rb
111
+ - lib/api/api_9_2.rb
112
+ - lib/api/api_experimental.rb
106
113
  - lib/proj.rb
107
114
  - lib/proj/area.rb
108
- - lib/proj/config.rb
115
+ - lib/proj/axis_info.rb
116
+ - lib/proj/bounds.rb
109
117
  - lib/proj/context.rb
118
+ - lib/proj/conversion.rb
110
119
  - lib/proj/coordinate.rb
120
+ - lib/proj/coordinate_operation_mixin.rb
121
+ - lib/proj/coordinate_system.rb
111
122
  - lib/proj/crs.rb
123
+ - lib/proj/crs_info.rb
124
+ - lib/proj/database.rb
125
+ - lib/proj/datum.rb
126
+ - lib/proj/datum_ensemble.rb
112
127
  - lib/proj/ellipsoid.rb
113
128
  - lib/proj/error.rb
129
+ - lib/proj/file_api.rb
130
+ - lib/proj/grid.rb
131
+ - lib/proj/grid_cache.rb
132
+ - lib/proj/grid_info.rb
133
+ - lib/proj/network_api.rb
114
134
  - lib/proj/operation.rb
135
+ - lib/proj/operation_factory_context.rb
136
+ - lib/proj/parameter.rb
137
+ - lib/proj/parameters.rb
115
138
  - lib/proj/pj_object.rb
116
- - lib/proj/point.rb
139
+ - lib/proj/pj_objects.rb
117
140
  - lib/proj/prime_meridian.rb
118
141
  - lib/proj/projection.rb
142
+ - lib/proj/session.rb
143
+ - lib/proj/strings.rb
119
144
  - lib/proj/transformation.rb
120
145
  - lib/proj/unit.rb
121
146
  - lib/proj4.rb
122
147
  - proj4rb.gemspec
123
148
  - test/abstract_test.rb
124
149
  - test/context_test.rb
150
+ - test/conversion_test.rb
151
+ - test/coordinate_system_test.rb
125
152
  - test/coordinate_test.rb
126
153
  - test/crs_test.rb
154
+ - test/database_test.rb
155
+ - test/datum_ensemble_test.rb
156
+ - test/datum_test.rb
127
157
  - test/ellipsoid_test.rb
158
+ - test/file_api_test.rb
159
+ - test/grid_cache_test.rb
160
+ - test/grid_test.rb
161
+ - test/network_api_test.rb
162
+ - test/operation_factory_context_test.rb
128
163
  - test/operation_test.rb
129
- - test/prime_meridians_test.rb
164
+ - test/parameters_test.rb
165
+ - test/pj_object_test.rb
166
+ - test/prime_meridian_test.rb
130
167
  - test/proj_test.rb
131
168
  - test/projection_test.rb
169
+ - test/session_test.rb
132
170
  - test/transformation_test.rb
133
171
  - test/unit_test.rb
134
172
  homepage: https://github.com/cfis/proj4rb
@@ -143,16 +181,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
143
181
  requirements:
144
182
  - - ">="
145
183
  - !ruby/object:Gem::Version
146
- version: 2.4.1
184
+ version: '2.7'
147
185
  required_rubygems_version: !ruby/object:Gem::Requirement
148
186
  requirements:
149
187
  - - ">="
150
188
  - !ruby/object:Gem::Version
151
189
  version: '0'
152
190
  requirements:
153
- - Proj (Proj4) Library
154
- rubygems_version: 3.2.28
191
+ - Proj Library
192
+ rubygems_version: 3.4.6
155
193
  signing_key:
156
194
  specification_version: 4
157
- summary: Ruby bindings for the Proj.4 Carthographic Projection library
195
+ summary: Ruby bindings for the Proj coordinate transformation library
158
196
  test_files: []
data/lib/api/api_4_9.rb DELETED
@@ -1,31 +0,0 @@
1
- module Proj
2
- module Api
3
- ######### Deprecated API from proj_api.h. Don't use these anymore! ##############
4
- typedef :pointer, :projPJ
5
-
6
- class ProjUV < FFI::Struct
7
- layout :u, :double,
8
- :v, :double
9
- end
10
-
11
- ProjXY = ProjUV
12
- ProjLP = ProjUV
13
-
14
- attach_function :pj_init, [:int, :pointer], :projPJ
15
- attach_function :pj_free, [:projPJ], :void
16
-
17
- attach_function :pj_get_release, [], :string
18
- attach_function :pj_set_searchpath, [:int, :pointer], :void
19
-
20
- attach_function :pj_get_errno_ref, [], :pointer
21
- attach_function :pj_strerrno, [:int], :string
22
-
23
- attach_function :pj_get_def, [:projPJ, :int], :string
24
- attach_function :pj_is_latlong, [:projPJ], :bool
25
- attach_function :pj_is_geocent, [:projPJ], :bool
26
-
27
- attach_function :pj_fwd, [ProjLP.by_value, :projPJ], ProjXY.by_value
28
- attach_function :pj_inv, [ProjXY.by_value, :projPJ], ProjLP.by_value
29
- attach_function :pj_transform, [:projPJ, :projPJ, :long, :int, :pointer, :pointer, :pointer], :bool
30
- end
31
- end
data/lib/proj/config.rb DELETED
@@ -1,70 +0,0 @@
1
- require 'singleton'
2
-
3
- module Proj
4
- class Config
5
- include Singleton
6
-
7
- def set_search_paths
8
- p_paths = self.search_paths_pointer
9
- items = p_paths.type_size/p_paths.size
10
-
11
- # Set search paths on default context - any new contexts will inherit from this
12
- if Api.method_defined?(:proj_context_set_search_paths)
13
- Api.proj_context_set_search_paths(nil, items, p_paths)
14
- end
15
-
16
- if Api.method_defined?(:pj_set_searchpath)
17
- Api.pj_set_searchpath(items, p_paths)
18
- end
19
- end
20
-
21
- def search_paths
22
- ['/usr/share/proj',
23
- '/usr/local/share/proj',
24
- '/opt/share/proj',
25
- '/opt/local/share/proj',
26
- 'c:/msys64/mingw64/share/proj',
27
- 'c:/mingw64/share/proj',
28
- '/opt/local/lib/proj6/share/proj',
29
- '/opt/local/lib/proj5/share/proj',
30
- '/opt/local/lib/proj49/share/proj']
31
- end
32
-
33
- def data_path
34
- if ENV['PROJ_LIB'] && File.directory?(ENV['PROJ_LIB'])
35
- ENV['PROJ_LIB']
36
- else
37
- result = self.search_paths.detect do |path|
38
- File.directory?(path)
39
- end
40
-
41
- unless result
42
- raise(Error, "Could not find Proj data directory. Please set the PROJ_LIB environmental variable to correct directory")
43
- end
44
-
45
- result
46
- end
47
- end
48
-
49
- def search_paths_pointer
50
- p_path = FFI::MemoryPointer.from_string(self.data_path)
51
- p_paths = FFI::MemoryPointer.new(:pointer, 1)
52
- p_paths[0].write_pointer(p_path)
53
- p_paths
54
- end
55
-
56
- def db_path
57
- result = self.search_paths.map do |path|
58
- File.join(path, 'proj.db')
59
- end.detect do |path|
60
- File.exists?(path)
61
- end
62
-
63
- unless result
64
- raise(Error, "Could not find Proj database (proj.db). Please set the PROJ_LIB environmental variable to directory that contains it")
65
- end
66
-
67
- result
68
- end
69
- end
70
- end
data/lib/proj/point.rb DELETED
@@ -1,72 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- module Proj
4
- # @deprecated This class is *DEPRECATED.* It will be removed when Proj 7 is released and removes the
5
- # underlying API's this class uses. Code should be ported to use Coordinate objects.
6
- class Point
7
- def self.from_pointer(pointer)
8
- result = self.allocate
9
- result.instance_variable_set(:@struct, pointer)
10
- result
11
- end
12
-
13
- # Create new Point object from coordinates.
14
- def initialize(x, y)
15
- @struct = Api::ProjUV.new
16
- @struct[:u] = x
17
- @struct[:v] = y
18
- end
19
-
20
- def to_ptr
21
- @struct.to_ptr
22
- end
23
-
24
- def to_radians
25
- self.class.new(Api.proj_torad(self.x), Api.proj_torad(self.y))
26
- end
27
-
28
- def to_degrees
29
- self.class.new(Api.proj_todeg(self.x), Api.proj_todeg(self.y))
30
- end
31
-
32
- # Get x coordinate.
33
- def x
34
- @struct[:u]
35
- end
36
-
37
- # Set x coordinate.
38
- def x=(value)
39
- @struct[:u] = value
40
- end
41
-
42
- # Get y coordinate.
43
- def y
44
- @struct[:v]
45
- end
46
-
47
- # Set y coordinate.
48
- def y=(value)
49
- @struct[:v] = value
50
- end
51
-
52
- # Get longitude/x coordinate.
53
- def lon
54
- @struct[:u]
55
- end
56
-
57
- # Set longitude/x coordinate.
58
- def lon=(value)
59
- @struct[:u] = value
60
- end
61
-
62
- # Get latitude/y coordinate.
63
- def lat
64
- @struct[:v]
65
- end
66
-
67
- # Set latitude/y coordinate.
68
- def lat=(value)
69
- @struct[:v] = value
70
- end
71
- end
72
- end