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
data/lib/proj/crs.rb
CHANGED
@@ -6,13 +6,13 @@ module Proj
|
|
6
6
|
class Crs < PjObject
|
7
7
|
# Create a ProjectedCRS.
|
8
8
|
#
|
9
|
-
# @param
|
9
|
+
# @param context [Context] Context
|
10
10
|
# @param name [String] Name of the GeographicCRS. Default is nil.
|
11
|
-
# @param geodetic_crs [
|
11
|
+
# @param geodetic_crs [Crs] Base GeodeticCRS
|
12
12
|
# @param conversion [Conversion] Conversion
|
13
13
|
# @param coordinate_system [CoordinateSystem] Cartesian coordinate system
|
14
14
|
#
|
15
|
-
# @return [
|
15
|
+
# @return [Crs]
|
16
16
|
def self.create_projected(context, name: nil, geodetic_crs:, conversion:, coordinate_system:)
|
17
17
|
pointer = Api.proj_create_projected_crs(context, name, geodetic_crs, conversion, coordinate_system)
|
18
18
|
|
@@ -25,12 +25,12 @@ module Proj
|
|
25
25
|
|
26
26
|
# Returns a BoundCRS
|
27
27
|
#
|
28
|
-
# @param
|
29
|
-
# @param base_crs [
|
30
|
-
# @param hub_crs [
|
28
|
+
# @param context [Context] Context
|
29
|
+
# @param base_crs [Crs] Base CRS
|
30
|
+
# @param hub_crs [Crs] HUB CRS
|
31
31
|
# @param transformation [Transformation]
|
32
32
|
#
|
33
|
-
# @return [
|
33
|
+
# @return [Crs]
|
34
34
|
def self.create_bound(context, base_crs:, hub_crs:, transformation:)
|
35
35
|
pointer = Api.proj_crs_create_bound_crs(context, base_crs, hub_crs, transformation)
|
36
36
|
|
@@ -43,8 +43,8 @@ module Proj
|
|
43
43
|
|
44
44
|
# Returns a BoundCRS with a transformation to EPSG:4326 wrapping it
|
45
45
|
#
|
46
|
-
# @param
|
47
|
-
# @param crs [
|
46
|
+
# @param context [Context] Context
|
47
|
+
# @param crs [Crs] CRS to wrap
|
48
48
|
# @param allow_intermediate_crs [String] Specifies if an intermediate CRS may be considered when
|
49
49
|
# computing the possible transformations. Allowed values are:
|
50
50
|
# * ALWAYS
|
@@ -53,7 +53,7 @@ module Proj
|
|
53
53
|
#
|
54
54
|
# Default is NEVER
|
55
55
|
#
|
56
|
-
# @return [
|
56
|
+
# @return [Crs]
|
57
57
|
def self.create_bound_to_wgs84(context, crs:, allow_intermediate_crs: "NEVER")
|
58
58
|
options = {"ALLOW_INTERMEDIATE_CRS": allow_intermediate_crs}
|
59
59
|
options_ptr = create_options_pointer(options)
|
@@ -69,10 +69,10 @@ module Proj
|
|
69
69
|
|
70
70
|
# Create a a EngineeringCRS
|
71
71
|
#
|
72
|
-
# @param
|
72
|
+
# @param context [Context] Context
|
73
73
|
# @param name [String] Name of the CRS. Default is nil.
|
74
74
|
#
|
75
|
-
# @return [
|
75
|
+
# @return [Crs]
|
76
76
|
def self.create_engineering(context, name:)
|
77
77
|
pointer = Api.proj_create_engineering_crs(context, name)
|
78
78
|
|
@@ -85,13 +85,13 @@ module Proj
|
|
85
85
|
|
86
86
|
# Create a VerticalCRS. For additional functionality see Crs#create_vertical_ex
|
87
87
|
#
|
88
|
-
# @param
|
88
|
+
# @param context [Context] Context
|
89
89
|
# @param name [String] Name of the GeographicCRS. Default is nil.
|
90
90
|
# @param datum_name [String] Name of the GeodeticReferenceFrame. Default is nil.
|
91
91
|
# @param linear_units [String] Name of the angular units. Or nil for meters.
|
92
|
-
# @param linear_units_conv [
|
92
|
+
# @param linear_units_conv [Float] Conversion factor from linear units to meters. Default is 0 if linear_units is nil
|
93
93
|
#
|
94
|
-
# @return [
|
94
|
+
# @return [Crs]
|
95
95
|
def self.create_vertical(context, name:, datum_name:, linear_units:, linear_units_conv:)
|
96
96
|
pointer = Api.proj_create_vertical_crs(context, name, datum_name, linear_units, linear_units_conv)
|
97
97
|
|
@@ -105,12 +105,12 @@ module Proj
|
|
105
105
|
# Create a Bound Vertical CRS, with a transformation to a hub geographic 3D crs, such as
|
106
106
|
# EPSG:4979 or WGS84, using a grid
|
107
107
|
#
|
108
|
-
# @param
|
109
|
-
# @param vertical_crs [
|
110
|
-
# @param
|
108
|
+
# @param context [Context] Context
|
109
|
+
# @param vertical_crs [Crs] A VerticalCRS
|
110
|
+
# @param hub_crs [Crs] A Geographic 3D CRS
|
111
111
|
# @param grid_name [String] Grid name (typically a .gtx file)
|
112
112
|
#
|
113
|
-
# @return [
|
113
|
+
# @return [Crs]
|
114
114
|
def self.create_bound_vertical(context, vertical_crs:, hub_crs:, grid_name:)
|
115
115
|
pointer = Api.proj_crs_create_bound_vertical_crs(context, vertical_crs, hub_crs, grid_name)
|
116
116
|
|
@@ -124,20 +124,20 @@ module Proj
|
|
124
124
|
# Create a VerticalCRS. This is an extended version of Crs#create_vertical that adds
|
125
125
|
# the capability of defining a geoid model.
|
126
126
|
#
|
127
|
-
# @param
|
127
|
+
# @param context [Context] Context
|
128
128
|
# @param name [String] Name of the GeographicCRS. Default is nil.
|
129
129
|
# @param datum_name [String] Name of the GeodeticReferenceFrame. Default is nil.
|
130
130
|
# @param datum_auth_name [String] Authority name of the VerticalReferenceFrame. Default is nil.
|
131
131
|
# @param datum_code [String] Code of the VerticalReferenceFrame. Default is nil.
|
132
132
|
# @param linear_units [String] Name of the angular units. Or nil for meters.
|
133
|
-
# @param linear_units_conv [
|
133
|
+
# @param linear_units_conv [Float] Conversion factor from linear units to meters. Default is 0 if linear_units is nil
|
134
134
|
# @param geoid_model_name [String] Geoid model name. Can be a name from the geoid_model name or a string "PROJ foo.gtx". Default is nil.
|
135
135
|
# @param geoid_model_auth_name [String] Authority name of the transformation for the geoid model. Default is nil.
|
136
136
|
# @param geoid_model_code [String] Code of the transformation for the geoid model. Default is nil.
|
137
137
|
# @param geoid_geog_crs [Crs] Geographic CRS for the geoid transformation. Default is nil.
|
138
|
-
# @param accuracy [
|
138
|
+
# @param accuracy [Float] Accuracy in meters. Default is nil
|
139
139
|
#
|
140
|
-
# @return [
|
140
|
+
# @return [Crs]
|
141
141
|
def self.create_vertical_ex(context, name: nil, datum_name: nil, datum_auth_name: nil, datum_code: nil,
|
142
142
|
linear_units: nil, linear_units_conv: 0,
|
143
143
|
geoid_model_name: nil, geoid_model_auth_name: nil, geoid_model_code: nil,
|
@@ -157,12 +157,12 @@ module Proj
|
|
157
157
|
|
158
158
|
# Create a CompoundCRS.
|
159
159
|
#
|
160
|
-
# @param
|
160
|
+
# @param context [Context] Context
|
161
161
|
# @param name [String] Name of the GeographicCRS. Default is nil.
|
162
|
-
# @param horizontal_crs [
|
163
|
-
# @param vertical_crs [
|
162
|
+
# @param horizontal_crs [Crs] A horizontal CRS
|
163
|
+
# @param vertical_crs [Crs] A vertical CRS
|
164
164
|
#
|
165
|
-
# @return [
|
165
|
+
# @return [Crs]
|
166
166
|
def self.create_compound(context, name:, horizontal_crs:, vertical_crs:)
|
167
167
|
pointer = Api.proj_create_compound_crs(context, name, horizontal_crs, vertical_crs)
|
168
168
|
|
@@ -175,21 +175,21 @@ module Proj
|
|
175
175
|
|
176
176
|
# Create a GeographicCRS.
|
177
177
|
#
|
178
|
-
# @param
|
178
|
+
# @param context [Context] Context
|
179
179
|
# @param name [String] Name of the GeographicCRS. Default is nil.
|
180
180
|
# @param datum_name [String] Name of the GeodeticReferenceFrame. Default is nil.
|
181
181
|
# @param ellipsoid_name [String] Name of the Ellipsoid. Default is nil.
|
182
|
-
# @param semi_major_meter [
|
183
|
-
# @param inv_flattening [
|
182
|
+
# @param semi_major_meter [Float] Ellipsoid semi-major axis, in meters.
|
183
|
+
# @param inv_flattening [Float] Ellipsoid inverse flattening. Or 0 for a sphere.
|
184
184
|
# @param prime_meridian_name [String] Name of the PrimeMeridian. Default is nil.
|
185
|
-
# @param prime_meridian_offset [
|
185
|
+
# @param prime_meridian_offset [Float] Offset of the prime meridian, expressed in the specified angular units.
|
186
186
|
# @param pm_angular_units [String] Name of the angular units. Or nil for degrees.
|
187
|
-
# @param pm_angular_units_conv [
|
187
|
+
# @param pm_angular_units_conv [Float] Conversion factor from the angular unit to radians. Default is 0 if pm_angular_units is nil
|
188
188
|
# @param coordinate_system [CoordinateSystem] Ellipsoidal coordinate system
|
189
189
|
#
|
190
|
-
# @return [
|
191
|
-
def self.create_geographic(context, name:, datum_name:,
|
192
|
-
pointer = Api.proj_create_geographic_crs(context, name, datum_name,
|
190
|
+
# @return [Crs]
|
191
|
+
def self.create_geographic(context, name:, datum_name:, ellipsoid_name:, semi_major_meter:, inv_flattening:, prime_meridian_name:, prime_meridian_offset:, pm_angular_units:, pm_angular_units_conv:, coordinate_system:)
|
192
|
+
pointer = Api.proj_create_geographic_crs(context, name, datum_name, ellipsoid_name, semi_major_meter, inv_flattening, prime_meridian_name, prime_meridian_offset, pm_angular_units, pm_angular_units_conv, coordinate_system)
|
193
193
|
|
194
194
|
if pointer.null?
|
195
195
|
Error.check_context(context)
|
@@ -200,12 +200,12 @@ module Proj
|
|
200
200
|
|
201
201
|
# Create a GeographicCRS from a datum
|
202
202
|
#
|
203
|
-
# @param
|
203
|
+
# @param context [Context] Context
|
204
204
|
# @param name [String] Name of the GeographicCRS. Default is nil.
|
205
|
-
# @param datum [Datum
|
205
|
+
# @param datum [Datum, DatumEnsemble] Datum or DatumEnsemble
|
206
206
|
# @param coordinate_system [CoordinateSystem] Ellipsoidal coordinate system
|
207
207
|
#
|
208
|
-
# @return [
|
208
|
+
# @return [Crs]
|
209
209
|
def self.create_geographic_from_datum(context, name:, datum:, coordinate_system:)
|
210
210
|
pointer = Api.proj_create_geographic_crs_from_datum(context, name, datum, coordinate_system)
|
211
211
|
|
@@ -218,22 +218,22 @@ module Proj
|
|
218
218
|
|
219
219
|
# Create a GeographicCRS.
|
220
220
|
#
|
221
|
-
# @param
|
221
|
+
# @param context [Context] Context
|
222
222
|
# @param name [String] Name of the GeographicCRS. Default is nil.
|
223
223
|
# @param datum_name [String] Name of the GeodeticReferenceFrame. Default is nil.
|
224
224
|
# @param ellipsoid_name [String] Name of the Ellipsoid. Default is nil.
|
225
|
-
# @param semi_major_meter [
|
226
|
-
# @param inv_flattening [
|
225
|
+
# @param semi_major_meter [Float] Ellipsoid semi-major axis, in meters.
|
226
|
+
# @param inv_flattening [Float] Ellipsoid inverse flattening. Or 0 for a sphere.
|
227
227
|
# @param prime_meridian_name [String] Name of the PrimeMeridian. Default is nil.
|
228
|
-
# @param prime_meridian_offset [
|
228
|
+
# @param prime_meridian_offset [Float] Offset of the prime meridian, expressed in the specified angular units.
|
229
229
|
# @param angular_units [String] Name of the angular units. Or nil for degrees.
|
230
|
-
# @param angular_units_conv [
|
230
|
+
# @param angular_units_conv [Float] Conversion factor from the angular unit to radians. Default is 0 if angular_units is nil
|
231
231
|
# @param linear_units [String] Name of the angular units. Or nil for meters.
|
232
|
-
# @param linear_units_conv [
|
232
|
+
# @param linear_units_conv [Float] Conversion factor from linear units to meters. Default is 0 if linear_units is nil
|
233
233
|
#
|
234
|
-
# @return [
|
235
|
-
def self.create_geocentric(context, name:, datum_name:,
|
236
|
-
pointer = Api.proj_create_geocentric_crs(context, name, datum_name,
|
234
|
+
# @return [Crs]
|
235
|
+
def self.create_geocentric(context, name:, datum_name:, ellipsoid_name:, semi_major_meter:, inv_flattening:, prime_meridian_name:, prime_meridian_offset:, angular_units:, angular_units_conv:, linear_units:, linear_units_conv:)
|
236
|
+
pointer = Api.proj_create_geocentric_crs(context, name, datum_name, ellipsoid_name, semi_major_meter, inv_flattening, prime_meridian_name, prime_meridian_offset, angular_units, angular_units_conv, linear_units, linear_units_conv)
|
237
237
|
|
238
238
|
if pointer.null?
|
239
239
|
Error.check_context(context)
|
@@ -244,13 +244,13 @@ module Proj
|
|
244
244
|
|
245
245
|
# Create a GeodeticCRS of geocentric type
|
246
246
|
#
|
247
|
-
# @param
|
247
|
+
# @param context [Context] Context
|
248
248
|
# @param name [String] Name of the GeographicCRS. Default is nil.
|
249
|
-
# @param datum [Datum
|
249
|
+
# @param datum [Datum, DatumEnsemble] Datum or DatumEnsemble
|
250
250
|
# @param linear_units [String] Name of the angular units. Or nil for meters.
|
251
|
-
# @param linear_units_conv [
|
251
|
+
# @param linear_units_conv [Float] Conversion factor from linear units to meters. Default is 0 if linear_units is nil
|
252
252
|
#
|
253
|
-
# @return [
|
253
|
+
# @return [Crs]
|
254
254
|
def self.create_geocentric_from_datum(context, name:, datum:, linear_units:, linear_units_conv:)
|
255
255
|
pointer = Api.proj_create_geocentric_crs_from_datum(context, name, datum, linear_units, linear_units_conv)
|
256
256
|
|
@@ -263,13 +263,13 @@ module Proj
|
|
263
263
|
|
264
264
|
# Create a DerivedGeograhicCRS
|
265
265
|
#
|
266
|
-
# @param
|
266
|
+
# @param context [Context] Context
|
267
267
|
# @param name [String] Name of the GeographicCRS. Default is nil.
|
268
|
-
# @param base_geographic_crs [
|
268
|
+
# @param base_geographic_crs [Crs] Base Geographic CRS
|
269
269
|
# @param conversion [Conversion] Conversion from the base Geographic to the DerivedGeograhicCRS
|
270
270
|
# @param coordinate_system [CoordinateSystem] Ellipsoidal coordinate system
|
271
271
|
#
|
272
|
-
# @return [
|
272
|
+
# @return [Crs]
|
273
273
|
def self.create_derived_geographic(context, name: nil, base_geographic_crs:, conversion:, coordinate_system:)
|
274
274
|
pointer = Api.proj_create_derived_geographic_crs(context, name, base_geographic_crs, conversion, coordinate_system)
|
275
275
|
|
@@ -282,8 +282,8 @@ module Proj
|
|
282
282
|
|
283
283
|
# Find GeodeticCRSes that use the specified datum
|
284
284
|
#
|
285
|
-
# @param
|
286
|
-
# @param auth_name [
|
285
|
+
# @param context [Context] Context
|
286
|
+
# @param auth_name [String] - Authority name. Default is nil.
|
287
287
|
# @param datum_auth_name [String] Datum authority name
|
288
288
|
# @param datum_code [String] Datum code
|
289
289
|
# @param crs_type [String] The CRS type. Default is nil. Allowed values are:
|
@@ -358,7 +358,7 @@ module Proj
|
|
358
358
|
#
|
359
359
|
# @see https://proj.org/development/reference/functions.html#c.proj_crs_get_geodetic_crs
|
360
360
|
#
|
361
|
-
# @return [
|
361
|
+
# @return [Crs]
|
362
362
|
def geodetic_crs
|
363
363
|
pointer = Api.proj_crs_get_geodetic_crs(self.context, self)
|
364
364
|
self.class.create_object(pointer, self.context)
|
@@ -370,7 +370,7 @@ module Proj
|
|
370
370
|
#
|
371
371
|
# @param index [Integer] Index of the CRS component (typically 0 = horizontal, 1 = vertical)
|
372
372
|
#
|
373
|
-
# @return [
|
373
|
+
# @return [Crs]
|
374
374
|
def sub_crs(index)
|
375
375
|
pointer = Api.proj_crs_get_sub_crs(self.context, self, index)
|
376
376
|
self.class.create_object(pointer, self.context)
|
@@ -407,7 +407,7 @@ module Proj
|
|
407
407
|
#
|
408
408
|
# @see https://proj.org/development/reference/functions.html#c.proj_crs_get_horizontal_datum
|
409
409
|
#
|
410
|
-
# @return [
|
410
|
+
# @return [Crs]
|
411
411
|
def horizontal_datum
|
412
412
|
pointer = Api.proj_crs_get_horizontal_datum(self.context, self)
|
413
413
|
self.class.create_object(pointer, self.context)
|
@@ -461,6 +461,14 @@ module Proj
|
|
461
461
|
self.class.create_object(ptr, self.context)
|
462
462
|
end
|
463
463
|
|
464
|
+
# Returns whether a CRS has an associated PointMotionOperation
|
465
|
+
#
|
466
|
+
# @return [Boolean]
|
467
|
+
def point_motion_operation?
|
468
|
+
result = Api.proj_crs_get_coordoperation(self.context, self)
|
469
|
+
result == 1 ? true : false
|
470
|
+
end
|
471
|
+
|
464
472
|
# Returns the prime meridian
|
465
473
|
#
|
466
474
|
# @see https://proj.org/development/reference/functions.html#c.proj_get_prime_meridian
|
@@ -473,7 +481,7 @@ module Proj
|
|
473
481
|
|
474
482
|
# Returns a list of matching reference CRS, and the percentage (0-100) of confidence in the match.
|
475
483
|
#
|
476
|
-
# @param auth_name [
|
484
|
+
# @param auth_name [String] - Authority name, or nil for all authorities
|
477
485
|
#
|
478
486
|
# @return [Array] - Array of CRS objects sorted by decreasing confidence.
|
479
487
|
def identify(auth_name)
|
@@ -501,7 +509,7 @@ module Proj
|
|
501
509
|
#
|
502
510
|
# @param name [String] The new name of the CRS
|
503
511
|
#
|
504
|
-
# @return [
|
512
|
+
# @return [Crs]
|
505
513
|
def alter_name(name)
|
506
514
|
ptr = Api.proj_alter_name(self.context, self, name)
|
507
515
|
|
@@ -514,10 +522,10 @@ module Proj
|
|
514
522
|
|
515
523
|
# Return a copy of the CRS with its identifier changed
|
516
524
|
#
|
517
|
-
# @param
|
525
|
+
# @param auth_name [String] The new authority name of the CRS
|
518
526
|
# @param code [String] The new code of the CRS
|
519
527
|
#
|
520
|
-
# @return [
|
528
|
+
# @return [Crs]
|
521
529
|
def alter_id(auth_name, code)
|
522
530
|
ptr = Api.proj_alter_id(self.context, self, auth_name, code)
|
523
531
|
|
@@ -535,9 +543,9 @@ module Proj
|
|
535
543
|
# CRS with new_geod_crs.
|
536
544
|
# * In other cases, it returns a clone of obj.
|
537
545
|
#
|
538
|
-
# @param new_geod_crs [
|
546
|
+
# @param new_geod_crs [Crs] A GeodeticCRS
|
539
547
|
#
|
540
|
-
# @return [
|
548
|
+
# @return [Crs]
|
541
549
|
def alter_geodetic_crs(new_geod_crs)
|
542
550
|
ptr = Api.proj_crs_alter_geodetic_crs(self.context, self, new_geod_crs)
|
543
551
|
|
@@ -551,11 +559,11 @@ module Proj
|
|
551
559
|
# Return a copy of the CRS with its angular units changed
|
552
560
|
#
|
553
561
|
# @param angular_units [String] Name of the angular units. Or nil for degrees.
|
554
|
-
# @param angular_units_conv [
|
562
|
+
# @param angular_units_conv [Float] Conversion factor from the angular unit to radians. Default is 0 if angular_units is nil
|
555
563
|
# @param unit_auth_name [String] Unit authority name. Defaults to nil.
|
556
564
|
# @param unit_code [String] Unit code. Defaults to nil.
|
557
565
|
#
|
558
|
-
# @return [
|
566
|
+
# @return [Crs]
|
559
567
|
def alter_cs_angular_unit(angular_units: nil, angular_units_conv: 0, unit_auth_name: nil, unit_code: nil)
|
560
568
|
ptr = Api.proj_crs_alter_cs_angular_unit(self.context, self, angular_units, angular_units_conv, unit_auth_name, unit_code)
|
561
569
|
|
@@ -570,11 +578,11 @@ module Proj
|
|
570
578
|
# must be or contain a ProjectedCRS, VerticalCRS or a GeocentricCRS.
|
571
579
|
#
|
572
580
|
# @param linear_units [String] Name of the linear units. Or nil for meters.
|
573
|
-
# @param linear_units_conv [
|
581
|
+
# @param linear_units_conv [Float] Conversion factor from the linear unit to meters. Default is 0 if linear_units is nil
|
574
582
|
# @param unit_auth_name [String] Unit authority name. Defaults to nil.
|
575
583
|
# @param unit_code [String] Unit code. Defaults to nil.
|
576
584
|
#
|
577
|
-
# @return [
|
585
|
+
# @return [Crs]
|
578
586
|
def alter_cs_linear_unit(linear_units: nil, linear_units_conv: 0, unit_auth_name: nil, unit_code: nil)
|
579
587
|
ptr = Api.proj_crs_alter_cs_linear_unit(self.context, self, linear_units, linear_units_conv, unit_auth_name, unit_code)
|
580
588
|
|
@@ -589,7 +597,7 @@ module Proj
|
|
589
597
|
# must be or contain a ProjectedCRS, VerticalCRS or a GeocentricCRS.
|
590
598
|
#
|
591
599
|
# @param linear_units [String] Name of the linear units. Or nil for meters.
|
592
|
-
# @param linear_units_conv [
|
600
|
+
# @param linear_units_conv [Float] Conversion factor from the linear unit to meters. Default is 0 if linear_units is nil
|
593
601
|
# @param unit_auth_name [String] Unit authority name. Defaults to nil.
|
594
602
|
# @param unit_code [String] Unit code. Defaults to nil.
|
595
603
|
# @param convert_to_new_unit [Boolean] If true then existing values will be converted from
|
@@ -597,7 +605,7 @@ module Proj
|
|
597
605
|
# and the unit overridden (so the resulting CRS will not be equivalent to the
|
598
606
|
# original one for reprojection purposes).
|
599
607
|
#
|
600
|
-
# @return [
|
608
|
+
# @return [Crs]
|
601
609
|
def alter_parameters_linear_unit(linear_units: nil, linear_units_conv: 0, unit_auth_name: nil, unit_code: nil, convert_to_new_unit:)
|
602
610
|
ptr = Api.proj_crs_alter_parameters_linear_unit(self.context, self, linear_units, linear_units_conv,
|
603
611
|
unit_auth_name, unit_code,
|
@@ -615,7 +623,7 @@ module Proj
|
|
615
623
|
#
|
616
624
|
# @param name [String] CRS name. If nil then the name of this CRS will be used.
|
617
625
|
#
|
618
|
-
# @return [
|
626
|
+
# @return [Crs]
|
619
627
|
def promote_to_3d(name: nil)
|
620
628
|
ptr = Api.proj_crs_promote_to_3D(self.context, name, self)
|
621
629
|
|
@@ -630,7 +638,7 @@ module Proj
|
|
630
638
|
#
|
631
639
|
# @param name [String] CRS name. If nil then the name of this CRS will be used.
|
632
640
|
#
|
633
|
-
# @return [
|
641
|
+
# @return [Crs]
|
634
642
|
def demote_to_2d(name: nil)
|
635
643
|
ptr = Api.proj_crs_demote_to_2D(self.context, name, self)
|
636
644
|
|
@@ -656,9 +664,9 @@ module Proj
|
|
656
664
|
# This is equivalent to using Crs#promote_to_3d
|
657
665
|
#
|
658
666
|
# @param name [String] CRS name. If nil then the name of this CRS will be used.
|
659
|
-
# @param
|
667
|
+
# @param geog_3d_crs [Crs] Base geographic 3D CRS for the new CRS. Defaults to nil.
|
660
668
|
#
|
661
|
-
# @return [
|
669
|
+
# @return [Crs]
|
662
670
|
def projected_3d(name: nil, geog_3d_crs: nil)
|
663
671
|
ptr = Api.proj_crs_create_projected_3D_crs_from_2D(self.context, name, self, geog_3d_crs)
|
664
672
|
|
data/lib/proj/crs_info.rb
CHANGED
@@ -1,23 +1,23 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
module Proj
|
3
3
|
class CrsInfo
|
4
|
-
attr_reader :auth_name, :code, :name, :
|
4
|
+
attr_reader :auth_name, :code, :name, :crs_type, :deprecated, :bbox_valid,
|
5
5
|
:west_lon_degree, :south_lat_degree, :east_lon_degree, :north_lat_degree,
|
6
6
|
:area_name, :projection_method_name, :celestial_body_name
|
7
7
|
|
8
8
|
def self.from_proj_crs_info(proj_crs_info)
|
9
|
-
data = {auth_name: proj_crs_info[:auth_name],
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
9
|
+
data = { auth_name: proj_crs_info[:auth_name],
|
10
|
+
code: proj_crs_info[:code],
|
11
|
+
name: proj_crs_info[:name],
|
12
|
+
crs_type: proj_crs_info[:type],
|
13
|
+
deprecated: proj_crs_info[:deprecated] == 1 ? true : false,
|
14
|
+
bbox_valid: proj_crs_info[:bbox_valid] == 1 ? true : false,
|
15
|
+
west_lon_degree: proj_crs_info[:west_lon_degree],
|
16
|
+
south_lat_degree: proj_crs_info[:south_lat_degree],
|
17
|
+
east_lon_degree: proj_crs_info[:east_lon_degree],
|
18
|
+
north_lat_degree: proj_crs_info[:north_lat_degree],
|
19
|
+
area_name: proj_crs_info[:area_name],
|
20
|
+
projection_method_name: proj_crs_info[:projection_method_name]}
|
21
21
|
|
22
22
|
if Api::PROJ_VERSION >= Gem::Version.new('8.1.0')
|
23
23
|
data[:celestial_body_name] = proj_crs_info[:celestial_body_name]
|
@@ -26,13 +26,13 @@ module Proj
|
|
26
26
|
new(**data)
|
27
27
|
end
|
28
28
|
|
29
|
-
def initialize(auth_name:, code:, name:,
|
29
|
+
def initialize(auth_name:, code:, name:, crs_type:, deprecated:, bbox_valid:,
|
30
30
|
west_lon_degree:, south_lat_degree:, east_lon_degree:, north_lat_degree:,
|
31
31
|
area_name:, projection_method_name:, celestial_body_name: nil)
|
32
32
|
@auth_name = auth_name
|
33
33
|
@code = code
|
34
34
|
@name = name
|
35
|
-
@
|
35
|
+
@crs_type = crs_type
|
36
36
|
@deprecated = deprecated
|
37
37
|
@bbox_valid = bbox_valid
|
38
38
|
@west_lon_degree = west_lon_degree
|
data/lib/proj/database.rb
CHANGED
@@ -84,12 +84,12 @@ module Proj
|
|
84
84
|
# @see https://proj.org/development/reference/functions.html#c.proj_get_codes_from_database
|
85
85
|
#
|
86
86
|
# @param auth_name [String] Authority name. Must not be nil.
|
87
|
-
# @param
|
87
|
+
# @param pj_type [PJ_TYPE] Proj Object type.
|
88
88
|
# @param allow_deprecated [Boolean] Specifies if deprecated objects should be returned. Default is false.
|
89
89
|
#
|
90
90
|
# @return [Strings] Returned authority codes
|
91
|
-
def codes(auth_name,
|
92
|
-
ptr = Api.proj_get_codes_from_database(self.context, auth_name,
|
91
|
+
def codes(auth_name, pj_type, allow_deprecated = false)
|
92
|
+
ptr = Api.proj_get_codes_from_database(self.context, auth_name, pj_type, allow_deprecated ? 1 : 0)
|
93
93
|
Strings.new(ptr)
|
94
94
|
end
|
95
95
|
|
data/lib/proj/datum.rb
CHANGED
@@ -4,7 +4,7 @@ module Proj
|
|
4
4
|
#
|
5
5
|
# @see https://proj.org/development/reference/functions.html#c.proj_dynamic_datum_get_frame_reference_epoch
|
6
6
|
#
|
7
|
-
# @return [
|
7
|
+
# @return [Float] The frame reference epoch as decimal year, or -1 in case of error.
|
8
8
|
def frame_reference_epoch
|
9
9
|
Api.proj_dynamic_datum_get_frame_reference_epoch(self.context, self)
|
10
10
|
end
|
data/lib/proj/ellipsoid.rb
CHANGED
@@ -43,7 +43,7 @@ module Proj
|
|
43
43
|
#
|
44
44
|
# @see https://proj.org/development/reference/functions.html#c.proj_ellipsoid_get_parameters
|
45
45
|
#
|
46
|
-
# @return [
|
46
|
+
# @return [Float]
|
47
47
|
def semi_major_axis
|
48
48
|
self.parameters[:semi_major_axis]
|
49
49
|
end
|
@@ -52,7 +52,7 @@ module Proj
|
|
52
52
|
#
|
53
53
|
# @see https://proj.org/development/reference/functions.html#c.proj_ellipsoid_get_parameters
|
54
54
|
#
|
55
|
-
# @return [
|
55
|
+
# @return [Float]
|
56
56
|
def semi_minor_axis
|
57
57
|
self.parameters[:semi_minor_axis]
|
58
58
|
end
|
@@ -70,7 +70,7 @@ module Proj
|
|
70
70
|
#
|
71
71
|
# @see https://proj.org/development/reference/functions.html#c.proj_ellipsoid_get_parameters
|
72
72
|
#
|
73
|
-
# @return [
|
73
|
+
# @return [Float]
|
74
74
|
def inverse_flattening
|
75
75
|
self.parameters[:inverse_flattening]
|
76
76
|
end
|
data/lib/proj/grid.rb
CHANGED
@@ -85,7 +85,7 @@ module Proj
|
|
85
85
|
# @see https://proj.org/development/reference/functions.html#c.proj_download_file
|
86
86
|
#
|
87
87
|
# @param ignore_ttl [Boolean] If set to FALSE, PROJ will only check the recentness of an already downloaded file, if the delay between the last time it has been verified and the current time exceeds the TTL setting. This can save network accesses. If set to TRUE, PROJ will unconditionally check from the server the recentness of the file.
|
88
|
-
# @yieldparam percent [
|
88
|
+
# @yieldparam percent [Float] The progress downloading the file in the range of 0 to 1
|
89
89
|
#
|
90
90
|
# @return [Boolean] True if the download was successful or unneeded. Otherwise false
|
91
91
|
def download(ignore_ttl = false)
|
data/lib/proj/operation.rb
CHANGED
@@ -3,10 +3,10 @@ module Proj
|
|
3
3
|
attr_reader :id, :description
|
4
4
|
|
5
5
|
def self.list
|
6
|
-
pointer_to_array = FFI::Pointer.new(Api::
|
6
|
+
pointer_to_array = FFI::Pointer.new(Api::PJ_LIST, Api.proj_list_operations)
|
7
7
|
result = Array.new
|
8
8
|
0.step do |i|
|
9
|
-
operation_info = Api::
|
9
|
+
operation_info = Api::PJ_LIST.new(pointer_to_array[i])
|
10
10
|
break result if operation_info[:id].nil?
|
11
11
|
id = operation_info[:id]
|
12
12
|
description = operation_info[:descr].read_pointer.read_string.force_encoding('UTF-8')
|
@@ -3,6 +3,7 @@ module Proj
|
|
3
3
|
class OperationFactoryContext
|
4
4
|
attr_reader :context
|
5
5
|
|
6
|
+
# @!visibility private
|
6
7
|
def self.finalize(pointer)
|
7
8
|
proc do
|
8
9
|
Api.proj_operation_factory_context_destroy(pointer)
|
@@ -44,7 +45,7 @@ module Proj
|
|
44
45
|
|
45
46
|
# Set the desired accuracy of the resulting coordinate transformations.
|
46
47
|
#
|
47
|
-
# @param value [
|
48
|
+
# @param value [Float] - Accuracy in meters. Set to 0 to disable the filter.
|
48
49
|
def desired_accuracy=(value)
|
49
50
|
Api.proj_operation_factory_context_set_desired_accuracy(self.context, self, value)
|
50
51
|
end
|
data/lib/proj/parameters.rb
CHANGED
data/lib/proj/pj_object.rb
CHANGED
@@ -31,6 +31,8 @@ module Proj
|
|
31
31
|
Ellipsoid
|
32
32
|
when :PJ_TYPE_PRIME_MERIDIAN
|
33
33
|
PrimeMeridian
|
34
|
+
when :PJ_TYPE_COORDINATE_METADATA
|
35
|
+
CoordinateMetadata
|
34
36
|
else
|
35
37
|
# Return whatever the current class is
|
36
38
|
self
|
@@ -205,7 +207,7 @@ module Proj
|
|
205
207
|
|
206
208
|
# Assign a new context to this object
|
207
209
|
#
|
208
|
-
# @param [Context] The context to assign to this object
|
210
|
+
# @param value [Context] The context to assign to this object
|
209
211
|
def context=(value)
|
210
212
|
Api.proj_assign_context(self, value)
|
211
213
|
end
|
@@ -310,7 +312,7 @@ module Proj
|
|
310
312
|
#
|
311
313
|
# @see https://proj.org/development/reference/functions.html#c.proj_pj_info
|
312
314
|
#
|
313
|
-
# @return [
|
315
|
+
# @return [Float]
|
314
316
|
def accuracy
|
315
317
|
self.info[:accuracy]
|
316
318
|
end
|
@@ -468,7 +470,7 @@ module Proj
|
|
468
470
|
# @param coord1 [Coordinate] Coordinate of first point. Must be lat/long in radians
|
469
471
|
# @param coord2 [Coordinate] Coordinate of second point. Must be lat/long in radians
|
470
472
|
#
|
471
|
-
# @return [
|
473
|
+
# @return [Float] Distance between the coordinates in meters
|
472
474
|
def lp_distance(coord1, coord2)
|
473
475
|
Api.proj_lp_dist(self, coord1, coord2)
|
474
476
|
end
|
@@ -485,7 +487,7 @@ module Proj
|
|
485
487
|
# @param coord1 [Coordinate] Coordinate of first point. Must be lat/long in radians
|
486
488
|
# @param coord2 [Coordinate] Coordinate of second point. Must be lat/long in radians
|
487
489
|
#
|
488
|
-
# @return [
|
490
|
+
# @return [Float] Distance between the coordinates in meters
|
489
491
|
def lpz_distance(coord1, coord2)
|
490
492
|
Api.proj_lpz_dist(self, coord1, coord2)
|
491
493
|
end
|
@@ -497,7 +499,7 @@ module Proj
|
|
497
499
|
# @param coord1 [Coordinate] Coordinate of first point
|
498
500
|
# @param coord2 [Coordinate] Coordinate of second point
|
499
501
|
#
|
500
|
-
# @return [
|
502
|
+
# @return [Float] Distance between the coordinates in meters
|
501
503
|
def xy_distance(coord1, coord2)
|
502
504
|
Api.proj_xy_dist(coord1, coord2)
|
503
505
|
end
|
@@ -510,7 +512,7 @@ module Proj
|
|
510
512
|
# @param coord1 [Coordinate] Coordinate of first point
|
511
513
|
# @param coord2 [Coordinate] Coordinate of second point
|
512
514
|
#
|
513
|
-
# @return [
|
515
|
+
# @return [Float] Distance between the coordinates in meters
|
514
516
|
def xyz_distance(coord1, coord2)
|
515
517
|
Api.proj_xyz_dist(coord1, coord2)
|
516
518
|
end
|