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
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
|
/******************************************************************************
*
* Project: PROJ
* Purpose: C API wraper of C++ API
* Author: Even Rouault <even dot rouault at spatialys dot com>
*
******************************************************************************
* Copyright (c) 2018, Even Rouault <even dot rouault at spatialys dot com>
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
****************************************************************************/
#ifndef FROM_PROJ_CPP
#define FROM_PROJ_CPP
#endif
#include <cassert>
#include <cstdarg>
#include <cstring>
#include <map>
#include <utility>
#include <vector>
#include "proj/common.hpp"
#include "proj/coordinateoperation.hpp"
#include "proj/crs.hpp"
#include "proj/datum.hpp"
#include "proj/io.hpp"
#include "proj/metadata.hpp"
#include "proj/util.hpp"
#include "proj/internal/internal.hpp"
// PROJ include order is sensitive
// clang-format off
#include "proj_internal.h"
#include "proj.h"
#include "projects.h"
// clang-format on
using namespace NS_PROJ::common;
using namespace NS_PROJ::crs;
using namespace NS_PROJ::datum;
using namespace NS_PROJ::io;
using namespace NS_PROJ::internal;
using namespace NS_PROJ::metadata;
using namespace NS_PROJ::operation;
using namespace NS_PROJ::util;
using namespace NS_PROJ;
// ---------------------------------------------------------------------------
static void PROJ_NO_INLINE proj_log_error(PJ_CONTEXT *ctx, const char *function,
const char *text) {
std::string msg(function);
msg += ": ";
msg += text;
ctx->logger(ctx->app_data, PJ_LOG_ERROR, msg.c_str());
}
// ---------------------------------------------------------------------------
static void PROJ_NO_INLINE proj_log_debug(PJ_CONTEXT *ctx, const char *function,
const char *text) {
std::string msg(function);
msg += ": ";
msg += text;
ctx->logger(ctx->app_data, PJ_LOG_DEBUG, msg.c_str());
}
// ---------------------------------------------------------------------------
/** \brief Opaque object representing a Ellipsoid, Datum, CRS or Coordinate
* Operation. Should be used by at most one thread at a time. */
struct PJ_OBJ {
//! @cond Doxygen_Suppress
PJ_CONTEXT *ctx;
IdentifiedObjectNNPtr obj;
// cached results
std::string lastWKT{};
std::string lastPROJString{};
bool gridsNeededAsked = false;
std::vector<GridDescription> gridsNeeded{};
explicit PJ_OBJ(PJ_CONTEXT *ctxIn, const IdentifiedObjectNNPtr &objIn)
: ctx(ctxIn), obj(objIn) {}
static PJ_OBJ *create(PJ_CONTEXT *ctxIn,
const IdentifiedObjectNNPtr &objIn);
PJ_OBJ(const PJ_OBJ &) = delete;
PJ_OBJ &operator=(const PJ_OBJ &) = delete;
//! @endcond
};
//! @cond Doxygen_Suppress
PJ_OBJ *PJ_OBJ::create(PJ_CONTEXT *ctxIn, const IdentifiedObjectNNPtr &objIn) {
return new PJ_OBJ(ctxIn, objIn);
}
//! @endcond
// ---------------------------------------------------------------------------
/** \brief Opaque object representing a set of operation results. */
struct PJ_OBJ_LIST {
//! @cond Doxygen_Suppress
PJ_CONTEXT *ctx;
std::vector<IdentifiedObjectNNPtr> objects;
explicit PJ_OBJ_LIST(PJ_CONTEXT *ctxIn,
std::vector<IdentifiedObjectNNPtr> &&objectsIn)
: ctx(ctxIn), objects(std::move(objectsIn)) {}
PJ_OBJ_LIST(const PJ_OBJ_LIST &) = delete;
PJ_OBJ_LIST &operator=(const PJ_OBJ_LIST &) = delete;
//! @endcond
};
// ---------------------------------------------------------------------------
//! @cond Doxygen_Suppress
/** Auxiliary structure to PJ_CONTEXT storing C++ context stuff. */
struct projCppContext {
DatabaseContextNNPtr databaseContext;
explicit projCppContext(PJ_CONTEXT *ctxt, const char *dbPath = nullptr,
const char *const *auxDbPaths = nullptr)
: databaseContext(DatabaseContext::create(
dbPath ? dbPath : std::string(), toVector(auxDbPaths))) {
databaseContext->attachPJContext(ctxt);
}
static std::vector<std::string> toVector(const char *const *auxDbPaths) {
std::vector<std::string> res;
for (auto iter = auxDbPaths; iter && *iter; ++iter) {
res.emplace_back(std::string(*iter));
}
return res;
}
};
// ---------------------------------------------------------------------------
void proj_context_delete_cpp_context(struct projCppContext *cppContext) {
delete cppContext;
}
//! @endcond
// ---------------------------------------------------------------------------
//! @cond Doxygen_Suppress
#define SANITIZE_CTX(ctx) \
do { \
if (ctx == nullptr) { \
ctx = pj_get_default_ctx(); \
} \
} while (0)
// ---------------------------------------------------------------------------
static PROJ_NO_INLINE const DatabaseContextNNPtr &
getDBcontext(PJ_CONTEXT *ctx) {
if (ctx->cpp_context == nullptr) {
ctx->cpp_context = new projCppContext(ctx);
}
return ctx->cpp_context->databaseContext;
}
// ---------------------------------------------------------------------------
static PROJ_NO_INLINE DatabaseContextPtr
getDBcontextNoException(PJ_CONTEXT *ctx, const char *function) {
try {
return getDBcontext(ctx).as_nullable();
} catch (const std::exception &e) {
proj_log_debug(ctx, function, e.what());
return nullptr;
}
}
//! @endcond
// ---------------------------------------------------------------------------
/** \brief Explicitly point to the main PROJ CRS and coordinate operation
* definition database ("proj.db"), and potentially auxiliary databases with
* same structure.
*
* @param ctx PROJ context, or NULL for default context
* @param dbPath Path to main database, or NULL for default.
* @param auxDbPaths NULL-terminated list of auxiliary database filenames, or
* NULL.
* @param options should be set to NULL for now
* @return TRUE in case of success
*/
int proj_context_set_database_path(PJ_CONTEXT *ctx, const char *dbPath,
const char *const *auxDbPaths,
const char *const *options) {
SANITIZE_CTX(ctx);
(void)options;
delete ctx->cpp_context;
ctx->cpp_context = nullptr;
try {
ctx->cpp_context = new projCppContext(ctx, dbPath, auxDbPaths);
return true;
} catch (const std::exception &e) {
proj_log_error(ctx, __FUNCTION__, e.what());
return false;
}
}
// ---------------------------------------------------------------------------
/** \brief Returns the path to the database.
*
* The returned pointer remains valid while ctx is valid, and until
* proj_context_set_database_path() is called.
*
* @param ctx PROJ context, or NULL for default context
* @return path, or nullptr
*/
const char *proj_context_get_database_path(PJ_CONTEXT *ctx) {
SANITIZE_CTX(ctx);
try {
return getDBcontext(ctx)->getPath().c_str();
} catch (const std::exception &e) {
proj_log_error(ctx, __FUNCTION__, e.what());
return nullptr;
}
}
// ---------------------------------------------------------------------------
/** \brief Guess the "dialect" of the WKT string.
*
* @param ctx PROJ context, or NULL for default context
* @param wkt String (must not be NULL)
*/
PJ_GUESSED_WKT_DIALECT proj_context_guess_wkt_dialect(PJ_CONTEXT *ctx,
const char *wkt) {
(void)ctx;
assert(wkt);
switch (WKTParser().guessDialect(wkt)) {
case WKTParser::WKTGuessedDialect::WKT2_2018:
return PJ_GUESSED_WKT2_2018;
case WKTParser::WKTGuessedDialect::WKT2_2015:
return PJ_GUESSED_WKT2_2015;
case WKTParser::WKTGuessedDialect::WKT1_GDAL:
return PJ_GUESSED_WKT1_GDAL;
case WKTParser::WKTGuessedDialect::WKT1_ESRI:
return PJ_GUESSED_WKT1_ESRI;
case WKTParser::WKTGuessedDialect::NOT_WKT:
break;
}
return PJ_GUESSED_NOT_WKT;
}
// ---------------------------------------------------------------------------
/** \brief Instanciate an object from a WKT string, PROJ string or object code
* (like "EPSG:4326", "urn:ogc:def:crs:EPSG::4326",
* "urn:ogc:def:coordinateOperation:EPSG::1671").
*
* This function calls osgeo::proj::io::createFromUserInput()
*
* The returned object must be unreferenced with proj_obj_unref() after use.
* It should be used by at most one thread at a time.
*
* @param ctx PROJ context, or NULL for default context
* @param text String (must not be NULL)
* @param options should be set to NULL for now
* @return Object that must be unreferenced with proj_obj_unref(), or NULL in
* case of error.
*/
PJ_OBJ *proj_obj_create_from_user_input(PJ_CONTEXT *ctx, const char *text,
const char *const *options) {
SANITIZE_CTX(ctx);
assert(text);
(void)options;
auto dbContext = getDBcontextNoException(ctx, __FUNCTION__);
try {
auto identifiedObject = nn_dynamic_pointer_cast<IdentifiedObject>(
createFromUserInput(text, dbContext));
if (identifiedObject) {
return PJ_OBJ::create(ctx, NN_NO_CHECK(identifiedObject));
}
} catch (const std::exception &e) {
proj_log_error(ctx, __FUNCTION__, e.what());
}
return nullptr;
}
// ---------------------------------------------------------------------------
/** \brief Instanciate an object from a WKT string.
*
* This function calls osgeo::proj::io::WKTParser::createFromWKT()
*
* The returned object must be unreferenced with proj_obj_unref() after use.
* It should be used by at most one thread at a time.
*
* @param ctx PROJ context, or NULL for default context
* @param wkt WKT string (must not be NULL)
* @param options should be set to NULL for now
* @return Object that must be unreferenced with proj_obj_unref(), or NULL in
* case of error.
*/
PJ_OBJ *proj_obj_create_from_wkt(PJ_CONTEXT *ctx, const char *wkt,
const char *const *options) {
SANITIZE_CTX(ctx);
assert(wkt);
(void)options;
try {
auto identifiedObject = nn_dynamic_pointer_cast<IdentifiedObject>(
WKTParser().createFromWKT(wkt));
if (identifiedObject) {
return PJ_OBJ::create(ctx, NN_NO_CHECK(identifiedObject));
}
} catch (const std::exception &e) {
proj_log_error(ctx, __FUNCTION__, e.what());
}
return nullptr;
}
// ---------------------------------------------------------------------------
/** \brief Instanciate an object from a PROJ string.
*
* This function calls osgeo::proj::io::PROJStringParser::createFromPROJString()
*
* The returned object must be unreferenced with proj_obj_unref() after use.
* It should be used by at most one thread at a time.
*
* @param ctx PROJ context, or NULL for default context
* @param proj_string PROJ string (must not be NULL)
* @param options should be set to NULL for now
* @return Object that must be unreferenced with proj_obj_unref(), or NULL in
* case of error.
*/
PJ_OBJ *proj_obj_create_from_proj_string(PJ_CONTEXT *ctx,
const char *proj_string,
const char *const *options) {
SANITIZE_CTX(ctx);
(void)options;
assert(proj_string);
try {
auto identifiedObject = nn_dynamic_pointer_cast<IdentifiedObject>(
PROJStringParser().createFromPROJString(proj_string));
if (identifiedObject) {
return PJ_OBJ::create(ctx, NN_NO_CHECK(identifiedObject));
}
} catch (const std::exception &e) {
proj_log_error(ctx, __FUNCTION__, e.what());
}
return nullptr;
}
// ---------------------------------------------------------------------------
/** \brief Instanciate an object from a database lookup.
*
* The returned object must be unreferenced with proj_obj_unref() after use.
* It should be used by at most one thread at a time.
*
* @param ctx Context, or NULL for default context.
* @param auth_name Authority name (must not be NULL)
* @param code Object code (must not be NULL)
* @param category Object category
* @param usePROJAlternativeGridNames Whether PROJ alternative grid names
* should be substituted to the official grid names. Only used on
* transformations
* @param options should be set to NULL for now
* @return Object that must be unreferenced with proj_obj_unref(), or NULL in
* case of error.
*/
PJ_OBJ *proj_obj_create_from_database(PJ_CONTEXT *ctx, const char *auth_name,
const char *code,
PJ_OBJ_CATEGORY category,
int usePROJAlternativeGridNames,
const char *const *options) {
assert(auth_name);
assert(code);
(void)options;
SANITIZE_CTX(ctx);
const std::string codeStr(code);
try {
auto factory = AuthorityFactory::create(getDBcontext(ctx), auth_name);
IdentifiedObjectPtr obj;
switch (category) {
case PJ_OBJ_CATEGORY_ELLIPSOID:
obj = factory->createEllipsoid(codeStr).as_nullable();
break;
case PJ_OBJ_CATEGORY_DATUM:
obj = factory->createDatum(codeStr).as_nullable();
break;
case PJ_OBJ_CATEGORY_CRS:
obj =
factory->createCoordinateReferenceSystem(codeStr).as_nullable();
break;
case PJ_OBJ_CATEGORY_COORDINATE_OPERATION:
obj = factory
->createCoordinateOperation(
codeStr, usePROJAlternativeGridNames != 0)
.as_nullable();
break;
}
return PJ_OBJ::create(ctx, NN_NO_CHECK(obj));
} catch (const std::exception &e) {
proj_log_error(ctx, __FUNCTION__, e.what());
}
return nullptr;
}
// ---------------------------------------------------------------------------
/** \brief Drops a reference on an object.
*
* This method should be called one and exactly one for each function
* returning a PJ_OBJ*
*
* @param obj Object, or NULL.
*/
void proj_obj_unref(PJ_OBJ *obj) { delete obj; }
// ---------------------------------------------------------------------------
//! @cond Doxygen_Suppress
static AuthorityFactory::ObjectType
convertPJObjectTypeToObjectType(PJ_OBJ_TYPE type, bool &valid) {
valid = true;
AuthorityFactory::ObjectType cppType = AuthorityFactory::ObjectType::CRS;
switch (type) {
case PJ_OBJ_TYPE_ELLIPSOID:
cppType = AuthorityFactory::ObjectType::ELLIPSOID;
break;
case PJ_OBJ_TYPE_GEODETIC_REFERENCE_FRAME:
case PJ_OBJ_TYPE_DYNAMIC_GEODETIC_REFERENCE_FRAME:
cppType = AuthorityFactory::ObjectType::GEODETIC_REFERENCE_FRAME;
break;
case PJ_OBJ_TYPE_VERTICAL_REFERENCE_FRAME:
case PJ_OBJ_TYPE_DYNAMIC_VERTICAL_REFERENCE_FRAME:
cppType = AuthorityFactory::ObjectType::VERTICAL_REFERENCE_FRAME;
break;
case PJ_OBJ_TYPE_DATUM_ENSEMBLE:
cppType = AuthorityFactory::ObjectType::DATUM;
break;
case PJ_OBJ_TYPE_CRS:
cppType = AuthorityFactory::ObjectType::CRS;
break;
case PJ_OBJ_TYPE_GEODETIC_CRS:
cppType = AuthorityFactory::ObjectType::GEODETIC_CRS;
break;
case PJ_OBJ_TYPE_GEOCENTRIC_CRS:
cppType = AuthorityFactory::ObjectType::GEOCENTRIC_CRS;
break;
case PJ_OBJ_TYPE_GEOGRAPHIC_CRS:
cppType = AuthorityFactory::ObjectType::GEOGRAPHIC_CRS;
break;
case PJ_OBJ_TYPE_GEOGRAPHIC_2D_CRS:
cppType = AuthorityFactory::ObjectType::GEOGRAPHIC_2D_CRS;
break;
case PJ_OBJ_TYPE_GEOGRAPHIC_3D_CRS:
cppType = AuthorityFactory::ObjectType::GEOGRAPHIC_3D_CRS;
break;
case PJ_OBJ_TYPE_VERTICAL_CRS:
cppType = AuthorityFactory::ObjectType::VERTICAL_CRS;
break;
case PJ_OBJ_TYPE_PROJECTED_CRS:
cppType = AuthorityFactory::ObjectType::PROJECTED_CRS;
break;
case PJ_OBJ_TYPE_COMPOUND_CRS:
cppType = AuthorityFactory::ObjectType::COMPOUND_CRS;
break;
case PJ_OBJ_TYPE_TEMPORAL_CRS:
valid = false;
break;
case PJ_OBJ_TYPE_BOUND_CRS:
valid = false;
break;
case PJ_OBJ_TYPE_OTHER_CRS:
cppType = AuthorityFactory::ObjectType::CRS;
break;
case PJ_OBJ_TYPE_CONVERSION:
cppType = AuthorityFactory::ObjectType::CONVERSION;
break;
case PJ_OBJ_TYPE_TRANSFORMATION:
cppType = AuthorityFactory::ObjectType::TRANSFORMATION;
break;
case PJ_OBJ_TYPE_CONCATENATED_OPERATION:
cppType = AuthorityFactory::ObjectType::CONCATENATED_OPERATION;
break;
case PJ_OBJ_TYPE_OTHER_COORDINATE_OPERATION:
cppType = AuthorityFactory::ObjectType::COORDINATE_OPERATION;
break;
case PJ_OBJ_TYPE_UNKNOWN:
valid = false;
break;
}
return cppType;
}
//! @endcond
// ---------------------------------------------------------------------------
/** \brief Return a list of objects by their name.
*
* @param ctx Context, or NULL for default context.
* @param auth_name Authority name, used to restrict the search.
* Or NULL for all authorities.
* @param searchedName Searched name. Must be at least 2 character long.
* @param types List of object types into which to search. If
* NULL, all object types will be searched.
* @param typesCount Number of elements in types, or 0 if types is NULL
* @param approximateMatch Whether approximate name identification is allowed.
* @param limitResultCount Maximum number of results to return.
* Or 0 for unlimited.
* @param options should be set to NULL for now
* @return a result set that must be unreferenced with
* proj_obj_list_unref(), or NULL in case of error.
*/
PJ_OBJ_LIST *proj_obj_create_from_name(PJ_CONTEXT *ctx, const char *auth_name,
const char *searchedName,
const PJ_OBJ_TYPE *types,
size_t typesCount, int approximateMatch,
size_t limitResultCount,
const char *const *options) {
assert(searchedName);
assert((types != nullptr && typesCount > 0) ||
(types == nullptr && typesCount == 0));
(void)options;
SANITIZE_CTX(ctx);
try {
auto factory = AuthorityFactory::create(getDBcontext(ctx),
auth_name ? auth_name : "");
std::vector<AuthorityFactory::ObjectType> allowedTypes;
for (size_t i = 0; i < typesCount; ++i) {
bool valid = false;
auto type = convertPJObjectTypeToObjectType(types[i], valid);
if (valid) {
allowedTypes.push_back(type);
}
}
auto res = factory->createObjectsFromName(searchedName, allowedTypes,
approximateMatch != 0,
limitResultCount);
std::vector<IdentifiedObjectNNPtr> objects;
for (const auto &obj : res) {
objects.push_back(obj);
}
return new PJ_OBJ_LIST(ctx, std::move(objects));
} catch (const std::exception &e) {
proj_log_error(ctx, __FUNCTION__, e.what());
}
return nullptr;
}
// ---------------------------------------------------------------------------
/** \brief Return the type of an object.
*
* @param obj Object (must not be NULL)
* @return its type.
*/
PJ_OBJ_TYPE proj_obj_get_type(PJ_OBJ *obj) {
assert(obj);
auto ptr = obj->obj.get();
if (dynamic_cast<Ellipsoid *>(ptr)) {
return PJ_OBJ_TYPE_ELLIPSOID;
}
if (dynamic_cast<DynamicGeodeticReferenceFrame *>(ptr)) {
return PJ_OBJ_TYPE_DYNAMIC_GEODETIC_REFERENCE_FRAME;
}
if (dynamic_cast<GeodeticReferenceFrame *>(ptr)) {
return PJ_OBJ_TYPE_GEODETIC_REFERENCE_FRAME;
}
if (dynamic_cast<DynamicVerticalReferenceFrame *>(ptr)) {
return PJ_OBJ_TYPE_DYNAMIC_VERTICAL_REFERENCE_FRAME;
}
if (dynamic_cast<VerticalReferenceFrame *>(ptr)) {
return PJ_OBJ_TYPE_VERTICAL_REFERENCE_FRAME;
}
if (dynamic_cast<DatumEnsemble *>(ptr)) {
return PJ_OBJ_TYPE_DATUM_ENSEMBLE;
}
{
auto crs = dynamic_cast<GeographicCRS *>(ptr);
if (crs) {
if (crs->coordinateSystem()->axisList().size() == 2) {
return PJ_OBJ_TYPE_GEOGRAPHIC_2D_CRS;
} else {
return PJ_OBJ_TYPE_GEOGRAPHIC_3D_CRS;
}
}
}
{
auto crs = dynamic_cast<GeodeticCRS *>(ptr);
if (crs) {
if (crs->isGeocentric()) {
return PJ_OBJ_TYPE_GEOCENTRIC_CRS;
} else {
return PJ_OBJ_TYPE_GEODETIC_CRS;
}
}
}
if (dynamic_cast<VerticalCRS *>(ptr)) {
return PJ_OBJ_TYPE_VERTICAL_CRS;
}
if (dynamic_cast<ProjectedCRS *>(ptr)) {
return PJ_OBJ_TYPE_PROJECTED_CRS;
}
if (dynamic_cast<CompoundCRS *>(ptr)) {
return PJ_OBJ_TYPE_COMPOUND_CRS;
}
if (dynamic_cast<TemporalCRS *>(ptr)) {
return PJ_OBJ_TYPE_TEMPORAL_CRS;
}
if (dynamic_cast<BoundCRS *>(ptr)) {
return PJ_OBJ_TYPE_BOUND_CRS;
}
if (dynamic_cast<CRS *>(ptr)) {
return PJ_OBJ_TYPE_OTHER_CRS;
}
if (dynamic_cast<Conversion *>(ptr)) {
return PJ_OBJ_TYPE_CONVERSION;
}
if (dynamic_cast<Transformation *>(ptr)) {
return PJ_OBJ_TYPE_TRANSFORMATION;
}
if (dynamic_cast<ConcatenatedOperation *>(ptr)) {
return PJ_OBJ_TYPE_CONCATENATED_OPERATION;
}
if (dynamic_cast<CoordinateOperation *>(ptr)) {
return PJ_OBJ_TYPE_OTHER_COORDINATE_OPERATION;
}
return PJ_OBJ_TYPE_UNKNOWN;
}
// ---------------------------------------------------------------------------
/** \brief Return whether an object is deprecated.
*
* @param obj Object (must not be NULL)
* @return TRUE if it is deprecated, FALSE otherwise
*/
int proj_obj_is_deprecated(PJ_OBJ *obj) {
assert(obj);
return obj->obj->isDeprecated();
}
// ---------------------------------------------------------------------------
/** \brief Return whether two objects are equivalent.
*
* @param obj Object (must not be NULL)
* @param other Other object (must not be NULL)
* @param criterion Comparison criterion
* @return TRUE if they are equivalent
*/
int proj_obj_is_equivalent_to(PJ_OBJ *obj, PJ_OBJ *other,
PJ_COMPARISON_CRITERION criterion) {
assert(obj);
assert(other);
// Make sure that the C and C++ enumerations match
static_assert(static_cast<int>(PJ_COMP_STRICT) ==
static_cast<int>(IComparable::Criterion::STRICT),
"");
static_assert(static_cast<int>(PJ_COMP_EQUIVALENT) ==
static_cast<int>(IComparable::Criterion::EQUIVALENT),
"");
static_assert(
static_cast<int>(PJ_COMP_EQUIVALENT_EXCEPT_AXIS_ORDER_GEOGCRS) ==
static_cast<int>(
IComparable::Criterion::EQUIVALENT_EXCEPT_AXIS_ORDER_GEOGCRS),
"");
// Make sure we enumerate all values. If adding a new value, as we
// don't have a default clause, the compiler will warn.
switch (criterion) {
case PJ_COMP_STRICT:
case PJ_COMP_EQUIVALENT:
case PJ_COMP_EQUIVALENT_EXCEPT_AXIS_ORDER_GEOGCRS:
break;
}
const IComparable::Criterion cppCriterion =
static_cast<IComparable::Criterion>(criterion);
return obj->obj->isEquivalentTo(other->obj.get(), cppCriterion);
}
// ---------------------------------------------------------------------------
/** \brief Return whether an object is a CRS
*
* @param obj Object (must not be NULL)
*/
int proj_obj_is_crs(PJ_OBJ *obj) {
assert(obj);
return dynamic_cast<CRS *>(obj->obj.get()) != nullptr;
}
// ---------------------------------------------------------------------------
/** \brief Get the name of an object.
*
* The lifetime of the returned string is the same as the input obj parameter.
*
* @param obj Object (must not be NULL)
* @return a string, or NULL in case of error or missing name.
*/
const char *proj_obj_get_name(PJ_OBJ *obj) {
assert(obj);
const auto &desc = obj->obj->name()->description();
if (!desc.has_value()) {
return nullptr;
}
// The object will still be alived after the function call.
// cppcheck-suppress stlcstr
return desc->c_str();
}
// ---------------------------------------------------------------------------
/** \brief Get the authority name / codespace of an identifier of an object.
*
* The lifetime of the returned string is the same as the input obj parameter.
*
* @param obj Object (must not be NULL)
* @param index Index of the identifier. 0 = first identifier
* @return a string, or NULL in case of error or missing name.
*/
const char *proj_obj_get_id_auth_name(PJ_OBJ *obj, int index) {
assert(obj);
const auto &ids = obj->obj->identifiers();
if (static_cast<size_t>(index) >= ids.size()) {
return nullptr;
}
const auto &codeSpace = ids[index]->codeSpace();
if (!codeSpace.has_value()) {
return nullptr;
}
// The object will still be alived after the function call.
// cppcheck-suppress stlcstr
return codeSpace->c_str();
}
// ---------------------------------------------------------------------------
/** \brief Get the code of an identifier of an object.
*
* The lifetime of the returned string is the same as the input obj parameter.
*
* @param obj Object (must not be NULL)
* @param index Index of the identifier. 0 = first identifier
* @return a string, or NULL in case of error or missing name.
*/
const char *proj_obj_get_id_code(PJ_OBJ *obj, int index) {
assert(obj);
const auto &ids = obj->obj->identifiers();
if (static_cast<size_t>(index) >= ids.size()) {
return nullptr;
}
return ids[index]->code().c_str();
}
// ---------------------------------------------------------------------------
//! @cond Doxygen_Suppress
static const char *getOptionValue(const char *option,
const char *keyWithEqual) noexcept {
if (ci_starts_with(option, keyWithEqual)) {
return option + strlen(keyWithEqual);
}
return nullptr;
}
//! @endcond
// ---------------------------------------------------------------------------
/** \brief Get a WKT representation of an object.
*
* The returned string is valid while the input obj parameter is valid,
* and until a next call to proj_obj_as_wkt() with the same input object.
*
* This function calls osgeo::proj::io::IWKTExportable::exportToWKT().
*
* This function may return NULL if the object is not compatible with an
* export to the requested type.
*
* @param obj Object (must not be NULL)
* @param type WKT version.
* @param options null-terminated list of options, or NULL. Currently
* supported options are:
* <ul>
* <li>MULTILINE=YES/NO. Defaults to YES, except for WKT1_ESRI</li>
* <li>INDENTATION_WIDTH=number. Defauls to 4 (when multiline output is
* on).</li>
* <li>OUTPUT_AXIS=AUTO/YES/NO. In AUTO mode, axis will be output for WKT2
* variants, for WKT1_GDAL for ProjectedCRS with easting/northing ordering
* (otherwise stripped), but not for WKT1_ESRI. Setting to YES will output
* them unconditionaly, and to NO will omit them unconditionaly.</li>
* </ul>
* @return a string, or NULL in case of error.
*/
const char *proj_obj_as_wkt(PJ_OBJ *obj, PJ_WKT_TYPE type,
const char *const *options) {
assert(obj);
// Make sure that the C and C++ enumerations match
static_assert(static_cast<int>(PJ_WKT2_2015) ==
static_cast<int>(WKTFormatter::Convention::WKT2_2015),
"");
static_assert(
static_cast<int>(PJ_WKT2_2015_SIMPLIFIED) ==
static_cast<int>(WKTFormatter::Convention::WKT2_2015_SIMPLIFIED),
"");
static_assert(static_cast<int>(PJ_WKT2_2018) ==
static_cast<int>(WKTFormatter::Convention::WKT2_2018),
"");
static_assert(
static_cast<int>(PJ_WKT2_2018_SIMPLIFIED) ==
static_cast<int>(WKTFormatter::Convention::WKT2_2018_SIMPLIFIED),
"");
static_assert(static_cast<int>(PJ_WKT1_GDAL) ==
static_cast<int>(WKTFormatter::Convention::WKT1_GDAL),
"");
static_assert(static_cast<int>(PJ_WKT1_ESRI) ==
static_cast<int>(WKTFormatter::Convention::WKT1_ESRI),
"");
// Make sure we enumerate all values. If adding a new value, as we
// don't have a default clause, the compiler will warn.
switch (type) {
case PJ_WKT2_2015:
case PJ_WKT2_2015_SIMPLIFIED:
case PJ_WKT2_2018:
case PJ_WKT2_2018_SIMPLIFIED:
case PJ_WKT1_GDAL:
case PJ_WKT1_ESRI:
break;
}
const WKTFormatter::Convention convention =
static_cast<WKTFormatter::Convention>(type);
try {
auto formatter = WKTFormatter::create(convention);
for (auto iter = options; iter && iter[0]; ++iter) {
const char *value;
if ((value = getOptionValue(*iter, "MULTILINE="))) {
formatter->setMultiLine(ci_equal(value, "YES"));
} else if ((value = getOptionValue(*iter, "INDENTATION_WIDTH="))) {
formatter->setIndentationWidth(std::atoi(value));
} else if ((value = getOptionValue(*iter, "OUTPUT_AXIS="))) {
if (!ci_equal(value, "AUTO")) {
formatter->setOutputAxis(
ci_equal(value, "YES")
? WKTFormatter::OutputAxisRule::YES
: WKTFormatter::OutputAxisRule::NO);
}
} else {
std::string msg("Unknown option :");
msg += *iter;
proj_log_error(obj->ctx, __FUNCTION__, msg.c_str());
return nullptr;
}
}
obj->lastWKT = obj->obj->exportToWKT(formatter.get());
return obj->lastWKT.c_str();
} catch (const std::exception &e) {
proj_log_error(obj->ctx, __FUNCTION__, e.what());
return nullptr;
}
}
// ---------------------------------------------------------------------------
/** \brief Get a PROJ string representation of an object.
*
* The returned string is valid while the input obj parameter is valid,
* and until a next call to proj_obj_as_proj_string() with the same input
* object.
*
* This function calls
* osgeo::proj::io::IPROJStringExportable::exportToPROJString().
*
* This function may return NULL if the object is not compatible with an
* export to the requested type.
*
* @param obj Object (must not be NULL)
* @param type PROJ String version.
* @param options NULL-terminated list of strings with "KEY=VALUE" format. or
* NULL.
* The currently recognized option is USE_ETMERC=YES to use
* +proj=etmerc instead of +proj=tmerc (or USE_ETMERC=NO to disable implicit
* use of etmerc by utm conversions)
* @return a string, or NULL in case of error.
*/
const char *proj_obj_as_proj_string(PJ_OBJ *obj, PJ_PROJ_STRING_TYPE type,
const char *const *options) {
assert(obj);
auto exportable =
dynamic_cast<const IPROJStringExportable *>(obj->obj.get());
if (!exportable) {
proj_log_error(obj->ctx, __FUNCTION__,
"Object type not exportable to PROJ");
return nullptr;
}
// Make sure that the C and C++ enumeration match
static_assert(static_cast<int>(PJ_PROJ_5) ==
static_cast<int>(PROJStringFormatter::Convention::PROJ_5),
"");
static_assert(static_cast<int>(PJ_PROJ_4) ==
static_cast<int>(PROJStringFormatter::Convention::PROJ_4),
"");
// Make sure we enumerate all values. If adding a new value, as we
// don't have a default clause, the compiler will warn.
switch (type) {
case PJ_PROJ_5:
case PJ_PROJ_4:
break;
}
const PROJStringFormatter::Convention convention =
static_cast<PROJStringFormatter::Convention>(type);
auto dbContext = getDBcontextNoException(obj->ctx, __FUNCTION__);
try {
auto formatter = PROJStringFormatter::create(convention, dbContext);
if (options != nullptr && options[0] != nullptr) {
if (ci_equal(options[0], "USE_ETMERC=YES")) {
formatter->setUseETMercForTMerc(true);
} else if (ci_equal(options[0], "USE_ETMERC=NO")) {
formatter->setUseETMercForTMerc(false);
}
}
obj->lastPROJString = exportable->exportToPROJString(formatter.get());
return obj->lastPROJString.c_str();
} catch (const std::exception &e) {
proj_log_error(obj->ctx, __FUNCTION__, e.what());
return nullptr;
}
}
// ---------------------------------------------------------------------------
/** \brief Return the area of use of an object.
*
* @param obj Object (must not be NULL)
* @param p_west_lon Pointer to a double to receive the west longitude (in
* degrees). Or NULL. If the returned value is -1000, the bounding box is
* unknown.
* @param p_south_lat Pointer to a double to receive the south latitude (in
* degrees). Or NULL. If the returned value is -1000, the bounding box is
* unknown.
* @param p_east_lon Pointer to a double to receive the east longitude (in
* degrees). Or NULL. If the returned value is -1000, the bounding box is
* unknown.
* @param p_north_lat Pointer to a double to receive the north latitude (in
* degrees). Or NULL. If the returned value is -1000, the bounding box is
* unknown.
* @param p_area_name Pointer to a string to receive the name of the area of
* use. Or NULL. *p_area_name is valid while obj is valid itself.
* @return TRUE in case of success, FALSE in case of error or if the area
* of use is unknown.
*/
int proj_obj_get_area_of_use(PJ_OBJ *obj, double *p_west_lon,
double *p_south_lat, double *p_east_lon,
double *p_north_lat, const char **p_area_name) {
if (p_area_name) {
*p_area_name = nullptr;
}
auto objectUsage = dynamic_cast<const ObjectUsage *>(obj->obj.get());
if (!objectUsage) {
return false;
}
const auto &domains = objectUsage->domains();
if (domains.empty()) {
return false;
}
const auto &extent = domains[0]->domainOfValidity();
if (!extent) {
return false;
}
const auto &desc = extent->description();
if (desc.has_value() && p_area_name) {
*p_area_name = desc->c_str();
}
const auto &geogElements = extent->geographicElements();
if (!geogElements.empty()) {
auto bbox =
dynamic_cast<const GeographicBoundingBox *>(geogElements[0].get());
if (bbox) {
if (p_west_lon) {
*p_west_lon = bbox->westBoundLongitude();
}
if (p_south_lat) {
*p_south_lat = bbox->southBoundLatitude();
}
if (p_east_lon) {
*p_east_lon = bbox->eastBoundLongitude();
}
if (p_north_lat) {
*p_north_lat = bbox->northBoundLatitude();
}
return true;
}
}
if (p_west_lon) {
*p_west_lon = -1000;
}
if (p_south_lat) {
*p_south_lat = -1000;
}
if (p_east_lon) {
*p_east_lon = -1000;
}
if (p_north_lat) {
*p_north_lat = -1000;
}
return true;
}
// ---------------------------------------------------------------------------
static const GeodeticCRS *extractGeodeticCRS(PJ_OBJ *crs, const char *fname) {
assert(crs);
auto l_crs = dynamic_cast<const CRS *>(crs->obj.get());
if (!l_crs) {
proj_log_error(crs->ctx, fname, "Object is not a CRS");
return nullptr;
}
auto geodCRS = l_crs->extractGeodeticCRSRaw();
if (!geodCRS) {
proj_log_error(crs->ctx, fname, "CRS has no geodetic CRS");
}
return geodCRS;
}
// ---------------------------------------------------------------------------
/** \brief Get the geodeticCRS / geographicCRS from a CRS
*
* The returned object must be unreferenced with proj_obj_unref() after
* use.
* It should be used by at most one thread at a time.
*
* @param crs Objet of type CRS (must not be NULL)
* @return Object that must be unreferenced with proj_obj_unref(), or NULL
* in case of error.
*/
PJ_OBJ *proj_obj_crs_get_geodetic_crs(PJ_OBJ *crs) {
auto geodCRS = extractGeodeticCRS(crs, __FUNCTION__);
if (!geodCRS) {
return nullptr;
}
return PJ_OBJ::create(crs->ctx,
NN_NO_CHECK(nn_dynamic_pointer_cast<IdentifiedObject>(
geodCRS->shared_from_this())));
}
// ---------------------------------------------------------------------------
/** \brief Get a CRS component from a CompoundCRS
*
* The returned object must be unreferenced with proj_obj_unref() after
* use.
* It should be used by at most one thread at a time.
*
* @param crs Objet of type CRS (must not be NULL)
* @param index Index of the CRS component (typically 0 = horizontal, 1 =
* vertical)
* @return Object that must be unreferenced with proj_obj_unref(), or NULL
* in case of error.
*/
PJ_OBJ *proj_obj_crs_get_sub_crs(PJ_OBJ *crs, int index) {
assert(crs);
auto l_crs = dynamic_cast<CompoundCRS *>(crs->obj.get());
if (!l_crs) {
proj_log_error(crs->ctx, __FUNCTION__, "Object is not a CompoundCRS");
return nullptr;
}
const auto &components = l_crs->componentReferenceSystems();
if (static_cast<size_t>(index) >= components.size()) {
return nullptr;
}
return PJ_OBJ::create(crs->ctx, components[index]);
}
// ---------------------------------------------------------------------------
/** \brief Returns potentially
* a BoundCRS, with a transformation to EPSG:4326, wrapping this CRS
*
* The returned object must be unreferenced with proj_obj_unref() after
* use.
* It should be used by at most one thread at a time.
*
* This is the same as method
* osgeo::proj::crs::CRS::createBoundCRSToWGS84IfPossible()
*
* @param crs Objet of type CRS (must not be NULL)
* @return Object that must be unreferenced with proj_obj_unref(), or NULL
* in case of error.
*/
PJ_OBJ *proj_obj_crs_create_bound_crs_to_WGS84(PJ_OBJ *crs) {
assert(crs);
auto l_crs = dynamic_cast<const CRS *>(crs->obj.get());
if (!l_crs) {
proj_log_error(crs->ctx, __FUNCTION__, "Object is not a CRS");
return nullptr;
}
auto dbContext = getDBcontextNoException(crs->ctx, __FUNCTION__);
return PJ_OBJ::create(crs->ctx,
l_crs->createBoundCRSToWGS84IfPossible(dbContext));
}
// ---------------------------------------------------------------------------
/** \brief Get the ellipsoid from a CRS or a GeodeticReferenceFrame.
*
* The returned object must be unreferenced with proj_obj_unref() after
* use.
* It should be used by at most one thread at a time.
*
* @param obj Objet of type CRS or GeodeticReferenceFrame (must not be NULL)
* @return Object that must be unreferenced with proj_obj_unref(), or NULL
* in case of error.
*/
PJ_OBJ *proj_obj_get_ellipsoid(PJ_OBJ *obj) {
auto ptr = obj->obj.get();
if (dynamic_cast<const CRS *>(ptr)) {
auto geodCRS = extractGeodeticCRS(obj, __FUNCTION__);
if (geodCRS) {
return PJ_OBJ::create(obj->ctx, geodCRS->ellipsoid());
}
} else {
auto datum = dynamic_cast<const GeodeticReferenceFrame *>(ptr);
if (datum) {
return PJ_OBJ::create(obj->ctx, datum->ellipsoid());
}
}
proj_log_error(obj->ctx, __FUNCTION__,
"Object is not a CRS or GeodeticReferenceFrame");
return nullptr;
}
// ---------------------------------------------------------------------------
/** \brief Get the horizontal datum from a CRS
*
* The returned object must be unreferenced with proj_obj_unref() after
* use.
* It should be used by at most one thread at a time.
*
* @param crs Objet of type CRS (must not be NULL)
* @return Object that must be unreferenced with proj_obj_unref(), or NULL
* in case of error.
*/
PJ_OBJ *proj_obj_crs_get_horizontal_datum(PJ_OBJ *crs) {
auto geodCRS = extractGeodeticCRS(crs, __FUNCTION__);
if (!geodCRS) {
return nullptr;
}
const auto &datum = geodCRS->datum();
if (datum) {
return PJ_OBJ::create(crs->ctx, NN_NO_CHECK(datum));
}
const auto &datumEnsemble = geodCRS->datumEnsemble();
if (datumEnsemble) {
return PJ_OBJ::create(crs->ctx, NN_NO_CHECK(datumEnsemble));
}
proj_log_error(crs->ctx, __FUNCTION__, "CRS has no datum");
return nullptr;
}
// ---------------------------------------------------------------------------
/** \brief Return ellipsoid parameters.
*
* @param ellipsoid Object of type Ellipsoid (must not be NULL)
* @param pSemiMajorMetre Pointer to a value to store the semi-major axis in
* metre. or NULL
* @param pSemiMinorMetre Pointer to a value to store the semi-minor axis in
* metre. or NULL
* @param pIsSemiMinorComputed Pointer to a boolean value to indicate if the
* semi-minor value was computed. If FALSE, its value comes from the
* definition. or NULL
* @param pInverseFlattening Pointer to a value to store the inverse
* flattening. or NULL
* @return TRUE in case of success.
*/
int proj_obj_ellipsoid_get_parameters(PJ_OBJ *ellipsoid,
double *pSemiMajorMetre,
double *pSemiMinorMetre,
int *pIsSemiMinorComputed,
double *pInverseFlattening) {
assert(ellipsoid);
auto l_ellipsoid = dynamic_cast<const Ellipsoid *>(ellipsoid->obj.get());
if (!l_ellipsoid) {
proj_log_error(ellipsoid->ctx, __FUNCTION__,
"Object is not a Ellipsoid");
return FALSE;
}
if (pSemiMajorMetre) {
*pSemiMajorMetre = l_ellipsoid->semiMajorAxis().getSIValue();
}
if (pSemiMinorMetre) {
*pSemiMinorMetre = l_ellipsoid->computeSemiMinorAxis().getSIValue();
}
if (pIsSemiMinorComputed) {
*pIsSemiMinorComputed = !(l_ellipsoid->semiMinorAxis().has_value());
}
if (pInverseFlattening) {
*pInverseFlattening = l_ellipsoid->computedInverseFlattening();
}
return TRUE;
}
// ---------------------------------------------------------------------------
/** \brief Get the prime meridian of a CRS or a GeodeticReferenceFrame.
*
* The returned object must be unreferenced with proj_obj_unref() after
* use.
* It should be used by at most one thread at a time.
*
* @param obj Objet of type CRS or GeodeticReferenceFrame (must not be NULL)
* @return Object that must be unreferenced with proj_obj_unref(), or NULL
* in case of error.
*/
PJ_OBJ *proj_obj_get_prime_meridian(PJ_OBJ *obj) {
auto ptr = obj->obj.get();
if (dynamic_cast<CRS *>(ptr)) {
auto geodCRS = extractGeodeticCRS(obj, __FUNCTION__);
if (geodCRS) {
return PJ_OBJ::create(obj->ctx, geodCRS->primeMeridian());
}
} else {
auto datum = dynamic_cast<const GeodeticReferenceFrame *>(ptr);
if (datum) {
return PJ_OBJ::create(obj->ctx, datum->primeMeridian());
}
}
proj_log_error(obj->ctx, __FUNCTION__,
"Object is not a CRS or GeodeticReferenceFrame");
return nullptr;
}
// ---------------------------------------------------------------------------
/** \brief Return prime meridian parameters.
*
* @param prime_meridian Object of type PrimeMeridian (must not be NULL)
* @param pLongitude Pointer to a value to store the longitude of the prime
* meridian, in its native unit. or NULL
* @param pLongitudeUnitConvFactor Pointer to a value to store the conversion
* factor of the prime meridian longitude unit to radian. or NULL
* @param pLongitudeUnitName Pointer to a string value to store the unit name.
* or NULL
* @return TRUE in case of success.
*/
int proj_obj_prime_meridian_get_parameters(PJ_OBJ *prime_meridian,
double *pLongitude,
double *pLongitudeUnitConvFactor,
const char **pLongitudeUnitName) {
assert(prime_meridian);
auto l_pm = dynamic_cast<const PrimeMeridian *>(prime_meridian->obj.get());
if (!l_pm) {
proj_log_error(prime_meridian->ctx, __FUNCTION__,
"Object is not a PrimeMeridian");
return false;
}
const auto &longitude = l_pm->longitude();
if (pLongitude) {
*pLongitude = longitude.value();
}
const auto &unit = longitude.unit();
if (pLongitudeUnitConvFactor) {
*pLongitudeUnitConvFactor = unit.conversionToSI();
}
if (pLongitudeUnitName) {
*pLongitudeUnitName = unit.name().c_str();
}
return true;
}
// ---------------------------------------------------------------------------
/** \brief Return the base CRS of a BoundCRS or the source CRS of a
* CoordinateOperation.
*
* The returned object must be unreferenced with proj_obj_unref() after
* use.
* It should be used by at most one thread at a time.
*
* @param obj Objet of type BoundCRS or CoordinateOperation (must not be NULL)
* @return Object that must be unreferenced with proj_obj_unref(), or NULL
* in case of error, or missing source CRS.
*/
PJ_OBJ *proj_obj_get_source_crs(PJ_OBJ *obj) {
assert(obj);
auto ptr = obj->obj.get();
auto boundCRS = dynamic_cast<const BoundCRS *>(ptr);
if (boundCRS) {
return PJ_OBJ::create(obj->ctx, boundCRS->baseCRS());
}
auto co = dynamic_cast<const CoordinateOperation *>(ptr);
if (co) {
auto sourceCRS = co->sourceCRS();
if (sourceCRS) {
return PJ_OBJ::create(obj->ctx, NN_NO_CHECK(sourceCRS));
}
return nullptr;
}
proj_log_error(obj->ctx, __FUNCTION__,
"Object is not a BoundCRS or a CoordinateOperation");
return nullptr;
}
// ---------------------------------------------------------------------------
/** \brief Return the hub CRS of a BoundCRS or the target CRS of a
* CoordinateOperation.
*
* The returned object must be unreferenced with proj_obj_unref() after
* use.
* It should be used by at most one thread at a time.
*
* @param obj Objet of type BoundCRS or CoordinateOperation (must not be NULL)
* @return Object that must be unreferenced with proj_obj_unref(), or NULL
* in case of error, or missing target CRS.
*/
PJ_OBJ *proj_obj_get_target_crs(PJ_OBJ *obj) {
assert(obj);
auto ptr = obj->obj.get();
auto boundCRS = dynamic_cast<const BoundCRS *>(ptr);
if (boundCRS) {
return PJ_OBJ::create(obj->ctx, boundCRS->hubCRS());
}
auto co = dynamic_cast<const CoordinateOperation *>(ptr);
if (co) {
auto targetCRS = co->targetCRS();
if (targetCRS) {
return PJ_OBJ::create(obj->ctx, NN_NO_CHECK(targetCRS));
}
return nullptr;
}
proj_log_error(obj->ctx, __FUNCTION__,
"Object is not a BoundCRS or a CoordinateOperation");
return nullptr;
}
// ---------------------------------------------------------------------------
/** \brief Identify the CRS with reference CRSs.
*
* The candidate CRSs are either hard-coded, or looked in the database when
* authorityFactory is not null.
*
* The method returns a list of matching reference CRS, and the percentage
* (0-100) of confidence in the match.
* 100% means that the name of the reference entry
* perfectly matches the CRS name, and both are equivalent. In which case a
* single result is returned.
* 90% means that CRS are equivalent, but the names are not exactly the same.
* 70% means that CRS are equivalent), but the names do not match at all.
* 25% means that the CRS are not equivalent, but there is some similarity in
* the names.
* Other confidence values may be returned by some specialized implementations.
*
* This is implemented for GeodeticCRS, ProjectedCRS, VerticalCRS and
* CompoundCRS.
*
* @param obj Object of type CRS. Must not be NULL
* @param auth_name Authority name, or NULL for all authorities
* @param options Placeholder for future options. Should be set to NULL.
* @param confidence Output parameter. Pointer to an array of integers that will
* be allocated by the function and filled with the confidence values
* (0-100). There are as many elements in this array as
* proj_obj_list_get_count()
* returns on the return value of this function. *confidence should be
* released with proj_free_int_list().
* @return a list of matching reference CRS, or nullptr in case of error.
*/
PJ_OBJ_LIST *proj_obj_identify(PJ_OBJ *obj, const char *auth_name,
const char *const *options, int **confidence) {
assert(obj);
(void)options;
if (confidence) {
*confidence = nullptr;
}
auto ptr = obj->obj.get();
auto crs = dynamic_cast<const CRS *>(ptr);
if (!crs) {
proj_log_error(obj->ctx, __FUNCTION__, "Object is not a CRS");
} else {
int *confidenceTemp = nullptr;
try {
auto factory = AuthorityFactory::create(getDBcontext(obj->ctx),
auth_name ? auth_name : "");
auto res = crs->identify(factory);
std::vector<IdentifiedObjectNNPtr> objects;
confidenceTemp = confidence ? new int[res.size()] : nullptr;
size_t i = 0;
for (const auto &pair : res) {
objects.push_back(pair.first);
if (confidenceTemp) {
confidenceTemp[i] = pair.second;
++i;
}
}
auto ret = internal::make_unique<PJ_OBJ_LIST>(obj->ctx,
std::move(objects));
if (confidence) {
*confidence = confidenceTemp;
confidenceTemp = nullptr;
}
return ret.release();
} catch (const std::exception &e) {
delete[] confidenceTemp;
proj_log_error(obj->ctx, __FUNCTION__, e.what());
}
}
return nullptr;
}
// ---------------------------------------------------------------------------
/** \brief Free an array of integer. */
void proj_free_int_list(int *list) { delete[] list; }
// ---------------------------------------------------------------------------
static PROJ_STRING_LIST set_to_string_list(std::set<std::string> &&set) {
auto ret = new char *[set.size() + 1];
size_t i = 0;
for (const auto &str : set) {
ret[i] = new char[str.size() + 1];
std::memcpy(ret[i], str.c_str(), str.size() + 1);
i++;
}
ret[i] = nullptr;
return ret;
}
// ---------------------------------------------------------------------------
/** \brief Return the list of authorities used in the database.
*
* The returned list is NULL terminated and must be freed with
* proj_free_string_list().
*
* @param ctx PROJ context, or NULL for default context
*
* @return a NULL terminated list of NUL-terminated strings that must be
* freed with proj_free_string_list(), or NULL in case of error.
*/
PROJ_STRING_LIST proj_get_authorities_from_database(PJ_CONTEXT *ctx) {
SANITIZE_CTX(ctx);
try {
return set_to_string_list(getDBcontext(ctx)->getAuthorities());
} catch (const std::exception &e) {
proj_log_error(ctx, __FUNCTION__, e.what());
}
return nullptr;
}
// ---------------------------------------------------------------------------
/** \brief Returns the set of authority codes of the given object type.
*
* The returned list is NULL terminated and must be freed with
* proj_free_string_list().
*
* @param ctx PROJ context, or NULL for default context.
* @param auth_name Authority name (must not be NULL)
* @param type Object type.
* @param allow_deprecated whether we should return deprecated objects as well.
*
* @return a NULL terminated list of NUL-terminated strings that must be
* freed with proj_free_string_list(), or NULL in case of error.
*/
PROJ_STRING_LIST proj_get_codes_from_database(PJ_CONTEXT *ctx,
const char *auth_name,
PJ_OBJ_TYPE type,
int allow_deprecated) {
assert(auth_name);
SANITIZE_CTX(ctx);
try {
auto factory = AuthorityFactory::create(getDBcontext(ctx), auth_name);
bool valid = false;
auto typeInternal = convertPJObjectTypeToObjectType(type, valid);
if (!valid) {
return nullptr;
}
return set_to_string_list(
factory->getAuthorityCodes(typeInternal, allow_deprecated != 0));
} catch (const std::exception &e) {
proj_log_error(ctx, __FUNCTION__, e.what());
}
return nullptr;
}
// ---------------------------------------------------------------------------
/** Free a list of NULL terminated strings. */
void proj_free_string_list(PROJ_STRING_LIST list) {
if (list) {
for (size_t i = 0; list[i] != nullptr; i++) {
delete[] list[i];
}
delete[] list;
}
}
// ---------------------------------------------------------------------------
/** \brief Return the Conversion of a DerivedCRS (such as a ProjectedCRS),
* or the Transformation from the baseCRS to the hubCRS of a BoundCRS
*
* The returned object must be unreferenced with proj_obj_unref() after
* use.
* It should be used by at most one thread at a time.
*
* @param crs Objet of type DerivedCRS or BoundCRSs (must not be NULL)
* @param pMethodName Pointer to a string value to store the method
* (projection) name. or NULL
* @param pMethodAuthorityName Pointer to a string value to store the method
* authority name. or NULL
* @param pMethodCode Pointer to a string value to store the method
* code. or NULL
* @return Object of type SingleOperation that must be unreferenced with
* proj_obj_unref(), or NULL in case of error.
*/
PJ_OBJ *proj_obj_crs_get_coordoperation(PJ_OBJ *crs, const char **pMethodName,
const char **pMethodAuthorityName,
const char **pMethodCode) {
assert(crs);
SingleOperationPtr co;
auto derivedCRS = dynamic_cast<const DerivedCRS *>(crs->obj.get());
if (derivedCRS) {
co = derivedCRS->derivingConversion().as_nullable();
} else {
auto boundCRS = dynamic_cast<const BoundCRS *>(crs->obj.get());
if (boundCRS) {
co = boundCRS->transformation().as_nullable();
} else {
proj_log_error(crs->ctx, __FUNCTION__,
"Object is not a DerivedCRS or BoundCRS");
return nullptr;
}
}
const auto &method = co->method();
const auto &method_ids = method->identifiers();
if (pMethodName) {
*pMethodName = method->name()->description()->c_str();
}
if (pMethodAuthorityName) {
if (!method_ids.empty()) {
*pMethodAuthorityName = method_ids[0]->codeSpace()->c_str();
} else {
*pMethodAuthorityName = nullptr;
}
}
if (pMethodCode) {
if (!method_ids.empty()) {
*pMethodCode = method_ids[0]->code().c_str();
} else {
*pMethodCode = nullptr;
}
}
return PJ_OBJ::create(crs->ctx, NN_NO_CHECK(co));
}
// ---------------------------------------------------------------------------
//! @cond Doxygen_Suppress
static PropertyMap createPropertyMapName(const char *name) {
return PropertyMap().set(common::IdentifiedObject::NAME_KEY,
name ? name : "unnamed");
}
// ---------------------------------------------------------------------------
static UnitOfMeasure createLinearUnit(const char *name, double convFactor) {
return name == nullptr ? UnitOfMeasure::METRE
: UnitOfMeasure(name, convFactor);
}
// ---------------------------------------------------------------------------
static UnitOfMeasure createAngularUnit(const char *name, double convFactor) {
return name ? (ci_equal(name, "degree")
? UnitOfMeasure::DEGREE
: ci_equal(name, "grad")
? UnitOfMeasure::GRAD
: UnitOfMeasure(name, convFactor))
: UnitOfMeasure::DEGREE;
}
//! @endcond
// ---------------------------------------------------------------------------
/** \brief Create a GeographicCRS 2D from its definition.
*
* The returned object must be unreferenced with proj_obj_unref() after
* use.
* It should be used by at most one thread at a time.
*
* @param ctx PROJ context, or NULL for default context
* @param geogName Name of the GeographicCRS. Or NULL
* @param datumName Name of the GeodeticReferenceFrame. Or NULL
* @param ellipsoidName Name of the Ellipsoid. Or NULL
* @param semiMajorMetre Ellipsoid semi-major axis, in metres.
* @param invFlattening Ellipsoid inverse flattening. Or 0 for a sphere.
* @param primeMeridianName Name of the PrimeMeridian. Or NULL
* @param primeMeridianOffset Offset of the prime meridian, expressed in the
* specified angular units.
* @param angularUnits Name of the angular units. Or NULL for Degree
* @param angularUnitsConv Conversion factor from the angular unit to radian. Or
* 0 for Degree if angularUnits == NULL. Otherwise should be not NULL
* @param latLongOrder TRUE for Latitude Longitude axis order.
*
* @return Object of type GeographicCRS that must be unreferenced with
* proj_obj_unref(), or NULL in case of error.
*/
PJ_OBJ *proj_obj_create_geographic_crs(
PJ_CONTEXT *ctx, const char *geogName, const char *datumName,
const char *ellipsoidName, double semiMajorMetre, double invFlattening,
const char *primeMeridianName, double primeMeridianOffset,
const char *angularUnits, double angularUnitsConv, int latLongOrder) {
SANITIZE_CTX(ctx);
try {
const UnitOfMeasure angUnit(
createAngularUnit(angularUnits, angularUnitsConv));
auto dbContext = getDBcontext(ctx);
auto body = Ellipsoid::guessBodyName(dbContext, semiMajorMetre);
auto ellpsName = createPropertyMapName(ellipsoidName);
auto ellps =
invFlattening != 0.0
? Ellipsoid::createFlattenedSphere(ellpsName,
Length(semiMajorMetre),
Scale(invFlattening), body)
: Ellipsoid::createSphere(ellpsName, Length(semiMajorMetre),
body);
auto pm = PrimeMeridian::create(
PropertyMap().set(
common::IdentifiedObject::NAME_KEY,
primeMeridianName
? primeMeridianName
: primeMeridianOffset == 0.0
? (ellps->celestialBody() == Ellipsoid::EARTH
? "Greenwich"
: "Reference meridian")
: "unnamed"),
Angle(primeMeridianOffset, angUnit));
auto datum = GeodeticReferenceFrame::create(
createPropertyMapName(datumName), ellps,
util::optional<std::string>(), pm);
auto geogCRS = GeographicCRS::create(
createPropertyMapName(geogName), datum,
latLongOrder ? cs::EllipsoidalCS::createLatitudeLongitude(angUnit)
: cs::EllipsoidalCS::createLongitudeLatitude(angUnit));
return PJ_OBJ::create(ctx, geogCRS);
} catch (const std::exception &e) {
proj_log_error(ctx, __FUNCTION__, e.what());
}
return nullptr;
}
// ---------------------------------------------------------------------------
//! @cond Doxygen_Suppress
static PJ_OBJ *proj_obj_create_projected_crs(PJ_OBJ *geodetic_crs,
const char *crs_name,
const ConversionNNPtr &conv,
const UnitOfMeasure &linearUnit) {
assert(geodetic_crs);
auto geogCRS =
util::nn_dynamic_pointer_cast<GeodeticCRS>(geodetic_crs->obj);
if (!geogCRS) {
return nullptr;
}
auto crs = ProjectedCRS::create(
createPropertyMapName(crs_name), NN_NO_CHECK(geogCRS), conv,
cs::CartesianCS::createEastingNorthing(linearUnit));
return PJ_OBJ::create(geodetic_crs->ctx, crs);
}
//! @endcond
/* BEGIN: Generated by scripts/create_c_api_projections.py*/
// ---------------------------------------------------------------------------
/** \brief Instanciate a ProjectedCRS with a Universal Transverse Mercator
* conversion.
*
* See osgeo::proj::operation::Conversion::createUTM().
*
* Linear parameters are expressed in (linearUnitName, linearUnitConvFactor).
*/
PJ_OBJ *proj_obj_create_projected_crs_UTM(PJ_OBJ *geodetic_crs,
const char *crs_name, int zone,
int north) {
const auto &linearUnit = UnitOfMeasure::METRE;
auto conv = Conversion::createUTM(PropertyMap(), zone, north != 0);
return proj_obj_create_projected_crs(geodetic_crs, crs_name, conv,
linearUnit);
}
// ---------------------------------------------------------------------------
/** \brief Instanciate a ProjectedCRS with a conversion based on the Transverse
* Mercator projection method.
*
* See osgeo::proj::operation::Conversion::createTransverseMercator().
*
* Linear parameters are expressed in (linearUnitName, linearUnitConvFactor).
* Angular parameters are expressed in (angUnitName, angUnitConvFactor).
*/
PJ_OBJ *proj_obj_create_projected_crs_TransverseMercator(
PJ_OBJ *geodetic_crs, const char *crs_name, double centerLat,
double centerLong, double scale, double falseEasting, double falseNorthing,
const char *angUnitName, double angUnitConvFactor,
const char *linearUnitName, double linearUnitConvFactor) {
UnitOfMeasure linearUnit(
createLinearUnit(linearUnitName, linearUnitConvFactor));
UnitOfMeasure angUnit(createAngularUnit(angUnitName, angUnitConvFactor));
auto conv = Conversion::createTransverseMercator(
PropertyMap(), Angle(centerLat, angUnit), Angle(centerLong, angUnit),
Scale(scale), Length(falseEasting, linearUnit),
Length(falseNorthing, linearUnit));
return proj_obj_create_projected_crs(geodetic_crs, crs_name, conv,
linearUnit);
}
// ---------------------------------------------------------------------------
/** \brief Instanciate a ProjectedCRS with a conversion based on the Gauss
* Schreiber Transverse Mercator projection method.
*
* See
* osgeo::proj::operation::Conversion::createGaussSchreiberTransverseMercator().
*
* Linear parameters are expressed in (linearUnitName, linearUnitConvFactor).
* Angular parameters are expressed in (angUnitName, angUnitConvFactor).
*/
PJ_OBJ *proj_obj_create_projected_crs_GaussSchreiberTransverseMercator(
PJ_OBJ *geodetic_crs, const char *crs_name, double centerLat,
double centerLong, double scale, double falseEasting, double falseNorthing,
const char *angUnitName, double angUnitConvFactor,
const char *linearUnitName, double linearUnitConvFactor) {
UnitOfMeasure linearUnit(
createLinearUnit(linearUnitName, linearUnitConvFactor));
UnitOfMeasure angUnit(createAngularUnit(angUnitName, angUnitConvFactor));
auto conv = Conversion::createGaussSchreiberTransverseMercator(
PropertyMap(), Angle(centerLat, angUnit), Angle(centerLong, angUnit),
Scale(scale), Length(falseEasting, linearUnit),
Length(falseNorthing, linearUnit));
return proj_obj_create_projected_crs(geodetic_crs, crs_name, conv,
linearUnit);
}
// ---------------------------------------------------------------------------
/** \brief Instanciate a ProjectedCRS with a conversion based on the Transverse
* Mercator South Orientated projection method.
*
* See
* osgeo::proj::operation::Conversion::createTransverseMercatorSouthOriented().
*
* Linear parameters are expressed in (linearUnitName, linearUnitConvFactor).
* Angular parameters are expressed in (angUnitName, angUnitConvFactor).
*/
PJ_OBJ *proj_obj_create_projected_crs_TransverseMercatorSouthOriented(
PJ_OBJ *geodetic_crs, const char *crs_name, double centerLat,
double centerLong, double scale, double falseEasting, double falseNorthing,
const char *angUnitName, double angUnitConvFactor,
const char *linearUnitName, double linearUnitConvFactor) {
UnitOfMeasure linearUnit(
createLinearUnit(linearUnitName, linearUnitConvFactor));
UnitOfMeasure angUnit(createAngularUnit(angUnitName, angUnitConvFactor));
auto conv = Conversion::createTransverseMercatorSouthOriented(
PropertyMap(), Angle(centerLat, angUnit), Angle(centerLong, angUnit),
Scale(scale), Length(falseEasting, linearUnit),
Length(falseNorthing, linearUnit));
return proj_obj_create_projected_crs(geodetic_crs, crs_name, conv,
linearUnit);
}
// ---------------------------------------------------------------------------
/** \brief Instanciate a ProjectedCRS with a conversion based on the Two Point
* Equidistant projection method.
*
* See osgeo::proj::operation::Conversion::createTwoPointEquidistant().
*
* Linear parameters are expressed in (linearUnitName, linearUnitConvFactor).
* Angular parameters are expressed in (angUnitName, angUnitConvFactor).
*/
PJ_OBJ *proj_obj_create_projected_crs_TwoPointEquidistant(
PJ_OBJ *geodetic_crs, const char *crs_name, double latitudeFirstPoint,
double longitudeFirstPoint, double latitudeSecondPoint,
double longitudeSeconPoint, double falseEasting, double falseNorthing,
const char *angUnitName, double angUnitConvFactor,
const char *linearUnitName, double linearUnitConvFactor) {
UnitOfMeasure linearUnit(
createLinearUnit(linearUnitName, linearUnitConvFactor));
UnitOfMeasure angUnit(createAngularUnit(angUnitName, angUnitConvFactor));
auto conv = Conversion::createTwoPointEquidistant(
PropertyMap(), Angle(latitudeFirstPoint, angUnit),
Angle(longitudeFirstPoint, angUnit),
Angle(latitudeSecondPoint, angUnit),
Angle(longitudeSeconPoint, angUnit), Length(falseEasting, linearUnit),
Length(falseNorthing, linearUnit));
return proj_obj_create_projected_crs(geodetic_crs, crs_name, conv,
linearUnit);
}
// ---------------------------------------------------------------------------
/** \brief Instanciate a ProjectedCRS with a conversion based on the Tunisia
* Mapping Grid projection method.
*
* See osgeo::proj::operation::Conversion::createTunisiaMappingGrid().
*
* Linear parameters are expressed in (linearUnitName, linearUnitConvFactor).
* Angular parameters are expressed in (angUnitName, angUnitConvFactor).
*/
PJ_OBJ *proj_obj_create_projected_crs_TunisiaMappingGrid(
PJ_OBJ *geodetic_crs, const char *crs_name, double centerLat,
double centerLong, double falseEasting, double falseNorthing,
const char *angUnitName, double angUnitConvFactor,
const char *linearUnitName, double linearUnitConvFactor) {
UnitOfMeasure linearUnit(
createLinearUnit(linearUnitName, linearUnitConvFactor));
UnitOfMeasure angUnit(createAngularUnit(angUnitName, angUnitConvFactor));
auto conv = Conversion::createTunisiaMappingGrid(
PropertyMap(), Angle(centerLat, angUnit), Angle(centerLong, angUnit),
Length(falseEasting, linearUnit), Length(falseNorthing, linearUnit));
return proj_obj_create_projected_crs(geodetic_crs, crs_name, conv,
linearUnit);
}
// ---------------------------------------------------------------------------
/** \brief Instanciate a ProjectedCRS with a conversion based on the Albers
* Conic Equal Area projection method.
*
* See osgeo::proj::operation::Conversion::createAlbersEqualArea().
*
* Linear parameters are expressed in (linearUnitName, linearUnitConvFactor).
* Angular parameters are expressed in (angUnitName, angUnitConvFactor).
*/
PJ_OBJ *proj_obj_create_projected_crs_AlbersEqualArea(
PJ_OBJ *geodetic_crs, const char *crs_name, double latitudeFalseOrigin,
double longitudeFalseOrigin, double latitudeFirstParallel,
double latitudeSecondParallel, double eastingFalseOrigin,
double northingFalseOrigin, const char *angUnitName,
double angUnitConvFactor, const char *linearUnitName,
double linearUnitConvFactor) {
UnitOfMeasure linearUnit(
createLinearUnit(linearUnitName, linearUnitConvFactor));
UnitOfMeasure angUnit(createAngularUnit(angUnitName, angUnitConvFactor));
auto conv = Conversion::createAlbersEqualArea(
PropertyMap(), Angle(latitudeFalseOrigin, angUnit),
Angle(longitudeFalseOrigin, angUnit),
Angle(latitudeFirstParallel, angUnit),
Angle(latitudeSecondParallel, angUnit),
Length(eastingFalseOrigin, linearUnit),
Length(northingFalseOrigin, linearUnit));
return proj_obj_create_projected_crs(geodetic_crs, crs_name, conv,
linearUnit);
}
// ---------------------------------------------------------------------------
/** \brief Instanciate a ProjectedCRS with a conversion based on the Lambert
* Conic Conformal 1SP projection method.
*
* See osgeo::proj::operation::Conversion::createLambertConicConformal_1SP().
*
* Linear parameters are expressed in (linearUnitName, linearUnitConvFactor).
* Angular parameters are expressed in (angUnitName, angUnitConvFactor).
*/
PJ_OBJ *proj_obj_create_projected_crs_LambertConicConformal_1SP(
PJ_OBJ *geodetic_crs, const char *crs_name, double centerLat,
double centerLong, double scale, double falseEasting, double falseNorthing,
const char *angUnitName, double angUnitConvFactor,
const char *linearUnitName, double linearUnitConvFactor) {
UnitOfMeasure linearUnit(
createLinearUnit(linearUnitName, linearUnitConvFactor));
UnitOfMeasure angUnit(createAngularUnit(angUnitName, angUnitConvFactor));
auto conv = Conversion::createLambertConicConformal_1SP(
PropertyMap(), Angle(centerLat, angUnit), Angle(centerLong, angUnit),
Scale(scale), Length(falseEasting, linearUnit),
Length(falseNorthing, linearUnit));
return proj_obj_create_projected_crs(geodetic_crs, crs_name, conv,
linearUnit);
}
// ---------------------------------------------------------------------------
/** \brief Instanciate a ProjectedCRS with a conversion based on the Lambert
* Conic Conformal (2SP) projection method.
*
* See osgeo::proj::operation::Conversion::createLambertConicConformal_2SP().
*
* Linear parameters are expressed in (linearUnitName, linearUnitConvFactor).
* Angular parameters are expressed in (angUnitName, angUnitConvFactor).
*/
PJ_OBJ *proj_obj_create_projected_crs_LambertConicConformal_2SP(
PJ_OBJ *geodetic_crs, const char *crs_name, double latitudeFalseOrigin,
double longitudeFalseOrigin, double latitudeFirstParallel,
double latitudeSecondParallel, double eastingFalseOrigin,
double northingFalseOrigin, const char *angUnitName,
double angUnitConvFactor, const char *linearUnitName,
double linearUnitConvFactor) {
UnitOfMeasure linearUnit(
createLinearUnit(linearUnitName, linearUnitConvFactor));
UnitOfMeasure angUnit(createAngularUnit(angUnitName, angUnitConvFactor));
auto conv = Conversion::createLambertConicConformal_2SP(
PropertyMap(), Angle(latitudeFalseOrigin, angUnit),
Angle(longitudeFalseOrigin, angUnit),
Angle(latitudeFirstParallel, angUnit),
Angle(latitudeSecondParallel, angUnit),
Length(eastingFalseOrigin, linearUnit),
Length(northingFalseOrigin, linearUnit));
return proj_obj_create_projected_crs(geodetic_crs, crs_name, conv,
linearUnit);
}
// ---------------------------------------------------------------------------
/** \brief Instanciate a ProjectedCRS with a conversion based on the Lambert
* Conic Conformal (2SP Michigan) projection method.
*
* See
* osgeo::proj::operation::Conversion::createLambertConicConformal_2SP_Michigan().
*
* Linear parameters are expressed in (linearUnitName, linearUnitConvFactor).
* Angular parameters are expressed in (angUnitName, angUnitConvFactor).
*/
PJ_OBJ *proj_obj_create_projected_crs_LambertConicConformal_2SP_Michigan(
PJ_OBJ *geodetic_crs, const char *crs_name, double latitudeFalseOrigin,
double longitudeFalseOrigin, double latitudeFirstParallel,
double latitudeSecondParallel, double eastingFalseOrigin,
double northingFalseOrigin, double ellipsoidScalingFactor,
const char *angUnitName, double angUnitConvFactor,
const char *linearUnitName, double linearUnitConvFactor) {
UnitOfMeasure linearUnit(
createLinearUnit(linearUnitName, linearUnitConvFactor));
UnitOfMeasure angUnit(createAngularUnit(angUnitName, angUnitConvFactor));
auto conv = Conversion::createLambertConicConformal_2SP_Michigan(
PropertyMap(), Angle(latitudeFalseOrigin, angUnit),
Angle(longitudeFalseOrigin, angUnit),
Angle(latitudeFirstParallel, angUnit),
Angle(latitudeSecondParallel, angUnit),
Length(eastingFalseOrigin, linearUnit),
Length(northingFalseOrigin, linearUnit), Scale(ellipsoidScalingFactor));
return proj_obj_create_projected_crs(geodetic_crs, crs_name, conv,
linearUnit);
}
// ---------------------------------------------------------------------------
/** \brief Instanciate a ProjectedCRS with a conversion based on the Lambert
* Conic Conformal (2SP Belgium) projection method.
*
* See
* osgeo::proj::operation::Conversion::createLambertConicConformal_2SP_Belgium().
*
* Linear parameters are expressed in (linearUnitName, linearUnitConvFactor).
* Angular parameters are expressed in (angUnitName, angUnitConvFactor).
*/
PJ_OBJ *proj_obj_create_projected_crs_LambertConicConformal_2SP_Belgium(
PJ_OBJ *geodetic_crs, const char *crs_name, double latitudeFalseOrigin,
double longitudeFalseOrigin, double latitudeFirstParallel,
double latitudeSecondParallel, double eastingFalseOrigin,
double northingFalseOrigin, const char *angUnitName,
double angUnitConvFactor, const char *linearUnitName,
double linearUnitConvFactor) {
UnitOfMeasure linearUnit(
createLinearUnit(linearUnitName, linearUnitConvFactor));
UnitOfMeasure angUnit(createAngularUnit(angUnitName, angUnitConvFactor));
auto conv = Conversion::createLambertConicConformal_2SP_Belgium(
PropertyMap(), Angle(latitudeFalseOrigin, angUnit),
Angle(longitudeFalseOrigin, angUnit),
Angle(latitudeFirstParallel, angUnit),
Angle(latitudeSecondParallel, angUnit),
Length(eastingFalseOrigin, linearUnit),
Length(northingFalseOrigin, linearUnit));
return proj_obj_create_projected_crs(geodetic_crs, crs_name, conv,
linearUnit);
}
// ---------------------------------------------------------------------------
/** \brief Instanciate a ProjectedCRS with a conversion based on the Modified
* Azimuthal Equidistant projection method.
*
* See osgeo::proj::operation::Conversion::createAzimuthalEquidistant().
*
* Linear parameters are expressed in (linearUnitName, linearUnitConvFactor).
* Angular parameters are expressed in (angUnitName, angUnitConvFactor).
*/
PJ_OBJ *proj_obj_create_projected_crs_AzimuthalEquidistant(
PJ_OBJ *geodetic_crs, const char *crs_name, double latitudeNatOrigin,
double longitudeNatOrigin, double falseEasting, double falseNorthing,
const char *angUnitName, double angUnitConvFactor,
const char *linearUnitName, double linearUnitConvFactor) {
UnitOfMeasure linearUnit(
createLinearUnit(linearUnitName, linearUnitConvFactor));
UnitOfMeasure angUnit(createAngularUnit(angUnitName, angUnitConvFactor));
auto conv = Conversion::createAzimuthalEquidistant(
PropertyMap(), Angle(latitudeNatOrigin, angUnit),
Angle(longitudeNatOrigin, angUnit), Length(falseEasting, linearUnit),
Length(falseNorthing, linearUnit));
return proj_obj_create_projected_crs(geodetic_crs, crs_name, conv,
linearUnit);
}
// ---------------------------------------------------------------------------
/** \brief Instanciate a ProjectedCRS with a conversion based on the Guam
* Projection projection method.
*
* See osgeo::proj::operation::Conversion::createGuamProjection().
*
* Linear parameters are expressed in (linearUnitName, linearUnitConvFactor).
* Angular parameters are expressed in (angUnitName, angUnitConvFactor).
*/
PJ_OBJ *proj_obj_create_projected_crs_GuamProjection(
PJ_OBJ *geodetic_crs, const char *crs_name, double latitudeNatOrigin,
double longitudeNatOrigin, double falseEasting, double falseNorthing,
const char *angUnitName, double angUnitConvFactor,
const char *linearUnitName, double linearUnitConvFactor) {
UnitOfMeasure linearUnit(
createLinearUnit(linearUnitName, linearUnitConvFactor));
UnitOfMeasure angUnit(createAngularUnit(angUnitName, angUnitConvFactor));
auto conv = Conversion::createGuamProjection(
PropertyMap(), Angle(latitudeNatOrigin, angUnit),
Angle(longitudeNatOrigin, angUnit), Length(falseEasting, linearUnit),
Length(falseNorthing, linearUnit));
return proj_obj_create_projected_crs(geodetic_crs, crs_name, conv,
linearUnit);
}
// ---------------------------------------------------------------------------
/** \brief Instanciate a ProjectedCRS with a conversion based on the Bonne
* projection method.
*
* See osgeo::proj::operation::Conversion::createBonne().
*
* Linear parameters are expressed in (linearUnitName, linearUnitConvFactor).
* Angular parameters are expressed in (angUnitName, angUnitConvFactor).
*/
PJ_OBJ *proj_obj_create_projected_crs_Bonne(
PJ_OBJ *geodetic_crs, const char *crs_name, double latitudeNatOrigin,
double longitudeNatOrigin, double falseEasting, double falseNorthing,
const char *angUnitName, double angUnitConvFactor,
const char *linearUnitName, double linearUnitConvFactor) {
UnitOfMeasure linearUnit(
createLinearUnit(linearUnitName, linearUnitConvFactor));
UnitOfMeasure angUnit(createAngularUnit(angUnitName, angUnitConvFactor));
auto conv = Conversion::createBonne(
PropertyMap(), Angle(latitudeNatOrigin, angUnit),
Angle(longitudeNatOrigin, angUnit), Length(falseEasting, linearUnit),
Length(falseNorthing, linearUnit));
return proj_obj_create_projected_crs(geodetic_crs, crs_name, conv,
linearUnit);
}
// ---------------------------------------------------------------------------
/** \brief Instanciate a ProjectedCRS with a conversion based on the Lambert
* Cylindrical Equal Area (Spherical) projection method.
*
* See
* osgeo::proj::operation::Conversion::createLambertCylindricalEqualAreaSpherical().
*
* Linear parameters are expressed in (linearUnitName, linearUnitConvFactor).
* Angular parameters are expressed in (angUnitName, angUnitConvFactor).
*/
PJ_OBJ *proj_obj_create_projected_crs_LambertCylindricalEqualAreaSpherical(
PJ_OBJ *geodetic_crs, const char *crs_name, double latitudeFirstParallel,
double longitudeNatOrigin, double falseEasting, double falseNorthing,
const char *angUnitName, double angUnitConvFactor,
const char *linearUnitName, double linearUnitConvFactor) {
UnitOfMeasure linearUnit(
createLinearUnit(linearUnitName, linearUnitConvFactor));
UnitOfMeasure angUnit(createAngularUnit(angUnitName, angUnitConvFactor));
auto conv = Conversion::createLambertCylindricalEqualAreaSpherical(
PropertyMap(), Angle(latitudeFirstParallel, angUnit),
Angle(longitudeNatOrigin, angUnit), Length(falseEasting, linearUnit),
Length(falseNorthing, linearUnit));
return proj_obj_create_projected_crs(geodetic_crs, crs_name, conv,
linearUnit);
}
// ---------------------------------------------------------------------------
/** \brief Instanciate a ProjectedCRS with a conversion based on the Lambert
* Cylindrical Equal Area (ellipsoidal form) projection method.
*
* See osgeo::proj::operation::Conversion::createLambertCylindricalEqualArea().
*
* Linear parameters are expressed in (linearUnitName, linearUnitConvFactor).
* Angular parameters are expressed in (angUnitName, angUnitConvFactor).
*/
PJ_OBJ *proj_obj_create_projected_crs_LambertCylindricalEqualArea(
PJ_OBJ *geodetic_crs, const char *crs_name, double latitudeFirstParallel,
double longitudeNatOrigin, double falseEasting, double falseNorthing,
const char *angUnitName, double angUnitConvFactor,
const char *linearUnitName, double linearUnitConvFactor) {
UnitOfMeasure linearUnit(
createLinearUnit(linearUnitName, linearUnitConvFactor));
UnitOfMeasure angUnit(createAngularUnit(angUnitName, angUnitConvFactor));
auto conv = Conversion::createLambertCylindricalEqualArea(
PropertyMap(), Angle(latitudeFirstParallel, angUnit),
Angle(longitudeNatOrigin, angUnit), Length(falseEasting, linearUnit),
Length(falseNorthing, linearUnit));
return proj_obj_create_projected_crs(geodetic_crs, crs_name, conv,
linearUnit);
}
// ---------------------------------------------------------------------------
/** \brief Instanciate a ProjectedCRS with a conversion based on the
* Cassini-Soldner projection method.
*
* See osgeo::proj::operation::Conversion::createCassiniSoldner().
*
* Linear parameters are expressed in (linearUnitName, linearUnitConvFactor).
* Angular parameters are expressed in (angUnitName, angUnitConvFactor).
*/
PJ_OBJ *proj_obj_create_projected_crs_CassiniSoldner(
PJ_OBJ *geodetic_crs, const char *crs_name, double centerLat,
double centerLong, double falseEasting, double falseNorthing,
const char *angUnitName, double angUnitConvFactor,
const char *linearUnitName, double linearUnitConvFactor) {
UnitOfMeasure linearUnit(
createLinearUnit(linearUnitName, linearUnitConvFactor));
UnitOfMeasure angUnit(createAngularUnit(angUnitName, angUnitConvFactor));
auto conv = Conversion::createCassiniSoldner(
PropertyMap(), Angle(centerLat, angUnit), Angle(centerLong, angUnit),
Length(falseEasting, linearUnit), Length(falseNorthing, linearUnit));
return proj_obj_create_projected_crs(geodetic_crs, crs_name, conv,
linearUnit);
}
// ---------------------------------------------------------------------------
/** \brief Instanciate a ProjectedCRS with a conversion based on the Equidistant
* Conic projection method.
*
* See osgeo::proj::operation::Conversion::createEquidistantConic().
*
* Linear parameters are expressed in (linearUnitName, linearUnitConvFactor).
* Angular parameters are expressed in (angUnitName, angUnitConvFactor).
*/
PJ_OBJ *proj_obj_create_projected_crs_EquidistantConic(
PJ_OBJ *geodetic_crs, const char *crs_name, double centerLat,
double centerLong, double latitudeFirstParallel,
double latitudeSecondParallel, double falseEasting, double falseNorthing,
const char *angUnitName, double angUnitConvFactor,
const char *linearUnitName, double linearUnitConvFactor) {
UnitOfMeasure linearUnit(
createLinearUnit(linearUnitName, linearUnitConvFactor));
UnitOfMeasure angUnit(createAngularUnit(angUnitName, angUnitConvFactor));
auto conv = Conversion::createEquidistantConic(
PropertyMap(), Angle(centerLat, angUnit), Angle(centerLong, angUnit),
Angle(latitudeFirstParallel, angUnit),
Angle(latitudeSecondParallel, angUnit),
Length(falseEasting, linearUnit), Length(falseNorthing, linearUnit));
return proj_obj_create_projected_crs(geodetic_crs, crs_name, conv,
linearUnit);
}
// ---------------------------------------------------------------------------
/** \brief Instanciate a ProjectedCRS with a conversion based on the Eckert I
* projection method.
*
* See osgeo::proj::operation::Conversion::createEckertI().
*
* Linear parameters are expressed in (linearUnitName, linearUnitConvFactor).
* Angular parameters are expressed in (angUnitName, angUnitConvFactor).
*/
PJ_OBJ *proj_obj_create_projected_crs_EckertI(
PJ_OBJ *geodetic_crs, const char *crs_name, double centerLong,
double falseEasting, double falseNorthing, const char *angUnitName,
double angUnitConvFactor, const char *linearUnitName,
double linearUnitConvFactor) {
UnitOfMeasure linearUnit(
createLinearUnit(linearUnitName, linearUnitConvFactor));
UnitOfMeasure angUnit(createAngularUnit(angUnitName, angUnitConvFactor));
auto conv = Conversion::createEckertI(
PropertyMap(), Angle(centerLong, angUnit),
Length(falseEasting, linearUnit), Length(falseNorthing, linearUnit));
return proj_obj_create_projected_crs(geodetic_crs, crs_name, conv,
linearUnit);
}
// ---------------------------------------------------------------------------
/** \brief Instanciate a ProjectedCRS with a conversion based on the Eckert II
* projection method.
*
* See osgeo::proj::operation::Conversion::createEckertII().
*
* Linear parameters are expressed in (linearUnitName, linearUnitConvFactor).
* Angular parameters are expressed in (angUnitName, angUnitConvFactor).
*/
PJ_OBJ *proj_obj_create_projected_crs_EckertII(
PJ_OBJ *geodetic_crs, const char *crs_name, double centerLong,
double falseEasting, double falseNorthing, const char *angUnitName,
double angUnitConvFactor, const char *linearUnitName,
double linearUnitConvFactor) {
UnitOfMeasure linearUnit(
createLinearUnit(linearUnitName, linearUnitConvFactor));
UnitOfMeasure angUnit(createAngularUnit(angUnitName, angUnitConvFactor));
auto conv = Conversion::createEckertII(
PropertyMap(), Angle(centerLong, angUnit),
Length(falseEasting, linearUnit), Length(falseNorthing, linearUnit));
return proj_obj_create_projected_crs(geodetic_crs, crs_name, conv,
linearUnit);
}
// ---------------------------------------------------------------------------
/** \brief Instanciate a ProjectedCRS with a conversion based on the Eckert III
* projection method.
*
* See osgeo::proj::operation::Conversion::createEckertIII().
*
* Linear parameters are expressed in (linearUnitName, linearUnitConvFactor).
* Angular parameters are expressed in (angUnitName, angUnitConvFactor).
*/
PJ_OBJ *proj_obj_create_projected_crs_EckertIII(
PJ_OBJ *geodetic_crs, const char *crs_name, double centerLong,
double falseEasting, double falseNorthing, const char *angUnitName,
double angUnitConvFactor, const char *linearUnitName,
double linearUnitConvFactor) {
UnitOfMeasure linearUnit(
createLinearUnit(linearUnitName, linearUnitConvFactor));
UnitOfMeasure angUnit(createAngularUnit(angUnitName, angUnitConvFactor));
auto conv = Conversion::createEckertIII(
PropertyMap(), Angle(centerLong, angUnit),
Length(falseEasting, linearUnit), Length(falseNorthing, linearUnit));
return proj_obj_create_projected_crs(geodetic_crs, crs_name, conv,
linearUnit);
}
// ---------------------------------------------------------------------------
/** \brief Instanciate a ProjectedCRS with a conversion based on the Eckert IV
* projection method.
*
* See osgeo::proj::operation::Conversion::createEckertIV().
*
* Linear parameters are expressed in (linearUnitName, linearUnitConvFactor).
* Angular parameters are expressed in (angUnitName, angUnitConvFactor).
*/
PJ_OBJ *proj_obj_create_projected_crs_EckertIV(
PJ_OBJ *geodetic_crs, const char *crs_name, double centerLong,
double falseEasting, double falseNorthing, const char *angUnitName,
double angUnitConvFactor, const char *linearUnitName,
double linearUnitConvFactor) {
UnitOfMeasure linearUnit(
createLinearUnit(linearUnitName, linearUnitConvFactor));
UnitOfMeasure angUnit(createAngularUnit(angUnitName, angUnitConvFactor));
auto conv = Conversion::createEckertIV(
PropertyMap(), Angle(centerLong, angUnit),
Length(falseEasting, linearUnit), Length(falseNorthing, linearUnit));
return proj_obj_create_projected_crs(geodetic_crs, crs_name, conv,
linearUnit);
}
// ---------------------------------------------------------------------------
/** \brief Instanciate a ProjectedCRS with a conversion based on the Eckert V
* projection method.
*
* See osgeo::proj::operation::Conversion::createEckertV().
*
* Linear parameters are expressed in (linearUnitName, linearUnitConvFactor).
* Angular parameters are expressed in (angUnitName, angUnitConvFactor).
*/
PJ_OBJ *proj_obj_create_projected_crs_EckertV(
PJ_OBJ *geodetic_crs, const char *crs_name, double centerLong,
double falseEasting, double falseNorthing, const char *angUnitName,
double angUnitConvFactor, const char *linearUnitName,
double linearUnitConvFactor) {
UnitOfMeasure linearUnit(
createLinearUnit(linearUnitName, linearUnitConvFactor));
UnitOfMeasure angUnit(createAngularUnit(angUnitName, angUnitConvFactor));
auto conv = Conversion::createEckertV(
PropertyMap(), Angle(centerLong, angUnit),
Length(falseEasting, linearUnit), Length(falseNorthing, linearUnit));
return proj_obj_create_projected_crs(geodetic_crs, crs_name, conv,
linearUnit);
}
// ---------------------------------------------------------------------------
/** \brief Instanciate a ProjectedCRS with a conversion based on the Eckert VI
* projection method.
*
* See osgeo::proj::operation::Conversion::createEckertVI().
*
* Linear parameters are expressed in (linearUnitName, linearUnitConvFactor).
* Angular parameters are expressed in (angUnitName, angUnitConvFactor).
*/
PJ_OBJ *proj_obj_create_projected_crs_EckertVI(
PJ_OBJ *geodetic_crs, const char *crs_name, double centerLong,
double falseEasting, double falseNorthing, const char *angUnitName,
double angUnitConvFactor, const char *linearUnitName,
double linearUnitConvFactor) {
UnitOfMeasure linearUnit(
createLinearUnit(linearUnitName, linearUnitConvFactor));
UnitOfMeasure angUnit(createAngularUnit(angUnitName, angUnitConvFactor));
auto conv = Conversion::createEckertVI(
PropertyMap(), Angle(centerLong, angUnit),
Length(falseEasting, linearUnit), Length(falseNorthing, linearUnit));
return proj_obj_create_projected_crs(geodetic_crs, crs_name, conv,
linearUnit);
}
// ---------------------------------------------------------------------------
/** \brief Instanciate a ProjectedCRS with a conversion based on the Equidistant
* Cylindrical projection method.
*
* See osgeo::proj::operation::Conversion::createEquidistantCylindrical().
*
* Linear parameters are expressed in (linearUnitName, linearUnitConvFactor).
* Angular parameters are expressed in (angUnitName, angUnitConvFactor).
*/
PJ_OBJ *proj_obj_create_projected_crs_EquidistantCylindrical(
PJ_OBJ *geodetic_crs, const char *crs_name, double latitudeFirstParallel,
double longitudeNatOrigin, double falseEasting, double falseNorthing,
const char *angUnitName, double angUnitConvFactor,
const char *linearUnitName, double linearUnitConvFactor) {
UnitOfMeasure linearUnit(
createLinearUnit(linearUnitName, linearUnitConvFactor));
UnitOfMeasure angUnit(createAngularUnit(angUnitName, angUnitConvFactor));
auto conv = Conversion::createEquidistantCylindrical(
PropertyMap(), Angle(latitudeFirstParallel, angUnit),
Angle(longitudeNatOrigin, angUnit), Length(falseEasting, linearUnit),
Length(falseNorthing, linearUnit));
return proj_obj_create_projected_crs(geodetic_crs, crs_name, conv,
linearUnit);
}
// ---------------------------------------------------------------------------
/** \brief Instanciate a ProjectedCRS with a conversion based on the Equidistant
* Cylindrical (Spherical) projection method.
*
* See
* osgeo::proj::operation::Conversion::createEquidistantCylindricalSpherical().
*
* Linear parameters are expressed in (linearUnitName, linearUnitConvFactor).
* Angular parameters are expressed in (angUnitName, angUnitConvFactor).
*/
PJ_OBJ *proj_obj_create_projected_crs_EquidistantCylindricalSpherical(
PJ_OBJ *geodetic_crs, const char *crs_name, double latitudeFirstParallel,
double longitudeNatOrigin, double falseEasting, double falseNorthing,
const char *angUnitName, double angUnitConvFactor,
const char *linearUnitName, double linearUnitConvFactor) {
UnitOfMeasure linearUnit(
createLinearUnit(linearUnitName, linearUnitConvFactor));
UnitOfMeasure angUnit(createAngularUnit(angUnitName, angUnitConvFactor));
auto conv = Conversion::createEquidistantCylindricalSpherical(
PropertyMap(), Angle(latitudeFirstParallel, angUnit),
Angle(longitudeNatOrigin, angUnit), Length(falseEasting, linearUnit),
Length(falseNorthing, linearUnit));
return proj_obj_create_projected_crs(geodetic_crs, crs_name, conv,
linearUnit);
}
// ---------------------------------------------------------------------------
/** \brief Instanciate a ProjectedCRS with a conversion based on the Gall
* (Stereographic) projection method.
*
* See osgeo::proj::operation::Conversion::createGall().
*
* Linear parameters are expressed in (linearUnitName, linearUnitConvFactor).
* Angular parameters are expressed in (angUnitName, angUnitConvFactor).
*/
PJ_OBJ *proj_obj_create_projected_crs_Gall(
PJ_OBJ *geodetic_crs, const char *crs_name, double centerLong,
double falseEasting, double falseNorthing, const char *angUnitName,
double angUnitConvFactor, const char *linearUnitName,
double linearUnitConvFactor) {
UnitOfMeasure linearUnit(
createLinearUnit(linearUnitName, linearUnitConvFactor));
UnitOfMeasure angUnit(createAngularUnit(angUnitName, angUnitConvFactor));
auto conv = Conversion::createGall(
PropertyMap(), Angle(centerLong, angUnit),
Length(falseEasting, linearUnit), Length(falseNorthing, linearUnit));
return proj_obj_create_projected_crs(geodetic_crs, crs_name, conv,
linearUnit);
}
// ---------------------------------------------------------------------------
/** \brief Instanciate a ProjectedCRS with a conversion based on the Goode
* Homolosine projection method.
*
* See osgeo::proj::operation::Conversion::createGoodeHomolosine().
*
* Linear parameters are expressed in (linearUnitName, linearUnitConvFactor).
* Angular parameters are expressed in (angUnitName, angUnitConvFactor).
*/
PJ_OBJ *proj_obj_create_projected_crs_GoodeHomolosine(
PJ_OBJ *geodetic_crs, const char *crs_name, double centerLong,
double falseEasting, double falseNorthing, const char *angUnitName,
double angUnitConvFactor, const char *linearUnitName,
double linearUnitConvFactor) {
UnitOfMeasure linearUnit(
createLinearUnit(linearUnitName, linearUnitConvFactor));
UnitOfMeasure angUnit(createAngularUnit(angUnitName, angUnitConvFactor));
auto conv = Conversion::createGoodeHomolosine(
PropertyMap(), Angle(centerLong, angUnit),
Length(falseEasting, linearUnit), Length(falseNorthing, linearUnit));
return proj_obj_create_projected_crs(geodetic_crs, crs_name, conv,
linearUnit);
}
// ---------------------------------------------------------------------------
/** \brief Instanciate a ProjectedCRS with a conversion based on the Interrupted
* Goode Homolosine projection method.
*
* See osgeo::proj::operation::Conversion::createInterruptedGoodeHomolosine().
*
* Linear parameters are expressed in (linearUnitName, linearUnitConvFactor).
* Angular parameters are expressed in (angUnitName, angUnitConvFactor).
*/
PJ_OBJ *proj_obj_create_projected_crs_InterruptedGoodeHomolosine(
PJ_OBJ *geodetic_crs, const char *crs_name, double centerLong,
double falseEasting, double falseNorthing, const char *angUnitName,
double angUnitConvFactor, const char *linearUnitName,
double linearUnitConvFactor) {
UnitOfMeasure linearUnit(
createLinearUnit(linearUnitName, linearUnitConvFactor));
UnitOfMeasure angUnit(createAngularUnit(angUnitName, angUnitConvFactor));
auto conv = Conversion::createInterruptedGoodeHomolosine(
PropertyMap(), Angle(centerLong, angUnit),
Length(falseEasting, linearUnit), Length(falseNorthing, linearUnit));
return proj_obj_create_projected_crs(geodetic_crs, crs_name, conv,
linearUnit);
}
// ---------------------------------------------------------------------------
/** \brief Instanciate a ProjectedCRS with a conversion based on the
* Geostationary Satellite View projection method, with the sweep angle axis of
* the viewing instrument being x.
*
* See osgeo::proj::operation::Conversion::createGeostationarySatelliteSweepX().
*
* Linear parameters are expressed in (linearUnitName, linearUnitConvFactor).
* Angular parameters are expressed in (angUnitName, angUnitConvFactor).
*/
PJ_OBJ *proj_obj_create_projected_crs_GeostationarySatelliteSweepX(
PJ_OBJ *geodetic_crs, const char *crs_name, double centerLong,
double height, double falseEasting, double falseNorthing,
const char *angUnitName, double angUnitConvFactor,
const char *linearUnitName, double linearUnitConvFactor) {
UnitOfMeasure linearUnit(
createLinearUnit(linearUnitName, linearUnitConvFactor));
UnitOfMeasure angUnit(createAngularUnit(angUnitName, angUnitConvFactor));
auto conv = Conversion::createGeostationarySatelliteSweepX(
PropertyMap(), Angle(centerLong, angUnit), Length(height, linearUnit),
Length(falseEasting, linearUnit), Length(falseNorthing, linearUnit));
return proj_obj_create_projected_crs(geodetic_crs, crs_name, conv,
linearUnit);
}
// ---------------------------------------------------------------------------
/** \brief Instanciate a ProjectedCRS with a conversion based on the
* Geostationary Satellite View projection method, with the sweep angle axis of
* the viewing instrument being y.
*
* See osgeo::proj::operation::Conversion::createGeostationarySatelliteSweepY().
*
* Linear parameters are expressed in (linearUnitName, linearUnitConvFactor).
* Angular parameters are expressed in (angUnitName, angUnitConvFactor).
*/
PJ_OBJ *proj_obj_create_projected_crs_GeostationarySatelliteSweepY(
PJ_OBJ *geodetic_crs, const char *crs_name, double centerLong,
double height, double falseEasting, double falseNorthing,
const char *angUnitName, double angUnitConvFactor,
const char *linearUnitName, double linearUnitConvFactor) {
UnitOfMeasure linearUnit(
createLinearUnit(linearUnitName, linearUnitConvFactor));
UnitOfMeasure angUnit(createAngularUnit(angUnitName, angUnitConvFactor));
auto conv = Conversion::createGeostationarySatelliteSweepY(
PropertyMap(), Angle(centerLong, angUnit), Length(height, linearUnit),
Length(falseEasting, linearUnit), Length(falseNorthing, linearUnit));
return proj_obj_create_projected_crs(geodetic_crs, crs_name, conv,
linearUnit);
}
// ---------------------------------------------------------------------------
/** \brief Instanciate a ProjectedCRS with a conversion based on the Gnomonic
* projection method.
*
* See osgeo::proj::operation::Conversion::createGnomonic().
*
* Linear parameters are expressed in (linearUnitName, linearUnitConvFactor).
* Angular parameters are expressed in (angUnitName, angUnitConvFactor).
*/
PJ_OBJ *proj_obj_create_projected_crs_Gnomonic(
PJ_OBJ *geodetic_crs, const char *crs_name, double centerLat,
double centerLong, double falseEasting, double falseNorthing,
const char *angUnitName, double angUnitConvFactor,
const char *linearUnitName, double linearUnitConvFactor) {
UnitOfMeasure linearUnit(
createLinearUnit(linearUnitName, linearUnitConvFactor));
UnitOfMeasure angUnit(createAngularUnit(angUnitName, angUnitConvFactor));
auto conv = Conversion::createGnomonic(
PropertyMap(), Angle(centerLat, angUnit), Angle(centerLong, angUnit),
Length(falseEasting, linearUnit), Length(falseNorthing, linearUnit));
return proj_obj_create_projected_crs(geodetic_crs, crs_name, conv,
linearUnit);
}
// ---------------------------------------------------------------------------
/** \brief Instanciate a ProjectedCRS with a conversion based on the Hotine
* Oblique Mercator (Variant A) projection method.
*
* See
* osgeo::proj::operation::Conversion::createHotineObliqueMercatorVariantA().
*
* Linear parameters are expressed in (linearUnitName, linearUnitConvFactor).
* Angular parameters are expressed in (angUnitName, angUnitConvFactor).
*/
PJ_OBJ *proj_obj_create_projected_crs_HotineObliqueMercatorVariantA(
PJ_OBJ *geodetic_crs, const char *crs_name, double latitudeProjectionCentre,
double longitudeProjectionCentre, double azimuthInitialLine,
double angleFromRectifiedToSkrewGrid, double scale, double falseEasting,
double falseNorthing, const char *angUnitName, double angUnitConvFactor,
const char *linearUnitName, double linearUnitConvFactor) {
UnitOfMeasure linearUnit(
createLinearUnit(linearUnitName, linearUnitConvFactor));
UnitOfMeasure angUnit(createAngularUnit(angUnitName, angUnitConvFactor));
auto conv = Conversion::createHotineObliqueMercatorVariantA(
PropertyMap(), Angle(latitudeProjectionCentre, angUnit),
Angle(longitudeProjectionCentre, angUnit),
Angle(azimuthInitialLine, angUnit),
Angle(angleFromRectifiedToSkrewGrid, angUnit), Scale(scale),
Length(falseEasting, linearUnit), Length(falseNorthing, linearUnit));
return proj_obj_create_projected_crs(geodetic_crs, crs_name, conv,
linearUnit);
}
// ---------------------------------------------------------------------------
/** \brief Instanciate a ProjectedCRS with a conversion based on the Hotine
* Oblique Mercator (Variant B) projection method.
*
* See
* osgeo::proj::operation::Conversion::createHotineObliqueMercatorVariantB().
*
* Linear parameters are expressed in (linearUnitName, linearUnitConvFactor).
* Angular parameters are expressed in (angUnitName, angUnitConvFactor).
*/
PJ_OBJ *proj_obj_create_projected_crs_HotineObliqueMercatorVariantB(
PJ_OBJ *geodetic_crs, const char *crs_name, double latitudeProjectionCentre,
double longitudeProjectionCentre, double azimuthInitialLine,
double angleFromRectifiedToSkrewGrid, double scale,
double eastingProjectionCentre, double northingProjectionCentre,
const char *angUnitName, double angUnitConvFactor,
const char *linearUnitName, double linearUnitConvFactor) {
UnitOfMeasure linearUnit(
createLinearUnit(linearUnitName, linearUnitConvFactor));
UnitOfMeasure angUnit(createAngularUnit(angUnitName, angUnitConvFactor));
auto conv = Conversion::createHotineObliqueMercatorVariantB(
PropertyMap(), Angle(latitudeProjectionCentre, angUnit),
Angle(longitudeProjectionCentre, angUnit),
Angle(azimuthInitialLine, angUnit),
Angle(angleFromRectifiedToSkrewGrid, angUnit), Scale(scale),
Length(eastingProjectionCentre, linearUnit),
Length(northingProjectionCentre, linearUnit));
return proj_obj_create_projected_crs(geodetic_crs, crs_name, conv,
linearUnit);
}
// ---------------------------------------------------------------------------
/** \brief Instanciate a ProjectedCRS with a conversion based on the Hotine
* Oblique Mercator Two Point Natural Origin projection method.
*
* See
* osgeo::proj::operation::Conversion::createHotineObliqueMercatorTwoPointNaturalOrigin().
*
* Linear parameters are expressed in (linearUnitName, linearUnitConvFactor).
* Angular parameters are expressed in (angUnitName, angUnitConvFactor).
*/
PJ_OBJ *
proj_obj_create_projected_crs_HotineObliqueMercatorTwoPointNaturalOrigin(
PJ_OBJ *geodetic_crs, const char *crs_name, double latitudeProjectionCentre,
double latitudePoint1, double longitudePoint1, double latitudePoint2,
double longitudePoint2, double scale, double eastingProjectionCentre,
double northingProjectionCentre, const char *angUnitName,
double angUnitConvFactor, const char *linearUnitName,
double linearUnitConvFactor) {
UnitOfMeasure linearUnit(
createLinearUnit(linearUnitName, linearUnitConvFactor));
UnitOfMeasure angUnit(createAngularUnit(angUnitName, angUnitConvFactor));
auto conv = Conversion::createHotineObliqueMercatorTwoPointNaturalOrigin(
PropertyMap(), Angle(latitudeProjectionCentre, angUnit),
Angle(latitudePoint1, angUnit), Angle(longitudePoint1, angUnit),
Angle(latitudePoint2, angUnit), Angle(longitudePoint2, angUnit),
Scale(scale), Length(eastingProjectionCentre, linearUnit),
Length(northingProjectionCentre, linearUnit));
return proj_obj_create_projected_crs(geodetic_crs, crs_name, conv,
linearUnit);
}
// ---------------------------------------------------------------------------
/** \brief Instanciate a ProjectedCRS with a conversion based on the
* International Map of the World Polyconic projection method.
*
* See
* osgeo::proj::operation::Conversion::createInternationalMapWorldPolyconic().
*
* Linear parameters are expressed in (linearUnitName, linearUnitConvFactor).
* Angular parameters are expressed in (angUnitName, angUnitConvFactor).
*/
PJ_OBJ *proj_obj_create_projected_crs_InternationalMapWorldPolyconic(
PJ_OBJ *geodetic_crs, const char *crs_name, double centerLong,
double latitudeFirstParallel, double latitudeSecondParallel,
double falseEasting, double falseNorthing, const char *angUnitName,
double angUnitConvFactor, const char *linearUnitName,
double linearUnitConvFactor) {
UnitOfMeasure linearUnit(
createLinearUnit(linearUnitName, linearUnitConvFactor));
UnitOfMeasure angUnit(createAngularUnit(angUnitName, angUnitConvFactor));
auto conv = Conversion::createInternationalMapWorldPolyconic(
PropertyMap(), Angle(centerLong, angUnit),
Angle(latitudeFirstParallel, angUnit),
Angle(latitudeSecondParallel, angUnit),
Length(falseEasting, linearUnit), Length(falseNorthing, linearUnit));
return proj_obj_create_projected_crs(geodetic_crs, crs_name, conv,
linearUnit);
}
// ---------------------------------------------------------------------------
/** \brief Instanciate a ProjectedCRS with a conversion based on the Krovak
* (north oriented) projection method.
*
* See osgeo::proj::operation::Conversion::createKrovakNorthOriented().
*
* Linear parameters are expressed in (linearUnitName, linearUnitConvFactor).
* Angular parameters are expressed in (angUnitName, angUnitConvFactor).
*/
PJ_OBJ *proj_obj_create_projected_crs_KrovakNorthOriented(
PJ_OBJ *geodetic_crs, const char *crs_name, double latitudeProjectionCentre,
double longitudeOfOrigin, double colatitudeConeAxis,
double latitudePseudoStandardParallel,
double scaleFactorPseudoStandardParallel, double falseEasting,
double falseNorthing, const char *angUnitName, double angUnitConvFactor,
const char *linearUnitName, double linearUnitConvFactor) {
UnitOfMeasure linearUnit(
createLinearUnit(linearUnitName, linearUnitConvFactor));
UnitOfMeasure angUnit(createAngularUnit(angUnitName, angUnitConvFactor));
auto conv = Conversion::createKrovakNorthOriented(
PropertyMap(), Angle(latitudeProjectionCentre, angUnit),
Angle(longitudeOfOrigin, angUnit), Angle(colatitudeConeAxis, angUnit),
Angle(latitudePseudoStandardParallel, angUnit),
Scale(scaleFactorPseudoStandardParallel),
Length(falseEasting, linearUnit), Length(falseNorthing, linearUnit));
return proj_obj_create_projected_crs(geodetic_crs, crs_name, conv,
linearUnit);
}
// ---------------------------------------------------------------------------
/** \brief Instanciate a ProjectedCRS with a conversion based on the Krovak
* projection method.
*
* See osgeo::proj::operation::Conversion::createKrovak().
*
* Linear parameters are expressed in (linearUnitName, linearUnitConvFactor).
* Angular parameters are expressed in (angUnitName, angUnitConvFactor).
*/
PJ_OBJ *proj_obj_create_projected_crs_Krovak(
PJ_OBJ *geodetic_crs, const char *crs_name, double latitudeProjectionCentre,
double longitudeOfOrigin, double colatitudeConeAxis,
double latitudePseudoStandardParallel,
double scaleFactorPseudoStandardParallel, double falseEasting,
double falseNorthing, const char *angUnitName, double angUnitConvFactor,
const char *linearUnitName, double linearUnitConvFactor) {
UnitOfMeasure linearUnit(
createLinearUnit(linearUnitName, linearUnitConvFactor));
UnitOfMeasure angUnit(createAngularUnit(angUnitName, angUnitConvFactor));
auto conv = Conversion::createKrovak(
PropertyMap(), Angle(latitudeProjectionCentre, angUnit),
Angle(longitudeOfOrigin, angUnit), Angle(colatitudeConeAxis, angUnit),
Angle(latitudePseudoStandardParallel, angUnit),
Scale(scaleFactorPseudoStandardParallel),
Length(falseEasting, linearUnit), Length(falseNorthing, linearUnit));
return proj_obj_create_projected_crs(geodetic_crs, crs_name, conv,
linearUnit);
}
// ---------------------------------------------------------------------------
/** \brief Instanciate a ProjectedCRS with a conversion based on the Lambert
* Azimuthal Equal Area projection method.
*
* See osgeo::proj::operation::Conversion::createLambertAzimuthalEqualArea().
*
* Linear parameters are expressed in (linearUnitName, linearUnitConvFactor).
* Angular parameters are expressed in (angUnitName, angUnitConvFactor).
*/
PJ_OBJ *proj_obj_create_projected_crs_LambertAzimuthalEqualArea(
PJ_OBJ *geodetic_crs, const char *crs_name, double latitudeNatOrigin,
double longitudeNatOrigin, double falseEasting, double falseNorthing,
const char *angUnitName, double angUnitConvFactor,
const char *linearUnitName, double linearUnitConvFactor) {
UnitOfMeasure linearUnit(
createLinearUnit(linearUnitName, linearUnitConvFactor));
UnitOfMeasure angUnit(createAngularUnit(angUnitName, angUnitConvFactor));
auto conv = Conversion::createLambertAzimuthalEqualArea(
PropertyMap(), Angle(latitudeNatOrigin, angUnit),
Angle(longitudeNatOrigin, angUnit), Length(falseEasting, linearUnit),
Length(falseNorthing, linearUnit));
return proj_obj_create_projected_crs(geodetic_crs, crs_name, conv,
linearUnit);
}
// ---------------------------------------------------------------------------
/** \brief Instanciate a ProjectedCRS with a conversion based on the Miller
* Cylindrical projection method.
*
* See osgeo::proj::operation::Conversion::createMillerCylindrical().
*
* Linear parameters are expressed in (linearUnitName, linearUnitConvFactor).
* Angular parameters are expressed in (angUnitName, angUnitConvFactor).
*/
PJ_OBJ *proj_obj_create_projected_crs_MillerCylindrical(
PJ_OBJ *geodetic_crs, const char *crs_name, double centerLong,
double falseEasting, double falseNorthing, const char *angUnitName,
double angUnitConvFactor, const char *linearUnitName,
double linearUnitConvFactor) {
UnitOfMeasure linearUnit(
createLinearUnit(linearUnitName, linearUnitConvFactor));
UnitOfMeasure angUnit(createAngularUnit(angUnitName, angUnitConvFactor));
auto conv = Conversion::createMillerCylindrical(
PropertyMap(), Angle(centerLong, angUnit),
Length(falseEasting, linearUnit), Length(falseNorthing, linearUnit));
return proj_obj_create_projected_crs(geodetic_crs, crs_name, conv,
linearUnit);
}
// ---------------------------------------------------------------------------
/** \brief Instanciate a ProjectedCRS with a conversion based on the Mercator
* projection method.
*
* See osgeo::proj::operation::Conversion::createMercatorVariantA().
*
* Linear parameters are expressed in (linearUnitName, linearUnitConvFactor).
* Angular parameters are expressed in (angUnitName, angUnitConvFactor).
*/
PJ_OBJ *proj_obj_create_projected_crs_MercatorVariantA(
PJ_OBJ *geodetic_crs, const char *crs_name, double centerLat,
double centerLong, double scale, double falseEasting, double falseNorthing,
const char *angUnitName, double angUnitConvFactor,
const char *linearUnitName, double linearUnitConvFactor) {
UnitOfMeasure linearUnit(
createLinearUnit(linearUnitName, linearUnitConvFactor));
UnitOfMeasure angUnit(createAngularUnit(angUnitName, angUnitConvFactor));
auto conv = Conversion::createMercatorVariantA(
PropertyMap(), Angle(centerLat, angUnit), Angle(centerLong, angUnit),
Scale(scale), Length(falseEasting, linearUnit),
Length(falseNorthing, linearUnit));
return proj_obj_create_projected_crs(geodetic_crs, crs_name, conv,
linearUnit);
}
// ---------------------------------------------------------------------------
/** \brief Instanciate a ProjectedCRS with a conversion based on the Mercator
* projection method.
*
* See osgeo::proj::operation::Conversion::createMercatorVariantB().
*
* Linear parameters are expressed in (linearUnitName, linearUnitConvFactor).
* Angular parameters are expressed in (angUnitName, angUnitConvFactor).
*/
PJ_OBJ *proj_obj_create_projected_crs_MercatorVariantB(
PJ_OBJ *geodetic_crs, const char *crs_name, double latitudeFirstParallel,
double centerLong, double falseEasting, double falseNorthing,
const char *angUnitName, double angUnitConvFactor,
const char *linearUnitName, double linearUnitConvFactor) {
UnitOfMeasure linearUnit(
createLinearUnit(linearUnitName, linearUnitConvFactor));
UnitOfMeasure angUnit(createAngularUnit(angUnitName, angUnitConvFactor));
auto conv = Conversion::createMercatorVariantB(
PropertyMap(), Angle(latitudeFirstParallel, angUnit),
Angle(centerLong, angUnit), Length(falseEasting, linearUnit),
Length(falseNorthing, linearUnit));
return proj_obj_create_projected_crs(geodetic_crs, crs_name, conv,
linearUnit);
}
// ---------------------------------------------------------------------------
/** \brief Instanciate a ProjectedCRS with a conversion based on the Popular
* Visualisation Pseudo Mercator projection method.
*
* See
* osgeo::proj::operation::Conversion::createPopularVisualisationPseudoMercator().
*
* Linear parameters are expressed in (linearUnitName, linearUnitConvFactor).
* Angular parameters are expressed in (angUnitName, angUnitConvFactor).
*/
PJ_OBJ *proj_obj_create_projected_crs_PopularVisualisationPseudoMercator(
PJ_OBJ *geodetic_crs, const char *crs_name, double centerLat,
double centerLong, double falseEasting, double falseNorthing,
const char *angUnitName, double angUnitConvFactor,
const char *linearUnitName, double linearUnitConvFactor) {
UnitOfMeasure linearUnit(
createLinearUnit(linearUnitName, linearUnitConvFactor));
UnitOfMeasure angUnit(createAngularUnit(angUnitName, angUnitConvFactor));
auto conv = Conversion::createPopularVisualisationPseudoMercator(
PropertyMap(), Angle(centerLat, angUnit), Angle(centerLong, angUnit),
Length(falseEasting, linearUnit), Length(falseNorthing, linearUnit));
return proj_obj_create_projected_crs(geodetic_crs, crs_name, conv,
linearUnit);
}
// ---------------------------------------------------------------------------
/** \brief Instanciate a ProjectedCRS with a conversion based on the Mollweide
* projection method.
*
* See osgeo::proj::operation::Conversion::createMollweide().
*
* Linear parameters are expressed in (linearUnitName, linearUnitConvFactor).
* Angular parameters are expressed in (angUnitName, angUnitConvFactor).
*/
PJ_OBJ *proj_obj_create_projected_crs_Mollweide(
PJ_OBJ *geodetic_crs, const char *crs_name, double centerLong,
double falseEasting, double falseNorthing, const char *angUnitName,
double angUnitConvFactor, const char *linearUnitName,
double linearUnitConvFactor) {
UnitOfMeasure linearUnit(
createLinearUnit(linearUnitName, linearUnitConvFactor));
UnitOfMeasure angUnit(createAngularUnit(angUnitName, angUnitConvFactor));
auto conv = Conversion::createMollweide(
PropertyMap(), Angle(centerLong, angUnit),
Length(falseEasting, linearUnit), Length(falseNorthing, linearUnit));
return proj_obj_create_projected_crs(geodetic_crs, crs_name, conv,
linearUnit);
}
// ---------------------------------------------------------------------------
/** \brief Instanciate a ProjectedCRS with a conversion based on the New Zealand
* Map Grid projection method.
*
* See osgeo::proj::operation::Conversion::createNewZealandMappingGrid().
*
* Linear parameters are expressed in (linearUnitName, linearUnitConvFactor).
* Angular parameters are expressed in (angUnitName, angUnitConvFactor).
*/
PJ_OBJ *proj_obj_create_projected_crs_NewZealandMappingGrid(
PJ_OBJ *geodetic_crs, const char *crs_name, double centerLat,
double centerLong, double falseEasting, double falseNorthing,
const char *angUnitName, double angUnitConvFactor,
const char *linearUnitName, double linearUnitConvFactor) {
UnitOfMeasure linearUnit(
createLinearUnit(linearUnitName, linearUnitConvFactor));
UnitOfMeasure angUnit(createAngularUnit(angUnitName, angUnitConvFactor));
auto conv = Conversion::createNewZealandMappingGrid(
PropertyMap(), Angle(centerLat, angUnit), Angle(centerLong, angUnit),
Length(falseEasting, linearUnit), Length(falseNorthing, linearUnit));
return proj_obj_create_projected_crs(geodetic_crs, crs_name, conv,
linearUnit);
}
// ---------------------------------------------------------------------------
/** \brief Instanciate a ProjectedCRS with a conversion based on the Oblique
* Stereographic (Alternative) projection method.
*
* See osgeo::proj::operation::Conversion::createObliqueStereographic().
*
* Linear parameters are expressed in (linearUnitName, linearUnitConvFactor).
* Angular parameters are expressed in (angUnitName, angUnitConvFactor).
*/
PJ_OBJ *proj_obj_create_projected_crs_ObliqueStereographic(
PJ_OBJ *geodetic_crs, const char *crs_name, double centerLat,
double centerLong, double scale, double falseEasting, double falseNorthing,
const char *angUnitName, double angUnitConvFactor,
const char *linearUnitName, double linearUnitConvFactor) {
UnitOfMeasure linearUnit(
createLinearUnit(linearUnitName, linearUnitConvFactor));
UnitOfMeasure angUnit(createAngularUnit(angUnitName, angUnitConvFactor));
auto conv = Conversion::createObliqueStereographic(
PropertyMap(), Angle(centerLat, angUnit), Angle(centerLong, angUnit),
Scale(scale), Length(falseEasting, linearUnit),
Length(falseNorthing, linearUnit));
return proj_obj_create_projected_crs(geodetic_crs, crs_name, conv,
linearUnit);
}
// ---------------------------------------------------------------------------
/** \brief Instanciate a ProjectedCRS with a conversion based on the
* Orthographic projection method.
*
* See osgeo::proj::operation::Conversion::createOrthographic().
*
* Linear parameters are expressed in (linearUnitName, linearUnitConvFactor).
* Angular parameters are expressed in (angUnitName, angUnitConvFactor).
*/
PJ_OBJ *proj_obj_create_projected_crs_Orthographic(
PJ_OBJ *geodetic_crs, const char *crs_name, double centerLat,
double centerLong, double falseEasting, double falseNorthing,
const char *angUnitName, double angUnitConvFactor,
const char *linearUnitName, double linearUnitConvFactor) {
UnitOfMeasure linearUnit(
createLinearUnit(linearUnitName, linearUnitConvFactor));
UnitOfMeasure angUnit(createAngularUnit(angUnitName, angUnitConvFactor));
auto conv = Conversion::createOrthographic(
PropertyMap(), Angle(centerLat, angUnit), Angle(centerLong, angUnit),
Length(falseEasting, linearUnit), Length(falseNorthing, linearUnit));
return proj_obj_create_projected_crs(geodetic_crs, crs_name, conv,
linearUnit);
}
// ---------------------------------------------------------------------------
/** \brief Instanciate a ProjectedCRS with a conversion based on the American
* Polyconic projection method.
*
* See osgeo::proj::operation::Conversion::createAmericanPolyconic().
*
* Linear parameters are expressed in (linearUnitName, linearUnitConvFactor).
* Angular parameters are expressed in (angUnitName, angUnitConvFactor).
*/
PJ_OBJ *proj_obj_create_projected_crs_AmericanPolyconic(
PJ_OBJ *geodetic_crs, const char *crs_name, double centerLat,
double centerLong, double falseEasting, double falseNorthing,
const char *angUnitName, double angUnitConvFactor,
const char *linearUnitName, double linearUnitConvFactor) {
UnitOfMeasure linearUnit(
createLinearUnit(linearUnitName, linearUnitConvFactor));
UnitOfMeasure angUnit(createAngularUnit(angUnitName, angUnitConvFactor));
auto conv = Conversion::createAmericanPolyconic(
PropertyMap(), Angle(centerLat, angUnit), Angle(centerLong, angUnit),
Length(falseEasting, linearUnit), Length(falseNorthing, linearUnit));
return proj_obj_create_projected_crs(geodetic_crs, crs_name, conv,
linearUnit);
}
// ---------------------------------------------------------------------------
/** \brief Instanciate a ProjectedCRS with a conversion based on the Polar
* Stereographic (Variant A) projection method.
*
* See osgeo::proj::operation::Conversion::createPolarStereographicVariantA().
*
* Linear parameters are expressed in (linearUnitName, linearUnitConvFactor).
* Angular parameters are expressed in (angUnitName, angUnitConvFactor).
*/
PJ_OBJ *proj_obj_create_projected_crs_PolarStereographicVariantA(
PJ_OBJ *geodetic_crs, const char *crs_name, double centerLat,
double centerLong, double scale, double falseEasting, double falseNorthing,
const char *angUnitName, double angUnitConvFactor,
const char *linearUnitName, double linearUnitConvFactor) {
UnitOfMeasure linearUnit(
createLinearUnit(linearUnitName, linearUnitConvFactor));
UnitOfMeasure angUnit(createAngularUnit(angUnitName, angUnitConvFactor));
auto conv = Conversion::createPolarStereographicVariantA(
PropertyMap(), Angle(centerLat, angUnit), Angle(centerLong, angUnit),
Scale(scale), Length(falseEasting, linearUnit),
Length(falseNorthing, linearUnit));
return proj_obj_create_projected_crs(geodetic_crs, crs_name, conv,
linearUnit);
}
// ---------------------------------------------------------------------------
/** \brief Instanciate a ProjectedCRS with a conversion based on the Polar
* Stereographic (Variant B) projection method.
*
* See osgeo::proj::operation::Conversion::createPolarStereographicVariantB().
*
* Linear parameters are expressed in (linearUnitName, linearUnitConvFactor).
* Angular parameters are expressed in (angUnitName, angUnitConvFactor).
*/
PJ_OBJ *proj_obj_create_projected_crs_PolarStereographicVariantB(
PJ_OBJ *geodetic_crs, const char *crs_name, double latitudeStandardParallel,
double longitudeOfOrigin, double falseEasting, double falseNorthing,
const char *angUnitName, double angUnitConvFactor,
const char *linearUnitName, double linearUnitConvFactor) {
UnitOfMeasure linearUnit(
createLinearUnit(linearUnitName, linearUnitConvFactor));
UnitOfMeasure angUnit(createAngularUnit(angUnitName, angUnitConvFactor));
auto conv = Conversion::createPolarStereographicVariantB(
PropertyMap(), Angle(latitudeStandardParallel, angUnit),
Angle(longitudeOfOrigin, angUnit), Length(falseEasting, linearUnit),
Length(falseNorthing, linearUnit));
return proj_obj_create_projected_crs(geodetic_crs, crs_name, conv,
linearUnit);
}
// ---------------------------------------------------------------------------
/** \brief Instanciate a ProjectedCRS with a conversion based on the Robinson
* projection method.
*
* See osgeo::proj::operation::Conversion::createRobinson().
*
* Linear parameters are expressed in (linearUnitName, linearUnitConvFactor).
* Angular parameters are expressed in (angUnitName, angUnitConvFactor).
*/
PJ_OBJ *proj_obj_create_projected_crs_Robinson(
PJ_OBJ *geodetic_crs, const char *crs_name, double centerLong,
double falseEasting, double falseNorthing, const char *angUnitName,
double angUnitConvFactor, const char *linearUnitName,
double linearUnitConvFactor) {
UnitOfMeasure linearUnit(
createLinearUnit(linearUnitName, linearUnitConvFactor));
UnitOfMeasure angUnit(createAngularUnit(angUnitName, angUnitConvFactor));
auto conv = Conversion::createRobinson(
PropertyMap(), Angle(centerLong, angUnit),
Length(falseEasting, linearUnit), Length(falseNorthing, linearUnit));
return proj_obj_create_projected_crs(geodetic_crs, crs_name, conv,
linearUnit);
}
// ---------------------------------------------------------------------------
/** \brief Instanciate a ProjectedCRS with a conversion based on the Sinusoidal
* projection method.
*
* See osgeo::proj::operation::Conversion::createSinusoidal().
*
* Linear parameters are expressed in (linearUnitName, linearUnitConvFactor).
* Angular parameters are expressed in (angUnitName, angUnitConvFactor).
*/
PJ_OBJ *proj_obj_create_projected_crs_Sinusoidal(
PJ_OBJ *geodetic_crs, const char *crs_name, double centerLong,
double falseEasting, double falseNorthing, const char *angUnitName,
double angUnitConvFactor, const char *linearUnitName,
double linearUnitConvFactor) {
UnitOfMeasure linearUnit(
createLinearUnit(linearUnitName, linearUnitConvFactor));
UnitOfMeasure angUnit(createAngularUnit(angUnitName, angUnitConvFactor));
auto conv = Conversion::createSinusoidal(
PropertyMap(), Angle(centerLong, angUnit),
Length(falseEasting, linearUnit), Length(falseNorthing, linearUnit));
return proj_obj_create_projected_crs(geodetic_crs, crs_name, conv,
linearUnit);
}
// ---------------------------------------------------------------------------
/** \brief Instanciate a ProjectedCRS with a conversion based on the
* Stereographic projection method.
*
* See osgeo::proj::operation::Conversion::createStereographic().
*
* Linear parameters are expressed in (linearUnitName, linearUnitConvFactor).
* Angular parameters are expressed in (angUnitName, angUnitConvFactor).
*/
PJ_OBJ *proj_obj_create_projected_crs_Stereographic(
PJ_OBJ *geodetic_crs, const char *crs_name, double centerLat,
double centerLong, double scale, double falseEasting, double falseNorthing,
const char *angUnitName, double angUnitConvFactor,
const char *linearUnitName, double linearUnitConvFactor) {
UnitOfMeasure linearUnit(
createLinearUnit(linearUnitName, linearUnitConvFactor));
UnitOfMeasure angUnit(createAngularUnit(angUnitName, angUnitConvFactor));
auto conv = Conversion::createStereographic(
PropertyMap(), Angle(centerLat, angUnit), Angle(centerLong, angUnit),
Scale(scale), Length(falseEasting, linearUnit),
Length(falseNorthing, linearUnit));
return proj_obj_create_projected_crs(geodetic_crs, crs_name, conv,
linearUnit);
}
// ---------------------------------------------------------------------------
/** \brief Instanciate a ProjectedCRS with a conversion based on the Van der
* Grinten projection method.
*
* See osgeo::proj::operation::Conversion::createVanDerGrinten().
*
* Linear parameters are expressed in (linearUnitName, linearUnitConvFactor).
* Angular parameters are expressed in (angUnitName, angUnitConvFactor).
*/
PJ_OBJ *proj_obj_create_projected_crs_VanDerGrinten(
PJ_OBJ *geodetic_crs, const char *crs_name, double centerLong,
double falseEasting, double falseNorthing, const char *angUnitName,
double angUnitConvFactor, const char *linearUnitName,
double linearUnitConvFactor) {
UnitOfMeasure linearUnit(
createLinearUnit(linearUnitName, linearUnitConvFactor));
UnitOfMeasure angUnit(createAngularUnit(angUnitName, angUnitConvFactor));
auto conv = Conversion::createVanDerGrinten(
PropertyMap(), Angle(centerLong, angUnit),
Length(falseEasting, linearUnit), Length(falseNorthing, linearUnit));
return proj_obj_create_projected_crs(geodetic_crs, crs_name, conv,
linearUnit);
}
// ---------------------------------------------------------------------------
/** \brief Instanciate a ProjectedCRS with a conversion based on the Wagner I
* projection method.
*
* See osgeo::proj::operation::Conversion::createWagnerI().
*
* Linear parameters are expressed in (linearUnitName, linearUnitConvFactor).
* Angular parameters are expressed in (angUnitName, angUnitConvFactor).
*/
PJ_OBJ *proj_obj_create_projected_crs_WagnerI(
PJ_OBJ *geodetic_crs, const char *crs_name, double centerLong,
double falseEasting, double falseNorthing, const char *angUnitName,
double angUnitConvFactor, const char *linearUnitName,
double linearUnitConvFactor) {
UnitOfMeasure linearUnit(
createLinearUnit(linearUnitName, linearUnitConvFactor));
UnitOfMeasure angUnit(createAngularUnit(angUnitName, angUnitConvFactor));
auto conv = Conversion::createWagnerI(
PropertyMap(), Angle(centerLong, angUnit),
Length(falseEasting, linearUnit), Length(falseNorthing, linearUnit));
return proj_obj_create_projected_crs(geodetic_crs, crs_name, conv,
linearUnit);
}
// ---------------------------------------------------------------------------
/** \brief Instanciate a ProjectedCRS with a conversion based on the Wagner II
* projection method.
*
* See osgeo::proj::operation::Conversion::createWagnerII().
*
* Linear parameters are expressed in (linearUnitName, linearUnitConvFactor).
* Angular parameters are expressed in (angUnitName, angUnitConvFactor).
*/
PJ_OBJ *proj_obj_create_projected_crs_WagnerII(
PJ_OBJ *geodetic_crs, const char *crs_name, double centerLong,
double falseEasting, double falseNorthing, const char *angUnitName,
double angUnitConvFactor, const char *linearUnitName,
double linearUnitConvFactor) {
UnitOfMeasure linearUnit(
createLinearUnit(linearUnitName, linearUnitConvFactor));
UnitOfMeasure angUnit(createAngularUnit(angUnitName, angUnitConvFactor));
auto conv = Conversion::createWagnerII(
PropertyMap(), Angle(centerLong, angUnit),
Length(falseEasting, linearUnit), Length(falseNorthing, linearUnit));
return proj_obj_create_projected_crs(geodetic_crs, crs_name, conv,
linearUnit);
}
// ---------------------------------------------------------------------------
/** \brief Instanciate a ProjectedCRS with a conversion based on the Wagner III
* projection method.
*
* See osgeo::proj::operation::Conversion::createWagnerIII().
*
* Linear parameters are expressed in (linearUnitName, linearUnitConvFactor).
* Angular parameters are expressed in (angUnitName, angUnitConvFactor).
*/
PJ_OBJ *proj_obj_create_projected_crs_WagnerIII(
PJ_OBJ *geodetic_crs, const char *crs_name, double latitudeTrueScale,
double centerLong, double falseEasting, double falseNorthing,
const char *angUnitName, double angUnitConvFactor,
const char *linearUnitName, double linearUnitConvFactor) {
UnitOfMeasure linearUnit(
createLinearUnit(linearUnitName, linearUnitConvFactor));
UnitOfMeasure angUnit(createAngularUnit(angUnitName, angUnitConvFactor));
auto conv = Conversion::createWagnerIII(
PropertyMap(), Angle(latitudeTrueScale, angUnit),
Angle(centerLong, angUnit), Length(falseEasting, linearUnit),
Length(falseNorthing, linearUnit));
return proj_obj_create_projected_crs(geodetic_crs, crs_name, conv,
linearUnit);
}
// ---------------------------------------------------------------------------
/** \brief Instanciate a ProjectedCRS with a conversion based on the Wagner IV
* projection method.
*
* See osgeo::proj::operation::Conversion::createWagnerIV().
*
* Linear parameters are expressed in (linearUnitName, linearUnitConvFactor).
* Angular parameters are expressed in (angUnitName, angUnitConvFactor).
*/
PJ_OBJ *proj_obj_create_projected_crs_WagnerIV(
PJ_OBJ *geodetic_crs, const char *crs_name, double centerLong,
double falseEasting, double falseNorthing, const char *angUnitName,
double angUnitConvFactor, const char *linearUnitName,
double linearUnitConvFactor) {
UnitOfMeasure linearUnit(
createLinearUnit(linearUnitName, linearUnitConvFactor));
UnitOfMeasure angUnit(createAngularUnit(angUnitName, angUnitConvFactor));
auto conv = Conversion::createWagnerIV(
PropertyMap(), Angle(centerLong, angUnit),
Length(falseEasting, linearUnit), Length(falseNorthing, linearUnit));
return proj_obj_create_projected_crs(geodetic_crs, crs_name, conv,
linearUnit);
}
// ---------------------------------------------------------------------------
/** \brief Instanciate a ProjectedCRS with a conversion based on the Wagner V
* projection method.
*
* See osgeo::proj::operation::Conversion::createWagnerV().
*
* Linear parameters are expressed in (linearUnitName, linearUnitConvFactor).
* Angular parameters are expressed in (angUnitName, angUnitConvFactor).
*/
PJ_OBJ *proj_obj_create_projected_crs_WagnerV(
PJ_OBJ *geodetic_crs, const char *crs_name, double centerLong,
double falseEasting, double falseNorthing, const char *angUnitName,
double angUnitConvFactor, const char *linearUnitName,
double linearUnitConvFactor) {
UnitOfMeasure linearUnit(
createLinearUnit(linearUnitName, linearUnitConvFactor));
UnitOfMeasure angUnit(createAngularUnit(angUnitName, angUnitConvFactor));
auto conv = Conversion::createWagnerV(
PropertyMap(), Angle(centerLong, angUnit),
Length(falseEasting, linearUnit), Length(falseNorthing, linearUnit));
return proj_obj_create_projected_crs(geodetic_crs, crs_name, conv,
linearUnit);
}
// ---------------------------------------------------------------------------
/** \brief Instanciate a ProjectedCRS with a conversion based on the Wagner VI
* projection method.
*
* See osgeo::proj::operation::Conversion::createWagnerVI().
*
* Linear parameters are expressed in (linearUnitName, linearUnitConvFactor).
* Angular parameters are expressed in (angUnitName, angUnitConvFactor).
*/
PJ_OBJ *proj_obj_create_projected_crs_WagnerVI(
PJ_OBJ *geodetic_crs, const char *crs_name, double centerLong,
double falseEasting, double falseNorthing, const char *angUnitName,
double angUnitConvFactor, const char *linearUnitName,
double linearUnitConvFactor) {
UnitOfMeasure linearUnit(
createLinearUnit(linearUnitName, linearUnitConvFactor));
UnitOfMeasure angUnit(createAngularUnit(angUnitName, angUnitConvFactor));
auto conv = Conversion::createWagnerVI(
PropertyMap(), Angle(centerLong, angUnit),
Length(falseEasting, linearUnit), Length(falseNorthing, linearUnit));
return proj_obj_create_projected_crs(geodetic_crs, crs_name, conv,
linearUnit);
}
// ---------------------------------------------------------------------------
/** \brief Instanciate a ProjectedCRS with a conversion based on the Wagner VII
* projection method.
*
* See osgeo::proj::operation::Conversion::createWagnerVII().
*
* Linear parameters are expressed in (linearUnitName, linearUnitConvFactor).
* Angular parameters are expressed in (angUnitName, angUnitConvFactor).
*/
PJ_OBJ *proj_obj_create_projected_crs_WagnerVII(
PJ_OBJ *geodetic_crs, const char *crs_name, double centerLong,
double falseEasting, double falseNorthing, const char *angUnitName,
double angUnitConvFactor, const char *linearUnitName,
double linearUnitConvFactor) {
UnitOfMeasure linearUnit(
createLinearUnit(linearUnitName, linearUnitConvFactor));
UnitOfMeasure angUnit(createAngularUnit(angUnitName, angUnitConvFactor));
auto conv = Conversion::createWagnerVII(
PropertyMap(), Angle(centerLong, angUnit),
Length(falseEasting, linearUnit), Length(falseNorthing, linearUnit));
return proj_obj_create_projected_crs(geodetic_crs, crs_name, conv,
linearUnit);
}
// ---------------------------------------------------------------------------
/** \brief Instanciate a ProjectedCRS with a conversion based on the
* Quadrilateralized Spherical Cube projection method.
*
* See
* osgeo::proj::operation::Conversion::createQuadrilateralizedSphericalCube().
*
* Linear parameters are expressed in (linearUnitName, linearUnitConvFactor).
* Angular parameters are expressed in (angUnitName, angUnitConvFactor).
*/
PJ_OBJ *proj_obj_create_projected_crs_QuadrilateralizedSphericalCube(
PJ_OBJ *geodetic_crs, const char *crs_name, double centerLat,
double centerLong, double falseEasting, double falseNorthing,
const char *angUnitName, double angUnitConvFactor,
const char *linearUnitName, double linearUnitConvFactor) {
UnitOfMeasure linearUnit(
createLinearUnit(linearUnitName, linearUnitConvFactor));
UnitOfMeasure angUnit(createAngularUnit(angUnitName, angUnitConvFactor));
auto conv = Conversion::createQuadrilateralizedSphericalCube(
PropertyMap(), Angle(centerLat, angUnit), Angle(centerLong, angUnit),
Length(falseEasting, linearUnit), Length(falseNorthing, linearUnit));
return proj_obj_create_projected_crs(geodetic_crs, crs_name, conv,
linearUnit);
}
// ---------------------------------------------------------------------------
/** \brief Instanciate a ProjectedCRS with a conversion based on the Spherical
* Cross-Track Height projection method.
*
* See osgeo::proj::operation::Conversion::createSphericalCrossTrackHeight().
*
* Linear parameters are expressed in (linearUnitName, linearUnitConvFactor).
* Angular parameters are expressed in (angUnitName, angUnitConvFactor).
*/
PJ_OBJ *proj_obj_create_projected_crs_SphericalCrossTrackHeight(
PJ_OBJ *geodetic_crs, const char *crs_name, double pegPointLat,
double pegPointLong, double pegPointHeading, double pegPointHeight,
const char *angUnitName, double angUnitConvFactor,
const char *linearUnitName, double linearUnitConvFactor) {
UnitOfMeasure linearUnit(
createLinearUnit(linearUnitName, linearUnitConvFactor));
UnitOfMeasure angUnit(createAngularUnit(angUnitName, angUnitConvFactor));
auto conv = Conversion::createSphericalCrossTrackHeight(
PropertyMap(), Angle(pegPointLat, angUnit),
Angle(pegPointLong, angUnit), Angle(pegPointHeading, angUnit),
Length(pegPointHeight, linearUnit));
return proj_obj_create_projected_crs(geodetic_crs, crs_name, conv,
linearUnit);
}
// ---------------------------------------------------------------------------
/** \brief Instanciate a ProjectedCRS with a conversion based on the Equal Earth
* projection method.
*
* See osgeo::proj::operation::Conversion::createEqualEarth().
*
* Linear parameters are expressed in (linearUnitName, linearUnitConvFactor).
* Angular parameters are expressed in (angUnitName, angUnitConvFactor).
*/
PJ_OBJ *proj_obj_create_projected_crs_EqualEarth(
PJ_OBJ *geodetic_crs, const char *crs_name, double centerLong,
double falseEasting, double falseNorthing, const char *angUnitName,
double angUnitConvFactor, const char *linearUnitName,
double linearUnitConvFactor) {
UnitOfMeasure linearUnit(
createLinearUnit(linearUnitName, linearUnitConvFactor));
UnitOfMeasure angUnit(createAngularUnit(angUnitName, angUnitConvFactor));
auto conv = Conversion::createEqualEarth(
PropertyMap(), Angle(centerLong, angUnit),
Length(falseEasting, linearUnit), Length(falseNorthing, linearUnit));
return proj_obj_create_projected_crs(geodetic_crs, crs_name, conv,
linearUnit);
}
/* END: Generated by scripts/create_c_api_projections.py*/
// ---------------------------------------------------------------------------
/** \brief Return whether a coordinate operation can be instanciated as
* a PROJ pipeline, checking in particular that referenced grids are
* available.
*
* @param coordoperation Objet of type CoordinateOperation or derived classes
* (must not be NULL)
* @return TRUE or FALSE.
*/
int proj_coordoperation_is_instanciable(PJ_OBJ *coordoperation) {
assert(coordoperation);
auto op =
dynamic_cast<const CoordinateOperation *>(coordoperation->obj.get());
if (!op) {
proj_log_error(coordoperation->ctx, __FUNCTION__,
"Object is not a CoordinateOperation");
return 0;
}
auto dbContext = getDBcontextNoException(coordoperation->ctx, __FUNCTION__);
try {
return op->isPROJInstanciable(dbContext) ? 1 : 0;
} catch (const std::exception &) {
return 0;
}
}
// ---------------------------------------------------------------------------
/** \brief Return the number of parameters of a SingleOperation
*
* @param coordoperation Objet of type SingleOperation or derived classes
* (must not be NULL)
*/
int proj_coordoperation_get_param_count(PJ_OBJ *coordoperation) {
assert(coordoperation);
auto op = dynamic_cast<const SingleOperation *>(coordoperation->obj.get());
if (!op) {
proj_log_error(coordoperation->ctx, __FUNCTION__,
"Object is not a SingleOperation");
return 0;
}
return static_cast<int>(op->parameterValues().size());
}
// ---------------------------------------------------------------------------
/** \brief Return the index of a parameter of a SingleOperation
*
* @param coordoperation Objet of type SingleOperation or derived classes
* (must not be NULL)
* @param name Parameter name. Must not be NULL
* @return index (>=0), or -1 in case of error.
*/
int proj_coordoperation_get_param_index(PJ_OBJ *coordoperation,
const char *name) {
assert(coordoperation);
assert(name);
auto op = dynamic_cast<const SingleOperation *>(coordoperation->obj.get());
if (!op) {
proj_log_error(coordoperation->ctx, __FUNCTION__,
"Object is not a SingleOperation");
return -1;
}
int index = 0;
for (const auto &genParam : op->method()->parameters()) {
if (Identifier::isEquivalentName(genParam->nameStr().c_str(), name)) {
return index;
}
index++;
}
return -1;
}
// ---------------------------------------------------------------------------
/** \brief Return a parameter of a SingleOperation
*
* @param coordoperation Objet of type SingleOperation or derived classes
* (must not be NULL)
* @param index Parameter index.
* @param pName Pointer to a string value to store the parameter name. or NULL
* @param pNameAuthorityName Pointer to a string value to store the parameter
* authority name. or NULL
* @param pNameCode Pointer to a string value to store the parameter
* code. or NULL
* @param pValue Pointer to a double value to store the parameter
* value (if numeric). or NULL
* @param pValueString Pointer to a string value to store the parameter
* value (if of type string). or NULL
* @param pValueUnitConvFactor Pointer to a double value to store the parameter
* unit conversion factor. or NULL
* @param pValueUnitName Pointer to a string value to store the parameter
* unit name. or NULL
* @return TRUE in case of success.
*/
int proj_coordoperation_get_param(PJ_OBJ *coordoperation, int index,
const char **pName,
const char **pNameAuthorityName,
const char **pNameCode, double *pValue,
const char **pValueString,
double *pValueUnitConvFactor,
const char **pValueUnitName) {
assert(coordoperation);
auto op = dynamic_cast<const SingleOperation *>(coordoperation->obj.get());
if (!op) {
proj_log_error(coordoperation->ctx, __FUNCTION__,
"Object is not a SingleOperation");
return false;
}
const auto ¶meters = op->method()->parameters();
const auto &values = op->parameterValues();
if (static_cast<size_t>(index) >= parameters.size() ||
static_cast<size_t>(index) >= values.size()) {
proj_log_error(coordoperation->ctx, __FUNCTION__, "Invalid index");
return false;
}
const auto ¶m = parameters[index];
const auto ¶m_ids = param->identifiers();
if (pName) {
*pName = param->name()->description()->c_str();
}
if (pNameAuthorityName) {
if (!param_ids.empty()) {
*pNameAuthorityName = param_ids[0]->codeSpace()->c_str();
} else {
*pNameAuthorityName = nullptr;
}
}
if (pNameCode) {
if (!param_ids.empty()) {
*pNameCode = param_ids[0]->code().c_str();
} else {
*pNameCode = nullptr;
}
}
const auto &value = values[index];
ParameterValuePtr paramValue = nullptr;
auto opParamValue =
dynamic_cast<const OperationParameterValue *>(value.get());
if (opParamValue) {
paramValue = opParamValue->parameterValue().as_nullable();
}
if (pValue) {
*pValue = 0;
if (paramValue) {
if (paramValue->type() == ParameterValue::Type::MEASURE) {
*pValue = paramValue->value().value();
}
}
}
if (pValueString) {
*pValueString = nullptr;
if (paramValue) {
if (paramValue->type() == ParameterValue::Type::FILENAME) {
*pValueString = paramValue->valueFile().c_str();
} else if (paramValue->type() == ParameterValue::Type::STRING) {
*pValueString = paramValue->stringValue().c_str();
}
}
}
if (pValueUnitConvFactor) {
*pValueUnitConvFactor = 0;
if (paramValue) {
if (paramValue->type() == ParameterValue::Type::MEASURE) {
*pValueUnitConvFactor =
paramValue->value().unit().conversionToSI();
}
}
}
if (pValueUnitName) {
*pValueUnitName = nullptr;
if (paramValue) {
if (paramValue->type() == ParameterValue::Type::MEASURE) {
*pValueUnitName = paramValue->value().unit().name().c_str();
}
}
}
return true;
}
// ---------------------------------------------------------------------------
/** \brief Return the number of grids used by a CoordinateOperation
*
* @param coordoperation Objet of type CoordinateOperation or derived classes
* (must not be NULL)
*/
int proj_coordoperation_get_grid_used_count(PJ_OBJ *coordoperation) {
assert(coordoperation);
auto co =
dynamic_cast<const CoordinateOperation *>(coordoperation->obj.get());
if (!co) {
proj_log_error(coordoperation->ctx, __FUNCTION__,
"Object is not a CoordinateOperation");
return 0;
}
auto dbContext = getDBcontextNoException(coordoperation->ctx, __FUNCTION__);
try {
if (!coordoperation->gridsNeededAsked) {
coordoperation->gridsNeededAsked = true;
const auto gridsNeeded = co->gridsNeeded(dbContext);
for (const auto &gridDesc : gridsNeeded) {
coordoperation->gridsNeeded.emplace_back(gridDesc);
}
}
return static_cast<int>(coordoperation->gridsNeeded.size());
} catch (const std::exception &e) {
proj_log_error(coordoperation->ctx, __FUNCTION__, e.what());
return 0;
}
}
// ---------------------------------------------------------------------------
/** \brief Return a parameter of a SingleOperation
*
* @param coordoperation Objet of type SingleOperation or derived classes
* (must not be NULL)
* @param index Parameter index.
* @param pShortName Pointer to a string value to store the grid short name. or
* NULL
* @param pFullName Pointer to a string value to store the grid full filename.
* or NULL
* @param pPackageName Pointer to a string value to store the package name where
* the grid might be found. or NULL
* @param pURL Pointer to a string value to store the grid URL or the
* package URL where the grid might be found. or NULL
* @param pDirectDownload Pointer to a int (boolean) value to store whether
* *pURL can be downloaded directly. or NULL
* @param pOpenLicense Pointer to a int (boolean) value to store whether
* the grid is released with an open license. or NULL
* @param pAvailable Pointer to a int (boolean) value to store whether the grid
* is available at runtime. or NULL
* @return TRUE in case of success.
*/
int proj_coordoperation_get_grid_used(PJ_OBJ *coordoperation, int index,
const char **pShortName,
const char **pFullName,
const char **pPackageName,
const char **pURL, int *pDirectDownload,
int *pOpenLicense, int *pAvailable) {
const int count = proj_coordoperation_get_grid_used_count(coordoperation);
if (index < 0 || index >= count) {
proj_log_error(coordoperation->ctx, __FUNCTION__, "Invalid index");
return false;
}
const auto &gridDesc = coordoperation->gridsNeeded[index];
if (pShortName) {
*pShortName = gridDesc.shortName.c_str();
}
if (pFullName) {
*pFullName = gridDesc.fullName.c_str();
}
if (pPackageName) {
*pPackageName = gridDesc.packageName.c_str();
}
if (pURL) {
*pURL = gridDesc.url.c_str();
}
if (pDirectDownload) {
*pDirectDownload = gridDesc.directDownload;
}
if (pOpenLicense) {
*pOpenLicense = gridDesc.openLicense;
}
if (pAvailable) {
*pAvailable = gridDesc.available;
}
return true;
}
// ---------------------------------------------------------------------------
/** \brief Opaque object representing an operation factory context. */
struct PJ_OPERATION_FACTORY_CONTEXT {
//! @cond Doxygen_Suppress
PJ_CONTEXT *ctx;
CoordinateOperationContextNNPtr operationContext;
explicit PJ_OPERATION_FACTORY_CONTEXT(
PJ_CONTEXT *ctxIn, CoordinateOperationContextNNPtr &&operationContextIn)
: ctx(ctxIn), operationContext(std::move(operationContextIn)) {}
PJ_OPERATION_FACTORY_CONTEXT(const PJ_OPERATION_FACTORY_CONTEXT &) = delete;
PJ_OPERATION_FACTORY_CONTEXT &
operator=(const PJ_OPERATION_FACTORY_CONTEXT &) = delete;
//! @endcond
};
// ---------------------------------------------------------------------------
/** \brief Instanciate a context for building coordinate operations between
* two CRS.
*
* The returned object must be unreferenced with
* proj_operation_factory_context_unref() after use.
*
* @param ctx Context, or NULL for default context.
* @param authority Name of authority to which to restrict the search of
* canidate operations. Or NULL to allow any authority.
* @return Object that must be unreferenced with
* proj_operation_factory_context_unref(), or NULL in
* case of error.
*/
PJ_OPERATION_FACTORY_CONTEXT *
proj_create_operation_factory_context(PJ_CONTEXT *ctx, const char *authority) {
SANITIZE_CTX(ctx);
auto dbContext = getDBcontextNoException(ctx, __FUNCTION__);
try {
if (dbContext) {
auto factory = CoordinateOperationFactory::create();
auto authFactory = AuthorityFactory::create(
NN_NO_CHECK(dbContext),
std::string(authority ? authority : ""));
auto operationContext =
CoordinateOperationContext::create(authFactory, nullptr, 0.0);
return new PJ_OPERATION_FACTORY_CONTEXT(
ctx, std::move(operationContext));
} else {
auto operationContext =
CoordinateOperationContext::create(nullptr, nullptr, 0.0);
return new PJ_OPERATION_FACTORY_CONTEXT(
ctx, std::move(operationContext));
}
} catch (const std::exception &e) {
proj_log_error(ctx, __FUNCTION__, e.what());
}
return nullptr;
}
// ---------------------------------------------------------------------------
/** \brief Drops a reference on an object.
*
* This method should be called one and exactly one for each function
* returning a PJ_OPERATION_FACTORY_CONTEXT*
*
* @param ctxt Object, or NULL.
*/
void proj_operation_factory_context_unref(PJ_OPERATION_FACTORY_CONTEXT *ctxt) {
delete ctxt;
}
// ---------------------------------------------------------------------------
/** \brief Set the desired accuracy of the resulting coordinate transformations.
* @param ctxt Operation factory context. must not be NULL
* @param accuracy Accuracy in meter (or 0 to disable the filter).
*/
void proj_operation_factory_context_set_desired_accuracy(
PJ_OPERATION_FACTORY_CONTEXT *ctxt, double accuracy) {
assert(ctxt);
ctxt->operationContext->setDesiredAccuracy(accuracy);
}
// ---------------------------------------------------------------------------
/** \brief Set the desired area of interest for the resulting coordinate
* transformations.
*
* For an area of interest crossing the anti-meridian, west_lon will be
* greater than east_lon.
*
* @param ctxt Operation factory context. must not be NULL
* @param west_lon West longitude (in degrees).
* @param south_lat South latitude (in degrees).
* @param east_lon East longitude (in degrees).
* @param north_lat North latitude (in degrees).
*/
void proj_operation_factory_context_set_area_of_interest(
PJ_OPERATION_FACTORY_CONTEXT *ctxt, double west_lon, double south_lat,
double east_lon, double north_lat) {
assert(ctxt);
ctxt->operationContext->setAreaOfInterest(
Extent::createFromBBOX(west_lon, south_lat, east_lon, north_lat));
}
// ---------------------------------------------------------------------------
/** \brief Set how source and target CRS extent should be used
* when considering if a transformation can be used (only takes effect if
* no area of interest is explicitly defined).
*
* The default is PJ_CRS_EXTENT_SMALLEST.
*
* @param ctxt Operation factory context. must not be NULL
* @param use How source and target CRS extent should be used.
*/
void proj_operation_factory_context_set_crs_extent_use(
PJ_OPERATION_FACTORY_CONTEXT *ctxt, PROJ_CRS_EXTENT_USE use) {
assert(ctxt);
switch (use) {
case PJ_CRS_EXTENT_NONE:
ctxt->operationContext->setSourceAndTargetCRSExtentUse(
CoordinateOperationContext::SourceTargetCRSExtentUse::NONE);
break;
case PJ_CRS_EXTENT_BOTH:
ctxt->operationContext->setSourceAndTargetCRSExtentUse(
CoordinateOperationContext::SourceTargetCRSExtentUse::BOTH);
break;
case PJ_CRS_EXTENT_INTERSECTION:
ctxt->operationContext->setSourceAndTargetCRSExtentUse(
CoordinateOperationContext::SourceTargetCRSExtentUse::INTERSECTION);
break;
case PJ_CRS_EXTENT_SMALLEST:
ctxt->operationContext->setSourceAndTargetCRSExtentUse(
CoordinateOperationContext::SourceTargetCRSExtentUse::SMALLEST);
break;
}
}
// ---------------------------------------------------------------------------
/** \brief Set the spatial criterion to use when comparing the area of
* validity of coordinate operations with the area of interest / area of
* validity of
* source and target CRS.
*
* The default is PROJ_SPATIAL_CRITERION_STRICT_CONTAINMENT.
*
* @param ctxt Operation factory context. must not be NULL
* @param criterion patial criterion to use
*/
void PROJ_DLL proj_operation_factory_context_set_spatial_criterion(
PJ_OPERATION_FACTORY_CONTEXT *ctxt, PROJ_SPATIAL_CRITERION criterion) {
assert(ctxt);
switch (criterion) {
case PROJ_SPATIAL_CRITERION_STRICT_CONTAINMENT:
ctxt->operationContext->setSpatialCriterion(
CoordinateOperationContext::SpatialCriterion::STRICT_CONTAINMENT);
break;
case PROJ_SPATIAL_CRITERION_PARTIAL_INTERSECTION:
ctxt->operationContext->setSpatialCriterion(
CoordinateOperationContext::SpatialCriterion::PARTIAL_INTERSECTION);
break;
}
}
// ---------------------------------------------------------------------------
/** \brief Set how grid availability is used.
*
* The default is USE_FOR_SORTING.
*
* @param ctxt Operation factory context. must not be NULL
* @param use how grid availability is used.
*/
void PROJ_DLL proj_operation_factory_context_set_grid_availability_use(
PJ_OPERATION_FACTORY_CONTEXT *ctxt, PROJ_GRID_AVAILABILITY_USE use) {
assert(ctxt);
switch (use) {
case PROJ_GRID_AVAILABILITY_USED_FOR_SORTING:
ctxt->operationContext->setGridAvailabilityUse(
CoordinateOperationContext::GridAvailabilityUse::USE_FOR_SORTING);
break;
case PROJ_GRID_AVAILABILITY_DISCARD_OPERATION_IF_MISSING_GRID:
ctxt->operationContext->setGridAvailabilityUse(
CoordinateOperationContext::GridAvailabilityUse::
DISCARD_OPERATION_IF_MISSING_GRID);
break;
case PROJ_GRID_AVAILABILITY_IGNORED:
ctxt->operationContext->setGridAvailabilityUse(
CoordinateOperationContext::GridAvailabilityUse::
IGNORE_GRID_AVAILABILITY);
break;
}
}
// ---------------------------------------------------------------------------
/** \brief Set whether PROJ alternative grid names should be substituted to
* the official authority names.
*
* The default is true.
*
* @param ctxt Operation factory context. must not be NULL
* @param usePROJNames whether PROJ alternative grid names should be used
*/
void proj_operation_factory_context_set_use_proj_alternative_grid_names(
PJ_OPERATION_FACTORY_CONTEXT *ctxt, int usePROJNames) {
assert(ctxt);
ctxt->operationContext->setUsePROJAlternativeGridNames(usePROJNames != 0);
}
// ---------------------------------------------------------------------------
/** \brief Set whether an intermediate pivot CRS can be used for researching
* coordinate operations between a source and target CRS.
*
* Concretely if in the database there is an operation from A to C
* (or C to A), and another one from C to B (or B to C), but no direct
* operation between A and B, setting this parameter to true, allow
* chaining both operations.
*
* The current implementation is limited to researching one intermediate
* step.
*
* By default, all potential C candidates will be used.
* proj_operation_factory_context_set_allowed_intermediate_crs()
* can be used to restrict them.
*
* The default is true.
*
* @param ctxt Operation factory context. must not be NULL
* @param allow whether intermediate CRS may be used.
*/
void proj_operation_factory_context_set_allow_use_intermediate_crs(
PJ_OPERATION_FACTORY_CONTEXT *ctxt, int allow) {
assert(ctxt);
ctxt->operationContext->setAllowUseIntermediateCRS(allow != 0);
}
// ---------------------------------------------------------------------------
/** \brief Restrict the potential pivot CRSs that can be used when trying to
* build a coordinate operation between two CRS that have no direct operation.
*
* @param ctxt Operation factory context. must not be NULL
* @param list_of_auth_name_codes an array of strings NLL terminated,
* with the format { "auth_name1", "code1", "auth_name2", "code2", ... NULL }
*/
void proj_operation_factory_context_set_allowed_intermediate_crs(
PJ_OPERATION_FACTORY_CONTEXT *ctxt,
const char *const *list_of_auth_name_codes) {
assert(ctxt);
std::vector<std::pair<std::string, std::string>> pivots;
for (auto iter = list_of_auth_name_codes; iter && iter[0] && iter[1];
iter += 2) {
pivots.emplace_back(std::pair<std::string, std::string>(
std::string(iter[0]), std::string(iter[1])));
}
ctxt->operationContext->setIntermediateCRS(pivots);
}
// ---------------------------------------------------------------------------
/** \brief Find a list of CoordinateOperation from source_crs to target_crs.
*
* The operations are sorted with the most relevant ones first: by
* descending
* area (intersection of the transformation area with the area of interest,
* or intersection of the transformation with the area of use of the CRS),
* and
* by increasing accuracy. Operations with unknown accuracy are sorted last,
* whatever their area.
*
* @param source_crs source CRS. Must not be NULL.
* @param target_crs source CRS. Must not be NULL.
* @param operationContext Search context. Must not be NULL.
* @return a result set that must be unreferenced with
* proj_obj_list_unref(), or NULL in case of error.
*/
PJ_OBJ_LIST *
proj_obj_create_operations(PJ_OBJ *source_crs, PJ_OBJ *target_crs,
PJ_OPERATION_FACTORY_CONTEXT *operationContext) {
assert(source_crs);
assert(target_crs);
assert(operationContext);
auto sourceCRS = nn_dynamic_pointer_cast<CRS>(source_crs->obj);
if (!sourceCRS) {
proj_log_error(operationContext->ctx, __FUNCTION__,
"source_crs is not a CRS");
return nullptr;
}
auto targetCRS = nn_dynamic_pointer_cast<CRS>(target_crs->obj);
if (!targetCRS) {
proj_log_error(operationContext->ctx, __FUNCTION__,
"target_crs is not a CRS");
return nullptr;
}
try {
auto factory = CoordinateOperationFactory::create();
std::vector<IdentifiedObjectNNPtr> objects;
auto ops = factory->createOperations(
NN_NO_CHECK(sourceCRS), NN_NO_CHECK(targetCRS),
operationContext->operationContext);
for (const auto &op : ops) {
objects.emplace_back(op);
}
return new PJ_OBJ_LIST(operationContext->ctx, std::move(objects));
} catch (const std::exception &e) {
proj_log_error(operationContext->ctx, __FUNCTION__, e.what());
return nullptr;
}
}
// ---------------------------------------------------------------------------
/** \brief Return the number of objects in the result set
*
* @param result Objet of type PJ_OBJ_LIST (must not be NULL)
*/
int proj_obj_list_get_count(PJ_OBJ_LIST *result) {
assert(result);
return static_cast<int>(result->objects.size());
}
// ---------------------------------------------------------------------------
/** \brief Return an object from the result set
*
* The returned object must be unreferenced with proj_obj_unref() after
* use.
* It should be used by at most one thread at a time.
*
* @param result Objet of type PJ_OBJ_LIST (must not be NULL)
* @param index Index
* @return a new object that must be unreferenced with proj_obj_unref(),
* or nullptr in case of error.
*/
PJ_OBJ *proj_obj_list_get(PJ_OBJ_LIST *result, int index) {
assert(result);
if (index < 0 || index >= proj_obj_list_get_count(result)) {
proj_log_error(result->ctx, __FUNCTION__, "Invalid index");
return nullptr;
}
return PJ_OBJ::create(result->ctx, result->objects[index]);
}
// ---------------------------------------------------------------------------
/** \brief Drops a reference on the result set.
*
* This method should be called one and exactly one for each function
* returning a PJ_OBJ_LIST*
*
* @param result Object, or NULL.
*/
void proj_obj_list_unref(PJ_OBJ_LIST *result) { delete result; }
// ---------------------------------------------------------------------------
/** \brief Return the accuracy (in metre) of a coordinate operation.
*
* @return the accuracy, or a negative value if unknown or in case of error.
*/
double proj_coordoperation_get_accuracy(PJ_OBJ *coordoperation) {
assert(coordoperation);
auto co =
dynamic_cast<const CoordinateOperation *>(coordoperation->obj.get());
if (!co) {
proj_log_error(coordoperation->ctx, __FUNCTION__,
"Object is not a CoordinateOperation");
return -1;
}
const auto &accuracies = co->coordinateOperationAccuracies();
if (accuracies.empty()) {
return -1;
}
try {
return c_locale_stod(accuracies[0]->value());
} catch (const std::exception &) {
}
return -1;
}
|