proj4rb 2.0.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog +34 -8
- data/README.rdoc +24 -25
- data/Rakefile +1 -0
- data/lib/api/api.rb +118 -0
- data/lib/api/api_4_9.rb +31 -0
- data/lib/api/api_5_0.rb +301 -0
- data/lib/api/api_5_1.rb +7 -0
- data/lib/api/api_5_2.rb +5 -0
- data/lib/api/api_6_0.rb +42 -0
- data/lib/api/api_6_1.rb +5 -0
- data/lib/api/api_6_2.rb +7 -0
- data/lib/{area.rb → proj/area.rb} +32 -32
- data/lib/{config.rb → proj/config.rb} +69 -69
- data/lib/{context.rb → proj/context.rb} +102 -102
- data/lib/{coordinate.rb → proj/coordinate.rb} +197 -197
- data/lib/{crs.rb → proj/crs.rb} +204 -206
- data/lib/{ellipsoid.rb → proj/ellipsoid.rb} +41 -41
- data/lib/{error.rb → proj/error.rb} +17 -17
- data/lib/{operation.rb → proj/operation.rb} +42 -42
- data/lib/{pj_object.rb → proj/pj_object.rb} +80 -82
- data/lib/{point.rb → proj/point.rb} +72 -72
- data/lib/{prime_meridian.rb → proj/prime_meridian.rb} +39 -39
- data/lib/{projection.rb → proj/projection.rb} +206 -206
- data/lib/{transformation.rb → proj/transformation.rb} +60 -60
- data/lib/{unit.rb → proj/unit.rb} +53 -53
- data/lib/proj.rb +31 -31
- data/proj4rb.gemspec +5 -3
- data/test/context_test.rb +81 -81
- data/test/crs_test.rb +1 -1
- data/test/proj_test.rb +5 -5
- data/test/projection_test.rb +183 -181
- metadata +58 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4d2946731ccd3cf4e96e214fce1e8e3c7fc46313f5f1d1fcc119c84e9b88f26f
|
4
|
+
data.tar.gz: 17ca8b08ed1b03be5d910ba77013b7028d88e45160b352764619799f7f156887
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a23e8938aa5d6289dabe4b1f0e5ad2aa204281f6ff2f0073fcbc20b6d404bc6b265120cb0c22561ad68338248a16959fd36873777cdbe7ebae4cbf86258ad2f
|
7
|
+
data.tar.gz: 78b42798c55214f7d73df85575b5d6a4a64283ab51583656a9441a725c369fde5a7b12c36944a8dd0a66c67bdf9ef6b48e189e34a3c6d280f11e0adca4116835
|
data/ChangeLog
CHANGED
@@ -1,16 +1,42 @@
|
|
1
|
-
|
1
|
+
3.0.0 (September 26, 2021)
|
2
|
+
=========================
|
3
|
+
* Support Proj 8 which removes the old Proj API (Charlie Savage)
|
4
|
+
* Support newer versions of FFI which remove support for returning strings from callbacks (Charlie Savage)
|
5
|
+
|
6
|
+
2.2.2 (January 10, 2020)
|
2
7
|
=========================
|
3
|
-
|
4
|
-
|
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
|
8
|
+
* Move proj_context_set_autoclose_database to api 6.2 (Jan Klimke)
|
9
|
+
* Improve search path generation code (Charlie Savage)
|
8
10
|
|
9
|
-
|
11
|
+
2.2.1 (January 8, 2020)
|
12
|
+
=========================
|
13
|
+
* Move proj_as_projjson from version 6.0 to 6.2 api (Charlie Savage)
|
14
|
+
* Improve search path generation code (Charlie Savage)
|
15
|
+
|
16
|
+
2.2.0 (January 7, 2020)
|
17
|
+
=========================
|
18
|
+
* Fix broken gem - was not including all api files (Jan Klimke)
|
19
|
+
* Add paths on MacOS when using Brew (Jan Klimke)
|
20
|
+
* Various code cleanups (Charlie Savage)
|
21
|
+
|
22
|
+
2.1.0 (January 5, 2020)
|
23
|
+
=========================
|
24
|
+
* Set Ruby 2.4.1 to be the minimum allowed version (Samuel Williams)
|
25
|
+
* Fix incorrect use of context, reduce warnings when running tests (Samuel Williams)
|
26
|
+
* Fix `bundle exec rake test` (Samuel Williams)
|
27
|
+
* Add 2.4.1 to the travis test matrix (Samuel Williams)
|
28
|
+
|
29
|
+
2.0.0 (December 30, 2019)
|
30
|
+
=========================
|
31
|
+
- Full rewrite to support API changes in Proj versions 5 and 6 (Charlie Savage)
|
32
|
+
- As part of rewrite switch bindings to use FFI versus a C extension (Charlie Savage)
|
33
|
+
- Split Ruby code into multiple files based on classes (Charlie Savage)
|
34
|
+
- Add in a bunch of new classes including Context, Crs, Coordinate, Ellipsoid, Prime Meridian and Transform (Charlie Savage)
|
35
|
+
- Deprecate Projection and Point - these will stop working with Proj 7 since the use an older deprecated API (Charlie Savage)
|
10
36
|
|
11
37
|
1.0.0 (December 14, 2014)
|
12
38
|
=========================
|
13
|
-
- Calling this 1.0.0 since its a very stable gem
|
39
|
+
- Calling this 1.0.0 since its a very stable gem (Charlie Savage)
|
14
40
|
|
15
41
|
0.4.3 (August 30, 2011)
|
16
42
|
=========================
|
data/README.rdoc
CHANGED
@@ -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
|
|
@@ -21,8 +24,8 @@ If you are using the old Proj4 namespace, then you can do this:
|
|
21
24
|
require 'proj4'
|
22
25
|
|
23
26
|
=== Crs
|
24
|
-
If you are using Proj 6 create a coordinate system. To create a coordinate system, you can use CRS codes,
|
25
|
-
or old-style Proj4 strings (which are deprecated).
|
27
|
+
If you are using Proj 6, or newer, create a coordinate system. To create a coordinate system, you can use CRS codes,
|
28
|
+
well-known text (WKT) strings or old-style Proj4 strings (which are deprecated).
|
26
29
|
|
27
30
|
crs1 = Proj::Crs.new('EPSG:4326')
|
28
31
|
|
@@ -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,
|
80
|
-
assert_in_delta(8.429263044355544, to.y,
|
81
|
-
assert_in_delta(-5.1790915237, to.z,
|
82
|
-
assert_in_delta(0, to.t,
|
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,
|
90
|
-
assert_in_delta(3458375.3367194114, to.y,
|
91
|
-
assert_in_delta(0, to.z,
|
92
|
-
assert_in_delta(0, to.t,
|
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
|
118
|
-
are deprecated classes but will continue to work
|
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 with Proj version 7 and older. Please refer to the documentation
|
119
118
|
for more information.
|
120
119
|
|
121
120
|
== Error handling
|
@@ -133,15 +132,15 @@ 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
|
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
|
-
classes. However, these classes are no longer documented in this Readme because
|
140
|
-
|
141
|
-
So please port your code! But take note of the changes in Proj 6 described below.
|
139
|
+
classes. However, these classes are no longer documented in this Readme because the underlying API
|
140
|
+
they rely on was removed in Proj 8. So please port your code! But take note of the changes in Proj 6 described below.
|
142
141
|
|
143
|
-
Proj 5 introduced the
|
144
|
-
metadata APIs were added, so the amount of information about each object is somewhat limited.
|
142
|
+
Proj 5 introduced the Coordinate, Crs and Tranformation APIs. However, it wasn't until Proj 6 that additional
|
143
|
+
metadata APIs were added, so the amount of information about each object is somewhat limited in Proj 5.
|
145
144
|
|
146
145
|
Proj 6 makes a big change compared to previous releases that is not well documented (see
|
147
146
|
https://github.com/OSGeo/PROJ/pull/1182). When creating tranformations with EPSG values Proj 6
|
@@ -166,5 +165,5 @@ Proj4rb is released under the MIT license.
|
|
166
165
|
==Authors
|
167
166
|
The proj4rb Ruby bindings were started by Guilhem Vellut with most of the code
|
168
167
|
written by Jochen Topf. Charlie Savage ported the code to Windows and added
|
169
|
-
the Windows build infrastructure. Later, he
|
170
|
-
Proj version 5 and 6 and ported
|
168
|
+
the Windows build infrastructure. Later, he rewrote the code to support
|
169
|
+
Proj version 5 and 6 and ported it to use FFI.
|
data/Rakefile
CHANGED
data/lib/api/api.rb
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
require 'rbconfig'
|
2
|
+
require 'ffi'
|
3
|
+
|
4
|
+
module Proj
|
5
|
+
module Api
|
6
|
+
extend FFI::Library
|
7
|
+
|
8
|
+
def self.library_versions
|
9
|
+
[22, # 8.0 and 8.1
|
10
|
+
19, # 7.x
|
11
|
+
17, # 6.2 *and* 6.1
|
12
|
+
15, # 6.0
|
13
|
+
14, # 5.2
|
14
|
+
13, # 5.0
|
15
|
+
12, # 4.9
|
16
|
+
11] # 4.9
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.search_paths
|
20
|
+
result = case RbConfig::CONFIG['host_os']
|
21
|
+
when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
|
22
|
+
self.windows_search_paths
|
23
|
+
when /darwin|mac os/
|
24
|
+
self.macos_search_paths
|
25
|
+
else
|
26
|
+
self.linux_search_paths
|
27
|
+
end
|
28
|
+
|
29
|
+
result << 'libproj'
|
30
|
+
result
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.windows_search_paths
|
34
|
+
self.library_versions.map do |version|
|
35
|
+
"libproj-#{version}"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.linux_search_paths
|
40
|
+
self.library_versions.map do |version|
|
41
|
+
"libproj.so.#{version}"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.macos_search_paths
|
46
|
+
# Mac Ports
|
47
|
+
paths1 = self.library_versions.map do |version|
|
48
|
+
case version
|
49
|
+
when 15..17
|
50
|
+
"/opt/local/lib/proj6/lib/libproj.#{version}.dylib"
|
51
|
+
when 13..14
|
52
|
+
"/opt/local/lib/proj5/lib/libproj.#{version}.dylib"
|
53
|
+
when 11..12
|
54
|
+
"/opt/local/lib/proj49/lib/libproj.#{version}.dylib"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
# Mac HomeBrew
|
59
|
+
paths2 = self.library_versions.map do |version|
|
60
|
+
"/usr/local/lib/libproj.#{version}.dylib"
|
61
|
+
end
|
62
|
+
|
63
|
+
paths1 + paths2
|
64
|
+
end
|
65
|
+
|
66
|
+
ffi_lib self.search_paths
|
67
|
+
|
68
|
+
library = ffi_libraries.first
|
69
|
+
|
70
|
+
# proj_info was introduced in Proj 5
|
71
|
+
if library.find_function('proj_info')
|
72
|
+
require_relative './api_5_0'
|
73
|
+
PROJ_VERSION = Gem::Version.new(self.proj_info[:version])
|
74
|
+
else
|
75
|
+
# Load the old deprecated api
|
76
|
+
require_relative './api_4_9'
|
77
|
+
|
78
|
+
release = self.pj_get_release
|
79
|
+
version = release.match(/\d\.\d\.\d/)
|
80
|
+
PROJ_VERSION = Gem::Version.new(version)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
if Api::PROJ_VERSION < Gem::Version.new('5.0.0')
|
85
|
+
def Api.proj_torad(value)
|
86
|
+
value * 0.017453292519943296
|
87
|
+
end
|
88
|
+
|
89
|
+
def Api.proj_todeg(value)
|
90
|
+
value * 57.295779513082321
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
# Load the old deprecated API for versions before version 8
|
95
|
+
if Api::PROJ_VERSION < Gem::Version.new('8.0.0')
|
96
|
+
require_relative './api_4_9'
|
97
|
+
end
|
98
|
+
|
99
|
+
if Api::PROJ_VERSION >= Gem::Version.new('5.1.0')
|
100
|
+
require_relative './api_5_1'
|
101
|
+
end
|
102
|
+
|
103
|
+
if Api::PROJ_VERSION >= Gem::Version.new('5.2.0')
|
104
|
+
require_relative './api_5_2'
|
105
|
+
end
|
106
|
+
|
107
|
+
if Api::PROJ_VERSION >= Gem::Version.new('6.0.0')
|
108
|
+
require_relative './api_6_0'
|
109
|
+
end
|
110
|
+
|
111
|
+
if Api::PROJ_VERSION >= Gem::Version.new('6.1.0')
|
112
|
+
require_relative './api_6_1'
|
113
|
+
end
|
114
|
+
|
115
|
+
if Api::PROJ_VERSION >= Gem::Version.new('6.2.0')
|
116
|
+
require_relative './api_6_2'
|
117
|
+
end
|
118
|
+
end
|
data/lib/api/api_4_9.rb
ADDED
@@ -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
|
data/lib/api/api_5_0.rb
ADDED
@@ -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
|
data/lib/api/api_5_1.rb
ADDED
data/lib/api/api_5_2.rb
ADDED
data/lib/api/api_6_0.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
module Proj
|
2
|
+
module Api
|
3
|
+
callback :proj_file_finder, [:PJ_CONTEXT, :string, :pointer], :pointer
|
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
|
+
|
24
|
+
# Projection database functions
|
25
|
+
attach_function :proj_context_set_database_path, [:PJ_CONTEXT, :string, :pointer, :pointer], :int
|
26
|
+
attach_function :proj_context_get_database_path, [:PJ_CONTEXT], :string
|
27
|
+
attach_function :proj_context_get_database_metadata, [:PJ_CONTEXT, :string], :string
|
28
|
+
|
29
|
+
# CRS methods
|
30
|
+
attach_function :proj_crs_get_geodetic_crs, [:PJ_CONTEXT, :PJ], :PJ
|
31
|
+
attach_function :proj_crs_get_horizontal_datum, [:PJ_CONTEXT, :PJ], :PJ
|
32
|
+
attach_function :proj_crs_get_sub_crs, [:PJ_CONTEXT, :PJ, :int], :PJ
|
33
|
+
attach_function :proj_crs_get_datum, [:PJ_CONTEXT, :PJ], :PJ
|
34
|
+
attach_function :proj_crs_get_coordinate_system, [:PJ_CONTEXT, :PJ], :PJ
|
35
|
+
attach_function :proj_cs_get_type, [:PJ_CONTEXT, :PJ], :PJ_COORDINATE_SYSTEM_TYPE
|
36
|
+
attach_function :proj_cs_get_axis_count, [:PJ_CONTEXT, :PJ], :int
|
37
|
+
attach_function :proj_cs_get_axis_info, [:PJ_CONTEXT, :PJ, :int, :pointer, :pointer, :pointer, :pointer, :pointer, :pointer, :pointer], :bool
|
38
|
+
attach_function :proj_get_prime_meridian, [:PJ_CONTEXT, :PJ], :PJ
|
39
|
+
attach_function :proj_get_ellipsoid, [:PJ_CONTEXT, :PJ], :PJ
|
40
|
+
attach_function :proj_crs_get_coordoperation, [:PJ_CONTEXT, :PJ], :PJ
|
41
|
+
end
|
42
|
+
end
|