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
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
|
|
3
|
+
require_relative './abstract_test'
|
|
4
|
+
|
|
5
|
+
class CoordinateMetadataTest < AbstractTest
|
|
6
|
+
if Proj::Api::PROJ_VERSION >= Gem::Version.new('9.4.0')
|
|
7
|
+
def test_create_static_crs
|
|
8
|
+
crs = Proj::Crs.new("EPSG:4326")
|
|
9
|
+
metadata = Proj::CoordinateMetadata.new(crs)
|
|
10
|
+
assert(metadata)
|
|
11
|
+
assert_equal(:PJ_TYPE_COORDINATE_METADATA, metadata.proj_type)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def test_create_with_epoch
|
|
15
|
+
crs = Proj::Crs.new("EPSG:9000")
|
|
16
|
+
metadata = Proj::CoordinateMetadata.new(crs, nil, 2025.0)
|
|
17
|
+
assert(metadata)
|
|
18
|
+
assert_in_delta(2025.0, metadata.epoch)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def test_create_with_context
|
|
22
|
+
context = Proj::Context.new
|
|
23
|
+
crs = Proj::Crs.new("EPSG:4326", context)
|
|
24
|
+
metadata = Proj::CoordinateMetadata.new(crs, context)
|
|
25
|
+
assert(metadata)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def test_epoch_static_crs
|
|
29
|
+
crs = Proj::Crs.new("EPSG:4326")
|
|
30
|
+
metadata = Proj::CoordinateMetadata.new(crs)
|
|
31
|
+
assert_in_delta(0.0, metadata.epoch)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -1,144 +1,162 @@
|
|
|
1
|
-
# encoding: UTF-8
|
|
2
|
-
|
|
3
|
-
require_relative './abstract_test'
|
|
4
|
-
|
|
5
|
-
class CoordinateSystemTest < AbstractTest
|
|
6
|
-
def test_create
|
|
7
|
-
context = Proj::Context.new
|
|
8
|
-
crs = Proj::Crs.new('EPSG:4326', context)
|
|
9
|
-
cs = crs.coordinate_system
|
|
10
|
-
axes = cs.axes
|
|
11
|
-
cs = Proj::CoordinateSystem.create(cs.cs_type, axes, context)
|
|
12
|
-
assert_equal(2, cs.axis_count)
|
|
13
|
-
assert_equal(:PJ_CS_TYPE_ELLIPSOIDAL, cs.cs_type)
|
|
14
|
-
assert_equal(:PJ_TYPE_UNKNOWN, cs.proj_type)
|
|
15
|
-
refute(cs.auth_name)
|
|
16
|
-
refute(cs.id_code)
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def test_create_ellipsoidal_2d
|
|
20
|
-
context = Proj::Context.new
|
|
21
|
-
cs = Proj::CoordinateSystem.create_ellipsoidal_2d(:PJ_ELLPS2D_LONGITUDE_LATITUDE, context)
|
|
22
|
-
assert_equal(2, cs.axis_count)
|
|
23
|
-
assert_equal(:PJ_CS_TYPE_ELLIPSOIDAL, cs.cs_type)
|
|
24
|
-
assert_equal(:PJ_TYPE_UNKNOWN, cs.proj_type)
|
|
25
|
-
refute(cs.auth_name)
|
|
26
|
-
refute(cs.id_code)
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def test_create_ellipsoidal_3d
|
|
30
|
-
context = Proj::Context.new
|
|
31
|
-
cs = Proj::CoordinateSystem.create_ellipsoidal_3d(:PJ_ELLPS3D_LATITUDE_LONGITUDE_HEIGHT, context)
|
|
32
|
-
assert_equal(3, cs.axis_count)
|
|
33
|
-
assert_equal(:PJ_CS_TYPE_ELLIPSOIDAL, cs.cs_type)
|
|
34
|
-
assert_equal(:PJ_TYPE_UNKNOWN, cs.proj_type)
|
|
35
|
-
|
|
36
|
-
axis = cs.axis_info(0)
|
|
37
|
-
assert_equal("Latitude", axis.name)
|
|
38
|
-
assert_equal("lat", axis.abbreviation)
|
|
39
|
-
assert_equal("north", axis.direction)
|
|
40
|
-
assert_equal("degree", axis.unit_name)
|
|
41
|
-
assert_in_delta(0.017453292519943295, axis.unit_conv_factor)
|
|
42
|
-
|
|
43
|
-
axis = cs.axis_info(1)
|
|
44
|
-
assert_equal("Longitude", axis.name)
|
|
45
|
-
assert_equal("lon", axis.abbreviation)
|
|
46
|
-
assert_equal("east", axis.direction)
|
|
47
|
-
assert_equal("degree", axis.unit_name)
|
|
48
|
-
assert_in_delta(0.017453292519943295, axis.unit_conv_factor)
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
def test_create_ellipsoidal_3d_custom_units
|
|
52
|
-
context = Proj::Context.new
|
|
53
|
-
cs = Proj::CoordinateSystem.create_ellipsoidal_3d(:PJ_ELLPS3D_LATITUDE_LONGITUDE_HEIGHT, context,
|
|
54
|
-
horizontal_angular_unit_name: "foo", horizontal_angular_unit_conv_factor: 0.5,
|
|
55
|
-
vertical_linear_unit_name: "bar", vertical_linear_unit_conv_factor: 0.6)
|
|
56
|
-
assert_equal(3, cs.axis_count)
|
|
57
|
-
assert_equal(:PJ_CS_TYPE_ELLIPSOIDAL, cs.cs_type)
|
|
58
|
-
assert_equal(:PJ_TYPE_UNKNOWN, cs.proj_type)
|
|
59
|
-
|
|
60
|
-
axis = cs.axis_info(0)
|
|
61
|
-
assert_equal("Latitude", axis.name)
|
|
62
|
-
assert_equal("lat", axis.abbreviation)
|
|
63
|
-
assert_equal("north", axis.direction)
|
|
64
|
-
assert_equal("foo", axis.unit_name)
|
|
65
|
-
assert_equal(0.5, axis.unit_conv_factor)
|
|
66
|
-
|
|
67
|
-
axis = cs.axis_info(1)
|
|
68
|
-
assert_equal("Longitude", axis.name)
|
|
69
|
-
assert_equal("lon", axis.abbreviation)
|
|
70
|
-
assert_equal("east", axis.direction)
|
|
71
|
-
assert_equal("foo", axis.unit_name)
|
|
72
|
-
assert_equal(0.5, axis.unit_conv_factor)
|
|
73
|
-
|
|
74
|
-
axis = cs.axis_info(2)
|
|
75
|
-
assert_equal("Ellipsoidal height", axis.name)
|
|
76
|
-
assert_equal("h", axis.abbreviation)
|
|
77
|
-
assert_equal("up", axis.direction)
|
|
78
|
-
assert_equal("bar", axis.unit_name)
|
|
79
|
-
assert_equal(0.6, axis.unit_conv_factor)
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
def test_create_cartesian
|
|
83
|
-
context = Proj::Context.new
|
|
84
|
-
coordinate_system = Proj::CoordinateSystem.create_cartesian_2d(context, :PJ_CART2D_EASTING_NORTHING)
|
|
85
|
-
assert_equal(2, coordinate_system.axis_count)
|
|
86
|
-
assert_equal(:PJ_CS_TYPE_CARTESIAN, coordinate_system.cs_type)
|
|
87
|
-
assert_equal(:PJ_TYPE_UNKNOWN, coordinate_system.proj_type)
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
def test_type
|
|
91
|
-
crs = Proj::Crs.new('EPSG:4326')
|
|
92
|
-
cs = crs.coordinate_system
|
|
93
|
-
refute(cs.name)
|
|
94
|
-
assert_equal(:PJ_CS_TYPE_ELLIPSOIDAL, cs.cs_type)
|
|
95
|
-
assert_equal(:PJ_TYPE_UNKNOWN, cs.proj_type)
|
|
96
|
-
assert_equal("EPSG", cs.auth_name)
|
|
97
|
-
assert_equal("6422", cs.id_code)
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
def test_axis_count
|
|
101
|
-
crs = Proj::Crs.new('EPSG:4326')
|
|
102
|
-
cs = crs.coordinate_system
|
|
103
|
-
assert_equal(2, cs.axis_count)
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
def test_axis_info
|
|
107
|
-
crs = Proj::Crs.new('EPSG:4326')
|
|
108
|
-
cs = crs.coordinate_system
|
|
109
|
-
axis_info = cs.axis_info(0)
|
|
110
|
-
|
|
111
|
-
assert_equal("Geodetic latitude", axis_info.name)
|
|
112
|
-
assert_equal("Lat", axis_info.abbreviation)
|
|
113
|
-
assert_equal("north", axis_info.direction)
|
|
114
|
-
assert_equal(0.017453292519943295, axis_info.unit_conv_factor)
|
|
115
|
-
assert_equal("degree", axis_info.unit_name)
|
|
116
|
-
assert_equal("EPSG", axis_info.unit_auth_name)
|
|
117
|
-
assert_equal("9122", axis_info.unit_code)
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
def
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
assert_equal(
|
|
143
|
-
|
|
144
|
-
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
|
|
3
|
+
require_relative './abstract_test'
|
|
4
|
+
|
|
5
|
+
class CoordinateSystemTest < AbstractTest
|
|
6
|
+
def test_create
|
|
7
|
+
context = Proj::Context.new
|
|
8
|
+
crs = Proj::Crs.new('EPSG:4326', context)
|
|
9
|
+
cs = crs.coordinate_system
|
|
10
|
+
axes = cs.axes
|
|
11
|
+
cs = Proj::CoordinateSystem.create(cs.cs_type, axes, context)
|
|
12
|
+
assert_equal(2, cs.axis_count)
|
|
13
|
+
assert_equal(:PJ_CS_TYPE_ELLIPSOIDAL, cs.cs_type)
|
|
14
|
+
assert_equal(:PJ_TYPE_UNKNOWN, cs.proj_type)
|
|
15
|
+
refute(cs.auth_name)
|
|
16
|
+
refute(cs.id_code)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def test_create_ellipsoidal_2d
|
|
20
|
+
context = Proj::Context.new
|
|
21
|
+
cs = Proj::CoordinateSystem.create_ellipsoidal_2d(:PJ_ELLPS2D_LONGITUDE_LATITUDE, context)
|
|
22
|
+
assert_equal(2, cs.axis_count)
|
|
23
|
+
assert_equal(:PJ_CS_TYPE_ELLIPSOIDAL, cs.cs_type)
|
|
24
|
+
assert_equal(:PJ_TYPE_UNKNOWN, cs.proj_type)
|
|
25
|
+
refute(cs.auth_name)
|
|
26
|
+
refute(cs.id_code)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def test_create_ellipsoidal_3d
|
|
30
|
+
context = Proj::Context.new
|
|
31
|
+
cs = Proj::CoordinateSystem.create_ellipsoidal_3d(:PJ_ELLPS3D_LATITUDE_LONGITUDE_HEIGHT, context)
|
|
32
|
+
assert_equal(3, cs.axis_count)
|
|
33
|
+
assert_equal(:PJ_CS_TYPE_ELLIPSOIDAL, cs.cs_type)
|
|
34
|
+
assert_equal(:PJ_TYPE_UNKNOWN, cs.proj_type)
|
|
35
|
+
|
|
36
|
+
axis = cs.axis_info(0)
|
|
37
|
+
assert_equal("Latitude", axis.name)
|
|
38
|
+
assert_equal("lat", axis.abbreviation)
|
|
39
|
+
assert_equal("north", axis.direction)
|
|
40
|
+
assert_equal("degree", axis.unit_name)
|
|
41
|
+
assert_in_delta(0.017453292519943295, axis.unit_conv_factor)
|
|
42
|
+
|
|
43
|
+
axis = cs.axis_info(1)
|
|
44
|
+
assert_equal("Longitude", axis.name)
|
|
45
|
+
assert_equal("lon", axis.abbreviation)
|
|
46
|
+
assert_equal("east", axis.direction)
|
|
47
|
+
assert_equal("degree", axis.unit_name)
|
|
48
|
+
assert_in_delta(0.017453292519943295, axis.unit_conv_factor)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def test_create_ellipsoidal_3d_custom_units
|
|
52
|
+
context = Proj::Context.new
|
|
53
|
+
cs = Proj::CoordinateSystem.create_ellipsoidal_3d(:PJ_ELLPS3D_LATITUDE_LONGITUDE_HEIGHT, context,
|
|
54
|
+
horizontal_angular_unit_name: "foo", horizontal_angular_unit_conv_factor: 0.5,
|
|
55
|
+
vertical_linear_unit_name: "bar", vertical_linear_unit_conv_factor: 0.6)
|
|
56
|
+
assert_equal(3, cs.axis_count)
|
|
57
|
+
assert_equal(:PJ_CS_TYPE_ELLIPSOIDAL, cs.cs_type)
|
|
58
|
+
assert_equal(:PJ_TYPE_UNKNOWN, cs.proj_type)
|
|
59
|
+
|
|
60
|
+
axis = cs.axis_info(0)
|
|
61
|
+
assert_equal("Latitude", axis.name)
|
|
62
|
+
assert_equal("lat", axis.abbreviation)
|
|
63
|
+
assert_equal("north", axis.direction)
|
|
64
|
+
assert_equal("foo", axis.unit_name)
|
|
65
|
+
assert_equal(0.5, axis.unit_conv_factor)
|
|
66
|
+
|
|
67
|
+
axis = cs.axis_info(1)
|
|
68
|
+
assert_equal("Longitude", axis.name)
|
|
69
|
+
assert_equal("lon", axis.abbreviation)
|
|
70
|
+
assert_equal("east", axis.direction)
|
|
71
|
+
assert_equal("foo", axis.unit_name)
|
|
72
|
+
assert_equal(0.5, axis.unit_conv_factor)
|
|
73
|
+
|
|
74
|
+
axis = cs.axis_info(2)
|
|
75
|
+
assert_equal("Ellipsoidal height", axis.name)
|
|
76
|
+
assert_equal("h", axis.abbreviation)
|
|
77
|
+
assert_equal("up", axis.direction)
|
|
78
|
+
assert_equal("bar", axis.unit_name)
|
|
79
|
+
assert_equal(0.6, axis.unit_conv_factor)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def test_create_cartesian
|
|
83
|
+
context = Proj::Context.new
|
|
84
|
+
coordinate_system = Proj::CoordinateSystem.create_cartesian_2d(context, :PJ_CART2D_EASTING_NORTHING)
|
|
85
|
+
assert_equal(2, coordinate_system.axis_count)
|
|
86
|
+
assert_equal(:PJ_CS_TYPE_CARTESIAN, coordinate_system.cs_type)
|
|
87
|
+
assert_equal(:PJ_TYPE_UNKNOWN, coordinate_system.proj_type)
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def test_type
|
|
91
|
+
crs = Proj::Crs.new('EPSG:4326')
|
|
92
|
+
cs = crs.coordinate_system
|
|
93
|
+
refute(cs.name)
|
|
94
|
+
assert_equal(:PJ_CS_TYPE_ELLIPSOIDAL, cs.cs_type)
|
|
95
|
+
assert_equal(:PJ_TYPE_UNKNOWN, cs.proj_type)
|
|
96
|
+
assert_equal("EPSG", cs.auth_name)
|
|
97
|
+
assert_equal("6422", cs.id_code)
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def test_axis_count
|
|
101
|
+
crs = Proj::Crs.new('EPSG:4326')
|
|
102
|
+
cs = crs.coordinate_system
|
|
103
|
+
assert_equal(2, cs.axis_count)
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def test_axis_info
|
|
107
|
+
crs = Proj::Crs.new('EPSG:4326')
|
|
108
|
+
cs = crs.coordinate_system
|
|
109
|
+
axis_info = cs.axis_info(0)
|
|
110
|
+
|
|
111
|
+
assert_equal("Geodetic latitude", axis_info.name)
|
|
112
|
+
assert_equal("Lat", axis_info.abbreviation)
|
|
113
|
+
assert_equal("north", axis_info.direction)
|
|
114
|
+
assert_equal(0.017453292519943295, axis_info.unit_conv_factor)
|
|
115
|
+
assert_equal("degree", axis_info.unit_name)
|
|
116
|
+
assert_equal("EPSG", axis_info.unit_auth_name)
|
|
117
|
+
assert_equal("9122", axis_info.unit_code)
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
def test_axis_info_to_description_uses_unit_name
|
|
121
|
+
axis_info = Proj::AxisInfo.new(name: "Latitude", abbreviation: "lat", direction: "north",
|
|
122
|
+
unit_conv_factor: 0.017453292519943295, unit_name: "degree",
|
|
123
|
+
unit_auth_name: "EPSG", unit_code: "9122")
|
|
124
|
+
description = axis_info.to_description
|
|
125
|
+
assert_equal("degree", description[:unit_name].read_string_to_null)
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
def test_axis_description_retains_string_pointers
|
|
129
|
+
description = Proj::Api::PjAxisDescription.create(name: "Latitude", abbreviation: "lat",
|
|
130
|
+
direction: "north", unit_name: "degree",
|
|
131
|
+
unit_conv_factor: 0.017453292519943295,
|
|
132
|
+
unit_type: :PJ_UT_ANGULAR)
|
|
133
|
+
retained_ptrs = description.instance_variable_get(:@retained_ptrs)
|
|
134
|
+
assert_instance_of(Array, retained_ptrs)
|
|
135
|
+
assert_equal(4, retained_ptrs.size)
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
def test_axes
|
|
139
|
+
crs = Proj::Crs.new('EPSG:4326')
|
|
140
|
+
cs = crs.coordinate_system
|
|
141
|
+
axes = cs.axes
|
|
142
|
+
assert_equal(2, axes.count)
|
|
143
|
+
|
|
144
|
+
axis_info = axes[0]
|
|
145
|
+
assert_equal("Geodetic latitude", axis_info.name)
|
|
146
|
+
assert_equal("Lat", axis_info.abbreviation)
|
|
147
|
+
assert_equal("north", axis_info.direction)
|
|
148
|
+
assert_equal(0.017453292519943295, axis_info.unit_conv_factor)
|
|
149
|
+
assert_equal("degree", axis_info.unit_name)
|
|
150
|
+
assert_equal("EPSG", axis_info.unit_auth_name)
|
|
151
|
+
assert_equal("9122", axis_info.unit_code)
|
|
152
|
+
|
|
153
|
+
axis_info = axes[1]
|
|
154
|
+
assert_equal("Geodetic longitude", axis_info.name)
|
|
155
|
+
assert_equal("Lon", axis_info.abbreviation)
|
|
156
|
+
assert_equal("east", axis_info.direction)
|
|
157
|
+
assert_equal(0.017453292519943295, axis_info.unit_conv_factor)
|
|
158
|
+
assert_equal("degree", axis_info.unit_name)
|
|
159
|
+
assert_equal("EPSG", axis_info.unit_auth_name)
|
|
160
|
+
assert_equal("9122", axis_info.unit_code)
|
|
161
|
+
end
|
|
162
|
+
end
|
data/test/coordinate_test.rb
CHANGED
|
@@ -1,35 +1,290 @@
|
|
|
1
|
-
# encoding: UTF-8
|
|
2
|
-
|
|
3
|
-
require_relative './abstract_test'
|
|
4
|
-
|
|
5
|
-
class CoordinateTest < AbstractTest
|
|
6
|
-
def test_create_xyzt
|
|
7
|
-
coord = Proj::Coordinate.new(:x => 1, :y => 2, :z => 3, :t => 4)
|
|
8
|
-
assert_equal('v0: 1.0, v1: 2.0, v2: 3.0, v3: 4.0', coord.to_s)
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def test_create_uvwt
|
|
12
|
-
coord = Proj::Coordinate.new(:u => 5, :v => 6, :w => 7, :t => 8)
|
|
13
|
-
assert_equal('v0: 5.0, v1: 6.0, v2: 7.0, v3: 8.0', coord.to_s)
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def test_create_lpzt
|
|
17
|
-
coord = Proj::Coordinate.new(:lam => 9, :phi => 10, :z => 11, :t => 12)
|
|
18
|
-
assert_equal('v0: 9.0, v1: 10.0, v2: 11.0, v3: 12.0', coord.to_s)
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def test_create_geod
|
|
22
|
-
coord = Proj::Coordinate.new(:s => 13, :a1 => 14, :a2 => 15)
|
|
23
|
-
assert_equal('v0: 13.0, v1: 14.0, v2: 15.0, v3: 0.0', coord.to_s)
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def test_create_opk
|
|
27
|
-
coord = Proj::Coordinate.new(:o => 16, :p => 17, :k => 18)
|
|
28
|
-
assert_equal('v0: 16.0, v1: 17.0, v2: 18.0, v3: 0.0', coord.to_s)
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def test_create_enu
|
|
32
|
-
coord = Proj::Coordinate.new(:e => 19, :n => 20, :u => 21)
|
|
33
|
-
assert_equal('v0: 19.0, v1: 20.0, v2: 21.0, v3: 0.0', coord.to_s)
|
|
34
|
-
end
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
|
|
3
|
+
require_relative './abstract_test'
|
|
4
|
+
|
|
5
|
+
class CoordinateTest < AbstractTest
|
|
6
|
+
def test_create_xyzt
|
|
7
|
+
coord = Proj::Coordinate.new(:x => 1, :y => 2, :z => 3, :t => 4)
|
|
8
|
+
assert_equal('v0: 1.0, v1: 2.0, v2: 3.0, v3: 4.0', coord.to_s)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def test_create_uvwt
|
|
12
|
+
coord = Proj::Coordinate.new(:u => 5, :v => 6, :w => 7, :t => 8)
|
|
13
|
+
assert_equal('v0: 5.0, v1: 6.0, v2: 7.0, v3: 8.0', coord.to_s)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def test_create_lpzt
|
|
17
|
+
coord = Proj::Coordinate.new(:lam => 9, :phi => 10, :z => 11, :t => 12)
|
|
18
|
+
assert_equal('v0: 9.0, v1: 10.0, v2: 11.0, v3: 12.0', coord.to_s)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def test_create_geod
|
|
22
|
+
coord = Proj::Coordinate.new(:s => 13, :a1 => 14, :a2 => 15)
|
|
23
|
+
assert_equal('v0: 13.0, v1: 14.0, v2: 15.0, v3: 0.0', coord.to_s)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def test_create_opk
|
|
27
|
+
coord = Proj::Coordinate.new(:o => 16, :p => 17, :k => 18)
|
|
28
|
+
assert_equal('v0: 16.0, v1: 17.0, v2: 18.0, v3: 0.0', coord.to_s)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def test_create_enu
|
|
32
|
+
coord = Proj::Coordinate.new(:e => 19, :n => 20, :u => 21)
|
|
33
|
+
assert_equal('v0: 19.0, v1: 20.0, v2: 21.0, v3: 0.0', coord.to_s)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def test_eql
|
|
37
|
+
coord1 = Proj::Coordinate.new(x: 1, y: 2, z: 3, t: 4)
|
|
38
|
+
coord2 = Proj::Coordinate.new(x: 1, y: 2, z: 3, t: 4)
|
|
39
|
+
assert(coord1.eql?(coord2))
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def test_eql_different
|
|
43
|
+
coord1 = Proj::Coordinate.new(x: 1, y: 2)
|
|
44
|
+
coord2 = Proj::Coordinate.new(x: 1, y: 3)
|
|
45
|
+
refute(coord1.eql?(coord2))
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def test_eql_non_coordinate
|
|
49
|
+
coord = Proj::Coordinate.new(x: 1, y: 2)
|
|
50
|
+
refute(coord.eql?("not a coordinate"))
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def test_equal
|
|
54
|
+
coord1 = Proj::Coordinate.new(x: 1, y: 2, z: 3, t: 4)
|
|
55
|
+
coord2 = Proj::Coordinate.new(x: 1, y: 2, z: 3, t: 4)
|
|
56
|
+
assert_equal(coord1, coord2)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def test_not_equal
|
|
60
|
+
coord1 = Proj::Coordinate.new(x: 1, y: 2)
|
|
61
|
+
coord2 = Proj::Coordinate.new(x: 1, y: 3)
|
|
62
|
+
refute_equal(coord1, coord2)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def test_equal_non_coordinate
|
|
66
|
+
coord = Proj::Coordinate.new(x: 1, y: 2)
|
|
67
|
+
refute_equal(coord, "not a coordinate")
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def test_xyzt_accessor
|
|
71
|
+
coord = Proj::Coordinate.new(x: 1, y: 2, z: 3, t: 4)
|
|
72
|
+
xyzt = coord.xyzt
|
|
73
|
+
assert_equal(1.0, xyzt[:x])
|
|
74
|
+
assert_equal(2.0, xyzt[:y])
|
|
75
|
+
assert_equal(3.0, xyzt[:z])
|
|
76
|
+
assert_equal(4.0, xyzt[:t])
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def test_xyz_accessor
|
|
80
|
+
coord = Proj::Coordinate.new(x: 1, y: 2, z: 3)
|
|
81
|
+
xyz = coord.xyz
|
|
82
|
+
assert_equal(1.0, xyz[:x])
|
|
83
|
+
assert_equal(2.0, xyz[:y])
|
|
84
|
+
assert_equal(3.0, xyz[:z])
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def test_xy_accessor
|
|
88
|
+
coord = Proj::Coordinate.new(x: 1, y: 2)
|
|
89
|
+
xy = coord.xy
|
|
90
|
+
assert_equal(1.0, xy[:x])
|
|
91
|
+
assert_equal(2.0, xy[:y])
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def test_uvwt_accessor
|
|
95
|
+
coord = Proj::Coordinate.new(u: 5, v: 6, w: 7, t: 8)
|
|
96
|
+
uvwt = coord.uvwt
|
|
97
|
+
assert_equal(5.0, uvwt[:u])
|
|
98
|
+
assert_equal(6.0, uvwt[:v])
|
|
99
|
+
assert_equal(7.0, uvwt[:w])
|
|
100
|
+
assert_equal(8.0, uvwt[:t])
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
def test_uvw_accessor
|
|
104
|
+
coord = Proj::Coordinate.new(u: 5, v: 6, w: 7)
|
|
105
|
+
uvw = coord.uvw
|
|
106
|
+
assert_equal(5.0, uvw[:u])
|
|
107
|
+
assert_equal(6.0, uvw[:v])
|
|
108
|
+
assert_equal(7.0, uvw[:w])
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def test_uv_accessor
|
|
112
|
+
coord = Proj::Coordinate.new(u: 5, v: 6)
|
|
113
|
+
uv = coord.uv
|
|
114
|
+
assert_equal(5.0, uv[:u])
|
|
115
|
+
assert_equal(6.0, uv[:v])
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
def test_lpzt_accessor
|
|
119
|
+
coord = Proj::Coordinate.new(lam: 9, phi: 10, z: 11, t: 12)
|
|
120
|
+
lpzt = coord.lpzt
|
|
121
|
+
assert_equal(9.0, lpzt[:lam])
|
|
122
|
+
assert_equal(10.0, lpzt[:phi])
|
|
123
|
+
assert_equal(11.0, lpzt[:z])
|
|
124
|
+
assert_equal(12.0, lpzt[:t])
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
def test_lpz_accessor
|
|
128
|
+
coord = Proj::Coordinate.new(lam: 9, phi: 10, z: 11)
|
|
129
|
+
lpz = coord.lpz
|
|
130
|
+
assert_equal(9.0, lpz[:lam])
|
|
131
|
+
assert_equal(10.0, lpz[:phi])
|
|
132
|
+
assert_equal(11.0, lpz[:z])
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
def test_lp_accessor
|
|
136
|
+
coord = Proj::Coordinate.new(lam: 9, phi: 10)
|
|
137
|
+
lp = coord.lp
|
|
138
|
+
assert_equal(9.0, lp[:lam])
|
|
139
|
+
assert_equal(10.0, lp[:phi])
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
def test_enu_accessor
|
|
143
|
+
coord = Proj::Coordinate.new(e: 19, n: 20, u: 21)
|
|
144
|
+
enu = coord.enu
|
|
145
|
+
assert_equal(19.0, enu[:e])
|
|
146
|
+
assert_equal(20.0, enu[:n])
|
|
147
|
+
assert_equal(21.0, enu[:u])
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
def test_geod_accessor
|
|
151
|
+
coord = Proj::Coordinate.new(s: 13, a1: 14, a2: 15)
|
|
152
|
+
geod = coord.geod
|
|
153
|
+
assert_equal(13.0, geod[:s])
|
|
154
|
+
assert_equal(14.0, geod[:a1])
|
|
155
|
+
assert_equal(15.0, geod[:a2])
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
def test_opk_accessor
|
|
159
|
+
coord = Proj::Coordinate.new(o: 16, p: 17, k: 18)
|
|
160
|
+
opk = coord.opk
|
|
161
|
+
assert_equal(16.0, opk[:o])
|
|
162
|
+
assert_equal(17.0, opk[:p])
|
|
163
|
+
assert_equal(18.0, opk[:k])
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
# Constructor branch coverage
|
|
167
|
+
|
|
168
|
+
def test_create_xyz
|
|
169
|
+
coord = Proj::Coordinate.new(x: 1, y: 2, z: 3)
|
|
170
|
+
assert_equal(1.0, coord.x)
|
|
171
|
+
assert_equal(2.0, coord.y)
|
|
172
|
+
assert_equal(3.0, coord.z)
|
|
173
|
+
assert_equal(0.0, coord.t)
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
def test_create_xy
|
|
177
|
+
coord = Proj::Coordinate.new(x: 1, y: 2)
|
|
178
|
+
assert_equal(1.0, coord.x)
|
|
179
|
+
assert_equal(2.0, coord.y)
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
def test_create_uv
|
|
183
|
+
coord = Proj::Coordinate.new(u: 5, v: 6)
|
|
184
|
+
assert_equal(5.0, coord.u)
|
|
185
|
+
assert_equal(6.0, coord.v)
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
def test_create_uvw
|
|
189
|
+
coord = Proj::Coordinate.new(u: 5, v: 6, w: 7)
|
|
190
|
+
assert_equal(5.0, coord.u)
|
|
191
|
+
assert_equal(6.0, coord.v)
|
|
192
|
+
assert_equal(7.0, coord.w)
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
def test_create_lp
|
|
196
|
+
coord = Proj::Coordinate.new(lam: 9, phi: 10)
|
|
197
|
+
assert_equal(9.0, coord.lam)
|
|
198
|
+
assert_equal(10.0, coord.phi)
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
def test_create_lpz
|
|
202
|
+
coord = Proj::Coordinate.new(lam: 9, phi: 10, z: 11)
|
|
203
|
+
assert_equal(9.0, coord.lam)
|
|
204
|
+
assert_equal(10.0, coord.phi)
|
|
205
|
+
assert_equal(11.0, coord.z)
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
def test_create_lonlat
|
|
209
|
+
coord = Proj::Coordinate.new(lon: 9, lat: 10)
|
|
210
|
+
assert_equal(9.0, coord.lon)
|
|
211
|
+
assert_equal(10.0, coord.lat)
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
def test_create_lonlatz
|
|
215
|
+
coord = Proj::Coordinate.new(lon: 9, lat: 10, z: 11)
|
|
216
|
+
assert_equal(9.0, coord.lon)
|
|
217
|
+
assert_equal(10.0, coord.lat)
|
|
218
|
+
assert_equal(11.0, coord.z)
|
|
219
|
+
end
|
|
220
|
+
|
|
221
|
+
def test_create_lonlatzt
|
|
222
|
+
coord = Proj::Coordinate.new(lon: 9, lat: 10, z: 11, t: 12)
|
|
223
|
+
assert_equal(9.0, coord.lon)
|
|
224
|
+
assert_equal(10.0, coord.lat)
|
|
225
|
+
assert_equal(11.0, coord.z)
|
|
226
|
+
assert_equal(12.0, coord.t)
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
def test_create_empty
|
|
230
|
+
coord = Proj::Coordinate.new
|
|
231
|
+
assert_equal(0.0, coord.x)
|
|
232
|
+
assert_equal(0.0, coord.y)
|
|
233
|
+
assert_equal(0.0, coord.z)
|
|
234
|
+
assert_equal(0.0, coord.t)
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
# Individual value accessors
|
|
238
|
+
|
|
239
|
+
def test_xyzt_values
|
|
240
|
+
coord = Proj::Coordinate.new(x: 1, y: 2, z: 3, t: 4)
|
|
241
|
+
assert_equal(1.0, coord.x)
|
|
242
|
+
assert_equal(2.0, coord.y)
|
|
243
|
+
assert_equal(3.0, coord.z)
|
|
244
|
+
assert_equal(4.0, coord.t)
|
|
245
|
+
end
|
|
246
|
+
|
|
247
|
+
def test_uvw_values
|
|
248
|
+
coord = Proj::Coordinate.new(u: 5, v: 6, w: 7)
|
|
249
|
+
assert_equal(5.0, coord.u)
|
|
250
|
+
assert_equal(6.0, coord.v)
|
|
251
|
+
assert_equal(7.0, coord.w)
|
|
252
|
+
end
|
|
253
|
+
|
|
254
|
+
def test_lonlat_values
|
|
255
|
+
coord = Proj::Coordinate.new(lon: 9, lat: 10)
|
|
256
|
+
assert_equal(9.0, coord.lon)
|
|
257
|
+
assert_equal(10.0, coord.lat)
|
|
258
|
+
end
|
|
259
|
+
|
|
260
|
+
def test_lamphi_values
|
|
261
|
+
coord = Proj::Coordinate.new(lam: 9, phi: 10)
|
|
262
|
+
assert_equal(9.0, coord.lam)
|
|
263
|
+
assert_equal(10.0, coord.phi)
|
|
264
|
+
end
|
|
265
|
+
|
|
266
|
+
def test_opk_values
|
|
267
|
+
coord = Proj::Coordinate.new(o: 16, p: 17, k: 18)
|
|
268
|
+
assert_equal(16.0, coord.o)
|
|
269
|
+
assert_equal(17.0, coord.p)
|
|
270
|
+
assert_equal(18.0, coord.k)
|
|
271
|
+
end
|
|
272
|
+
|
|
273
|
+
def test_enu_values
|
|
274
|
+
coord = Proj::Coordinate.new(e: 19, n: 20, u: 21)
|
|
275
|
+
assert_equal(19.0, coord.e)
|
|
276
|
+
assert_equal(20.0, coord.n)
|
|
277
|
+
end
|
|
278
|
+
|
|
279
|
+
def test_geod_values
|
|
280
|
+
coord = Proj::Coordinate.new(s: 13, a1: 14, a2: 15)
|
|
281
|
+
assert_equal(13.0, coord.s)
|
|
282
|
+
assert_equal(14.0, coord.a1)
|
|
283
|
+
assert_equal(15.0, coord.a2)
|
|
284
|
+
end
|
|
285
|
+
|
|
286
|
+
def test_to_s
|
|
287
|
+
coord = Proj::Coordinate.new(x: 1, y: 2, z: 3, t: 4)
|
|
288
|
+
assert_equal("v0: 1.0, v1: 2.0, v2: 3.0, v3: 4.0", coord.to_s)
|
|
289
|
+
end
|
|
35
290
|
end
|