proj4rb 4.1.0 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +98 -0
- data/Gemfile +4 -4
- data/README.md +53 -0
- data/lib/api/proj.rb +750 -0
- data/lib/api/proj_experimental.rb +7 -0
- data/lib/api/proj_ffi.rb +47 -0
- data/lib/api/proj_version.rb +26 -0
- data/lib/examples/axis_order_normalization.rb +13 -0
- data/lib/examples/batch_transformation.rb +25 -0
- data/lib/examples/context_logging.rb +26 -0
- data/lib/examples/crs_identification.rb +18 -0
- data/lib/examples/database_query.rb +27 -0
- data/lib/examples/geodetic_distance.rb +38 -0
- data/lib/examples/geodetic_to_projected.rb +18 -0
- data/lib/examples/operation_factory_context.rb +19 -0
- data/lib/examples/pipeline_operator.rb +21 -0
- data/lib/examples/promote_demote_3d.rb +23 -0
- data/lib/examples/serialization_formats.rb +17 -0
- data/lib/examples/transform_bounds.rb +18 -0
- data/lib/examples/transformation_with_area.rb +18 -0
- data/lib/proj/area.rb +74 -74
- data/lib/proj/axis_info.rb +44 -44
- data/lib/proj/bounds.rb +22 -0
- data/lib/proj/bounds3d.rb +45 -0
- data/lib/proj/context.rb +57 -23
- data/lib/proj/conversion.rb +94 -91
- data/lib/proj/coordinate.rb +304 -281
- data/lib/proj/coordinate_metadata.rb +38 -0
- data/lib/proj/coordinate_operation_mixin.rb +464 -381
- data/lib/proj/coordinate_system.rb +143 -137
- data/lib/proj/crs.rb +688 -672
- data/lib/proj/crs_info.rb +47 -47
- data/lib/proj/database.rb +310 -305
- data/lib/proj/datum.rb +32 -32
- data/lib/proj/datum_ensemble.rb +34 -34
- data/lib/proj/domain.rb +82 -0
- data/lib/proj/ellipsoid.rb +77 -77
- data/lib/proj/error.rb +7 -8
- data/lib/proj/file_api_callbacks.rb +165 -0
- data/lib/proj/grid.rb +121 -121
- data/lib/proj/grid_cache.rb +65 -64
- data/lib/proj/grid_info.rb +19 -19
- data/lib/proj/life_span.rb +21 -0
- data/lib/proj/network_api_callbacks.rb +86 -0
- data/lib/proj/operation.rb +66 -42
- data/lib/proj/operation_factory_context.rb +4 -2
- data/lib/proj/options.rb +41 -0
- data/lib/proj/parameter.rb +37 -37
- data/lib/proj/parameters.rb +106 -107
- data/lib/proj/pj_axis_description.rb +26 -0
- data/lib/proj/pj_object.rb +602 -670
- data/lib/proj/pj_objects.rb +45 -45
- data/lib/proj/pj_param_description.rb +28 -0
- data/lib/proj/prime_meridian.rb +65 -65
- data/lib/proj/projection.rb +1771 -698
- data/lib/proj/session.rb +2 -0
- data/lib/proj/transformation.rb +102 -102
- data/lib/proj/unit.rb +81 -108
- data/lib/proj.rb +10 -3
- data/lib/proj4.rb +5 -5
- data/proj4rb.gemspec +10 -5
- data/test/abstract_test.rb +7 -28
- data/test/context_test.rb +210 -172
- data/test/context_validation_test.rb +11 -0
- data/test/conversion_test.rb +376 -368
- data/test/coordinate_metadata_test.rb +34 -0
- data/test/coordinate_system_test.rb +162 -144
- data/test/coordinate_test.rb +289 -34
- data/test/crs_test.rb +1112 -1072
- data/test/database_test.rb +407 -359
- data/test/datum_ensemble_test.rb +64 -64
- data/test/datum_test.rb +61 -54
- data/test/domain_test.rb +72 -0
- data/test/ellipsoid_test.rb +80 -80
- data/test/examples_test.rb +149 -0
- data/test/file_api_example.rb +58 -0
- data/test/file_api_test.rb +74 -66
- data/test/grid_cache_test.rb +72 -72
- data/test/grid_test.rb +126 -141
- data/test/network_api_example.rb +48 -0
- data/test/network_api_test.rb +33 -45
- data/test/operation_factory_context_test.rb +225 -201
- data/test/operation_test.rb +40 -29
- data/test/options_test.rb +17 -0
- data/test/parameters_test.rb +86 -40
- data/test/pj_object_test.rb +221 -179
- data/test/prime_meridian_test.rb +75 -75
- data/test/proj_test.rb +58 -58
- data/test/projection_test.rb +680 -650
- data/test/session_test.rb +78 -77
- data/test/transformation_test.rb +238 -210
- data/test/unit_test.rb +114 -76
- metadata +45 -31
- data/ChangeLog +0 -89
- data/README.rdoc +0 -207
- data/lib/api/api.rb +0 -117
- data/lib/api/api_5_0.rb +0 -338
- data/lib/api/api_5_1.rb +0 -7
- data/lib/api/api_5_2.rb +0 -5
- data/lib/api/api_6_0.rb +0 -146
- data/lib/api/api_6_1.rb +0 -5
- data/lib/api/api_6_2.rb +0 -10
- data/lib/api/api_6_3.rb +0 -6
- data/lib/api/api_7_0.rb +0 -69
- data/lib/api/api_7_1.rb +0 -73
- data/lib/api/api_7_2.rb +0 -14
- data/lib/api/api_8_0.rb +0 -6
- data/lib/api/api_8_1.rb +0 -24
- data/lib/api/api_8_2.rb +0 -6
- data/lib/api/api_9_1.rb +0 -7
- data/lib/api/api_9_2.rb +0 -9
- data/lib/api/api_experimental.rb +0 -201
- data/lib/proj/file_api.rb +0 -166
- data/lib/proj/network_api.rb +0 -92
data/test/parameters_test.rb
CHANGED
|
@@ -1,40 +1,86 @@
|
|
|
1
|
-
# encoding: UTF-8
|
|
2
|
-
|
|
3
|
-
require_relative './abstract_test'
|
|
4
|
-
|
|
5
|
-
class ParametersTest < AbstractTest
|
|
6
|
-
def test_types_nil
|
|
7
|
-
params = Proj::Parameters.new
|
|
8
|
-
assert(params.types.empty?)
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def test_types_one
|
|
12
|
-
types = [:PJ_TYPE_GEODETIC_CRS]
|
|
13
|
-
params = Proj::Parameters.new
|
|
14
|
-
params.types = types
|
|
15
|
-
assert_equal(types, params.types)
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def test_types_many
|
|
19
|
-
types = [:PJ_TYPE_GEODETIC_CRS, :PJ_TYPE_GEOCENTRIC_CRS, :PJ_TYPE_GEOGRAPHIC_CRS]
|
|
20
|
-
params = Proj::Parameters.new
|
|
21
|
-
params.types = types
|
|
22
|
-
assert_equal(types, params.types)
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
params.
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
|
|
3
|
+
require_relative './abstract_test'
|
|
4
|
+
|
|
5
|
+
class ParametersTest < AbstractTest
|
|
6
|
+
def test_types_nil
|
|
7
|
+
params = Proj::Parameters.new
|
|
8
|
+
assert(params.types.empty?)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def test_types_one
|
|
12
|
+
types = [:PJ_TYPE_GEODETIC_CRS]
|
|
13
|
+
params = Proj::Parameters.new
|
|
14
|
+
params.types = types
|
|
15
|
+
assert_equal(types, params.types)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def test_types_many
|
|
19
|
+
types = [:PJ_TYPE_GEODETIC_CRS, :PJ_TYPE_GEOCENTRIC_CRS, :PJ_TYPE_GEOGRAPHIC_CRS]
|
|
20
|
+
params = Proj::Parameters.new
|
|
21
|
+
params.types = types
|
|
22
|
+
assert_equal(types, params.types)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def test_to_description_unit_name
|
|
26
|
+
param = Proj::Parameter.new(name: "Latitude of natural origin",
|
|
27
|
+
value: 0.0,
|
|
28
|
+
unit_conv_factor: 0.0174532925199433,
|
|
29
|
+
unit_name: "degree",
|
|
30
|
+
unit_type: :PJ_UT_ANGULAR)
|
|
31
|
+
desc = param.to_description
|
|
32
|
+
assert_equal("degree", desc[:unit_name])
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def test_types_buffer_is_retained
|
|
36
|
+
params = Proj::Parameters.new
|
|
37
|
+
params.types = [:PJ_TYPE_GEODETIC_CRS]
|
|
38
|
+
|
|
39
|
+
# The buffer assigned into the native struct must be strongly referenced
|
|
40
|
+
# on the Ruby side to avoid dangling pointers after GC.
|
|
41
|
+
assert_instance_of(FFI::MemoryPointer, params.instance_variable_get(:@types_ptr))
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def test_bbox_valid
|
|
45
|
+
params = Proj::Parameters.new
|
|
46
|
+
|
|
47
|
+
params.bbox_valid = false
|
|
48
|
+
refute(params.bbox_valid)
|
|
49
|
+
|
|
50
|
+
params.bbox_valid = true
|
|
51
|
+
assert(params.bbox_valid)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def test_allow_deprecated
|
|
55
|
+
params = Proj::Parameters.new
|
|
56
|
+
refute(params.allow_deprecated)
|
|
57
|
+
|
|
58
|
+
params.allow_deprecated = true
|
|
59
|
+
assert(params.allow_deprecated)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def test_bbox_coordinates
|
|
63
|
+
params = Proj::Parameters.new
|
|
64
|
+
params.west_lon_degree = -120.0
|
|
65
|
+
params.south_lat_degree = 40.0
|
|
66
|
+
params.east_lon_degree = -80.0
|
|
67
|
+
params.north_lat_degree = 64.0
|
|
68
|
+
|
|
69
|
+
assert_equal(-120.0, params.west_lon_degree)
|
|
70
|
+
assert_equal(40.0, params.south_lat_degree)
|
|
71
|
+
assert_equal(-80.0, params.east_lon_degree)
|
|
72
|
+
assert_equal(64.0, params.north_lat_degree)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def test_crs_area_of_use_contains_bbox
|
|
76
|
+
params = Proj::Parameters.new
|
|
77
|
+
params.crs_area_of_use_contains_bbox = 1
|
|
78
|
+
assert_equal(1, params.crs_area_of_use_contains_bbox)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def test_celestial_body_name
|
|
82
|
+
params = Proj::Parameters.new
|
|
83
|
+
params.celestial_body_name = "Earth"
|
|
84
|
+
assert_equal("Earth", params.celestial_body_name)
|
|
85
|
+
end
|
|
86
|
+
end
|
data/test/pj_object_test.rb
CHANGED
|
@@ -1,179 +1,221 @@
|
|
|
1
|
-
# encoding: UTF-8
|
|
2
|
-
|
|
3
|
-
require_relative './abstract_test'
|
|
4
|
-
class PjObjectTest < AbstractTest
|
|
5
|
-
def test_clone
|
|
6
|
-
object = Proj::PjObject.create("+proj=longlat")
|
|
7
|
-
clone = object.clone
|
|
8
|
-
assert(object.equivalent_to?(clone, :PJ_COMP_STRICT))
|
|
9
|
-
assert(object.context.equal?(clone.context))
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def test_dup
|
|
13
|
-
object = Proj::PjObject.create("+proj=longlat")
|
|
14
|
-
clone = object.dup
|
|
15
|
-
assert(object.equivalent_to?(clone, :PJ_COMP_STRICT))
|
|
16
|
-
assert(object.context.equal?(clone.context))
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def test_equivalent
|
|
20
|
-
from_epsg = Proj::PjObject.create_from_database("EPSG", "7844", :PJ_CATEGORY_CRS)
|
|
21
|
-
from_wkt = Proj::PjObject.create_from_wkt(<<~EOS)
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
assert(from_epsg.equivalent_to?(from_wkt, :PJ_COMP_EQUIVALENT))
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
def test_accuracy_crs
|
|
41
|
-
object = Proj::PjObject.create_from_database("EPSG", "4326", :PJ_CATEGORY_CRS)
|
|
42
|
-
assert_equal(-1, object.accuracy)
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
def test_accuracy_coordinate_operation
|
|
46
|
-
object = Proj::PjObject.create_from_database("EPSG", "1170", :PJ_CATEGORY_COORDINATE_OPERATION)
|
|
47
|
-
assert_equal(16.0, object.accuracy)
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
def test_accuracy_projection
|
|
51
|
-
object = Proj::Conversion.new("+proj=helmert")
|
|
52
|
-
assert_equal(-1.0, object.accuracy)
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
def test_id_code
|
|
56
|
-
crs = Proj::Crs.new('EPSG:4326')
|
|
57
|
-
assert_equal("4326", crs.id_code)
|
|
58
|
-
refute(crs.id_code(1))
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
def test_remarks_transformation
|
|
62
|
-
transformation = Proj::PjObject.create_from_database("EPSG", "8048", :PJ_CATEGORY_COORDINATE_OPERATION)
|
|
63
|
-
|
|
64
|
-
expected = "Scale difference in ppb where 1/billion = 1E-9. See CT codes 8444-46 for NTv2 method giving equivalent results for Christmas Island, Cocos Islands and Australia respectively. See CT code 8447 for alternative including distortion model for Australia only."
|
|
65
|
-
assert_equal(expected, transformation.remarks)
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
def test_remarks_conversion
|
|
69
|
-
operation = Proj::PjObject.create_from_database("EPSG", "3811", :PJ_CATEGORY_COORDINATE_OPERATION)
|
|
70
|
-
|
|
71
|
-
expected = "Replaces Lambert 2005."
|
|
72
|
-
assert_equal(expected, operation.remarks)
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
def test_scope_transformation
|
|
76
|
-
transformation = Proj::PjObject.create_from_database("EPSG", "8048", :PJ_CATEGORY_COORDINATE_OPERATION)
|
|
77
|
-
|
|
78
|
-
expected = "Transformation of GDA94 coordinates that have been derived through GNSS CORS."
|
|
79
|
-
assert_equal(expected, transformation.scope)
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
def test_scope_conversion
|
|
83
|
-
operation = Proj::PjObject.create_from_database("EPSG", "3811", :PJ_CATEGORY_COORDINATE_OPERATION)
|
|
84
|
-
|
|
85
|
-
expected = "Engineering survey, topographic mapping."
|
|
86
|
-
assert_equal(expected, operation.scope)
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
def test_scope_invalid
|
|
90
|
-
operation = Proj::Conversion.new("+proj=noop")
|
|
91
|
-
refute(operation.scope)
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
def test_factors
|
|
95
|
-
conversion = Proj::Conversion.new("+proj=merc +ellps=WGS84")
|
|
96
|
-
coord = Proj::Coordinate.new(lon: Proj.degrees_to_radians(12), lat: Proj.degrees_to_radians(55))
|
|
97
|
-
factors = conversion.factors(coord)
|
|
98
|
-
|
|
99
|
-
assert_in_delta(1.739526610076288, factors[:meridional_scale], 1e-7)
|
|
100
|
-
assert_in_delta(1.739526609938368, factors[:parallel_scale], 1e-7)
|
|
101
|
-
assert_in_delta(3.0259528269235867, factors[:areal_scale], 1e-7)
|
|
102
|
-
|
|
103
|
-
assert_in_delta(0.0, factors[:angular_distortion], 1e-7)
|
|
104
|
-
assert_in_delta(1.5707963267948966, factors[:meridian_parallel_angle], 1e-7)
|
|
105
|
-
assert_in_delta(0.0, factors[:meridian_convergence], 1e-7)
|
|
106
|
-
|
|
107
|
-
assert_in_delta(1.7395266100073281, factors[:tissot_semimajor], 1e-7)
|
|
108
|
-
assert_in_delta(1.7395266100073281, factors[:tissot_semiminor], 1e-7)
|
|
109
|
-
|
|
110
|
-
assert_in_delta(0.9999999999996122, factors[:dx_dlam], 1e-7)
|
|
111
|
-
assert_in_delta(0.0, factors[:dx_dphi], 1e-7)
|
|
112
|
-
assert_in_delta(0.0, factors[:dy_dlam], 1e-7)
|
|
113
|
-
assert_in_delta(1.7395897312200146, factors[:dy_dphi], 1e-7)
|
|
114
|
-
end
|
|
115
|
-
|
|
116
|
-
def test_create_from_name
|
|
117
|
-
context = Proj::Context.new
|
|
118
|
-
objects = Proj::PjObject.create_from_name("WGS 84", context)
|
|
119
|
-
assert_equal(5, objects.size)
|
|
120
|
-
end
|
|
121
|
-
|
|
122
|
-
def test_create_from_name_with_auth_name
|
|
123
|
-
context = Proj::Context.new
|
|
124
|
-
objects = Proj::PjObject.create_from_name("WGS 84", context, auth_name: "xx")
|
|
125
|
-
assert_equal(0, objects.size)
|
|
126
|
-
end
|
|
127
|
-
|
|
128
|
-
def test_create_from_name_with_types
|
|
129
|
-
context = Proj::Context.new
|
|
130
|
-
objects = Proj::PjObject.create_from_name("WGS 84", context, types: [:PJ_TYPE_GEODETIC_CRS, :PJ_TYPE_PROJECTED_CRS])
|
|
131
|
-
assert_equal(3, objects.size)
|
|
132
|
-
end
|
|
133
|
-
|
|
134
|
-
def test_create_from_name_with_types_and_approximate_match
|
|
135
|
-
context = Proj::Context.new
|
|
136
|
-
objects = Proj::PjObject.create_from_name("WGS 84", context, approximate_match: true,
|
|
137
|
-
types: [:PJ_TYPE_GEODETIC_CRS, :PJ_TYPE_PROJECTED_CRS])
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
|
|
3
|
+
require_relative './abstract_test'
|
|
4
|
+
class PjObjectTest < AbstractTest
|
|
5
|
+
def test_clone
|
|
6
|
+
object = Proj::PjObject.create("+proj=longlat")
|
|
7
|
+
clone = object.clone
|
|
8
|
+
assert(object.equivalent_to?(clone, :PJ_COMP_STRICT))
|
|
9
|
+
assert(object.context.equal?(clone.context))
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def test_dup
|
|
13
|
+
object = Proj::PjObject.create("+proj=longlat")
|
|
14
|
+
clone = object.dup
|
|
15
|
+
assert(object.equivalent_to?(clone, :PJ_COMP_STRICT))
|
|
16
|
+
assert(object.context.equal?(clone.context))
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def test_equivalent
|
|
20
|
+
from_epsg = Proj::PjObject.create_from_database("EPSG", "7844", :PJ_CATEGORY_CRS)
|
|
21
|
+
from_wkt = Proj::PjObject.create_from_wkt(<<~EOS)
|
|
22
|
+
GEOGCRS["GDA2020",
|
|
23
|
+
DATUM["GDA2020",
|
|
24
|
+
ELLIPSOID["GRS_1980",6378137,298.257222101,
|
|
25
|
+
LENGTHUNIT["metre",1]]],
|
|
26
|
+
PRIMEM["Greenwich",0,
|
|
27
|
+
ANGLEUNIT["Degree",0.0174532925199433]],
|
|
28
|
+
CS[ellipsoidal,2],
|
|
29
|
+
AXIS["geodetic latitude (Lat)",north,
|
|
30
|
+
ORDER[1],
|
|
31
|
+
ANGLEUNIT["degree",0.0174532925199433]],
|
|
32
|
+
AXIS["geodetic longitude (Lon)",east,
|
|
33
|
+
ORDER[2],
|
|
34
|
+
ANGLEUNIT["degree",0.0174532925199433]]]"
|
|
35
|
+
EOS
|
|
36
|
+
|
|
37
|
+
assert(from_epsg.equivalent_to?(from_wkt, :PJ_COMP_EQUIVALENT))
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def test_accuracy_crs
|
|
41
|
+
object = Proj::PjObject.create_from_database("EPSG", "4326", :PJ_CATEGORY_CRS)
|
|
42
|
+
assert_equal(-1, object.accuracy)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def test_accuracy_coordinate_operation
|
|
46
|
+
object = Proj::PjObject.create_from_database("EPSG", "1170", :PJ_CATEGORY_COORDINATE_OPERATION)
|
|
47
|
+
assert_equal(16.0, object.accuracy)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def test_accuracy_projection
|
|
51
|
+
object = Proj::Conversion.new("+proj=helmert")
|
|
52
|
+
assert_equal(-1.0, object.accuracy)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def test_id_code
|
|
56
|
+
crs = Proj::Crs.new('EPSG:4326')
|
|
57
|
+
assert_equal("4326", crs.id_code)
|
|
58
|
+
refute(crs.id_code(1))
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def test_remarks_transformation
|
|
62
|
+
transformation = Proj::PjObject.create_from_database("EPSG", "8048", :PJ_CATEGORY_COORDINATE_OPERATION)
|
|
63
|
+
|
|
64
|
+
expected = "Scale difference in ppb where 1/billion = 1E-9. See CT codes 8444-46 for NTv2 method giving equivalent results for Christmas Island, Cocos Islands and Australia respectively. See CT code 8447 for alternative including distortion model for Australia only."
|
|
65
|
+
assert_equal(expected, transformation.remarks)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def test_remarks_conversion
|
|
69
|
+
operation = Proj::PjObject.create_from_database("EPSG", "3811", :PJ_CATEGORY_COORDINATE_OPERATION)
|
|
70
|
+
|
|
71
|
+
expected = "Replaces Lambert 2005."
|
|
72
|
+
assert_equal(expected, operation.remarks)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def test_scope_transformation
|
|
76
|
+
transformation = Proj::PjObject.create_from_database("EPSG", "8048", :PJ_CATEGORY_COORDINATE_OPERATION)
|
|
77
|
+
|
|
78
|
+
expected = "Transformation of GDA94 coordinates that have been derived through GNSS CORS."
|
|
79
|
+
assert_equal(expected, transformation.scope)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def test_scope_conversion
|
|
83
|
+
operation = Proj::PjObject.create_from_database("EPSG", "3811", :PJ_CATEGORY_COORDINATE_OPERATION)
|
|
84
|
+
|
|
85
|
+
expected = "Engineering survey, topographic mapping."
|
|
86
|
+
assert_equal(expected, operation.scope)
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def test_scope_invalid
|
|
90
|
+
operation = Proj::Conversion.new("+proj=noop")
|
|
91
|
+
refute(operation.scope)
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def test_factors
|
|
95
|
+
conversion = Proj::Conversion.new("+proj=merc +ellps=WGS84")
|
|
96
|
+
coord = Proj::Coordinate.new(lon: Proj.degrees_to_radians(12), lat: Proj.degrees_to_radians(55))
|
|
97
|
+
factors = conversion.factors(coord)
|
|
98
|
+
|
|
99
|
+
assert_in_delta(1.739526610076288, factors[:meridional_scale], 1e-7)
|
|
100
|
+
assert_in_delta(1.739526609938368, factors[:parallel_scale], 1e-7)
|
|
101
|
+
assert_in_delta(3.0259528269235867, factors[:areal_scale], 1e-7)
|
|
102
|
+
|
|
103
|
+
assert_in_delta(0.0, factors[:angular_distortion], 1e-7)
|
|
104
|
+
assert_in_delta(1.5707963267948966, factors[:meridian_parallel_angle], 1e-7)
|
|
105
|
+
assert_in_delta(0.0, factors[:meridian_convergence], 1e-7)
|
|
106
|
+
|
|
107
|
+
assert_in_delta(1.7395266100073281, factors[:tissot_semimajor], 1e-7)
|
|
108
|
+
assert_in_delta(1.7395266100073281, factors[:tissot_semiminor], 1e-7)
|
|
109
|
+
|
|
110
|
+
assert_in_delta(0.9999999999996122, factors[:dx_dlam], 1e-7)
|
|
111
|
+
assert_in_delta(0.0, factors[:dx_dphi], 1e-7)
|
|
112
|
+
assert_in_delta(0.0, factors[:dy_dlam], 1e-7)
|
|
113
|
+
assert_in_delta(1.7395897312200146, factors[:dy_dphi], 1e-7)
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
def test_create_from_name
|
|
117
|
+
context = Proj::Context.new
|
|
118
|
+
objects = Proj::PjObject.create_from_name("WGS 84", context)
|
|
119
|
+
assert_equal(5, objects.size)
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
def test_create_from_name_with_auth_name
|
|
123
|
+
context = Proj::Context.new
|
|
124
|
+
objects = Proj::PjObject.create_from_name("WGS 84", context, auth_name: "xx")
|
|
125
|
+
assert_equal(0, objects.size)
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
def test_create_from_name_with_types
|
|
129
|
+
context = Proj::Context.new
|
|
130
|
+
objects = Proj::PjObject.create_from_name("WGS 84", context, types: [:PJ_TYPE_GEODETIC_CRS, :PJ_TYPE_PROJECTED_CRS])
|
|
131
|
+
assert_equal(3, objects.size)
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
def test_create_from_name_with_types_and_approximate_match
|
|
135
|
+
context = Proj::Context.new
|
|
136
|
+
objects = Proj::PjObject.create_from_name("WGS 84", context, approximate_match: true,
|
|
137
|
+
types: [:PJ_TYPE_GEODETIC_CRS, :PJ_TYPE_PROJECTED_CRS])
|
|
138
|
+
|
|
139
|
+
minimum = case
|
|
140
|
+
when Proj::Api::PROJ_VERSION >= Gem::Version.new('9.6.0')
|
|
141
|
+
461
|
|
142
|
+
when Proj::Api::PROJ_VERSION >= Gem::Version.new('9.3.0')
|
|
143
|
+
443
|
|
144
|
+
when Proj::Api::PROJ_VERSION >= Gem::Version.new('9.0.0')
|
|
145
|
+
442
|
|
146
|
+
else
|
|
147
|
+
440
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
assert_operator(objects.size, :>=, minimum)
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
def test_create_from_name_with_types_and_approximate_match_and_limit
|
|
154
|
+
context = Proj::Context.new
|
|
155
|
+
objects = Proj::PjObject.create_from_name("WGS 84", context, approximate_match: true, limit: 25,
|
|
156
|
+
types: [:PJ_TYPE_GEODETIC_CRS, :PJ_TYPE_PROJECTED_CRS])
|
|
157
|
+
assert_equal(25, objects.size)
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
def test_deprecated_true
|
|
161
|
+
wkt = <<~EOS
|
|
162
|
+
GEOGCRS["SAD69 (deprecated)",
|
|
163
|
+
DATUM["South_American_Datum_1969",
|
|
164
|
+
ELLIPSOID["GRS 1967",6378160,298.247167427,
|
|
165
|
+
LENGTHUNIT["metre",1,
|
|
166
|
+
ID["EPSG",9001]]]],
|
|
167
|
+
PRIMEM["Greenwich",0,
|
|
168
|
+
ANGLEUNIT["degree",0.0174532925199433,
|
|
169
|
+
ID["EPSG",9122]]],
|
|
170
|
+
CS[ellipsoidal,2],
|
|
171
|
+
AXIS["latitude",north,
|
|
172
|
+
ORDER[1],
|
|
173
|
+
ANGLEUNIT["degree",0.0174532925199433,
|
|
174
|
+
ID["EPSG",9122]]],
|
|
175
|
+
AXIS["longitude",east,
|
|
176
|
+
ORDER[2],
|
|
177
|
+
ANGLEUNIT["degree",0.0174532925199433,
|
|
178
|
+
ID["EPSG",9122]]]]
|
|
179
|
+
EOS
|
|
180
|
+
|
|
181
|
+
crs = Proj::Crs.create(wkt)
|
|
182
|
+
assert(crs.deprecated?)
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
def test_deprecated_false
|
|
186
|
+
crs = Proj::Crs.create_from_database("EPSG", "4326", :PJ_CATEGORY_CRS)
|
|
187
|
+
refute(crs.deprecated?)
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
def test_assign_context
|
|
191
|
+
GC.stress = true
|
|
192
|
+
context1 = Proj::Context.new
|
|
193
|
+
object = Proj::PjObject.create("+proj=longlat", context1)
|
|
194
|
+
assert_equal(context1, object.context)
|
|
195
|
+
|
|
196
|
+
context2 = Proj::Context.new
|
|
197
|
+
object.context = context2
|
|
198
|
+
assert_equal(context2, object.context)
|
|
199
|
+
ensure
|
|
200
|
+
GC.stress = false
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
def test_destroy
|
|
204
|
+
object = Proj::PjObject.create("+proj=longlat")
|
|
205
|
+
refute(object.to_ptr.null?)
|
|
206
|
+
|
|
207
|
+
object.destroy
|
|
208
|
+
assert(object.to_ptr.null?)
|
|
209
|
+
end
|
|
210
|
+
|
|
211
|
+
if Proj::Api::PROJ_VERSION >= Gem::Version.new('9.7.0')
|
|
212
|
+
def test_geod_direct
|
|
213
|
+
crs = Proj::Crs.new("EPSG:4326")
|
|
214
|
+
# Start at equator/prime meridian, go due east 111319.49 meters (approx 1 degree at equator)
|
|
215
|
+
coord = Proj::Coordinate.new(lam: 0.0, phi: 0.0)
|
|
216
|
+
result = crs.geod_direct(coord, Proj.degrees_to_radians(90), 111319.49)
|
|
217
|
+
assert_in_delta(Proj.degrees_to_radians(1.0), result.lam, 1e-4)
|
|
218
|
+
assert_in_delta(0.0, result.phi, 1e-4)
|
|
219
|
+
end
|
|
220
|
+
end
|
|
221
|
+
end
|