proj4rb 4.0.0 → 4.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog +11 -0
- data/README.rdoc +22 -40
- data/lib/api/api.rb +22 -1
- data/lib/api/api_5_0.rb +7 -1
- data/lib/api/api_6_0.rb +4 -2
- data/lib/api/api_7_0.rb +1 -0
- data/lib/api/api_9_4.rb +6 -0
- data/lib/api/api_experimental.rb +5 -0
- data/lib/proj/area.rb +1 -0
- data/lib/proj/axis_info.rb +1 -1
- data/lib/proj/context.rb +4 -3
- data/lib/proj/conversion.rb +1 -2
- data/lib/proj/coordinate_metadata.rb +38 -0
- data/lib/proj/coordinate_operation_mixin.rb +9 -9
- data/lib/proj/coordinate_system.rb +18 -18
- data/lib/proj/crs.rb +83 -75
- data/lib/proj/crs_info.rb +15 -15
- data/lib/proj/database.rb +3 -3
- data/lib/proj/datum.rb +1 -1
- data/lib/proj/ellipsoid.rb +3 -3
- data/lib/proj/grid.rb +1 -1
- data/lib/proj/operation.rb +2 -2
- data/lib/proj/operation_factory_context.rb +2 -1
- data/lib/proj/parameters.rb +1 -0
- data/lib/proj/pj_object.rb +8 -6
- data/lib/proj/pj_objects.rb +1 -0
- data/lib/proj/prime_meridian.rb +2 -2
- data/lib/proj/projection.rb +1742 -698
- data/lib/proj/session.rb +2 -1
- data/lib/proj/transformation.rb +4 -4
- data/lib/proj/unit.rb +1 -1
- data/lib/proj.rb +11 -7
- data/proj4rb.gemspec +1 -1
- data/test/abstract_test.rb +0 -23
- data/test/conversion_test.rb +11 -11
- data/test/coordinate_system_test.rb +7 -7
- data/test/crs_test.rb +25 -15
- data/test/database_test.rb +60 -28
- data/test/operation_factory_context_test.rb +13 -9
- data/test/pj_object_test.rb +38 -30
- data/test/projection_test.rb +187 -187
- data/test/transformation_test.rb +7 -7
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26b50da982077e9d6cd97efc8746bd4e888bccf689d7bb3a8e0a752493165181
|
4
|
+
data.tar.gz: 3001ce9757d511e27bc4c7c0118bf2da986ab8e811c106c1517d5a5cf3cdd6a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6da17b22219016b19b4e93b78a3bbb01a4794b1a21d57b2ef76cff54eb7d4c5ef50ef73679c9f91497774a10690c359f1d7bdd297892ab5745c0149bf1a3eeec
|
7
|
+
data.tar.gz: 991f95662e5d10663da570b9e6efed6b37ba2c2b86d94389d485050e385c50ed6a13ad44aa84ac42b29d6a74830350739fa47a2ae5f736b09325fc5db439f5dc
|
data/ChangeLog
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
4.1.1 - January 30, 2024
|
2
|
+
======================
|
3
|
+
* Update tests for Proj 9.3
|
4
|
+
* Initial support for CoordinateMetadata in Proj 9.4 (not released yet)
|
5
|
+
|
6
|
+
4.1.0 - March 12, 2023
|
7
|
+
======================
|
8
|
+
* Fix YARD warnings
|
9
|
+
* Fix YARD types to match RBS types
|
10
|
+
* Don't use type as attribute or method name to avoid conflicts with RBS
|
11
|
+
|
1
12
|
4.0.0 - March 12, 2023
|
2
13
|
======================
|
3
14
|
* Support Proj 9
|
data/README.rdoc
CHANGED
@@ -1,20 +1,19 @@
|
|
1
1
|
= Proj4rb
|
2
|
-
This gem provides Ruby bindings for the Proj Library (https://proj.org). The Proj Library supports converting coordinates
|
3
|
-
|
2
|
+
This gem provides Ruby bindings for the Proj Library (https://proj.org). The Proj Library supports converting coordinates between a number of different coordinate systems and projections. Note the Proj library used to be know as Proj4.
|
3
|
+
|
4
|
+
The bindings support Proj version 4 through the current version (9.3.1). The Proj library and API were completelely written during this time. To support all these versions, the gem dynamically loads code based on the installed Proj version.
|
4
5
|
|
5
6
|
== Documentation
|
6
7
|
Reference documentation is available at https://rubydoc.info/github/cfis/proj4rb.
|
7
8
|
|
8
|
-
Examples can be found in this README file as well as in the
|
9
|
+
Examples can be found in this README file as well as in the Examples file. In addition, the test suite has exapmles of calling almost every API so when in doubt take a look at them!
|
9
10
|
|
10
11
|
== Installation
|
11
|
-
First install the gem
|
12
|
+
First install the gem:
|
12
13
|
|
13
14
|
gem install proj4rb
|
14
15
|
|
15
|
-
Next install the Proj Library. This of course varies per system, but you want to install the latest version Proj
|
16
|
-
possible. Once installed, you'll need to make sure that libproj is installed on your operating system's
|
17
|
-
load path.
|
16
|
+
Next install the Proj Library. This of course varies per system, but you want to install the latest version Proj possible. Once installed, you'll need to make sure that libproj is installed on your operating system's load path.
|
18
17
|
|
19
18
|
== Usage
|
20
19
|
To get started first require the gem:
|
@@ -58,19 +57,16 @@ To create a coordinate system, you can use CRS codes, well-known text (WKT) stri
|
|
58
57
|
|
59
58
|
Notice when using the old-style Proj4 string, the addition of the "+type=crs" value.
|
60
59
|
|
61
|
-
If you are using Proj 5, then you should create a transformation using epsg strings (see below). If you are using Proj 4,
|
62
|
-
you need to use the deprecated Projection class (see documentation).
|
60
|
+
If you are using Proj 5 or newer, then you should create a transformation using epsg strings (see below). If you are using Proj 4, you need to use the deprecated Projection class (see documentation).
|
63
61
|
|
64
62
|
=== Transformation
|
65
|
-
After you have created two coordinate systems, you can then create a transformation. For example, if you want to
|
66
|
-
convert coordinates from the "3-degree Gauss-Kruger zone 3" coordinate system to WGS84 (one version of lat-long)
|
67
|
-
first create a transformation:
|
63
|
+
After you have created two coordinate systems, you can then create a transformation. For example, if you want to convert coordinates from the "3-degree Gauss-Kruger zone 3" coordinate system to WGS84 (one version of lat-long) first create a transformation:
|
68
64
|
|
69
65
|
crs_gk = Proj::Crs.new('EPSG:31467')
|
70
66
|
crs_wgs84 = Proj::Crs.new('EPSG:4326')
|
71
67
|
transform = Proj::Transformation.new(crs_gk, crs_wgs84)
|
72
68
|
|
73
|
-
Alternatively, or if you are using Proj 5, you can create a transformation without first
|
69
|
+
Alternatively, or if you are using Proj 5 or later, you can create a transformation without first
|
74
70
|
creating Crs instances. Instead, pass the EPSG information directly to the transformation:
|
75
71
|
|
76
72
|
transform = Proj::Transformation.new('EPSG:31467', 'EPSG:4326')
|
@@ -105,8 +101,7 @@ Transformations are a type of Coordinate Operation. PROJ divides coordinate oper
|
|
105
101
|
|
106
102
|
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
103
|
|
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.
|
104
|
+
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 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
105
|
|
111
106
|
Transformations are coordinate operations that do cause a change in reference frames. The Ruby bindings support these via the Transformation class.
|
112
107
|
|
@@ -116,9 +111,7 @@ For more information see https://proj.org/operations/index.html
|
|
116
111
|
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
112
|
|
118
113
|
=== Coordinate
|
119
|
-
Notice the examples above transform Coordinate objects. A Coordinate consists
|
120
|
-
of up to four double values to represent three directions plus time. In general
|
121
|
-
you will need to fill out at least the first two values:
|
114
|
+
Notice the examples above transform Coordinate objects. A Coordinate consists of up to four double values to represent three directions plus time. In general you will need to fill out at least the first two values:
|
122
115
|
|
123
116
|
from = Proj::Coordinate.new(x: 5428192.0, y: 3458305.0, z: -5.1790915237)
|
124
117
|
from = Proj::Coordinate.new(lam: 48.9906726079, phi: 8.4302123334)
|
@@ -138,41 +131,31 @@ If you prefer to work with a uniform axis order, regardless of the axis orders m
|
|
138
131
|
|
139
132
|
The normalized transformation will return output coordinates in longitude, latitude order for geographic CRSes and easting, northing for most projected CRSes.
|
140
133
|
|
141
|
-
For more information see
|
134
|
+
For more information see https://proj.org/faq.html#why-is-the-axis-ordering-in-proj-not-consistent.
|
142
135
|
|
143
136
|
=== Context
|
144
|
-
Contexts are used to support multi-threaded programs. The bindings expose this object via Context.current
|
145
|
-
and store it using thread local storage. Use the context object to access error codes, set proj4
|
146
|
-
compatability settings, set the logging level and to install custom logging code.
|
137
|
+
Contexts are used to support multi-threaded programs. The bindings expose this object via Context.current and store it using thread local storage. Use the context object to access error codes, set proj4 compatability settings, set the logging level and to install custom logging code.
|
147
138
|
|
148
|
-
Both Crs and Transformation objects take a context object in their constructors. If none is passed, they default
|
149
|
-
to using Context.current
|
139
|
+
Both Crs and Transformation objects take a context object in their constructors. If none is passed, they default to using Context.current
|
150
140
|
|
151
141
|
== 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
|
142
|
+
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
143
|
|
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
|
144
|
+
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=.
|
155
145
|
|
156
146
|
== Error handling
|
157
|
-
When an error occurs, a Proj::Error instance will be thrown with the underlying message provided
|
158
|
-
from the Proj library.
|
147
|
+
When an error occurs, a Proj::Error instance will be thrown with the underlying message provided from the Proj library.
|
159
148
|
|
160
149
|
== 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.
|
150
|
+
proj4rb will search in a number of well-known locations for the libproj shared library. You can override this by specifying the full path to the library using the PROJ_LIB_PATH environmental variable.
|
164
151
|
|
165
152
|
== Finding Proj Files (PROJ_DATA)
|
166
|
-
Starting with version 6, Proj stores its information (datums, ellipsoids, prime meridians, coordinate systems,
|
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).
|
153
|
+
Starting with version 6, Proj stores its information (datums, ellipsoids, prime meridians, coordinate systems, units, etc) in a sqlite file called proj.db. If Proj cannot find its database an exception will be raised. In this case, you can set the environmental variable PROJ_DATA to point to the folder that contains the proj.db file. Note PROJ_LIB must be set by whatever launches your Ruby program. The Ruby program itself cannot set this variable and have it work correctly (at least not on windows).
|
171
154
|
|
172
155
|
For more information see https://proj.org/resource_files.html
|
173
156
|
|
174
157
|
== Class Hierarchy
|
175
|
-
The proj4rb class hierarchy is based on Proj's class hiearchy which, in turn, is derived from
|
158
|
+
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. It is:
|
176
159
|
|
177
160
|
PjObject
|
178
161
|
CoordinateOperationMixin
|
@@ -194,8 +177,7 @@ The PjObject class defines several methods to create new objects:
|
|
194
177
|
The methods will return instances of the correct subclass.
|
195
178
|
|
196
179
|
== Tests
|
197
|
-
Proj4rb ships with a full test suite designed to work using Proj 6. If you are using an earlier version of Proj,
|
198
|
-
then expect *many* test failures.
|
180
|
+
Proj4rb ships with a full test suite designed to work using Proj 6. If you are using an earlier version of Proj, then expect *many* test failures.
|
199
181
|
|
200
182
|
== License
|
201
183
|
Proj4rb is released under the MIT license.
|
@@ -204,4 +186,4 @@ Proj4rb is released under the MIT license.
|
|
204
186
|
The proj4rb Ruby bindings were started by Guilhem Vellut with most of the code
|
205
187
|
written by Jochen Topf. Charlie Savage ported the code to Windows and added
|
206
188
|
the Windows build infrastructure. Later, he rewrote the code to support
|
207
|
-
Proj version 5 and
|
189
|
+
Proj version 5, 6, 7, 8 and 9 and ported it to use FFI.
|
data/lib/api/api.rb
CHANGED
@@ -5,6 +5,9 @@ module Proj
|
|
5
5
|
module Api
|
6
6
|
extend FFI::Library
|
7
7
|
|
8
|
+
# List of knows PROJ library versions
|
9
|
+
#
|
10
|
+
# @return [Array<String>]
|
8
11
|
def self.library_versions
|
9
12
|
["25", # 9.2
|
10
13
|
"9_1", # 9.1
|
@@ -18,6 +21,9 @@ module Proj
|
|
18
21
|
"11"] # 4.9
|
19
22
|
end
|
20
23
|
|
24
|
+
# Search paths to use when looking for PROJ library
|
25
|
+
#
|
26
|
+
# @return [Array<String>]
|
21
27
|
def self.search_paths
|
22
28
|
result = case RbConfig::CONFIG['host_os']
|
23
29
|
when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
|
@@ -33,18 +39,27 @@ module Proj
|
|
33
39
|
result
|
34
40
|
end
|
35
41
|
|
42
|
+
# Windows search paths for PROJ library
|
43
|
+
#
|
44
|
+
# @return [Array<String>]
|
36
45
|
def self.windows_search_paths
|
37
46
|
self.library_versions.map do |version|
|
38
47
|
["libproj-#{version}", "libproj_#{version}"]
|
39
48
|
end.flatten
|
40
49
|
end
|
41
50
|
|
51
|
+
# Linux search paths for PROJ library
|
52
|
+
#
|
53
|
+
# @return [Array<String>]
|
42
54
|
def self.linux_search_paths
|
43
55
|
self.library_versions.map do |version|
|
44
56
|
"libproj.so.#{version}"
|
45
57
|
end
|
46
58
|
end
|
47
59
|
|
60
|
+
# MacOS search paths for PROJ library
|
61
|
+
#
|
62
|
+
# @return [Array<String>]
|
48
63
|
def self.macos_search_paths
|
49
64
|
# On MacOS only support HomeBrew since the MacPort is unsupported and ancient (5.2).
|
50
65
|
self.library_versions.map do |version|
|
@@ -52,6 +67,9 @@ module Proj
|
|
52
67
|
end
|
53
68
|
end
|
54
69
|
|
70
|
+
# Load PROJ library
|
71
|
+
#
|
72
|
+
# @return [FFI::DynamicLibrary]
|
55
73
|
def self.load_library
|
56
74
|
if ENV["PROJ_LIB_PATH"]
|
57
75
|
ffi_lib ENV["PROJ_LIB_PATH"]
|
@@ -62,6 +80,9 @@ module Proj
|
|
62
80
|
ffi_libraries.first
|
63
81
|
end
|
64
82
|
|
83
|
+
# Load API files based on PROJ version
|
84
|
+
#
|
85
|
+
# @return [nil]
|
65
86
|
def self.load_api
|
66
87
|
# First load the base 5.0 api so we can determine the Proj Version
|
67
88
|
require_relative './api_5_0'
|
@@ -72,7 +93,7 @@ module Proj
|
|
72
93
|
'6.0.0', '6.1.0', '6.2.0', '6.3.0',
|
73
94
|
'7.0.0', '7.1.0', '7.2.0',
|
74
95
|
'8.0.0', '8.1.0', '8.2.0',
|
75
|
-
'9.1.0', '9.2.0']
|
96
|
+
'9.1.0', '9.2.0', '9.4.0']
|
76
97
|
|
77
98
|
versions.each do |version|
|
78
99
|
api_version = Gem::Version.new(version)
|
data/lib/api/api_5_0.rb
CHANGED
@@ -28,7 +28,6 @@ module Proj
|
|
28
28
|
:PJ, :pointer, # projection entry point
|
29
29
|
:descr, :pointer # description text
|
30
30
|
end
|
31
|
-
PJ_OPERATIONS = PJ_LIST
|
32
31
|
|
33
32
|
class PJ_ELLPS < FFI::Struct
|
34
33
|
layout :id, :string, # ellipse keyword name
|
@@ -197,6 +196,7 @@ module Proj
|
|
197
196
|
:lastupdate, [:string, 16] # Date of last update in YYYY-MM-DD format
|
198
197
|
end
|
199
198
|
|
199
|
+
# @return [Symbol]
|
200
200
|
PJ_LOG_LEVEL = enum(:PJ_LOG_NONE , 0,
|
201
201
|
:PJ_LOG_ERROR, 1,
|
202
202
|
:PJ_LOG_DEBUG, 2,
|
@@ -206,11 +206,13 @@ module Proj
|
|
206
206
|
:PJ_LOG_DEBUG_MINOR, 3) # for proj_api.h compatibility
|
207
207
|
|
208
208
|
# Apply transformation to observation - in forward or inverse direction
|
209
|
+
# @return [Symbol]
|
209
210
|
PJ_DIRECTION = enum(:PJ_FWD, 1, # Forward
|
210
211
|
:PJ_IDENT, 0, # Do nothing
|
211
212
|
:PJ_INV, -1) # Inverse
|
212
213
|
|
213
214
|
# Object category
|
215
|
+
# @return [Symbol]
|
214
216
|
PJ_CATEGORY = enum(:PJ_CATEGORY_ELLIPSOID,
|
215
217
|
:PJ_CATEGORY_PRIME_MERIDIAN,
|
216
218
|
:PJ_CATEGORY_DATUM,
|
@@ -218,6 +220,7 @@ module Proj
|
|
218
220
|
:PJ_CATEGORY_COORDINATE_OPERATION,
|
219
221
|
:PJ_CATEGORY_DATUM_ENSEMBLE)
|
220
222
|
|
223
|
+
# @return [Symbol]
|
221
224
|
PJ_TYPE = enum(:PJ_TYPE_UNKNOWN,
|
222
225
|
:PJ_TYPE_ELLIPSOID,
|
223
226
|
:PJ_TYPE_PRIME_MERIDIAN,
|
@@ -256,9 +259,11 @@ module Proj
|
|
256
259
|
|
257
260
|
:PJ_TYPE_COORDINATE_METADATA)
|
258
261
|
|
262
|
+
# @return [Symbol]
|
259
263
|
PJ_PROJ_STRING_TYPE = enum(:PJ_PROJ_5,
|
260
264
|
:PJ_PROJ_4)
|
261
265
|
|
266
|
+
# @return [Symbol]
|
262
267
|
PJ_COORDINATE_SYSTEM_TYPE = enum(:PJ_CS_TYPE_UNKNOWN,
|
263
268
|
:PJ_CS_TYPE_CARTESIAN,
|
264
269
|
:PJ_CS_TYPE_ELLIPSOIDAL,
|
@@ -270,6 +275,7 @@ module Proj
|
|
270
275
|
:PJ_CS_TYPE_TEMPORALCOUNT,
|
271
276
|
:PJ_CS_TYPE_TEMPORALMEASURE)
|
272
277
|
|
278
|
+
# @return [Symbol]
|
273
279
|
PJ_WKT_TYPE = enum(:PJ_WKT2_2015,
|
274
280
|
:PJ_WKT2_2015_SIMPLIFIED,
|
275
281
|
:PJ_WKT2_2019,
|
data/lib/api/api_6_0.rb
CHANGED
@@ -1,11 +1,13 @@
|
|
1
1
|
module Proj
|
2
2
|
module Api
|
3
3
|
# Comparison criteria
|
4
|
+
# @return [Symbol]
|
4
5
|
PJ_COMPARISON_CRITERION = enum(:PJ_COMP_STRICT, # All properties are identical
|
5
6
|
:PJ_COMP_EQUIVALENT, # The objects are equivalent for the purpose of coordinate operations. They can differ by the name of their objects, identifiers, other metadata. Parameters may be expressed in different units, provided that the value is (with some tolerance) the same once expressed in a common unit.
|
6
7
|
:PJ_COMP_EQUIVALENT_EXCEPT_AXIS_ORDER_GEOGCRS) # Same as EQUIVALENT, relaxed with an exception that the axis order of the base CRS of a DerivedCRS/ProjectedCRS or the axis order of a GeographicCRS is ignored. Only to be used with DerivedCRS/ProjectedCRS/GeographicCRS
|
7
8
|
|
8
9
|
#Guessed WKT "dialect"
|
10
|
+
# @return [Symbol]
|
9
11
|
PJ_GUESSED_WKT_DIALECT = enum(:PJ_GUESSED_WKT2_2019,
|
10
12
|
:PJ_GUESSED_WKT2_2018,
|
11
13
|
:PJ_GUESSED_WKT2_2015,
|
@@ -65,9 +67,9 @@ module Proj
|
|
65
67
|
:type, PJ_TYPE, # Object type
|
66
68
|
:deprecated, :int, # Whether the object is deprecated
|
67
69
|
:bbox_valid, :int, # Whether bbox values in degrees are valid
|
68
|
-
:west_lon_degree, :double,
|
70
|
+
:west_lon_degree, :double, # Western-most longitude of the area of use, in degrees.
|
69
71
|
:south_lat_degree, :double, # Southern-most latitude of the area of use, in degrees.
|
70
|
-
:east_lon_degree, :double,
|
72
|
+
:east_lon_degree, :double, # Eastern-most longitude of the area of use, in degrees.
|
71
73
|
:north_lat_degree, :double, # Northern-most latitude of the area of use, in degrees.
|
72
74
|
:area_name, :string, # Name of the area of use
|
73
75
|
:projection_method_name, :string] # Name of the projection method for a projected CRS. Might be NULL even for projected CRS in some cases.
|
data/lib/api/api_7_0.rb
CHANGED
@@ -4,6 +4,7 @@ module Proj
|
|
4
4
|
typedef :pointer, :PROJ_FILE_HANDLE
|
5
5
|
typedef :pointer, :USER_DATA
|
6
6
|
|
7
|
+
# @return [Symbol]
|
7
8
|
PROJ_OPEN_ACCESS = enum(:PROJ_OPEN_ACCESS_READ_ONLY, # Read-only access. Equivalent to "rb"
|
8
9
|
:PROJ_OPEN_ACCESS_READ_UPDATE, # Read-update access. File should be created if not existing. Equivalent to "r+b
|
9
10
|
:PROJ_OPEN_ACCESS_CREATE) # Create access. File should be truncated to 0-byte if already existing. Equivalent to "w+b"
|
data/lib/api/api_9_4.rb
ADDED
data/lib/api/api_experimental.rb
CHANGED
@@ -1,17 +1,21 @@
|
|
1
1
|
module Proj
|
2
2
|
module Api
|
3
3
|
if Api::PROJ_VERSION >= Gem::Version.new('6.0.0')
|
4
|
+
|
5
|
+
# @return [Symbol]
|
4
6
|
PJ_UNIT_TYPE = enum(:PJ_UT_ANGULAR,
|
5
7
|
:PJ_UT_LINEAR,
|
6
8
|
:PJ_UT_SCALE,
|
7
9
|
:PJ_UT_TIME)
|
8
10
|
|
11
|
+
# @return [Symbol]
|
9
12
|
PJ_CARTESIAN_CS_2D_TYPE = enum(:PJ_CART2D_EASTING_NORTHING,
|
10
13
|
:PJ_CART2D_NORTHING_EASTING,
|
11
14
|
:PJ_CART2D_NORTH_POLE_EASTING_SOUTH_NORTHING_SOUTH,
|
12
15
|
:PJ_CART2D_SOUTH_POLE_EASTING_NORTH_NORTHING_NORTH,
|
13
16
|
:PJ_CART2D_WESTING_SOUTHING)
|
14
17
|
|
18
|
+
# @return [Symbol]
|
15
19
|
PJ_ELLIPSOIDAL_CS_2D_TYPE = enum(:PJ_ELLPS2D_LONGITUDE_LATITUDE,
|
16
20
|
:PJ_ELLPS2D_LATITUDE_LONGITUDE)
|
17
21
|
|
@@ -156,6 +160,7 @@ module Proj
|
|
156
160
|
end
|
157
161
|
|
158
162
|
if Api::PROJ_VERSION >= Gem::Version.new('6.3.0')
|
163
|
+
# @return [Symbol]
|
159
164
|
PJ_ELLIPSOIDAL_CS_3D_TYPE = enum(:PJ_ELLPS3D_LONGITUDE_LATITUDE_HEIGHT,
|
160
165
|
:PJ_ELLPS3D_LATITUDE_LONGITUDE_HEIGHT)
|
161
166
|
|
data/lib/proj/area.rb
CHANGED
data/lib/proj/axis_info.rb
CHANGED
data/lib/proj/context.rb
CHANGED
@@ -23,6 +23,7 @@ module Proj
|
|
23
23
|
Thread.current[:proj_context] ||= Context.new
|
24
24
|
end
|
25
25
|
|
26
|
+
# @!visibility private
|
26
27
|
def self.finalize(pointer)
|
27
28
|
proc do
|
28
29
|
Api.proj_context_destroy(pointer)
|
@@ -177,7 +178,7 @@ module Proj
|
|
177
178
|
#
|
178
179
|
# @see https://proj.org/development/reference/functions.html#c.proj_context_get_user_writable_directory
|
179
180
|
#
|
180
|
-
# @param [Boolean] If
|
181
|
+
# @param create [Boolean] If true create the directory if it does not exist already. Defaults to false.
|
181
182
|
#
|
182
183
|
# @return [String] Directory
|
183
184
|
def user_directory(create = false)
|
@@ -206,7 +207,7 @@ module Proj
|
|
206
207
|
end
|
207
208
|
end
|
208
209
|
|
209
|
-
# Installs a new {FileApi
|
210
|
+
# Installs a new {FileApiImpl FileApi}
|
210
211
|
#
|
211
212
|
# @see https://proj.org/development/reference/functions.html#c.proj_context_set_fileapi
|
212
213
|
def set_file_api(file_api_klass)
|
@@ -219,7 +220,7 @@ module Proj
|
|
219
220
|
@file_api = file_api_klass.new(self)
|
220
221
|
end
|
221
222
|
|
222
|
-
# Installs a new {NetworkApi
|
223
|
+
# Installs a new {NetworkApiImpl NetworkApi}
|
223
224
|
#
|
224
225
|
# @see https://proj.org/development/reference/functions.html#c.proj_context_set_network_callbacks
|
225
226
|
def set_network_api(network_api_klass)
|
data/lib/proj/conversion.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
require 'stringio'
|
3
3
|
|
4
4
|
module Proj
|
5
|
-
# Conversions are {
|
5
|
+
# Conversions are {CoordinateOperationMixin coordinate operations} that convert a source
|
6
6
|
# {Coordinate coordinate} to a new value. In Proj they are defined as operations that
|
7
7
|
# do not exert a change in reference frame while {Transformation transformations } do.
|
8
8
|
class Conversion < PjObject
|
@@ -20,7 +20,6 @@ module Proj
|
|
20
20
|
# @param method_auth_name [String] Method authority name. Default is nil.
|
21
21
|
# @param method_code [String] Method code. Default is nil.
|
22
22
|
# @param params [Array<Parameter>] Parameter descriptions
|
23
|
-
# @param accuracy [Double] Accuracy of the transformation in meters. A negative value means unknown.
|
24
23
|
#
|
25
24
|
# @return [Conversion]
|
26
25
|
def self.create_conversion(context, name:, auth_name:, code:, method_name:, method_auth_name:, method_code:, params:)
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
module Proj
|
4
|
+
# Coordinate metadata is the information required to make coordinates unambiguous. For a
|
5
|
+
# coordinate set referenced to a static CRS it is the CRS definition. For a
|
6
|
+
# coordinate set referenced to a dynamic CRS it is the CRS definition together
|
7
|
+
# with the coordinate epoch of the coordinates in the coordinate set.
|
8
|
+
#
|
9
|
+
# In a dynamic CRS, coordinates of a point on the surface of the Earth may change with time.
|
10
|
+
# To be unambiguous the coordinates must always be qualified with the epoch at which they
|
11
|
+
# are valid. The coordinate epoch is not necessarily the epoch at which the observation
|
12
|
+
# was collected.
|
13
|
+
class CoordinateMetadata < PjObject
|
14
|
+
# Create a CoordinateMetadata object
|
15
|
+
#
|
16
|
+
# @param crs [Crs] The associated Crs
|
17
|
+
# @param context [Context]. An optional Context
|
18
|
+
# @param epoch [Double]. Epoch at wich the CRS is valid
|
19
|
+
#
|
20
|
+
# @return [CoordinateMetadata]
|
21
|
+
def initialize(crs, context=nil, epoch=nil)
|
22
|
+
ptr = Api.proj_coordinate_metadata_create(context || Context.current, crs, epoch)
|
23
|
+
|
24
|
+
if ptr.null?
|
25
|
+
Error.check_object(self)
|
26
|
+
end
|
27
|
+
|
28
|
+
super(ptr, context)
|
29
|
+
end
|
30
|
+
|
31
|
+
# Returns the coordinate epoch
|
32
|
+
#
|
33
|
+
# @return [Double]
|
34
|
+
def epoch
|
35
|
+
Api.proj_coordinate_metadata_get_epoch(self.context, self)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -6,7 +6,7 @@ module Proj
|
|
6
6
|
:unit_conv_factor, :unit_name, :unit_auth_name, :unit_code, :unit_category,
|
7
7
|
keyword_init: true)
|
8
8
|
|
9
|
-
# Coordinate Operations convert {Coordinate
|
9
|
+
# Coordinate Operations convert {Coordinate coordinates} to a new value. In Proj they are
|
10
10
|
# can either by {Conversion conversions} that do not exert a change in reference frame
|
11
11
|
# or {Transformation transformations} which do.
|
12
12
|
module CoordinateOperationMixin
|
@@ -168,8 +168,8 @@ module Proj
|
|
168
168
|
self.transform(coord, :PJ_INV)
|
169
169
|
end
|
170
170
|
|
171
|
-
# Transforms a {Coordinate} in the specified direction. See {
|
172
|
-
# {
|
171
|
+
# Transforms a {Coordinate} in the specified direction. See {CoordinateOperationMixin#forward forward} and
|
172
|
+
# {CoordinateOperationMixin#inverse inverse}
|
173
173
|
#
|
174
174
|
# @see https://proj.org/development/reference/functions.html#c.proj_trans
|
175
175
|
#
|
@@ -212,7 +212,7 @@ module Proj
|
|
212
212
|
# Transforms an array of {Coordinate coordinates}. Individual points that fail to transform
|
213
213
|
# will have their components set to Infinity.
|
214
214
|
#
|
215
|
-
# @param
|
215
|
+
# @param coordinates [Array<Coordinate>] Coordinates to transform
|
216
216
|
# @param direction [PJ_DIRECTION] The direction of the transformation
|
217
217
|
#
|
218
218
|
# @return [Array<Coordinate>] Array of transformed coordinates
|
@@ -245,7 +245,7 @@ module Proj
|
|
245
245
|
# @param iterations [Integer] The number of roundtrip transformations
|
246
246
|
# @param coordinate [Coordinate] The input coordinate
|
247
247
|
#
|
248
|
-
# @return [
|
248
|
+
# @return [Float] The euclidean distance of the starting point coordinate and the last coordinate after n iterations back and forth.
|
249
249
|
def roundtrip(direction, iterations, coordinate)
|
250
250
|
Api.proj_roundtrip(self, direction, iterations, coordinate.pj_coord)
|
251
251
|
end
|
@@ -254,7 +254,7 @@ module Proj
|
|
254
254
|
#
|
255
255
|
# @see https://proj.org/development/reference/functions.html#c.proj_normalize_for_visualization
|
256
256
|
#
|
257
|
-
# @return [
|
257
|
+
# @return [CoordinateOperationMixin] A new CoordinateOperation or nil in case of error
|
258
258
|
def normalize_for_visualization
|
259
259
|
ptr = Api.proj_normalize_for_visualization(self.context, self)
|
260
260
|
self.class.create_object(ptr, self.context)
|
@@ -264,7 +264,7 @@ module Proj
|
|
264
264
|
#
|
265
265
|
# @see }https://proj.org/development/reference/functions.html#c.proj_trans_get_last_used_operation proj_trans_get_last_used_operation
|
266
266
|
#
|
267
|
-
# @return [
|
267
|
+
# @return [CoordinateOperationMixin] The last used operation
|
268
268
|
def last_used_operation
|
269
269
|
ptr = Api.proj_trans_get_last_used_operation(self)
|
270
270
|
self.class.create_object(ptr, self.context)
|
@@ -284,7 +284,7 @@ module Proj
|
|
284
284
|
#
|
285
285
|
# @see https://proj.org/development/reference/functions.html#c.proj_coordoperation_get_accuracy
|
286
286
|
#
|
287
|
-
# @return [
|
287
|
+
# @return [Float] The accuracy, or a negative value if unknown or in case of error.
|
288
288
|
def accuracy
|
289
289
|
Api.proj_coordoperation_get_accuracy(self.context, self)
|
290
290
|
end
|
@@ -348,7 +348,7 @@ module Proj
|
|
348
348
|
#
|
349
349
|
# @param error_if_incompatible [Boolean] If true an exception is thrown if the coordinate operation is not compatible with a WKT1 TOWGS84 representation
|
350
350
|
#
|
351
|
-
# @return [Array<
|
351
|
+
# @return [Array<Float>]] Array of 7 numbers that represent translation, rotation and scale parameters.
|
352
352
|
# Rotation and scale difference terms might be zero if the transformation only includes translation parameters
|
353
353
|
def to_wgs84(error_if_incompatible = false)
|
354
354
|
parameter_count = 7
|
@@ -6,11 +6,11 @@ module Proj
|
|
6
6
|
# Create a CoordinateSystem
|
7
7
|
#
|
8
8
|
# @param context [Context] The context associated with the CoordinateSystem
|
9
|
-
# @param
|
9
|
+
# @param cs_type [PJ_COORDINATE_SYSTEM_TYPE] Coordinate system type
|
10
10
|
# @param axes [Array<PJ_AXIS_DESCRIPTION>] Array of Axes
|
11
11
|
#
|
12
12
|
# @return [CoordinateSystem]
|
13
|
-
def self.create(
|
13
|
+
def self.create(cs_type, axes, context)
|
14
14
|
axes_ptr = FFI::MemoryPointer.new(Api::PJ_AXIS_DESCRIPTION, axes.size)
|
15
15
|
axes.each_with_index do |axis, i|
|
16
16
|
axis_description_target = Api::PJ_AXIS_DESCRIPTION.new(axes_ptr[i])
|
@@ -18,7 +18,7 @@ module Proj
|
|
18
18
|
axis_description_target.to_ptr.__copy_from__(axis_description_source.to_ptr, Api::PJ_AXIS_DESCRIPTION.size)
|
19
19
|
end
|
20
20
|
|
21
|
-
pointer = Api.proj_create_cs(context,
|
21
|
+
pointer = Api.proj_create_cs(context, cs_type, axes.count, axes_ptr)
|
22
22
|
Error.check_context(context)
|
23
23
|
self.create_object(pointer, context)
|
24
24
|
end
|
@@ -26,13 +26,13 @@ module Proj
|
|
26
26
|
# Create an Ellipsoidal 2D CoordinateSystem
|
27
27
|
#
|
28
28
|
# @param context [Context] The context associated with the CoordinateSystem
|
29
|
-
# @param
|
29
|
+
# @param cs_type [PJ_COORDINATE_SYSTEM_TYPE] Coordinate system type
|
30
30
|
# @param unit_name [String] Name of the angular units. Or nil for degree
|
31
|
-
# @param unit_conv_factor [
|
31
|
+
# @param unit_conv_factor [Float] Conversion factor from the angular unit to radian. Set to 0 if unit name is degree
|
32
32
|
#
|
33
33
|
# @return [CoordinateSystem]
|
34
|
-
def self.create_ellipsoidal_2d(
|
35
|
-
pointer = Api.proj_create_ellipsoidal_2D_cs(context,
|
34
|
+
def self.create_ellipsoidal_2d(cs_type, context, unit_name: nil, unit_conv_factor: 0)
|
35
|
+
pointer = Api.proj_create_ellipsoidal_2D_cs(context, cs_type, unit_name, unit_conv_factor)
|
36
36
|
Error.check_context(context)
|
37
37
|
self.create_object(pointer, context)
|
38
38
|
end
|
@@ -40,15 +40,15 @@ module Proj
|
|
40
40
|
# Create an Ellipsoidal 3D CoordinateSystem
|
41
41
|
#
|
42
42
|
# @param context [Context] The context associated with the CoordinateSystem
|
43
|
-
# @param
|
43
|
+
# @param cs_type [PJ_COORDINATE_SYSTEM_TYPE] Coordinate system type
|
44
44
|
# @param horizontal_angular_unit_name [String] Name of the angular units. Or nil for degree
|
45
|
-
# @param horizontal_angular_unit_conv_factor [
|
46
|
-
# @param vertical_linear_unit_name [String] Name of the
|
47
|
-
# @param vertical_linear_unit_conv_factor [
|
45
|
+
# @param horizontal_angular_unit_conv_factor [Float] Conversion factor from the angular unit to radian. Set to 0 if horizontal_angular_unit_name name is degree
|
46
|
+
# @param vertical_linear_unit_name [String] Name of the linear units. Or nil for meters.
|
47
|
+
# # @param vertical_linear_unit_conv_factor [Float] Conversion factor from the linear unit to meter. Set to 0 if vertical_linear_unit_name is meter.
|
48
48
|
#
|
49
49
|
# @return [CoordinateSystem]
|
50
|
-
def self.create_ellipsoidal_3d(
|
51
|
-
pointer = Api.proj_create_ellipsoidal_3D_cs(context,
|
50
|
+
def self.create_ellipsoidal_3d(cs_type, context, horizontal_angular_unit_name: nil, horizontal_angular_unit_conv_factor: 0, vertical_linear_unit_name: nil, vertical_linear_unit_conv_factor: 0)
|
51
|
+
pointer = Api.proj_create_ellipsoidal_3D_cs(context, cs_type, horizontal_angular_unit_name, horizontal_angular_unit_conv_factor, vertical_linear_unit_name, vertical_linear_unit_conv_factor)
|
52
52
|
Error.check_context(context)
|
53
53
|
self.create_object(pointer, context)
|
54
54
|
end
|
@@ -56,13 +56,13 @@ module Proj
|
|
56
56
|
# Create a CartesiansCS 2D coordinate system
|
57
57
|
#
|
58
58
|
# @param context [Context] The context associated with the CoordinateSystem
|
59
|
-
# @param
|
59
|
+
# @param cs_type [PJ_COORDINATE_SYSTEM_TYPE] Coordinate system type
|
60
60
|
# @param unit_name [String] Name of the unit. Default is nil.
|
61
|
-
# @param unit_conv_factor [
|
61
|
+
# @param unit_conv_factor [Float] Unit conversion factor to SI. Default is 0.
|
62
62
|
#
|
63
63
|
# @return [CoordinateSystem]
|
64
|
-
def self.create_cartesian_2d(context,
|
65
|
-
pointer = Api.proj_create_cartesian_2D_cs(context,
|
64
|
+
def self.create_cartesian_2d(context, cs_type, unit_name: nil, unit_conv_factor: 0)
|
65
|
+
pointer = Api.proj_create_cartesian_2D_cs(context, cs_type, unit_name, unit_conv_factor)
|
66
66
|
Error.check_context(context)
|
67
67
|
self.create_object(pointer, context)
|
68
68
|
end
|
@@ -72,7 +72,7 @@ module Proj
|
|
72
72
|
# @see https://proj.org/development/reference/functions.html#c.proj_cs_get_type
|
73
73
|
#
|
74
74
|
# @return [PJ_COORDINATE_SYSTEM_TYPE]
|
75
|
-
def
|
75
|
+
def cs_type
|
76
76
|
result = Api.proj_cs_get_type(self.context, self)
|
77
77
|
if result == :PJ_CS_TYPE_UNKNOWN
|
78
78
|
Error.check_object(self)
|