proj4rb 2.0.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bdd77e892a3126bb4c0b4c984356e9ba6a32e73811813c2d5dcc5a2eb36a02ae
4
- data.tar.gz: 0217052b386be354cd4b48c5bc0536c179336c5c73026a3cb544e9630ad66810
3
+ metadata.gz: cc96e86f24cffe40c1a80db776c80e5e83fd76a6194b3267c9e6e2c4b5641326
4
+ data.tar.gz: bd9043ce0c2c1c0640b783ff802d4bd23adc6419bd59bb038a03abd8b9466438
5
5
  SHA512:
6
- metadata.gz: 9d0e577ede5260d24da9b474e10c52700f9179fe9a42e61728fba85f051be1b152af847c6c45c8df9ef9ad9f5b5ea71ca82ecbef977056b2361dfb2de3be7dac
7
- data.tar.gz: 050366cf1ce478ee809a4d82af9a9ed0a9e54e3fd28d4fd58d4fac4b22c0ddbb431969a61581c8a5e3990525e567f2fb7f03b1f9a010b734867c67c9795f7369
6
+ metadata.gz: e47e9dbb00d9cfe529aaab596dae15aff43a09a04d6550641a71674a626fd4e79ad177ee18dd402e8d0f1ebae1cd1e05fa61459534e2f601164b9ad1edbc545c
7
+ data.tar.gz: 752a5933c869f26be5fd84e085fe6c12b602dd969b7a363929cf47757abb23f0c65b607dd273f891046c1d8a986cffddda518a738b20f1a7a792b3427594d55a
data/ChangeLog CHANGED
@@ -1,16 +1,27 @@
1
- 2.0.0 (December 30, 2019)
1
+ 2.1.0 (January 7, 2020)
2
+ =========================
3
+ * Fix broken gem - was not including all api files (Jan Klimke)
4
+ * Add paths on MacOS when using Brew (Jan Klimke)
5
+ * Various code cleanups (Charlie Savage)
6
+
7
+ 2.0.1 (January 5, 2020)
2
8
  =========================
3
- - Full rewrite to support API changes in Proj versions 5 and 6
4
- - As part of rewrite switch bindings to use FFI versus a C extension
5
- - Split Ruby code into multiple files based on classes
6
- - Add in a bunch of new classes including Context, Crs, Coordinate, Ellipsoid, Prime Meridian and Transform
7
- - Deprecate Projection and Point - these will stop working with Proj 7 since the use an older deprecated API
9
+ * Set Ruby 2.4.1 to be the minimum allowed version (Samuel Williams)
10
+ * Fix incorrect use of context, reduce warnings when running tests (Samuel Williams)
11
+ * Fix `bundle exec rake test` (Samuel Williams)
12
+ * Add 2.4.1 to the travis test matrix (Samuel Williams)
8
13
 
9
- - Calling this 1.0.0 since its a very stable gem
14
+ 2.0.0 (December 30, 2019)
15
+ =========================
16
+ - Full rewrite to support API changes in Proj versions 5 and 6 (Charlie Savage)
17
+ - As part of rewrite switch bindings to use FFI versus a C extension (Charlie Savage)
18
+ - Split Ruby code into multiple files based on classes (Charlie Savage)
19
+ - Add in a bunch of new classes including Context, Crs, Coordinate, Ellipsoid, Prime Meridian and Transform (Charlie Savage)
20
+ - Deprecate Projection and Point - these will stop working with Proj 7 since the use an older deprecated API (Charlie Savage)
10
21
 
11
22
  1.0.0 (December 14, 2014)
12
23
  =========================
13
- - Calling this 1.0.0 since its a very stable gem
24
+ - Calling this 1.0.0 since its a very stable gem (Charlie Savage)
14
25
 
15
26
  0.4.3 (August 30, 2011)
16
27
  =========================
@@ -1,7 +1,10 @@
1
- =Proj4rb
1
+ = Proj4rb
2
2
  This gem provides Ruby bindings for the Proj Library (https://proj.org). The Proj Library supports converting coordinates
3
3
  between a number of different coordinate systems and projections.
4
4
 
5
+ == Documentation
6
+ Besides this readme file, reference documentation is available at https://rubydoc.info/github/cfis/proj4rb.
7
+
5
8
  == Installation
6
9
  First install the gem in the usual manner:
7
10
 
@@ -76,24 +79,20 @@ the +forward+ or +inverse+ methods. The forward transformation looks like this:
76
79
  from = Proj::Coordinate.new(x: 5428192.0, y: 3458305.0, z: -5.1790915237)
77
80
  to = transform.forward(from)
78
81
 
79
- assert_in_delta(48.98963932450735, to.x, PRECISION)
80
- assert_in_delta(8.429263044355544, to.y, PRECISION)
81
- assert_in_delta(-5.1790915237, to.z, PRECISION)
82
- assert_in_delta(0, to.t, PRECISION)
82
+ assert_in_delta(48.98963932450735, to.x, 0.01)
83
+ assert_in_delta(8.429263044355544, to.y, 0.01)
84
+ assert_in_delta(-5.1790915237, to.z, 0.01)
85
+ assert_in_delta(0, to.t, 0.01)
83
86
 
84
87
  While the inverse transformation looks like this:
85
88
 
86
89
  from = Proj::Coordinate.new(lam: 48.9906726079, phi: 8.4302123334)
87
90
  to = transform.inverse(from)
88
91
 
89
- assert_in_delta(5428306.389495558, to.x, PRECISION)
90
- assert_in_delta(3458375.3367194114, to.y, PRECISION)
91
- assert_in_delta(0, to.z, PRECISION)
92
- assert_in_delta(0, to.t, PRECISION)
93
-
94
- Transformation objects can also be created directly like this:
95
-
96
- transform = Proj::Transformation.new('epsg:31467', 'epsg:4326')
92
+ assert_in_delta(5428306.389495558, to.x, 0.01)
93
+ assert_in_delta(3458375.3367194114, to.y, 0.01)
94
+ assert_in_delta(0, to.z, 0.01)
95
+ assert_in_delta(0, to.t, 0.01)
97
96
 
98
97
  === Coordinate
99
98
  Notice the examples above transform Coordinate objects. A Coordinate consists
@@ -114,8 +113,8 @@ Both Crs and Transformation objects take a context object in their constructors.
114
113
  to using Context.current
115
114
 
116
115
  === Projection
117
- If you are using Proj 4, then instead of using Coordinates, Crses and Tranformations you use Points and Projections. Those
118
- are deprecated classes but will continue to work until the release of Proj 7. Please refer to the documentation
116
+ If you are using Proj 4, then instead of using Coordinates, Crses and Tranformations you need to us Points and Projections.
117
+ Those are deprecated classes but will continue to work until the release of Proj 7. Please refer to the documentation
119
118
  for more information.
120
119
 
121
120
  == Error handling
@@ -133,15 +132,16 @@ variable and have it work correctly (at least not on windows).
133
132
  == Backwards Compatibility
134
133
  Proj versions 5 and 6 are *very* different than Proj version 4. Changes are documented at
135
134
  https://proj.org/development/migration.html. Note that the gem should gracefully degrade
136
- (as in newer functionality stops working) depending on if you are using Proj 6, Proj 5 or Proj 4.
135
+ (as in newer functionality stops working but older functionality keeps working) depending on
136
+ the version of Proj you are using.
137
137
 
138
138
  To ensure backwards compatiblity, the Ruby bindings still include the older Point and Projection
139
139
  classes. However, these classes are no longer documented in this Readme because they will be
140
- removed upon the release of Proj 7 which will remove the underlying API's they are dependent upon.
140
+ removed upon the release of Proj 7 which will remove the underlying API's they depend on.
141
141
  So please port your code! But take note of the changes in Proj 6 described below.
142
142
 
143
- Proj 5 introduced the the Coordinate, Crs and Tranformation apis. However, it wasn't until Proj 6 that additional
144
- metadata APIs were added, so the amount of information about each object is somewhat limited.
143
+ Proj 5 introduced the Coordinate, Crs and Tranformation APIs. However, it wasn't until Proj 6 that additional
144
+ metadata APIs were added, so the amount of information about each object is somewhat limited in Proj 5.
145
145
 
146
146
  Proj 6 makes a big change compared to previous releases that is not well documented (see
147
147
  https://github.com/OSGeo/PROJ/pull/1182). When creating tranformations with EPSG values Proj 6
@@ -166,5 +166,5 @@ Proj4rb is released under the MIT license.
166
166
  ==Authors
167
167
  The proj4rb Ruby bindings were started by Guilhem Vellut with most of the code
168
168
  written by Jochen Topf. Charlie Savage ported the code to Windows and added
169
- the Windows build infrastructure. Later, he updated the code to support
170
- Proj version 5 and 6 and ported the code to use FFI.
169
+ the Windows build infrastructure. Later, he rewrote the code to support
170
+ Proj version 5 and 6 and ported it to use FFI.
data/Rakefile CHANGED
@@ -23,5 +23,6 @@ YARD::Rake::YardocTask.new
23
23
  # Test Task
24
24
  Rake::TestTask.new do |t|
25
25
  t.libs << "test"
26
+ t.test_files = FileList['test/*_test.rb']
26
27
  t.verbose = true
27
28
  end
@@ -0,0 +1,64 @@
1
+ require 'ffi'
2
+
3
+ module Proj
4
+ module Api
5
+ extend FFI::Library
6
+ ffi_lib ['libproj-15', # Mingw64 Proj 6
7
+ 'libproj.so.15', # Linux (Postgresql repository )Proj 6
8
+ 'libproj.so.13', # Linux (Fedora 31) Proj 5
9
+ 'libproj.so.12', # Linux (Ubuntu 18.04 ) Proj 4
10
+ 'libproj-12', # Mingw64 Proj 4
11
+ '/opt/local/lib/proj6/lib/libproj.15.dylib', # Macports Proj 6
12
+ '/opt/local/lib/proj5/lib/libproj.13.dylib', # Macports Proj 5
13
+ '/opt/local/lib/proj49/lib/libproj.12.dylib', # Macports Proj 5
14
+ '/usr/local/lib/libproj.15.dylib', # mac homebrew mac Proj 6
15
+ '/usr/local/lib/libproj.13.dylib', # mac howbrew Proj 5
16
+ '/usr/local/lib/libproj.12.dylib' # mac howbrew Proj 5
17
+ ]
18
+
19
+ # Load the old deprecated api - supported by all Proj versions (until Proj 7!)
20
+ require_relative './api_4_9'
21
+
22
+ library = ffi_libraries.first
23
+
24
+ # proj_info was introduced in Proj 5
25
+ if library.find_function('proj_info')
26
+ require_relative './api_5_0'
27
+ PROJ_VERSION = Gem::Version.new(self.proj_info[:version])
28
+ else
29
+ release = self.pj_get_release
30
+ version = release.match(/\d\.\d\.\d/)
31
+ PROJ_VERSION = Gem::Version.new(version)
32
+ end
33
+ end
34
+
35
+ if Api::PROJ_VERSION < Gem::Version.new('5.0.0')
36
+ def Api.proj_torad(value)
37
+ value * 0.017453292519943296
38
+ end
39
+
40
+ def Api.proj_todeg(value)
41
+ value * 57.295779513082321
42
+ end
43
+ end
44
+
45
+ if Api::PROJ_VERSION >= Gem::Version.new('5.1.0')
46
+ require_relative './api_5_1'
47
+ end
48
+
49
+ if Api::PROJ_VERSION >= Gem::Version.new('5.2.0')
50
+ require_relative './api_5_2'
51
+ end
52
+
53
+ if Api::PROJ_VERSION >= Gem::Version.new('6.0.0')
54
+ require_relative './api_6_0'
55
+ end
56
+
57
+ if Api::PROJ_VERSION >= Gem::Version.new('6.1.0')
58
+ require_relative './api_6_1'
59
+ end
60
+
61
+ if Api::PROJ_VERSION >= Gem::Version.new('6.2.0')
62
+ require_relative './api_6_2'
63
+ end
64
+ end
@@ -0,0 +1,31 @@
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
@@ -0,0 +1,301 @@
1
+ module Proj
2
+ module Api
3
+ typedef :pointer, :PJ
4
+ typedef :pointer, :PJ_CONTEXT
5
+ typedef :pointer, :PJ_AREA
6
+
7
+ class P5_FACTORS < FFI::Struct
8
+ layout :meridional_scale, :double, # h
9
+ :parallel_scale, :double, # k
10
+ :areal_scale, :double, # s
11
+
12
+ :angular_distortion, :double, # omega
13
+ :meridian_parallel_angle, :double, # theta-prime
14
+ :meridian_convergence, :double, # alpha
15
+
16
+ :tissot_semimajor, :double, # a
17
+ :tissot_semiminor, :double, # b
18
+
19
+ :dx_dlam, :double,
20
+ :dx_dphi, :double,
21
+ :dy_dlam, :double,
22
+ :dy_dphi, :double
23
+ end
24
+
25
+ # Data types for list of operations, ellipsoids, datums and units used in PROJ.4 */
26
+ class PJ_LIST < FFI::Struct
27
+ layout :id, :string, # projection keyword
28
+ :PJ, :pointer, # projection entry point
29
+ :descr, :pointer # description text
30
+ end
31
+ PJ_OPERATIONS = PJ_LIST
32
+
33
+ class PJ_ELLPS < FFI::Struct
34
+ layout :id, :string, # ellipse keyword name
35
+ :major, :string, # a= value
36
+ :ell, :string, # elliptical parameter
37
+ :name, :string # comments
38
+ end
39
+
40
+ class PJ_UNITS < FFI::Struct
41
+ layout :id, :string, # units keyword
42
+ :to_meter, :string, # multiply by value to get meters
43
+ :name, :string, # comments
44
+ :factor, :double # to_meter factor in actual numbers
45
+ end
46
+
47
+ class PJ_PRIME_MERIDIANS < FFI::Struct
48
+ layout :id, :string, # prime meridian keyword
49
+ :defn, :string # offset from greenwich in DMS format.
50
+ end
51
+
52
+ # Geodetic, mostly spatiotemporal coordinate types
53
+ class PJ_XYZT < FFI::Struct
54
+ layout :x, :double,
55
+ :y, :double,
56
+ :z, :double,
57
+ :t, :double
58
+ end
59
+
60
+ class PJ_UVWT < FFI::Struct
61
+ layout :u, :double,
62
+ :v, :double,
63
+ :w, :double,
64
+ :t, :double
65
+ end
66
+
67
+ class PJ_LPZT < FFI::Struct
68
+ layout :lam, :double,
69
+ :phi, :double,
70
+ :z, :double,
71
+ :t, :double
72
+ end
73
+
74
+ # Rotations: omega, phi, kappa
75
+ class PJ_OPK < FFI::Struct
76
+ layout :o, :double,
77
+ :p, :double,
78
+ :k, :double
79
+ end
80
+
81
+ # East, North, Up
82
+ class PJ_ENU < FFI::Struct
83
+ layout :e, :double,
84
+ :n, :double,
85
+ :u, :double
86
+ end
87
+
88
+ # Geodesic length, fwd azi, rev azi
89
+ class PJ_GEOD < FFI::Struct
90
+ layout :s, :double,
91
+ :a1, :double,
92
+ :a2, :double
93
+ end
94
+
95
+ # Classic proj.4 pair/triplet types - moved into the PJ_ name space.
96
+ class PJ_UV < FFI::Struct
97
+ layout :u, :double,
98
+ :v, :double
99
+ end
100
+
101
+ class PJ_XY < FFI::Struct
102
+ layout :x, :double,
103
+ :y, :double
104
+ end
105
+
106
+ class PJ_LP < FFI::Struct
107
+ layout :lam, :double,
108
+ :phi, :double
109
+ end
110
+
111
+ class PJ_XYZ < FFI::Struct
112
+ layout :x, :double,
113
+ :y, :double,
114
+ :z, :double
115
+ end
116
+
117
+ class PJ_UVW < FFI::Struct
118
+ layout :u, :double,
119
+ :v, :double,
120
+ :w, :double
121
+ end
122
+
123
+ class PJ_LPZ < FFI::Struct
124
+ layout :lam, :double,
125
+ :phi, :double,
126
+ :z, :double
127
+ end
128
+
129
+ class PJ_COORD < FFI::Union
130
+ layout :v, [:double, 4],
131
+ :xyzt, PJ_XYZT,
132
+ :uvwt, PJ_UVWT,
133
+ :lpzt, PJ_LPZT,
134
+ :geod, PJ_GEOD,
135
+ :opk, PJ_OPK,
136
+ :enu, PJ_ENU,
137
+ :xyz, PJ_XYZ,
138
+ :uvw, PJ_UVW,
139
+ :lpz, PJ_LPZ,
140
+ :xy, PJ_XY,
141
+ :uv, PJ_UV,
142
+ :lp, PJ_LP
143
+ end
144
+
145
+ class PJ_INFO < FFI::Struct
146
+ layout :major, :int, # Major release number
147
+ :minor, :int, # Minor release number
148
+ :patch, :int, # Patch level
149
+ :release, :string, # Release info. Version + date
150
+ :version, :string, # Full version number
151
+ :searchpath, :string, # Paths where init and grid files are looked for. Paths are separated by
152
+ # semi-colons on Windows, and colons on non-Windows platforms.
153
+ :paths, :pointer,
154
+ :path_count, :size_t
155
+ end
156
+
157
+ class PJ_PROJ_INFO < FFI::Struct
158
+ layout :id, :string, # Name of the projection in question
159
+ :description, :string, # Description of the projection
160
+ :definition, :string, # Projection definition
161
+ :has_inverse, :int, # 1 if an inverse mapping exists, 0 otherwise
162
+ :accuracy, :double # Expected accuracy of the transformation. -1 if unknown.
163
+
164
+ def to_s
165
+ "<#{self.class.name} id: #{self[:id]}, description: #{self[:description]}, definition: #{self[:definition]}, has_inverse: #{self[:has_inverse]} accuracy: #{self[:accuracy]}"
166
+ end
167
+ end
168
+
169
+ class PJ_GRID_INFO < FFI::Struct
170
+ layout :gridname, [:string, 32], # name of grid
171
+ :filename, [:string, 260], # full path to grid
172
+ :format, [:string, 8], # file format of grid
173
+ :lowerleft, PJ_LP, # Coordinates of lower left corner
174
+ :upperright, PJ_LP, # Coordinates of upper right corner
175
+ :n_lon, :int, # Grid size
176
+ :n_lat, :int, # Grid size
177
+ :cs_lon, :double, # Cell size of grid
178
+ :cs_lat, :double # Cell size of grid
179
+ end
180
+
181
+ class PJ_INIT_INFO < FFI::Struct
182
+ layout :name, [:string, 32], # name init file
183
+ :filename, [:string, 260], # full path to the init file
184
+ :version, [:string, 32], # version of the init file
185
+ :origin, [:string, 32], # origin of the file, e.g. EPSG
186
+ :lastupdate, [:string, 16] # Date of last update in YYYY-MM-DD format
187
+ end
188
+
189
+ enum :PJ_LOG_LEVEL, [:PJ_LOG_NONE , 0,
190
+ :PJ_LOG_ERROR, 1,
191
+ :PJ_LOG_DEBUG, 2,
192
+ :PJ_LOG_TRACE, 3,
193
+ :PJ_LOG_TELL , 4,
194
+ :PJ_LOG_DEBUG_MAJOR, 2, # for proj_api.h compatibility
195
+ :PJ_LOG_DEBUG_MINOR, 3] # for proj_api.h compatibility
196
+
197
+ # Apply transformation to observation - in forward or inverse direction
198
+ enum :PJ_DIRECTION, [:PJ_FWD, 1, # Forward
199
+ :PJ_IDENT, 0, # Do nothing
200
+ :PJ_INV, -1] # Inverse
201
+
202
+ enum :PJ_CATEGORY, [:PJ_CATEGORY_ELLIPSOID,
203
+ :PJ_CATEGORY_PRIME_MERIDIAN,
204
+ :PJ_CATEGORY_DATUM,
205
+ :PJ_CATEGORY_CRS,
206
+ :PJ_CATEGORY_COORDINATE_OPERATION]
207
+
208
+ enum :PJ_TYPE, [:PJ_TYPE_UNKNOWN,
209
+ :PJ_TYPE_ELLIPSOID,
210
+ :PJ_TYPE_PRIME_MERIDIAN,
211
+ :PJ_TYPE_GEODETIC_REFERENCE_FRAME,
212
+ :PJ_TYPE_DYNAMIC_GEODETIC_REFERENCE_FRAME,
213
+ :PJ_TYPE_VERTICAL_REFERENCE_FRAME,
214
+ :PJ_TYPE_DYNAMIC_VERTICAL_REFERENCE_FRAME,
215
+ :PJ_TYPE_DATUM_ENSEMBLE,
216
+
217
+ # Abstract type, not returned by proj_get_type()
218
+ :PJ_TYPE_CRS,
219
+
220
+ :PJ_TYPE_GEODETIC_CRS,
221
+ :PJ_TYPE_GEOCENTRIC_CRS,
222
+
223
+ # proj_get_type() will never return that type, but
224
+ # :PJ_TYPE_GEOGRAPHIC_2D_CRS or :PJ_TYPE_GEOGRAPHIC_3D_CRS.
225
+ :PJ_TYPE_GEOGRAPHIC_CRS,
226
+
227
+ :PJ_TYPE_GEOGRAPHIC_2D_CRS,
228
+ :PJ_TYPE_GEOGRAPHIC_3D_CRS,
229
+ :PJ_TYPE_VERTICAL_CRS,
230
+ :PJ_TYPE_PROJECTED_CRS,
231
+ :PJ_TYPE_COMPOUND_CRS,
232
+ :PJ_TYPE_TEMPORAL_CRS,
233
+ :PJ_TYPE_ENGINEERING_CRS,
234
+ :PJ_TYPE_BOUND_CRS,
235
+ :PJ_TYPE_OTHER_CRS,
236
+
237
+ :PJ_TYPE_CONVERSION,
238
+ :PJ_TYPE_TRANSFORMATION,
239
+ :PJ_TYPE_CONCATENATED_OPERATION,
240
+ :PJ_TYPE_OTHER_COORDINATE_OPERATION]
241
+
242
+ enum :PJ_PROJ_STRING_TYPE, [:PJ_PROJ_5,
243
+ :PJ_PROJ_4]
244
+
245
+ enum :PJ_COORDINATE_SYSTEM_TYPE, [:PJ_CS_TYPE_UNKNOWN,
246
+ :PJ_CS_TYPE_CARTESIAN,
247
+ :PJ_CS_TYPE_ELLIPSOIDAL,
248
+ :PJ_CS_TYPE_VERTICAL,
249
+ :PJ_CS_TYPE_SPHERICAL,
250
+ :PJ_CS_TYPE_ORDINAL,
251
+ :PJ_CS_TYPE_PARAMETRIC,
252
+ :PJ_CS_TYPE_DATETIMETEMPORAL,
253
+ :PJ_CS_TYPE_TEMPORALCOUNT,
254
+ :PJ_CS_TYPE_TEMPORALMEASURE]
255
+
256
+ enum :PJ_WKT_TYPE, [:PJ_WKT2_2015,
257
+ :PJ_WKT2_2015_SIMPLIFIED,
258
+ :PJ_WKT2_2018,
259
+ :PJ_WKT2_2018_SIMPLIFIED,
260
+ :PJ_WKT1_GDAL,
261
+ :PJ_WKT1_ESRI]
262
+
263
+ attach_function :proj_info, [], PJ_INFO.by_value
264
+ attach_function :proj_pj_info, [:PJ], PJ_PROJ_INFO.by_value
265
+ attach_function :proj_grid_info, [:string], PJ_GRID_INFO.by_value
266
+ attach_function :proj_init_info, [:string], PJ_INIT_INFO.by_value
267
+
268
+ # Contexts
269
+ attach_function :proj_context_create, [], :PJ_CONTEXT
270
+ attach_function :proj_context_destroy, [:PJ_CONTEXT], :PJ_CONTEXT
271
+
272
+ # Error handling
273
+ attach_function :proj_context_errno, [:PJ_CONTEXT], :int
274
+ attach_function :proj_errno, [:PJ], :int
275
+ attach_function :proj_errno_set, [:PJ, :int], :int
276
+ attach_function :proj_errno_reset, [:PJ], :int
277
+ attach_function :proj_errno_restore, [:PJ, :int], :int
278
+
279
+ # Manage the transformation definition object PJ
280
+ attach_function :proj_create, [:PJ_CONTEXT, :string], :PJ
281
+ attach_function :proj_create_argv, [:PJ_CONTEXT, :int, :pointer], :PJ
282
+ attach_function :proj_create_crs_to_crs, [:PJ_CONTEXT, :string, :string, :PJ_AREA], :PJ
283
+ attach_function :proj_destroy, [:PJ], :PJ
284
+
285
+ attach_function :proj_trans, [:PJ, :PJ_DIRECTION, PJ_COORD.by_value], PJ_COORD.by_value
286
+
287
+ # Get lists of operations, ellipsoids, units and prime meridians
288
+ attach_function :proj_list_operations, [], :pointer #PJ_LIST
289
+ attach_function :proj_list_ellps, [], :pointer #PJ_ELLPS
290
+ attach_function :proj_list_units, [], :pointer #PJ_UNITS
291
+ attach_function :proj_list_prime_meridians, [], :pointer #PJ_PRIME_MERIDIANS
292
+
293
+ # Degrees/radians
294
+ attach_function :proj_torad, [:double], :double
295
+ attach_function :proj_todeg, [:double], :double
296
+ attach_function :proj_dmstor, [:string, :pointer], :double
297
+ attach_function :proj_rtodms, [:string, :double, :int, :int], :string
298
+ attach_function :proj_angular_input, [:PJ, :PJ_DIRECTION], :bool
299
+ attach_function :proj_angular_output, [:PJ, :PJ_DIRECTION], :bool
300
+ end
301
+ end
@@ -0,0 +1,7 @@
1
+ module Proj
2
+ module Api
3
+ attach_function :proj_log_level, [:PJ_CONTEXT, :PJ_LOG_LEVEL], :PJ_LOG_LEVEL
4
+ callback :pj_log_function, [:pointer, :int, :string], :void
5
+ attach_function :proj_log_func, [:PJ_CONTEXT, :pointer, :pj_log_function], :void
6
+ end
7
+ end
@@ -0,0 +1,5 @@
1
+ module Proj
2
+ module Api
3
+ attach_function :proj_errno_string, [:int], :string
4
+ end
5
+ end
@@ -0,0 +1,44 @@
1
+ module Proj
2
+ module Api
3
+ callback :proj_file_finder, [:PJ_CONTEXT, :string, :pointer], :string
4
+ attach_function :proj_context_set_file_finder, [:PJ_CONTEXT, :proj_file_finder, :pointer], :void
5
+ attach_function :proj_context_set_search_paths, [:PJ_CONTEXT, :int, :pointer], :void
6
+
7
+ attach_function :proj_context_use_proj4_init_rules, [:PJ_CONTEXT, :int], :void
8
+ attach_function :proj_context_get_use_proj4_init_rules, [:PJ_CONTEXT, :int], :bool
9
+ attach_function :proj_list_angular_units, [], :pointer #PJ_UNITS
10
+
11
+ # Base methods
12
+ attach_function :proj_get_name, [:PJ], :string
13
+ attach_function :proj_get_id_auth_name, [:PJ, :int], :string
14
+ attach_function :proj_get_id_code, [:PJ, :int], :string
15
+ attach_function :proj_get_type, [:PJ], :PJ_TYPE
16
+ attach_function :proj_is_deprecated, [:PJ], :bool
17
+ attach_function :proj_is_crs, [:PJ], :bool
18
+ attach_function :proj_get_area_of_use, [:PJ_CONTEXT, :PJ, :pointer, :pointer, :pointer, :pointer, :pointer], :bool
19
+
20
+ # Export to various formats
21
+ attach_function :proj_as_wkt, [:PJ_CONTEXT, :PJ, :PJ_WKT_TYPE, :pointer], :string
22
+ attach_function :proj_as_proj_string, [:PJ_CONTEXT, :PJ, :PJ_PROJ_STRING_TYPE, :pointer], :string
23
+ attach_function :proj_as_projjson, [:PJ_CONTEXT, :PJ, :pointer], :string
24
+
25
+ # Projection database functions
26
+ attach_function :proj_context_set_autoclose_database, [:PJ_CONTEXT, :int], :void
27
+ attach_function :proj_context_set_database_path, [:PJ_CONTEXT, :string, :pointer, :pointer], :int
28
+ attach_function :proj_context_get_database_path, [:PJ_CONTEXT], :string
29
+ attach_function :proj_context_get_database_metadata, [:PJ_CONTEXT, :string], :string
30
+
31
+ # CRS methods
32
+ attach_function :proj_crs_get_geodetic_crs, [:PJ_CONTEXT, :PJ], :PJ
33
+ attach_function :proj_crs_get_horizontal_datum, [:PJ_CONTEXT, :PJ], :PJ
34
+ attach_function :proj_crs_get_sub_crs, [:PJ_CONTEXT, :PJ, :int], :PJ
35
+ attach_function :proj_crs_get_datum, [:PJ_CONTEXT, :PJ], :PJ
36
+ attach_function :proj_crs_get_coordinate_system, [:PJ_CONTEXT, :PJ], :PJ
37
+ attach_function :proj_cs_get_type, [:PJ_CONTEXT, :PJ], :PJ_COORDINATE_SYSTEM_TYPE
38
+ attach_function :proj_cs_get_axis_count, [:PJ_CONTEXT, :PJ], :int
39
+ attach_function :proj_cs_get_axis_info, [:PJ_CONTEXT, :PJ, :int, :pointer, :pointer, :pointer, :pointer, :pointer, :pointer, :pointer], :bool
40
+ attach_function :proj_get_prime_meridian, [:PJ_CONTEXT, :PJ], :PJ
41
+ attach_function :proj_get_ellipsoid, [:PJ_CONTEXT, :PJ], :PJ
42
+ attach_function :proj_crs_get_coordoperation, [:PJ_CONTEXT, :PJ], :PJ
43
+ end
44
+ end
@@ -0,0 +1,5 @@
1
+ module Proj
2
+ module Api
3
+ attach_function :proj_normalize_for_visualization, [:PJ_CONTEXT, :PJ], :PJ
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Proj
2
+ module Api
3
+ attach_function :proj_create_crs_to_crs_from_pj, [:PJ_CONTEXT, :PJ, :PJ, :PJ_AREA, :string], :PJ
4
+ end
5
+ end
data/lib/crs.rb CHANGED
@@ -89,7 +89,6 @@ module Proj
89
89
  #
90
90
  # @return [Integer]
91
91
  def axis_count
92
- foo = Api.proj_crs_get_coordinate_system(self.context, self)
93
92
  result = Api.proj_cs_get_axis_count(self.context, self.coordinate_system)
94
93
  if result == -1
95
94
  Error.check
@@ -131,7 +130,6 @@ module Proj
131
130
  #
132
131
  # @return [:PJ_COORDINATE_SYSTEM_TYPE]
133
132
  def crs_type
134
- foo = Api.proj_crs_get_coordinate_system(self.context, self)
135
133
  result = Api.proj_cs_get_type(self.context, self.coordinate_system)
136
134
  if result == :PJ_CS_TYPE_UNKNOWN
137
135
  Error.check
@@ -1,8 +1,6 @@
1
1
  # encoding: UTF-8
2
2
  module Proj
3
3
  class PjObject
4
- attr_reader :context
5
-
6
4
  def self.finalize(pointer)
7
5
  proc do
8
6
  Api.proj_destroy(pointer)
@@ -5,23 +5,23 @@ module Proj
5
5
  # underlying API's this class uses. Code should be ported to use Crs and Transformation objects.
6
6
  class Projection
7
7
  def self.parse(value)
8
- values = case value
9
- when Array
10
- value
11
- when String
12
- value.strip.split(' ')
13
- when Hash
14
- array = []
15
- value.each_pair do |key, value|
16
- key = "+#{key}"
17
- array << (value.nil? ? key : "#{key}=#{value}")
18
- end
19
- array
20
- when Projection
21
- value.getDef.split(' ')
22
- else
23
- raise ArgumentError, "Unknown type #{value.class} for projection definition"
24
- end
8
+ case value
9
+ when Array
10
+ value
11
+ when String
12
+ value.strip.split(' ')
13
+ when Hash
14
+ array = []
15
+ value.each_pair do |key, value|
16
+ key = "+#{key}"
17
+ array << (value.nil? ? key : "#{key}=#{value}")
18
+ end
19
+ array
20
+ when Projection
21
+ value.getDef.split(' ')
22
+ else
23
+ raise ArgumentError, "Unknown type #{value.class} for projection definition"
24
+ end
25
25
  end
26
26
 
27
27
  def self.finalize(pointer)
@@ -185,7 +185,7 @@ module Proj
185
185
  p_z = FFI::MemoryPointer.new(:double, 1)
186
186
  p_z.write_double(0)
187
187
 
188
- a = Api.pj_transform(self, other, 1, 1, p_x, p_y, p_z)
188
+ Api.pj_transform(self, other, 1, 1, p_x, p_y, p_z)
189
189
  self.check_error
190
190
 
191
191
  Point.new(p_x.read_double, p_y.read_double)
@@ -21,12 +21,12 @@ module Proj
21
21
  def initialize(source, target, context=nil)
22
22
  pointer = if source.is_a?(Crs) && target.is_a?(Crs)
23
23
  if Api.method_defined?(:proj_create_crs_to_crs_from_pj)
24
- Api.proj_create_crs_to_crs_from_pj(self.context, source, target, nil, nil)
24
+ Api.proj_create_crs_to_crs_from_pj(context, source, target, nil, nil)
25
25
  else
26
- Api.proj_create_crs_to_crs(self.context, source.definition, target.definition, nil)
26
+ Api.proj_create_crs_to_crs(context, source.definition, target.definition, nil)
27
27
  end
28
28
  else
29
- Api.proj_create_crs_to_crs(self.context, source, target, nil)
29
+ Api.proj_create_crs_to_crs(context, source, target, nil)
30
30
  end
31
31
 
32
32
  if pointer.null?
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = 'proj4rb'
3
- spec.version = '2.0.0'
3
+ spec.version = '2.2.0'
4
4
  spec.summary = 'Ruby bindings for the Proj.4 Carthographic Projection library'
5
5
  spec.description = <<-EOF
6
6
  Proj4rb is a ruby binding for the Proj.4 Carthographic Projection library, that supports conversions between a very large number of geographic coordinate systems and datumspec.
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
8
8
  spec.platform = Gem::Platform::RUBY
9
9
  spec.authors = ['Guilhem Vellut', 'Jochen Topf', 'Charlie Savage']
10
10
  spec.homepage = 'https://github.com/cfis/proj4rb'
11
- spec.required_ruby_version = '>= 2.4.9'
11
+ spec.required_ruby_version = '>= 2.4.1'
12
12
  spec.license = 'MIT'
13
13
 
14
14
  spec.requirements << 'Proj (Proj4) Library'
@@ -19,13 +19,15 @@ Gem::Specification.new do |spec|
19
19
  'proj4rb.gemspec',
20
20
  'Rakefile',
21
21
  'README.rdoc',
22
- 'lib/*.rb',
22
+ 'lib/**/*.rb',
23
23
  'test/*.rb']
24
24
 
25
25
  spec.test_files = Dir["test/test_*.rb"]
26
26
 
27
27
  spec.add_dependency "ffi"
28
28
 
29
+ spec.add_development_dependency('bundler')
30
+ spec.add_development_dependency('rake')
29
31
  spec.add_development_dependency('minitest')
30
32
  spec.add_development_dependency('yard')
31
33
  end
@@ -37,7 +37,7 @@ class TransformationTest < AbstractTest
37
37
  from = Proj::Coordinate.new(lam: 48.9906726079, phi: 8.4302123334)
38
38
  to = transform.inverse(from)
39
39
 
40
- assert_in_delta(5428307, to.x, PRECISION)
40
+ assert_in_delta(5428306.39, to.x, PRECISION)
41
41
  assert_in_delta(3458375, to.y, PRECISION)
42
42
  assert_in_delta(0, to.z, PRECISION)
43
43
  assert_in_delta(0, to.t, PRECISION)
@@ -49,7 +49,7 @@ class TransformationTest < AbstractTest
49
49
  from = Proj::Coordinate.new(lam: 48.9906726079, phi: 8.4302123334)
50
50
  to = transform.forward(from)
51
51
 
52
- assert_in_delta(5428307, to.x, PRECISION)
52
+ assert_in_delta(5428306.39, to.x, PRECISION)
53
53
  assert_in_delta(3458375, to.y, PRECISION)
54
54
  assert_in_delta(0, to.z, PRECISION)
55
55
  assert_in_delta(0, to.t, PRECISION)
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: 2.0.0
4
+ version: 2.2.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: 2019-12-31 00:00:00.000000000 Z
13
+ date: 2020-01-07 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: ffi
@@ -26,6 +26,34 @@ dependencies:
26
26
  - - ">="
27
27
  - !ruby/object:Gem::Version
28
28
  version: '0'
29
+ - !ruby/object:Gem::Dependency
30
+ name: bundler
31
+ requirement: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: '0'
36
+ type: :development
37
+ prerelease: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ - !ruby/object:Gem::Dependency
44
+ name: rake
45
+ requirement: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ type: :development
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
29
57
  - !ruby/object:Gem::Dependency
30
58
  name: minitest
31
59
  requirement: !ruby/object:Gem::Requirement
@@ -67,6 +95,14 @@ files:
67
95
  - MIT-LICENSE
68
96
  - README.rdoc
69
97
  - Rakefile
98
+ - lib/api/api.rb
99
+ - lib/api/api_4_9.rb
100
+ - lib/api/api_5_0.rb
101
+ - lib/api/api_5_1.rb
102
+ - lib/api/api_5_2.rb
103
+ - lib/api/api_6_0.rb
104
+ - lib/api/api_6_1.rb
105
+ - lib/api/api_6_2.rb
70
106
  - lib/area.rb
71
107
  - lib/config.rb
72
108
  - lib/context.rb
@@ -107,7 +143,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
107
143
  requirements:
108
144
  - - ">="
109
145
  - !ruby/object:Gem::Version
110
- version: 2.4.9
146
+ version: 2.4.1
111
147
  required_rubygems_version: !ruby/object:Gem::Requirement
112
148
  requirements:
113
149
  - - ">="