proj4rb 3.0.0 → 4.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 +26 -15
- data/README.rdoc +82 -44
- data/Rakefile +27 -27
- data/lib/api/api.rb +96 -118
- data/lib/api/api_5_0.rb +331 -300
- data/lib/api/api_5_1.rb +6 -6
- data/lib/api/api_5_2.rb +4 -4
- data/lib/api/api_6_0.rb +116 -14
- data/lib/api/api_6_1.rb +4 -4
- data/lib/api/api_6_2.rb +9 -6
- data/lib/api/api_6_3.rb +6 -0
- data/lib/api/api_7_0.rb +68 -0
- data/lib/api/api_7_1.rb +73 -0
- data/lib/api/api_7_2.rb +14 -0
- data/lib/api/api_8_0.rb +6 -0
- data/lib/api/api_8_1.rb +24 -0
- data/lib/api/api_8_2.rb +6 -0
- data/lib/api/api_9_1.rb +7 -0
- data/lib/api/api_9_2.rb +9 -0
- data/lib/api/api_experimental.rb +196 -0
- data/lib/proj/area.rb +73 -32
- data/lib/proj/axis_info.rb +44 -0
- data/lib/proj/bounds.rb +13 -0
- data/lib/proj/context.rb +174 -28
- data/lib/proj/conversion.rb +92 -0
- data/lib/proj/coordinate.rb +281 -197
- data/lib/proj/coordinate_operation_mixin.rb +381 -0
- data/lib/proj/coordinate_system.rb +137 -0
- data/lib/proj/crs.rb +672 -204
- data/lib/proj/crs_info.rb +47 -0
- data/lib/proj/database.rb +305 -0
- data/lib/proj/datum.rb +32 -0
- data/lib/proj/datum_ensemble.rb +34 -0
- data/lib/proj/ellipsoid.rb +77 -41
- data/lib/proj/error.rb +62 -9
- data/lib/proj/file_api.rb +166 -0
- data/lib/proj/grid.rb +121 -0
- data/lib/proj/grid_cache.rb +64 -0
- data/lib/proj/grid_info.rb +19 -0
- data/lib/proj/network_api.rb +92 -0
- data/lib/proj/operation.rb +42 -42
- data/lib/proj/operation_factory_context.rb +136 -0
- data/lib/proj/parameter.rb +38 -0
- data/lib/proj/parameters.rb +106 -0
- data/lib/proj/pj_object.rb +670 -80
- data/lib/proj/pj_objects.rb +44 -0
- data/lib/proj/prime_meridian.rb +65 -39
- data/lib/proj/projection.rb +698 -207
- data/lib/proj/session.rb +46 -0
- data/lib/proj/strings.rb +32 -0
- data/lib/proj/transformation.rb +101 -60
- data/lib/proj/unit.rb +108 -53
- data/lib/proj.rb +110 -9
- data/proj4rb.gemspec +5 -5
- data/test/abstract_test.rb +23 -1
- data/test/context_test.rb +172 -82
- data/test/conversion_test.rb +368 -0
- data/test/coordinate_system_test.rb +144 -0
- data/test/crs_test.rb +770 -71
- data/test/database_test.rb +360 -0
- data/test/datum_ensemble_test.rb +65 -0
- data/test/datum_test.rb +55 -0
- data/test/ellipsoid_test.rb +64 -18
- data/test/file_api_test.rb +66 -0
- data/test/grid_cache_test.rb +72 -0
- data/test/grid_test.rb +141 -0
- data/test/network_api_test.rb +45 -0
- data/test/operation_factory_context_test.rb +201 -0
- data/test/parameters_test.rb +40 -0
- data/test/pj_object_test.rb +179 -0
- data/test/prime_meridian_test.rb +76 -0
- data/test/proj_test.rb +46 -4
- data/test/projection_test.rb +646 -222
- data/test/session_test.rb +78 -0
- data/test/transformation_test.rb +149 -7
- data/test/unit_test.rb +57 -28
- metadata +51 -13
- data/lib/api/api_4_9.rb +0 -31
- data/lib/proj/config.rb +0 -70
- data/lib/proj/point.rb +0 -72
- data/test/prime_meridians_test.rb +0 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0d9e88b214716f78e690e7265c6a9edc9e2c9c77cbb6e40c32883eec61320cc5
|
4
|
+
data.tar.gz: 4102575947ce82e7fdc40d6feeb37bb4b34f024dbfeda66fe20a1909b4a93ccd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 87926009a11eb4a4d71cedcd79a4d72b8196e57df4ac7b59cb28c6b75da5635b89291fa564a1153fb4d2cd5cd910e5ff2c489695177aac54d5a6302a90d1cb26
|
7
|
+
data.tar.gz: 412e2777701a836b9b7d76f00e0e8526a5488711adf10051ea34f9603999a25d290d74b073d2e0f7940e68efc210c416f5a14b6f74e01e4572883caafe620738
|
data/ChangeLog
CHANGED
@@ -1,71 +1,82 @@
|
|
1
|
-
|
1
|
+
4.0.0 - March 12, 2023
|
2
|
+
======================
|
3
|
+
* Support Proj 9
|
4
|
+
* Add support for missing APIs - the gem now provides almost 100% coverage
|
5
|
+
* Add support for Proj experimental APIs including the creation of projection conversions
|
6
|
+
* Add/updated support for a number of ISO 19111 classes, including PrimeMeridian, Ellipsoid,
|
7
|
+
Datum, DatumEnsemble, CoordinateOperation and Parameters
|
8
|
+
* Greatly improved documentation (https://rubydoc.info/github/cfis/proj4rb)
|
9
|
+
* Remove old Proj 4.9 support
|
10
|
+
* Note this release does have some API changes. These include the removal of Proj 4.9 Point and Coordinate classes, changes to the PrimeMeridian class and changes to the Ellipsoid class. These changes should not impact most users.
|
11
|
+
|
12
|
+
3.0.0 - September 26, 2021
|
2
13
|
=========================
|
3
14
|
* Support Proj 8 which removes the old Proj API (Charlie Savage)
|
4
15
|
* Support newer versions of FFI which remove support for returning strings from callbacks (Charlie Savage)
|
5
16
|
|
6
|
-
2.2.2
|
17
|
+
2.2.2 - January 10, 2020
|
7
18
|
=========================
|
8
|
-
* Move proj_context_set_autoclose_database to api 6.2
|
19
|
+
* Move proj_context_set_autoclose_database to api 6.2 - Jan Klimke)
|
9
20
|
* Improve search path generation code (Charlie Savage)
|
10
21
|
|
11
|
-
2.2.1
|
22
|
+
2.2.1 - January 8, 2020
|
12
23
|
=========================
|
13
24
|
* Move proj_as_projjson from version 6.0 to 6.2 api (Charlie Savage)
|
14
25
|
* Improve search path generation code (Charlie Savage)
|
15
26
|
|
16
|
-
2.2.0
|
27
|
+
2.2.0 - January 7, 2020
|
17
28
|
=========================
|
18
29
|
* Fix broken gem - was not including all api files (Jan Klimke)
|
19
30
|
* Add paths on MacOS when using Brew (Jan Klimke)
|
20
31
|
* Various code cleanups (Charlie Savage)
|
21
32
|
|
22
|
-
2.1.0
|
33
|
+
2.1.0 - January 5, 2020
|
23
34
|
=========================
|
24
35
|
* Set Ruby 2.4.1 to be the minimum allowed version (Samuel Williams)
|
25
36
|
* Fix incorrect use of context, reduce warnings when running tests (Samuel Williams)
|
26
37
|
* Fix `bundle exec rake test` (Samuel Williams)
|
27
38
|
* Add 2.4.1 to the travis test matrix (Samuel Williams)
|
28
39
|
|
29
|
-
2.0.0
|
40
|
+
2.0.0 - December 30, 2019
|
30
41
|
=========================
|
31
|
-
- Full rewrite to support API changes in Proj versions 5 and 6
|
42
|
+
- Full rewrite to support API changes in Proj versions 5 and 6 - Charlie Savage)
|
32
43
|
- As part of rewrite switch bindings to use FFI versus a C extension (Charlie Savage)
|
33
44
|
- Split Ruby code into multiple files based on classes (Charlie Savage)
|
34
45
|
- Add in a bunch of new classes including Context, Crs, Coordinate, Ellipsoid, Prime Meridian and Transform (Charlie Savage)
|
35
46
|
- Deprecate Projection and Point - these will stop working with Proj 7 since the use an older deprecated API (Charlie Savage)
|
36
47
|
|
37
|
-
1.0.0
|
48
|
+
1.0.0 - December 14, 2014
|
38
49
|
=========================
|
39
50
|
- Calling this 1.0.0 since its a very stable gem (Charlie Savage)
|
40
51
|
|
41
|
-
0.4.3
|
52
|
+
0.4.3 - August 30, 2011
|
42
53
|
=========================
|
43
54
|
- Remove reference to now private projects.h header
|
44
55
|
|
45
|
-
0.4.2
|
56
|
+
0.4.2 - August 15, 2011
|
46
57
|
=========================
|
47
58
|
- Minor build tweak to support MSVC++
|
48
59
|
|
49
|
-
0.4.1
|
60
|
+
0.4.1 - July 30, 2011
|
50
61
|
=========================
|
51
62
|
- Search first for binaries when using windows gems
|
52
63
|
- Add # encoding to test files
|
53
64
|
- Reformat tests files to use standard ruby 2 space indenting
|
54
65
|
|
55
|
-
0.4.0
|
66
|
+
0.4.0 - July 30, 2011
|
56
67
|
=========================
|
57
68
|
- Update to compile on Ruby 1.9.* (Fabio Renzo Panettieri)
|
58
69
|
- Add in gemspec file (Charlie Savage)
|
59
70
|
- Add rake-compiler as development dependency, remove older MinGW build system (Charlie Savage)
|
60
71
|
- Move to GitHub (Charlie Savage)
|
61
72
|
|
62
|
-
0.3.1
|
73
|
+
0.3.1 - December 23, 2009
|
63
74
|
=========================
|
64
75
|
- Update extconf.conf file to be more flexible to make it easier to build
|
65
76
|
on OS X when using MacPorts
|
66
77
|
- Updated windows binary to link against proj4.7
|
67
78
|
|
68
|
-
0.3.0
|
79
|
+
0.3.0 - August 14, 2008
|
69
80
|
=========================
|
70
81
|
- Removed Proj4::UV class which was previously deprecated
|
71
82
|
- New build infrastructure for Windows (Charlie Savage)
|
data/README.rdoc
CHANGED
@@ -3,7 +3,9 @@ This gem provides Ruby bindings for the Proj Library (https://proj.org). The Pro
|
|
3
3
|
between a number of different coordinate systems and projections.
|
4
4
|
|
5
5
|
== Documentation
|
6
|
-
|
6
|
+
Reference documentation is available at https://rubydoc.info/github/cfis/proj4rb.
|
7
|
+
|
8
|
+
Examples can be found in this README file as well as in the {file:Examples.rdoc Examples} file. In addition, the test suite has exapmles of calling almost every API so when in doubt take a look at them!
|
7
9
|
|
8
10
|
== Installation
|
9
11
|
First install the gem in the usual manner:
|
@@ -23,9 +25,9 @@ If you are using the old Proj4 namespace, then you can do this:
|
|
23
25
|
|
24
26
|
require 'proj4'
|
25
27
|
|
26
|
-
===
|
27
|
-
|
28
|
-
|
28
|
+
=== CRS
|
29
|
+
To create a coordinate system, you can use CRS codes, well-known text (WKT) strings
|
30
|
+
or old-style Proj strings (which are deprecated).
|
29
31
|
|
30
32
|
crs1 = Proj::Crs.new('EPSG:4326')
|
31
33
|
|
@@ -64,14 +66,14 @@ After you have created two coordinate systems, you can then create a transformat
|
|
64
66
|
convert coordinates from the "3-degree Gauss-Kruger zone 3" coordinate system to WGS84 (one version of lat-long)
|
65
67
|
first create a transformation:
|
66
68
|
|
67
|
-
crs_gk = Proj::Crs.new('
|
68
|
-
crs_wgs84 = Proj::Crs.new('
|
69
|
+
crs_gk = Proj::Crs.new('EPSG:31467')
|
70
|
+
crs_wgs84 = Proj::Crs.new('EPSG:4326')
|
69
71
|
transform = Proj::Transformation.new(crs_gk, crs_wgs84)
|
70
72
|
|
71
73
|
Alternatively, or if you are using Proj 5, you can create a transformation without first
|
72
74
|
creating Crs instances. Instead, pass the EPSG information directly to the transformation:
|
73
75
|
|
74
|
-
transform = Proj::Transformation.new('
|
76
|
+
transform = Proj::Transformation.new('EPSG:31467', 'EPSG:4326')
|
75
77
|
|
76
78
|
Once you've created the transformation, you can tranform coordinates using either
|
77
79
|
the +forward+ or +inverse+ methods. The forward transformation looks like this:
|
@@ -94,6 +96,25 @@ While the inverse transformation looks like this:
|
|
94
96
|
assert_in_delta(0, to.z, 0.01)
|
95
97
|
assert_in_delta(0, to.t, 0.01)
|
96
98
|
|
99
|
+
=== Coordinate Operations
|
100
|
+
Transformations are a type of Coordinate Operation. PROJ divides coordinate operations into three groups:
|
101
|
+
|
102
|
+
* Conversions
|
103
|
+
* Projections
|
104
|
+
* Transformations
|
105
|
+
|
106
|
+
Conversions are coordinate operations that do not exert a change in reference frame. The Ruby bindings support these via the Conversion class. See https://proj.org/operations/conversions/index.html for more information.
|
107
|
+
|
108
|
+
Projections are cartographic mappings of the sphere onto the plane. Technically projections are conversions (according to ISO standards), but PROJ distinguishes them from conversions. The Ruby bindings support these
|
109
|
+
via the Projection module which has methods to create many common projections. A list can be found at https://proj.org/operations/projections/index.html.
|
110
|
+
|
111
|
+
Transformations are coordinate operations that do cause a change in reference frames. The Ruby bindings support these via the Transformation class.
|
112
|
+
|
113
|
+
For more information see https://proj.org/operations/index.html
|
114
|
+
|
115
|
+
=== Operation Factory
|
116
|
+
The OperationFactoryContext class can be used to build coordinate operations between two CRSes. This is done by first creating a factory and setting appropiate filters. These include spatial filters, accuracy filters, grid availability filters, etc. Once filters are set, then the factory can be queried for a list of possible conversions. For examples, please see the operation_factory_context_test.rb file.
|
117
|
+
|
97
118
|
=== Coordinate
|
98
119
|
Notice the examples above transform Coordinate objects. A Coordinate consists
|
99
120
|
of up to four double values to represent three directions plus time. In general
|
@@ -104,6 +125,21 @@ you will need to fill out at least the first two values:
|
|
104
125
|
|
105
126
|
Lam is longitude and phi is latitude.
|
106
127
|
|
128
|
+
=== Axis Order
|
129
|
+
By default tranformations accept coordinates expressed in the units and axis order of the source CRS and return transformed coordinates in the units and axis order of the target CRS.
|
130
|
+
|
131
|
+
For most geographic CRSes, the units will be in degrees. For geographic CRSes defined by the EPSG authority, the order of coordinates is latitude and then longitude.
|
132
|
+
|
133
|
+
For projected CRSes, the units will vary (metre, us-foot, etc.). For projected CRS defined by the EPSG authority, and with EAST / NORTH directions, the order might may be east and then north or north and then east.
|
134
|
+
|
135
|
+
If you prefer to work with a uniform axis order, regardless of the axis orders mandated by the source and target CRSes, then call the Context#normalize_for_visualization method:
|
136
|
+
|
137
|
+
normalized = transform.normalize_for_visualization
|
138
|
+
|
139
|
+
The normalized transformation will return output coordinates in longitude, latitude order for geographic CRSes and easting, northing for most projected CRSes.
|
140
|
+
|
141
|
+
For more information see {https://proj.org/faq.html#why-is-the-axis-ordering-in-proj-not-consistent Why Is The Axis Ordering In Proj Not Consistent?}
|
142
|
+
|
107
143
|
=== Context
|
108
144
|
Contexts are used to support multi-threaded programs. The bindings expose this object via Context.current
|
109
145
|
and store it using thread local storage. Use the context object to access error codes, set proj4
|
@@ -112,48 +148,50 @@ compatability settings, set the logging level and to install custom logging code
|
|
112
148
|
Both Crs and Transformation objects take a context object in their constructors. If none is passed, they default
|
113
149
|
to using Context.current
|
114
150
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
151
|
+
== Network Access
|
152
|
+
Proj supports downloading grid files on demand if network access is enabled (it is disabled by default). To enable network use the method {Context#network_enabled=}. To specify the url endpoint use {Context#url=}. Advanced users can replace Proj's networking code, which uses libcurl, with their own implementation. To do this see the NetworkApi class.
|
153
|
+
|
154
|
+
Downloaded grids are cached in a sqlite file named cache.db. To specify the location, size and other characteristics of the cache file refer to the {GridCache} class which is accessible via Context#cache. By default the cache size is 300MB. Caching is on by default but can be disabled via GridCache#enabled=.
|
119
155
|
|
120
156
|
== Error handling
|
121
157
|
When an error occurs, a Proj::Error instance will be thrown with the underlying message provided
|
122
158
|
from the Proj library.
|
123
159
|
|
124
|
-
== Finding Proj
|
160
|
+
== Finding Proj Library (PROJ_LIB_PATH)
|
161
|
+
proj4rb will search in a number of well-known locations for the libproj shared library. You
|
162
|
+
can override this by specifying the full path to the library using the PROJ_LIB_PATH
|
163
|
+
environmental variable.
|
164
|
+
|
165
|
+
== Finding Proj Files (PROJ_DATA)
|
125
166
|
Starting with version 6, Proj stores its information (datums, ellipsoids, prime meridians, coordinate systems,
|
126
|
-
units, etc) in a sqlite file called proj.db. If Proj cannot find its database
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
* Use degrees, not radians
|
156
|
-
* Swap the order of the lat and long values
|
167
|
+
units, etc) in a sqlite file called proj.db. If Proj cannot find its database an exception will be
|
168
|
+
raised. In this case, you can set the environmental variable PROJ_DATA to point to the folder that
|
169
|
+
contains the proj.db file. Note PROJ_LIB must be set by whatever launches your Ruby program.
|
170
|
+
The Ruby program itself cannot set this variable and have it work correctly (at least not on windows).
|
171
|
+
|
172
|
+
For more information see https://proj.org/resource_files.html
|
173
|
+
|
174
|
+
== Class Hierarchy
|
175
|
+
The proj4rb class hierarchy is based on Proj's class hiearchy which, in turn, is derived from {http://docs.opengeospatial.org/as/18-005r5/18-005r5.html ISO 19111:2019}. It is:
|
176
|
+
|
177
|
+
PjObject
|
178
|
+
CoordinateOperationMixin
|
179
|
+
Conversion
|
180
|
+
Transformation
|
181
|
+
CoordinateSystem
|
182
|
+
Crs
|
183
|
+
Datum
|
184
|
+
Ellipsoid
|
185
|
+
PrimeMerdian
|
186
|
+
|
187
|
+
The PjObject class defines several methods to create new objects:
|
188
|
+
|
189
|
+
* PjObject.create
|
190
|
+
* PjObject.create_from_database
|
191
|
+
* PjObject.create_from_name
|
192
|
+
* PjObject.create_from_wkt
|
193
|
+
|
194
|
+
The methods will return instances of the correct subclass.
|
157
195
|
|
158
196
|
== Tests
|
159
197
|
Proj4rb ships with a full test suite designed to work using Proj 6. If you are using an earlier version of Proj,
|
@@ -162,7 +200,7 @@ then expect *many* test failures.
|
|
162
200
|
== License
|
163
201
|
Proj4rb is released under the MIT license.
|
164
202
|
|
165
|
-
==Authors
|
203
|
+
== Authors
|
166
204
|
The proj4rb Ruby bindings were started by Guilhem Vellut with most of the code
|
167
205
|
written by Jochen Topf. Charlie Savage ported the code to Windows and added
|
168
206
|
the Windows build infrastructure. Later, he rewrote the code to support
|
data/Rakefile
CHANGED
@@ -1,28 +1,28 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "rubygems"
|
4
|
-
require "rake/testtask"
|
5
|
-
require "rubygems/package_task"
|
6
|
-
require "yard"
|
7
|
-
require "yaml"
|
8
|
-
|
9
|
-
# Read the spec file
|
10
|
-
GEM_NAME = "proj4rb"
|
11
|
-
spec = Gem::Specification.load("#{GEM_NAME}.gemspec")
|
12
|
-
|
13
|
-
# Setup generic gem
|
14
|
-
Gem::PackageTask.new(spec) do |pkg|
|
15
|
-
pkg.package_dir = 'pkg'
|
16
|
-
pkg.need_tar = false
|
17
|
-
end
|
18
|
-
|
19
|
-
# Yard Task
|
20
|
-
desc "Generate documentation"
|
21
|
-
YARD::Rake::YardocTask.new
|
22
|
-
|
23
|
-
# Test Task
|
24
|
-
Rake::TestTask.new do |t|
|
25
|
-
t.libs << "test"
|
26
|
-
t.test_files = FileList['test/*_test.rb']
|
27
|
-
t.verbose = true
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "rubygems"
|
4
|
+
require "rake/testtask"
|
5
|
+
require "rubygems/package_task"
|
6
|
+
require "yard"
|
7
|
+
require "yaml"
|
8
|
+
|
9
|
+
# Read the spec file
|
10
|
+
GEM_NAME = "proj4rb"
|
11
|
+
spec = Gem::Specification.load("#{GEM_NAME}.gemspec")
|
12
|
+
|
13
|
+
# Setup generic gem
|
14
|
+
Gem::PackageTask.new(spec) do |pkg|
|
15
|
+
pkg.package_dir = 'pkg'
|
16
|
+
pkg.need_tar = false
|
17
|
+
end
|
18
|
+
|
19
|
+
# Yard Task
|
20
|
+
desc "Generate documentation"
|
21
|
+
YARD::Rake::YardocTask.new
|
22
|
+
|
23
|
+
# Test Task
|
24
|
+
Rake::TestTask.new do |t|
|
25
|
+
t.libs << "test"
|
26
|
+
t.test_files = FileList['test/*_test.rb']
|
27
|
+
t.verbose = true
|
28
28
|
end
|
data/lib/api/api.rb
CHANGED
@@ -1,118 +1,96 @@
|
|
1
|
-
require 'rbconfig'
|
2
|
-
require 'ffi'
|
3
|
-
|
4
|
-
module Proj
|
5
|
-
module Api
|
6
|
-
extend FFI::Library
|
7
|
-
|
8
|
-
def self.library_versions
|
9
|
-
[
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
when /
|
24
|
-
self.
|
25
|
-
|
26
|
-
self.
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
end
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
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
|
1
|
+
require 'rbconfig'
|
2
|
+
require 'ffi'
|
3
|
+
|
4
|
+
module Proj
|
5
|
+
module Api
|
6
|
+
extend FFI::Library
|
7
|
+
|
8
|
+
def self.library_versions
|
9
|
+
["25", # 9.2
|
10
|
+
"9_1", # 9.1
|
11
|
+
"22", # 8.0 and 8.1
|
12
|
+
"19", # 7.x
|
13
|
+
"17", # 6.1 *and* 6.2
|
14
|
+
"15", # 6.0
|
15
|
+
"14", # 5.2
|
16
|
+
"13", # 5.0
|
17
|
+
"12", # 4.9
|
18
|
+
"11"] # 4.9
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.search_paths
|
22
|
+
result = case RbConfig::CONFIG['host_os']
|
23
|
+
when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
|
24
|
+
self.windows_search_paths
|
25
|
+
when /darwin|mac os/
|
26
|
+
self.macos_search_paths
|
27
|
+
else
|
28
|
+
self.linux_search_paths
|
29
|
+
end
|
30
|
+
|
31
|
+
# Try libproj as catch all
|
32
|
+
result << 'libproj'
|
33
|
+
result
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.windows_search_paths
|
37
|
+
self.library_versions.map do |version|
|
38
|
+
["libproj-#{version}", "libproj_#{version}"]
|
39
|
+
end.flatten
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.linux_search_paths
|
43
|
+
self.library_versions.map do |version|
|
44
|
+
"libproj.so.#{version}"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.macos_search_paths
|
49
|
+
# On MacOS only support HomeBrew since the MacPort is unsupported and ancient (5.2).
|
50
|
+
self.library_versions.map do |version|
|
51
|
+
"libproj.#{version}.dylib"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.load_library
|
56
|
+
if ENV["PROJ_LIB_PATH"]
|
57
|
+
ffi_lib ENV["PROJ_LIB_PATH"]
|
58
|
+
else
|
59
|
+
ffi_lib self.search_paths
|
60
|
+
end
|
61
|
+
|
62
|
+
ffi_libraries.first
|
63
|
+
end
|
64
|
+
|
65
|
+
def self.load_api
|
66
|
+
# First load the base 5.0 api so we can determine the Proj Version
|
67
|
+
require_relative './api_5_0'
|
68
|
+
Api.const_set('PROJ_VERSION', Gem::Version.new(self.proj_info[:version]))
|
69
|
+
|
70
|
+
# Now load the rest of the apis based on the proj version
|
71
|
+
versions = ['5.1.0', '5.2.0',
|
72
|
+
'6.0.0', '6.1.0', '6.2.0', '6.3.0',
|
73
|
+
'7.0.0', '7.1.0', '7.2.0',
|
74
|
+
'8.0.0', '8.1.0', '8.2.0',
|
75
|
+
'9.1.0', '9.2.0']
|
76
|
+
|
77
|
+
versions.each do |version|
|
78
|
+
api_version = Gem::Version.new(version)
|
79
|
+
|
80
|
+
if PROJ_VERSION >= api_version
|
81
|
+
require_relative "./api_#{api_version.segments[0]}_#{api_version.segments[1]}"
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
# Add in the experimental api
|
86
|
+
require_relative "./api_experimental"
|
87
|
+
end
|
88
|
+
|
89
|
+
# Load the library
|
90
|
+
load_library
|
91
|
+
|
92
|
+
# Load the api
|
93
|
+
load_api
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|