-
Notifications
You must be signed in to change notification settings - Fork 213
/
test_crs_coordinate_operation.py
791 lines (688 loc) · 25 KB
/
test_crs_coordinate_operation.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
import pytest
from numpy.testing import assert_almost_equal
from pyproj.crs import GeographicCRS
from pyproj.crs.coordinate_operation import (
AlbersEqualAreaConversion,
AzimuthalEquidistantConversion,
AzumuthalEquidistantConversion,
EquidistantCylindricalConversion,
GeostationarySatelliteConversion,
HotineObliqueMercatorBConversion,
LambertAzimuthalEqualAreaConversion,
LambertAzumuthalEqualAreaConversion,
LambertConformalConic1SPConversion,
LambertConformalConic2SPConversion,
LambertCylindricalEqualAreaConversion,
LambertCylindricalEqualAreaScaleConversion,
MercatorAConversion,
MercatorBConversion,
OrthographicConversion,
PlateCarreeConversion,
PolarStereographicAConversion,
PolarStereographicBConversion,
PoleRotationNetCDFCFConversion,
RotatedLatitudeLongitudeConversion,
SinusoidalConversion,
StereographicConversion,
ToWGS84Transformation,
TransverseMercatorConversion,
UTMConversion,
VerticalPerspectiveConversion,
)
from pyproj.exceptions import CRSError
from test.conftest import PROJ_GTE_82
def _to_dict(operation):
param_dict = {}
for param in operation.params:
param_dict[param.name] = param.value
return param_dict
def test_albers_equal_area_operation__defaults():
aeaop = AlbersEqualAreaConversion(
latitude_first_parallel=1, latitude_second_parallel=2
)
assert aeaop.name == "unknown"
assert aeaop.method_name == "Albers Equal Area"
assert _to_dict(aeaop) == {
"Easting at false origin": 0.0,
"Latitude of 1st standard parallel": 1.0,
"Latitude of 2nd standard parallel": 2.0,
"Latitude of false origin": 0.0,
"Longitude of false origin": 0.0,
"Northing at false origin": 0.0,
}
def test_albers_equal_area_operation():
aeaop = AlbersEqualAreaConversion(
latitude_first_parallel=1,
latitude_second_parallel=2,
latitude_false_origin=3,
longitude_false_origin=4,
easting_false_origin=5,
northing_false_origin=6,
)
assert aeaop.name == "unknown"
assert aeaop.method_name == "Albers Equal Area"
assert _to_dict(aeaop) == {
"Easting at false origin": 5.0,
"Latitude of 1st standard parallel": 1.0,
"Latitude of 2nd standard parallel": 2.0,
"Latitude of false origin": 3.0,
"Longitude of false origin": 4.0,
"Northing at false origin": 6.0,
}
def test_azumuthal_equidistant_operation__defaults():
with pytest.warns(FutureWarning, match="deprecated"):
aeop = AzumuthalEquidistantConversion()
assert aeop.name == "unknown"
assert aeop.method_name == "Modified Azimuthal Equidistant"
assert _to_dict(aeop) == {
"Latitude of natural origin": 0.0,
"Longitude of natural origin": 0.0,
"False easting": 0.0,
"False northing": 0.0,
}
def test_azimuthal_equidistant_operation__defaults():
aeop = AzimuthalEquidistantConversion()
assert aeop.name == "unknown"
assert aeop.method_name == "Modified Azimuthal Equidistant"
assert _to_dict(aeop) == {
"Latitude of natural origin": 0.0,
"Longitude of natural origin": 0.0,
"False easting": 0.0,
"False northing": 0.0,
}
def test_azimuthal_equidistant_operation():
aeop = AzimuthalEquidistantConversion(
latitude_natural_origin=1,
longitude_natural_origin=2,
false_easting=3,
false_northing=4,
)
assert aeop.name == "unknown"
assert aeop.method_name == "Modified Azimuthal Equidistant"
assert _to_dict(aeop) == {
"Latitude of natural origin": 1.0,
"Longitude of natural origin": 2.0,
"False easting": 3.0,
"False northing": 4.0,
}
def test_geostationary_operation__defaults():
geop = GeostationarySatelliteConversion(sweep_angle_axis="x", satellite_height=10)
assert geop.name == "unknown"
assert geop.method_name == "Geostationary Satellite (Sweep X)"
assert _to_dict(geop) == {
"Latitude of natural origin": 0.0,
"Longitude of natural origin": 0.0,
"False easting": 0.0,
"False northing": 0.0,
"Satellite height": 10.0,
}
def test_geostationary_operation():
with pytest.warns(UserWarning):
geop = GeostationarySatelliteConversion(
sweep_angle_axis="y",
satellite_height=11,
latitude_natural_origin=1,
longitude_natural_origin=2,
false_easting=3,
false_northing=4,
)
assert geop.name == "unknown"
assert geop.method_name == "Geostationary Satellite (Sweep Y)"
assert _to_dict(geop) == {
"Latitude of natural origin": 1.0,
"Longitude of natural origin": 2.0,
"False easting": 3.0,
"False northing": 4.0,
"Satellite height": 11.0,
}
def test_geostationary_operation__invalid_sweep():
with pytest.raises(CRSError):
GeostationarySatelliteConversion(sweep_angle_axis="P", satellite_height=10)
def test_lambert_azumuthal_equal_area_operation__defaults():
with pytest.warns(FutureWarning, match="deprecated"):
aeop = LambertAzumuthalEqualAreaConversion()
assert aeop.name == "unknown"
assert aeop.method_name == "Lambert Azimuthal Equal Area"
assert _to_dict(aeop) == {
"Latitude of natural origin": 0.0,
"Longitude of natural origin": 0.0,
"False easting": 0.0,
"False northing": 0.0,
}
def test_lambert_azimuthal_equal_area_operation__defaults():
aeop = LambertAzimuthalEqualAreaConversion()
assert aeop.name == "unknown"
assert aeop.method_name == "Lambert Azimuthal Equal Area"
assert _to_dict(aeop) == {
"Latitude of natural origin": 0.0,
"Longitude of natural origin": 0.0,
"False easting": 0.0,
"False northing": 0.0,
}
def test_lambert_azimuthal_equal_area_operation():
aeop = LambertAzimuthalEqualAreaConversion(
latitude_natural_origin=1,
longitude_natural_origin=2,
false_easting=3,
false_northing=4,
)
assert aeop.name == "unknown"
assert aeop.method_name == "Lambert Azimuthal Equal Area"
assert _to_dict(aeop) == {
"Latitude of natural origin": 1.0,
"Longitude of natural origin": 2.0,
"False easting": 3.0,
"False northing": 4.0,
}
def test_lambert_conformat_conic_2sp_operation__defaults():
aeaop = LambertConformalConic2SPConversion(
latitude_first_parallel=1, latitude_second_parallel=2
)
assert aeaop.name == "unknown"
assert aeaop.method_name == "Lambert Conic Conformal (2SP)"
assert _to_dict(aeaop) == {
"Easting at false origin": 0.0,
"Latitude of 1st standard parallel": 1.0,
"Latitude of 2nd standard parallel": 2.0,
"Latitude of false origin": 0.0,
"Longitude of false origin": 0.0,
"Northing at false origin": 0.0,
}
def test_lambert_conformat_conic_2sp_operation():
aeaop = LambertConformalConic2SPConversion(
latitude_first_parallel=1,
latitude_second_parallel=2,
latitude_false_origin=3,
longitude_false_origin=4,
easting_false_origin=5,
northing_false_origin=6,
)
assert aeaop.name == "unknown"
assert aeaop.method_name == "Lambert Conic Conformal (2SP)"
assert _to_dict(aeaop) == {
"Easting at false origin": 5.0,
"Latitude of 1st standard parallel": 1.0,
"Latitude of 2nd standard parallel": 2.0,
"Latitude of false origin": 3.0,
"Longitude of false origin": 4.0,
"Northing at false origin": 6.0,
}
def test_lambert_conformat_conic_1sp_operation__defaults():
aeaop = LambertConformalConic1SPConversion()
assert aeaop.name == "unknown"
assert aeaop.method_name == "Lambert Conic Conformal (1SP)"
assert _to_dict(aeaop) == {
"Latitude of natural origin": 0.0,
"Longitude of natural origin": 0.0,
"False easting": 0.0,
"False northing": 0.0,
"Scale factor at natural origin": 1.0,
}
def test_lambert_conformat_conic_1sp_operation():
aeaop = LambertConformalConic1SPConversion(
latitude_natural_origin=1,
longitude_natural_origin=2,
false_easting=3,
false_northing=4,
scale_factor_natural_origin=0.5,
)
assert aeaop.name == "unknown"
assert aeaop.method_name == "Lambert Conic Conformal (1SP)"
assert _to_dict(aeaop) == {
"Latitude of natural origin": 1.0,
"Longitude of natural origin": 2.0,
"False easting": 3.0,
"False northing": 4.0,
"Scale factor at natural origin": 0.5,
}
def test_lambert_cylindrical_area_operation__defaults():
lceaop = LambertCylindricalEqualAreaConversion()
assert lceaop.name == "unknown"
assert lceaop.method_name == "Lambert Cylindrical Equal Area"
assert _to_dict(lceaop) == {
"Latitude of 1st standard parallel": 0.0,
"Longitude of natural origin": 0.0,
"False easting": 0.0,
"False northing": 0.0,
}
def test_lambert_cylindrical_equal_area_operation():
lceaop = LambertCylindricalEqualAreaConversion(
latitude_first_parallel=1,
longitude_natural_origin=2,
false_easting=3,
false_northing=4,
)
assert lceaop.name == "unknown"
assert lceaop.method_name == "Lambert Cylindrical Equal Area"
assert _to_dict(lceaop) == {
"Latitude of 1st standard parallel": 1.0,
"Longitude of natural origin": 2.0,
"False easting": 3.0,
"False northing": 4.0,
}
def test_mercator_a_operation__defaults():
aeaop = MercatorAConversion()
assert aeaop.name == "unknown"
assert aeaop.method_name == "Mercator (variant A)"
assert _to_dict(aeaop) == {
"Latitude of natural origin": 0.0,
"Longitude of natural origin": 0.0,
"False easting": 0.0,
"False northing": 0.0,
"Scale factor at natural origin": 1.0,
}
def test_mercator_a_operation():
aeaop = MercatorAConversion(
latitude_natural_origin=0,
longitude_natural_origin=2,
false_easting=3,
false_northing=4,
scale_factor_natural_origin=0.5,
)
assert aeaop.name == "unknown"
assert aeaop.method_name == "Mercator (variant A)"
assert _to_dict(aeaop) == {
"Latitude of natural origin": 0.0,
"Longitude of natural origin": 2.0,
"False easting": 3.0,
"False northing": 4.0,
"Scale factor at natural origin": 0.5,
}
def test_mercator_a_operation__invalid_lat0():
with pytest.raises(CRSError):
MercatorAConversion(latitude_natural_origin=1)
def test_mercator_b_operation__defaults():
lceaop = MercatorBConversion()
assert lceaop.name == "unknown"
assert lceaop.method_name == "Mercator (variant B)"
assert _to_dict(lceaop) == {
"Latitude of 1st standard parallel": 0.0,
"Longitude of natural origin": 0.0,
"False easting": 0.0,
"False northing": 0.0,
}
def test_mercator_b_operation():
lceaop = MercatorBConversion(
latitude_first_parallel=1,
longitude_natural_origin=2,
false_easting=3,
false_northing=4,
)
assert lceaop.name == "unknown"
assert lceaop.method_name == "Mercator (variant B)"
assert _to_dict(lceaop) == {
"Latitude of 1st standard parallel": 1.0,
"Longitude of natural origin": 2.0,
"False easting": 3.0,
"False northing": 4.0,
}
def test_hotline_oblique_mercator_b_operation__defaults():
hop = HotineObliqueMercatorBConversion(
latitude_projection_centre=0,
longitude_projection_centre=0,
azimuth_initial_line=0,
angle_from_rectified_to_skew_grid=0,
)
assert hop.name == "unknown"
assert hop.method_name == "Hotine Oblique Mercator (variant B)"
assert _to_dict(hop) == {
"Latitude of projection centre": 0.0,
"Longitude of projection centre": 0.0,
"Azimuth of initial line": 0.0,
"Angle from Rectified to Skew Grid": 0.0,
"Scale factor on initial line": 1.0,
"Easting at projection centre": 0.0,
"Northing at projection centre": 0.0,
}
def test_hotline_oblique_mercator_b_operation():
hop = HotineObliqueMercatorBConversion(
latitude_projection_centre=1,
longitude_projection_centre=2,
azimuth_initial_line=3,
angle_from_rectified_to_skew_grid=4,
scale_factor_on_initial_line=0.5,
easting_projection_centre=6,
northing_projection_centre=7,
)
assert hop.name == "unknown"
assert hop.method_name == "Hotine Oblique Mercator (variant B)"
assert _to_dict(hop) == {
"Latitude of projection centre": 1.0,
"Longitude of projection centre": 2.0,
"Azimuth of initial line": 3.0,
"Angle from Rectified to Skew Grid": 4.0,
"Scale factor on initial line": 0.5,
"Easting at projection centre": 6.0,
"Northing at projection centre": 7.0,
}
def test_orthographic_operation__defaults():
aeop = OrthographicConversion()
assert aeop.name == "unknown"
assert aeop.method_name == "Orthographic"
assert _to_dict(aeop) == {
"Latitude of natural origin": 0.0,
"Longitude of natural origin": 0.0,
"False easting": 0.0,
"False northing": 0.0,
}
def test_orthographic_operation():
aeop = OrthographicConversion(
latitude_natural_origin=1,
longitude_natural_origin=2,
false_easting=3,
false_northing=4,
)
assert aeop.name == "unknown"
assert aeop.method_name == "Orthographic"
assert _to_dict(aeop) == {
"Latitude of natural origin": 1.0,
"Longitude of natural origin": 2.0,
"False easting": 3.0,
"False northing": 4.0,
}
def test_polar_stereographic_a_operation__defaults():
aeaop = PolarStereographicAConversion(90)
assert aeaop.name == "unknown"
assert aeaop.method_name == "Polar Stereographic (variant A)"
assert _to_dict(aeaop) == {
"Latitude of natural origin": 90.0,
"Longitude of natural origin": 0.0,
"False easting": 0.0,
"False northing": 0.0,
"Scale factor at natural origin": 1.0,
}
def test_polar_stereographic_a_operation():
aeaop = PolarStereographicAConversion(
latitude_natural_origin=-90,
longitude_natural_origin=2,
false_easting=3,
false_northing=4,
scale_factor_natural_origin=0.5,
)
assert aeaop.name == "unknown"
assert aeaop.method_name == "Polar Stereographic (variant A)"
assert _to_dict(aeaop) == {
"Latitude of natural origin": -90.0,
"Longitude of natural origin": 2.0,
"False easting": 3.0,
"False northing": 4.0,
"Scale factor at natural origin": 0.5,
}
def test_polar_stereographic_b_operation__defaults():
aeop = PolarStereographicBConversion()
assert aeop.name == "unknown"
assert aeop.method_name == "Polar Stereographic (variant B)"
assert _to_dict(aeop) == {
"Latitude of standard parallel": 0.0,
"Longitude of origin": 0.0,
"False easting": 0.0,
"False northing": 0.0,
}
def test_polar_stereographic_b_operation():
aeop = PolarStereographicBConversion(
latitude_standard_parallel=1,
longitude_origin=2,
false_easting=3,
false_northing=4,
)
assert aeop.name == "unknown"
assert aeop.method_name == "Polar Stereographic (variant B)"
assert _to_dict(aeop) == {
"Latitude of standard parallel": 1.0,
"Longitude of origin": 2.0,
"False easting": 3.0,
"False northing": 4.0,
}
def test_sinusoidal_operation__defaults():
aeop = SinusoidalConversion()
assert aeop.name == "unknown"
assert aeop.method_name == "Sinusoidal"
assert _to_dict(aeop) == {
"Longitude of natural origin": 0.0,
"False easting": 0.0,
"False northing": 0.0,
}
def test_sinusoidal_operation():
aeop = SinusoidalConversion(
longitude_natural_origin=2, false_easting=3, false_northing=4
)
assert aeop.name == "unknown"
assert aeop.method_name == "Sinusoidal"
assert _to_dict(aeop) == {
"Longitude of natural origin": 2.0,
"False easting": 3.0,
"False northing": 4.0,
}
def test_stereographic_operation__defaults():
aeaop = StereographicConversion()
assert aeaop.name == "unknown"
assert aeaop.method_name == "Stereographic"
assert _to_dict(aeaop) == {
"Latitude of natural origin": 0.0,
"Longitude of natural origin": 0.0,
"False easting": 0.0,
"False northing": 0.0,
"Scale factor at natural origin": 1.0,
}
def test_stereographic_operation():
aeaop = StereographicConversion(
latitude_natural_origin=1,
longitude_natural_origin=2,
false_easting=3,
false_northing=4,
scale_factor_natural_origin=0.5,
)
assert aeaop.name == "unknown"
assert aeaop.method_name == "Stereographic"
assert _to_dict(aeaop) == {
"Latitude of natural origin": 1.0,
"Longitude of natural origin": 2.0,
"False easting": 3.0,
"False northing": 4.0,
"Scale factor at natural origin": 0.5,
}
def test_utm_operation__defaults():
aeop = UTMConversion(zone=2)
assert aeop.name == "UTM zone 2N"
assert aeop.method_name == "Transverse Mercator"
def test_utm_operation():
aeop = UTMConversion(zone=2, hemisphere="s")
assert aeop.name == "UTM zone 2S"
assert aeop.method_name == "Transverse Mercator"
def test_transverse_mercator_operation__defaults():
aeaop = TransverseMercatorConversion()
assert aeaop.name == "unknown"
assert aeaop.method_name == "Transverse Mercator"
assert _to_dict(aeaop) == {
"Latitude of natural origin": 0.0,
"Longitude of natural origin": 0.0,
"False easting": 0.0,
"False northing": 0.0,
"Scale factor at natural origin": 1.0,
}
def test_transverse_mercator_operation():
aeaop = TransverseMercatorConversion(
latitude_natural_origin=1,
longitude_natural_origin=2,
false_easting=3,
false_northing=4,
scale_factor_natural_origin=0.5,
)
assert aeaop.name == "unknown"
assert aeaop.method_name == "Transverse Mercator"
assert _to_dict(aeaop) == {
"Latitude of natural origin": 1.0,
"Longitude of natural origin": 2.0,
"False easting": 3.0,
"False northing": 4.0,
"Scale factor at natural origin": 0.5,
}
def test_vertical_perspective_operation__defaults():
aeaop = VerticalPerspectiveConversion(viewpoint_height=10)
assert aeaop.name == "unknown"
assert aeaop.method_name == "Vertical Perspective"
assert _to_dict(aeaop) == {
"Latitude of topocentric origin": 0.0,
"Longitude of topocentric origin": 0.0,
"Ellipsoidal height of topocentric origin": 0.0,
"Viewpoint height": 10.0,
"False easting": 0.0,
"False northing": 0.0,
}
def test_vertical_perspective_operation():
aeaop = VerticalPerspectiveConversion(
viewpoint_height=10,
latitude_topocentric_origin=1,
longitude_topocentric_origin=2,
false_easting=3,
false_northing=4,
ellipsoidal_height_topocentric_origin=5,
)
assert aeaop.name == "unknown"
assert aeaop.method_name == "Vertical Perspective"
assert _to_dict(aeaop) == {
"Latitude of topocentric origin": 1.0,
"Longitude of topocentric origin": 2.0,
"Ellipsoidal height of topocentric origin": 5.0,
"Viewpoint height": 10.0,
"False easting": 3.0,
"False northing": 4.0,
}
def test_rotated_latitude_longitude_operation__defaults():
aeaop = RotatedLatitudeLongitudeConversion(o_lat_p=1, o_lon_p=2)
assert aeaop.name == "unknown"
assert aeaop.method_name == "PROJ ob_tran o_proj=longlat"
assert _to_dict(aeaop) == {"o_lat_p": 1.0, "o_lon_p": 2.0, "lon_0": 0.0}
def test_rotated_latitude_longitude_operation():
aeaop = RotatedLatitudeLongitudeConversion(o_lat_p=1, o_lon_p=2, lon_0=3)
assert aeaop.name == "unknown"
assert aeaop.method_name == "PROJ ob_tran o_proj=longlat"
assert _to_dict(aeaop) == {"o_lat_p": 1.0, "o_lon_p": 2.0, "lon_0": 3.0}
def test_pole_rotation_netcdf_cf_convention__defaults():
poleop = PoleRotationNetCDFCFConversion(
grid_north_pole_latitude=1, grid_north_pole_longitude=2
)
if PROJ_GTE_82:
assert poleop.name == "Pole rotation (netCDF CF convention)"
assert poleop.method_name == "Pole rotation (netCDF CF convention)"
assert _to_dict(poleop) == {
"Grid north pole latitude (netCDF CF convention)": 1.0,
"Grid north pole longitude (netCDF CF convention)": 2.0,
"North pole grid longitude (netCDF CF convention)": 0.0,
}
else:
assert poleop.name == "unknown"
assert poleop.method_name == "PROJ ob_tran o_proj=longlat"
assert _to_dict(poleop) == {
"o_lat_p": 1.0,
"o_lon_p": 0.0,
"lon_0": 182.0,
}
def test_pole_rotation_netcdf_cf_convention():
poleop = PoleRotationNetCDFCFConversion(
grid_north_pole_latitude=1,
grid_north_pole_longitude=2,
north_pole_grid_longitude=10,
)
if PROJ_GTE_82:
assert poleop.name == "Pole rotation (netCDF CF convention)"
assert poleop.method_name == "Pole rotation (netCDF CF convention)"
assert _to_dict(poleop) == {
"Grid north pole latitude (netCDF CF convention)": 1.0,
"Grid north pole longitude (netCDF CF convention)": 2.0,
"North pole grid longitude (netCDF CF convention)": 10.0,
}
else:
assert poleop.name == "unknown"
assert poleop.method_name == "PROJ ob_tran o_proj=longlat"
assert _to_dict(poleop) == {
"o_lat_p": 1.0,
"o_lon_p": 10.0,
"lon_0": 182.0,
}
def test_lambert_cylindrical_equal_area_scale_operation__defaults():
lceaop = LambertCylindricalEqualAreaScaleConversion()
assert lceaop.name == "unknown"
assert lceaop.method_name == "Lambert Cylindrical Equal Area"
assert _to_dict(lceaop) == {
"Latitude of 1st standard parallel": 0.0,
"Longitude of natural origin": 0.0,
"False easting": 0.0,
"False northing": 0.0,
}
def test_lambert_cylindrical_equal_area_scale_operation():
lceaop = LambertCylindricalEqualAreaScaleConversion(
longitude_natural_origin=2,
false_easting=3,
false_northing=4,
scale_factor_natural_origin=0.999,
)
assert lceaop.name == "unknown"
assert lceaop.method_name == "Lambert Cylindrical Equal Area"
op_dict = _to_dict(lceaop)
assert_almost_equal(
op_dict.pop("Latitude of 1st standard parallel"), 2.57, decimal=2
)
assert op_dict == {
"Longitude of natural origin": 2.0,
"False easting": 3.0,
"False northing": 4.0,
}
@pytest.mark.parametrize(
"eqc_class", [EquidistantCylindricalConversion, PlateCarreeConversion]
)
def test_equidistant_cylindrical_conversion__defaults(eqc_class):
eqc = eqc_class()
assert eqc.name == "unknown"
assert eqc.method_name == "Equidistant Cylindrical"
assert _to_dict(eqc) == {
"Latitude of 1st standard parallel": 0.0,
"Latitude of natural origin": 0.0,
"Longitude of natural origin": 0.0,
"False easting": 0.0,
"False northing": 0.0,
}
@pytest.mark.parametrize(
"eqc_class", [EquidistantCylindricalConversion, PlateCarreeConversion]
)
def test_equidistant_cylindrical_conversion(eqc_class):
eqc = eqc_class(
latitude_first_parallel=1.0,
latitude_natural_origin=2.0,
longitude_natural_origin=3.0,
false_easting=4.0,
false_northing=5.0,
)
assert eqc.name == "unknown"
assert eqc.method_name == "Equidistant Cylindrical"
assert _to_dict(eqc) == {
"Latitude of 1st standard parallel": 1.0,
"Latitude of natural origin": 2.0,
"Longitude of natural origin": 3.0,
"False easting": 4.0,
"False northing": 5.0,
}
def test_towgs84_transformation():
transformation = ToWGS84Transformation(GeographicCRS(), 1, 2, 3, 4, 5, 6, 7)
assert transformation.towgs84 == [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0]
assert _to_dict(transformation) == {
"Scale difference": 7.0,
"X-axis rotation": 4.0,
"X-axis translation": 1.0,
"Y-axis rotation": 5.0,
"Y-axis translation": 2.0,
"Z-axis rotation": 6.0,
"Z-axis translation": 3.0,
}
def test_towgs84_transformation__defaults():
transformation = ToWGS84Transformation(GeographicCRS())
assert transformation.towgs84 == [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
assert _to_dict(transformation) == {
"Scale difference": 0.0,
"X-axis rotation": 0.0,
"X-axis translation": 0.0,
"Y-axis rotation": 0.0,
"Y-axis translation": 0.0,
"Z-axis rotation": 0.0,
"Z-axis translation": 0.0,
}