forked from OSGeo/gdal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ogr_spatialref.h
1007 lines (833 loc) · 37.9 KB
/
ogr_spatialref.h
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
/******************************************************************************
* $Id$
*
* Project: OpenGIS Simple Features Reference Implementation
* Purpose: Classes for manipulating spatial reference systems in a
* platform non-specific manner.
* Author: Frank Warmerdam, [email protected]
*
******************************************************************************
* Copyright (c) 1999, Les Technologies SoftMap Inc.
* Copyright (c) 2008-2013, Even Rouault <even dot rouault at spatialys.com>
*
* SPDX-License-Identifier: MIT
****************************************************************************/
#ifndef OGR_SPATIALREF_H_INCLUDED
#define OGR_SPATIALREF_H_INCLUDED
#include "cpl_string.h"
#include "ogr_srs_api.h"
#include <cstddef>
#include <map>
#include <memory>
#include <vector>
/**
* \file ogr_spatialref.h
*
* Coordinate systems services.
*/
/************************************************************************/
/* OGR_SRSNode */
/************************************************************************/
/**
* Objects of this class are used to represent value nodes in the parsed
* representation of the WKT SRS format. For instance UNIT["METER",1]
* would be rendered into three OGR_SRSNodes. The root node would have a
* value of UNIT, and two children, the first with a value of METER, and the
* second with a value of 1.
*
* Normally application code just interacts with the OGRSpatialReference
* object, which uses the OGR_SRSNode to implement its data structure;
* however, this class is user accessible for detailed access to components
* of an SRS definition.
*/
class CPL_DLL OGR_SRSNode
{
public:
/** Listener that is notified of modification to nodes. */
struct Listener
{
virtual ~Listener();
/** Method triggered when a node is modified. */
virtual void notifyChange(OGR_SRSNode *) = 0;
};
explicit OGR_SRSNode(const char * = nullptr);
~OGR_SRSNode();
/** Register a (single) listener. */
void RegisterListener(const std::shared_ptr<Listener> &listener);
/** Return whether this is a leaf node.
* @return TRUE or FALSE
*/
int IsLeafNode() const
{
return nChildren == 0;
}
int GetChildCount() const
{
return nChildren;
}
OGR_SRSNode *GetChild(int);
const OGR_SRSNode *GetChild(int) const;
OGR_SRSNode *GetNode(const char *);
const OGR_SRSNode *GetNode(const char *) const;
void InsertChild(OGR_SRSNode *, int);
void AddChild(OGR_SRSNode *);
int FindChild(const char *) const;
void DestroyChild(int);
void ClearChildren();
void StripNodes(const char *);
const char *GetValue() const
{
return pszValue;
}
void SetValue(const char *);
void MakeValueSafe();
OGR_SRSNode *Clone() const;
OGRErr importFromWkt(char **)
/*! @cond Doxygen_Suppress */
CPL_WARN_DEPRECATED("Use importFromWkt(const char**)")
/*! @endcond */
;
OGRErr importFromWkt(const char **);
OGRErr exportToWkt(char **) const;
OGRErr exportToPrettyWkt(char **, int = 1) const;
private:
char *pszValue;
OGR_SRSNode **papoChildNodes;
OGR_SRSNode *poParent;
int nChildren;
int NeedsQuoting() const;
OGRErr importFromWkt(const char **, int nRecLevel, int *pnNodes);
std::weak_ptr<Listener> m_listener{};
void notifyChange();
CPL_DISALLOW_COPY_ASSIGN(OGR_SRSNode)
};
/************************************************************************/
/* OGRSpatialReference */
/************************************************************************/
/**
* This class represents an OpenGIS Spatial Reference System, and contains
* methods for converting between this object organization and well known
* text (WKT) format. This object is reference counted as one instance of
* the object is normally shared between many OGRGeometry objects.
*
* Normally application code can fetch needed parameter values for this
* SRS using GetAttrValue(), but in special cases the underlying parse tree
* (or OGR_SRSNode objects) can be accessed more directly.
*
* See <a href="https://gdal.org/tutorials/osr_api_tut.html">the tutorial
* </a> for more information on how to use this class.
*
* Consult also the <a href="https://gdal.org/tutorials/wktproblems.html">
* OGC WKT Coordinate System Issues</a> page for implementation details of
* WKT in OGR.
*/
class CPL_DLL OGRSpatialReference
{
struct Private;
std::unique_ptr<Private> d;
void GetNormInfo() const;
// No longer used with PROJ >= 8.1.0
OGRErr importFromURNPart(const char *pszAuthority, const char *pszCode,
const char *pszURN);
static CPLString lookupInDict(const char *pszDictFile, const char *pszCode);
OGRErr GetWKT2ProjectionMethod(const char **ppszMethodName,
const char **ppszMethodAuthName = nullptr,
const char **ppszMethodCode = nullptr) const;
public:
explicit OGRSpatialReference(const char * = nullptr);
OGRSpatialReference(const OGRSpatialReference &);
OGRSpatialReference(OGRSpatialReference &&);
virtual ~OGRSpatialReference();
static void DestroySpatialReference(OGRSpatialReference *poSRS);
OGRSpatialReference &operator=(const OGRSpatialReference &);
OGRSpatialReference &operator=(OGRSpatialReference &&);
OGRSpatialReference &AssignAndSetThreadSafe(const OGRSpatialReference &);
int Reference();
int Dereference();
int GetReferenceCount() const;
void Release();
const char *GetName() const;
OGRSpatialReference *Clone() const;
OGRSpatialReference *CloneGeogCS() const;
void dumpReadable();
OGRErr exportToWkt(char **) const;
OGRErr exportToWkt(char **ppszWKT, const char *const *papszOptions) const;
std::string exportToWkt(const char *const *papszOptions = nullptr) const;
OGRErr exportToPrettyWkt(char **, int = FALSE) const;
// cppcheck-suppress functionStatic
OGRErr exportToPROJJSON(char **, const char *const *papszOptions) const;
OGRErr exportToProj4(char **) const;
OGRErr exportToPCI(char **, char **, double **) const;
OGRErr exportToUSGS(long *, long *, double **, long *) const;
OGRErr exportToXML(char **, const char * = nullptr) const;
OGRErr exportToPanorama(long *, long *, long *, long *, double *) const;
OGRErr exportVertCSToPanorama(int *) const;
OGRErr exportToERM(char *pszProj, char *pszDatum, char *pszUnits);
OGRErr exportToMICoordSys(char **) const;
OGRErr exportToCF1(char **ppszGridMappingName, char ***ppapszKeyValues,
char **ppszUnits, CSLConstList papszOptions) const;
OGRErr importFromWkt(char **)
/*! @cond Doxygen_Suppress */
CPL_WARN_DEPRECATED(
"Use importFromWkt(const char**) or importFromWkt(const char*)")
/*! @endcond */
;
OGRErr importFromWkt(const char **);
/*! @cond Doxygen_Suppress */
OGRErr importFromWkt(const char *pszInput, CSLConstList papszOptions);
OGRErr importFromWkt(const char **ppszInput, CSLConstList papszOptions);
/*! @endcond */
OGRErr importFromWkt(const char *);
OGRErr importFromProj4(const char *);
OGRErr importFromEPSG(int);
OGRErr importFromEPSGA(int);
OGRErr importFromESRI(char **);
OGRErr importFromPCI(const char *, const char * = nullptr,
const double * = nullptr);
#define USGS_ANGLE_DECIMALDEGREES 0 /**< Angle is in decimal degrees. */
#define USGS_ANGLE_PACKEDDMS \
TRUE /**< Angle is in packed degree minute second. */
#define USGS_ANGLE_RADIANS 2 /**< Angle is in radians. */
OGRErr importFromUSGS(long iProjSys, long iZone, double *padfPrjParams,
long iDatum,
int nUSGSAngleFormat = USGS_ANGLE_PACKEDDMS);
OGRErr importFromPanorama(long, long, long, double *, bool bNorth = true);
OGRErr importVertCSFromPanorama(int);
OGRErr importFromOzi(const char *const *papszLines);
OGRErr importFromWMSAUTO(const char *pszAutoDef);
OGRErr importFromXML(const char *);
OGRErr importFromDict(const char *pszDict, const char *pszCode);
OGRErr importFromURN(const char *);
OGRErr importFromCRSURL(const char *);
OGRErr importFromERM(const char *pszProj, const char *pszDatum,
const char *pszUnits);
OGRErr importFromUrl(const char *);
OGRErr importFromMICoordSys(const char *);
OGRErr importFromCF1(CSLConstList papszKeyValues, const char *pszUnits);
OGRErr morphToESRI();
OGRErr morphFromESRI();
OGRSpatialReference *
convertToOtherProjection(const char *pszTargetProjection,
const char *const *papszOptions = nullptr) const;
OGRErr Validate() const;
OGRErr StripVertical();
bool StripTOWGS84IfKnownDatumAndAllowed();
bool StripTOWGS84IfKnownDatum();
int EPSGTreatsAsLatLong() const;
int EPSGTreatsAsNorthingEasting() const;
int GetAxesCount() const;
const char *GetAxis(const char *pszTargetKey, int iAxis,
OGRAxisOrientation *peOrientation,
double *pdfConvFactor = nullptr) const;
OGRErr SetAxes(const char *pszTargetKey, const char *pszXAxisName,
OGRAxisOrientation eXAxisOrientation,
const char *pszYAxisName,
OGRAxisOrientation eYAxisOrientation);
OSRAxisMappingStrategy GetAxisMappingStrategy() const;
void SetAxisMappingStrategy(OSRAxisMappingStrategy);
const std::vector<int> &GetDataAxisToSRSAxisMapping() const;
OGRErr SetDataAxisToSRSAxisMapping(const std::vector<int> &mapping);
// Machinery for accessing parse nodes
//! Return root node
OGR_SRSNode *GetRoot();
//! Return root node
const OGR_SRSNode *GetRoot() const;
void SetRoot(OGR_SRSNode *);
OGR_SRSNode *GetAttrNode(const char *);
const OGR_SRSNode *GetAttrNode(const char *) const;
const char *GetAttrValue(const char *, int = 0) const;
OGRErr SetNode(const char *, const char *);
// cppcheck-suppress functionStatic
OGRErr SetNode(const char *, double);
OGRErr
SetLinearUnitsAndUpdateParameters(const char *pszName, double dfInMeters,
const char *pszUnitAuthority = nullptr,
const char *pszUnitCode = nullptr);
OGRErr SetLinearUnits(const char *pszName, double dfInMeters);
OGRErr SetTargetLinearUnits(const char *pszTargetKey, const char *pszName,
double dfInMeters,
const char *pszUnitAuthority = nullptr,
const char *pszUnitCode = nullptr);
double GetLinearUnits(char **) const
/*! @cond Doxygen_Suppress */
CPL_WARN_DEPRECATED("Use GetLinearUnits(const char**) instead")
/*! @endcond */
;
double GetLinearUnits(const char ** = nullptr) const;
/*! @cond Doxygen_Suppress */
double GetLinearUnits(std::nullptr_t) const
{
return GetLinearUnits(static_cast<const char **>(nullptr));
}
/*! @endcond */
double GetTargetLinearUnits(const char *pszTargetKey,
char **ppszRetName) const
/*! @cond Doxygen_Suppress */
CPL_WARN_DEPRECATED(
"Use GetTargetLinearUnits(const char*, const char**)")
/*! @endcond */
;
double GetTargetLinearUnits(const char *pszTargetKey,
const char **ppszRetName = nullptr) const;
/*! @cond Doxygen_Suppress */
double GetTargetLinearUnits(const char *pszTargetKey, std::nullptr_t) const
{
return GetTargetLinearUnits(pszTargetKey,
static_cast<const char **>(nullptr));
}
/*! @endcond */
OGRErr SetAngularUnits(const char *pszName, double dfInRadians);
double GetAngularUnits(char **) const
/*! @cond Doxygen_Suppress */
CPL_WARN_DEPRECATED("Use GetAngularUnits(const char**) instead")
/*! @endcond */
;
double GetAngularUnits(const char ** = nullptr) const;
/*! @cond Doxygen_Suppress */
double GetAngularUnits(std::nullptr_t) const
{
return GetAngularUnits(static_cast<const char **>(nullptr));
}
/*! @endcond */
double GetPrimeMeridian(char **) const
/*! @cond Doxygen_Suppress */
CPL_WARN_DEPRECATED("Use GetPrimeMeridian(const char**) instead")
/*! @endcond */
;
double GetPrimeMeridian(const char ** = nullptr) const;
/*! @cond Doxygen_Suppress */
double GetPrimeMeridian(std::nullptr_t) const
{
return GetPrimeMeridian(static_cast<const char **>(nullptr));
}
/*! @endcond */
bool IsEmpty() const;
int IsGeographic() const;
int IsDerivedGeographic() const;
int IsProjected() const;
int IsDerivedProjected() const;
int IsGeocentric() const;
bool IsDynamic() const;
// cppcheck-suppress functionStatic
bool HasPointMotionOperation() const;
int IsLocal() const;
int IsVertical() const;
int IsCompound() const;
int IsSameGeogCS(const OGRSpatialReference *) const;
int IsSameGeogCS(const OGRSpatialReference *,
const char *const *papszOptions) const;
int IsSameVertCS(const OGRSpatialReference *) const;
int IsSame(const OGRSpatialReference *) const;
int IsSame(const OGRSpatialReference *,
const char *const *papszOptions) const;
void Clear();
OGRErr SetLocalCS(const char *);
OGRErr SetProjCS(const char *);
OGRErr SetProjection(const char *);
OGRErr SetGeocCS(const char *pszGeocName);
OGRErr SetGeogCS(const char *pszGeogName, const char *pszDatumName,
const char *pszEllipsoidName, double dfSemiMajor,
double dfInvFlattening, const char *pszPMName = nullptr,
double dfPMOffset = 0.0, const char *pszUnits = nullptr,
double dfConvertToRadians = 0.0);
OGRErr SetWellKnownGeogCS(const char *);
OGRErr CopyGeogCSFrom(const OGRSpatialReference *poSrcSRS);
OGRErr SetVertCS(const char *pszVertCSName, const char *pszVertDatumName,
int nVertDatumClass = 2005);
OGRErr SetCompoundCS(const char *pszName,
const OGRSpatialReference *poHorizSRS,
const OGRSpatialReference *poVertSRS);
void SetCoordinateEpoch(double dfCoordinateEpoch);
double GetCoordinateEpoch() const;
// cppcheck-suppress functionStatic
OGRErr PromoteTo3D(const char *pszName);
// cppcheck-suppress functionStatic
OGRErr DemoteTo2D(const char *pszName);
OGRErr SetFromUserInput(const char *);
static const char *const SET_FROM_USER_INPUT_LIMITATIONS[];
static CSLConstList SET_FROM_USER_INPUT_LIMITATIONS_get();
OGRErr SetFromUserInput(const char *, CSLConstList papszOptions);
OGRErr SetTOWGS84(double, double, double, double = 0.0, double = 0.0,
double = 0.0, double = 0.0);
OGRErr GetTOWGS84(double *padfCoef, int nCoeff = 7) const;
OGRErr AddGuessedTOWGS84();
double GetSemiMajor(OGRErr * = nullptr) const;
double GetSemiMinor(OGRErr * = nullptr) const;
double GetInvFlattening(OGRErr * = nullptr) const;
double GetEccentricity() const;
double GetSquaredEccentricity() const;
OGRErr SetAuthority(const char *pszTargetKey, const char *pszAuthority,
int nCode);
OGRErr AutoIdentifyEPSG();
OGRSpatialReferenceH *FindMatches(char **papszOptions, int *pnEntries,
int **ppanMatchConfidence) const;
OGRSpatialReference *
FindBestMatch(int nMinimumMatchConfidence = 90,
const char *pszPreferredAuthority = "EPSG",
CSLConstList papszOptions = nullptr) const;
int GetEPSGGeogCS() const;
const char *GetAuthorityCode(const char *pszTargetKey) const;
const char *GetAuthorityName(const char *pszTargetKey) const;
char *GetOGCURN() const;
bool GetAreaOfUse(double *pdfWestLongitudeDeg, double *pdfSouthLatitudeDeg,
double *pdfEastLongitudeDeg, double *pdfNorthLatitudeDeg,
const char **ppszAreaName) const;
const char *GetExtension(const char *pszTargetKey, const char *pszName,
const char *pszDefault = nullptr) const;
OGRErr SetExtension(const char *pszTargetKey, const char *pszName,
const char *pszValue);
int FindProjParm(const char *pszParameter,
const OGR_SRSNode *poPROJCS = nullptr) const;
OGRErr SetProjParm(const char *, double);
double GetProjParm(const char *, double = 0.0, OGRErr * = nullptr) const;
OGRErr SetNormProjParm(const char *, double);
double GetNormProjParm(const char *, double = 0.0,
OGRErr * = nullptr) const;
static int IsAngularParameter(const char *);
static int IsLongitudeParameter(const char *);
static int IsLinearParameter(const char *);
/** Albers Conic Equal Area */
OGRErr SetACEA(double dfStdP1, double dfStdP2, double dfCenterLat,
double dfCenterLong, double dfFalseEasting,
double dfFalseNorthing);
/** Azimuthal Equidistant */
OGRErr SetAE(double dfCenterLat, double dfCenterLong, double dfFalseEasting,
double dfFalseNorthing);
/** Bonne */
OGRErr SetBonne(double dfStdP1, double dfCentralMeridian,
double dfFalseEasting, double dfFalseNorthing);
/** Cylindrical Equal Area */
OGRErr SetCEA(double dfStdP1, double dfCentralMeridian,
double dfFalseEasting, double dfFalseNorthing);
/** Cassini-Soldner */
OGRErr SetCS(double dfCenterLat, double dfCenterLong, double dfFalseEasting,
double dfFalseNorthing);
/** Equidistant Conic */
OGRErr SetEC(double dfStdP1, double dfStdP2, double dfCenterLat,
double dfCenterLong, double dfFalseEasting,
double dfFalseNorthing);
/** Eckert I */
OGRErr SetEckert(int nVariation, double dfCentralMeridian,
double dfFalseEasting, double dfFalseNorthing);
/** Eckert IV */
OGRErr SetEckertIV(double dfCentralMeridian, double dfFalseEasting,
double dfFalseNorthing);
/** Eckert VI */
OGRErr SetEckertVI(double dfCentralMeridian, double dfFalseEasting,
double dfFalseNorthing);
/** Equirectangular */
OGRErr SetEquirectangular(double dfCenterLat, double dfCenterLong,
double dfFalseEasting, double dfFalseNorthing);
/** Equirectangular generalized form : */
OGRErr SetEquirectangular2(double dfCenterLat, double dfCenterLong,
double dfPseudoStdParallel1,
double dfFalseEasting, double dfFalseNorthing);
/** Geostationary Satellite */
OGRErr SetGEOS(double dfCentralMeridian, double dfSatelliteHeight,
double dfFalseEasting, double dfFalseNorthing);
/** Goode Homolosine */
OGRErr SetGH(double dfCentralMeridian, double dfFalseEasting,
double dfFalseNorthing);
/** Interrupted Goode Homolosine */
OGRErr SetIGH();
/** Gall Stereographic */
OGRErr SetGS(double dfCentralMeridian, double dfFalseEasting,
double dfFalseNorthing);
/** Gauss Schreiber Transverse Mercator */
OGRErr SetGaussSchreiberTMercator(double dfCenterLat, double dfCenterLong,
double dfScale, double dfFalseEasting,
double dfFalseNorthing);
/** Gnomonic */
OGRErr SetGnomonic(double dfCenterLat, double dfCenterLong,
double dfFalseEasting, double dfFalseNorthing);
/** Hotine Oblique Mercator */
OGRErr SetHOM(double dfCenterLat, double dfCenterLong, double dfAzimuth,
double dfRectToSkew, double dfScale, double dfFalseEasting,
double dfFalseNorthing);
/** Hotine Oblique Mercator 2 points */
OGRErr SetHOM2PNO(double dfCenterLat, double dfLat1, double dfLong1,
double dfLat2, double dfLong2, double dfScale,
double dfFalseEasting, double dfFalseNorthing);
/** Hotine Oblique Mercator Azimuth Center / Variant B */
OGRErr SetHOMAC(double dfCenterLat, double dfCenterLong, double dfAzimuth,
double dfRectToSkew, double dfScale, double dfFalseEasting,
double dfFalseNorthing);
/** Laborde Oblique Mercator */
OGRErr SetLOM(double dfCenterLat, double dfCenterLong, double dfAzimuth,
double dfScale, double dfFalseEasting,
double dfFalseNorthing);
/** International Map of the World Polyconic */
OGRErr SetIWMPolyconic(double dfLat1, double dfLat2, double dfCenterLong,
double dfFalseEasting, double dfFalseNorthing);
/** Krovak Oblique Conic Conformal */
OGRErr SetKrovak(double dfCenterLat, double dfCenterLong, double dfAzimuth,
double dfPseudoStdParallelLat, double dfScale,
double dfFalseEasting, double dfFalseNorthing);
/** Lambert Azimuthal Equal-Area */
OGRErr SetLAEA(double dfCenterLat, double dfCenterLong,
double dfFalseEasting, double dfFalseNorthing);
/** Lambert Conformal Conic */
OGRErr SetLCC(double dfStdP1, double dfStdP2, double dfCenterLat,
double dfCenterLong, double dfFalseEasting,
double dfFalseNorthing);
/** Lambert Conformal Conic 1SP */
OGRErr SetLCC1SP(double dfCenterLat, double dfCenterLong, double dfScale,
double dfFalseEasting, double dfFalseNorthing);
/** Lambert Conformal Conic (Belgium) */
OGRErr SetLCCB(double dfStdP1, double dfStdP2, double dfCenterLat,
double dfCenterLong, double dfFalseEasting,
double dfFalseNorthing);
/** Miller Cylindrical */
OGRErr SetMC(double dfCenterLat, double dfCenterLong, double dfFalseEasting,
double dfFalseNorthing);
/** Mercator 1SP */
OGRErr SetMercator(double dfCenterLat, double dfCenterLong, double dfScale,
double dfFalseEasting, double dfFalseNorthing);
/** Mercator 2SP */
OGRErr SetMercator2SP(double dfStdP1, double dfCenterLat,
double dfCenterLong, double dfFalseEasting,
double dfFalseNorthing);
/** Mollweide */
OGRErr SetMollweide(double dfCentralMeridian, double dfFalseEasting,
double dfFalseNorthing);
/** New Zealand Map Grid */
OGRErr SetNZMG(double dfCenterLat, double dfCenterLong,
double dfFalseEasting, double dfFalseNorthing);
/** Oblique Stereographic */
OGRErr SetOS(double dfOriginLat, double dfCMeridian, double dfScale,
double dfFalseEasting, double dfFalseNorthing);
/** Orthographic */
OGRErr SetOrthographic(double dfCenterLat, double dfCenterLong,
double dfFalseEasting, double dfFalseNorthing);
/** Polyconic */
OGRErr SetPolyconic(double dfCenterLat, double dfCenterLong,
double dfFalseEasting, double dfFalseNorthing);
/** Polar Stereographic */
OGRErr SetPS(double dfCenterLat, double dfCenterLong, double dfScale,
double dfFalseEasting, double dfFalseNorthing);
/** Robinson */
OGRErr SetRobinson(double dfCenterLong, double dfFalseEasting,
double dfFalseNorthing);
/** Sinusoidal */
OGRErr SetSinusoidal(double dfCenterLong, double dfFalseEasting,
double dfFalseNorthing);
/** Stereographic */
OGRErr SetStereographic(double dfCenterLat, double dfCenterLong,
double dfScale, double dfFalseEasting,
double dfFalseNorthing);
/** Swiss Oblique Cylindrical */
OGRErr SetSOC(double dfLatitudeOfOrigin, double dfCentralMeridian,
double dfFalseEasting, double dfFalseNorthing);
/** Transverse Mercator */
OGRErr SetTM(double dfCenterLat, double dfCenterLong, double dfScale,
double dfFalseEasting, double dfFalseNorthing);
/** Transverse Mercator variants. */
OGRErr SetTMVariant(const char *pszVariantName, double dfCenterLat,
double dfCenterLong, double dfScale,
double dfFalseEasting, double dfFalseNorthing);
/** Tunesia Mining Grid */
OGRErr SetTMG(double dfCenterLat, double dfCenterLong,
double dfFalseEasting, double dfFalseNorthing);
/** Transverse Mercator (South Oriented) */
OGRErr SetTMSO(double dfCenterLat, double dfCenterLong, double dfScale,
double dfFalseEasting, double dfFalseNorthing);
/** Two Point Equidistant */
OGRErr SetTPED(double dfLat1, double dfLong1, double dfLat2, double dfLong2,
double dfFalseEasting, double dfFalseNorthing);
/** VanDerGrinten */
OGRErr SetVDG(double dfCenterLong, double dfFalseEasting,
double dfFalseNorthing);
/** Universal Transverse Mercator */
OGRErr SetUTM(int nZone, int bNorth = TRUE);
int GetUTMZone(int *pbNorth = nullptr) const;
/** Wagner I -- VII */
OGRErr SetWagner(int nVariation, double dfCenterLat, double dfFalseEasting,
double dfFalseNorthing);
/** Quadrilateralized Spherical Cube */
OGRErr SetQSC(double dfCenterLat, double dfCenterLong);
/** Spherical, Cross-track, Height */
OGRErr SetSCH(double dfPegLat, double dfPegLong, double dfPegHeading,
double dfPegHgt);
/** Vertical Perspective / Near-sided Perspective */
OGRErr
SetVerticalPerspective(double dfTopoOriginLat, double dfTopoOriginLon,
double dfTopoOriginHeight, double dfViewPointHeight,
double dfFalseEasting, double dfFalseNorthing);
/** Pole rotation (GRIB convention) */
OGRErr SetDerivedGeogCRSWithPoleRotationGRIBConvention(
const char *pszCRSName, double dfSouthPoleLat, double dfSouthPoleLon,
double dfAxisRotation);
/** Pole rotation (netCDF CF convention) */
OGRErr SetDerivedGeogCRSWithPoleRotationNetCDFCFConvention(
const char *pszCRSName, double dfGridNorthPoleLat,
double dfGridNorthPoleLon, double dfNorthPoleGridLon);
/** State Plane */
OGRErr SetStatePlane(int nZone, int bNAD83 = TRUE,
const char *pszOverrideUnitName = nullptr,
double dfOverrideUnit = 0.0);
/** ImportFromESRIStatePlaneWKT */
OGRErr ImportFromESRIStatePlaneWKT(int nCode, const char *pszDatumName,
const char *pszUnitsName, int nPCSCode,
const char *pszCRSName = nullptr);
/** ImportFromESRIWisconsinWKT */
OGRErr ImportFromESRIWisconsinWKT(const char *pszPrjName,
double dfCentralMeridian,
double dfLatOfOrigin,
const char *pszUnitsName,
const char *pszCRSName = nullptr);
/*! @cond Doxygen_Suppress */
void UpdateCoordinateSystemFromGeogCRS();
/*! @endcond */
static OGRSpatialReference *GetWGS84SRS();
/** Convert a OGRSpatialReference* to a OGRSpatialReferenceH.
* @since GDAL 2.3
*/
static inline OGRSpatialReferenceH ToHandle(OGRSpatialReference *poSRS)
{
return reinterpret_cast<OGRSpatialReferenceH>(poSRS);
}
/** Convert a OGRSpatialReferenceH to a OGRSpatialReference*.
* @since GDAL 2.3
*/
static inline OGRSpatialReference *FromHandle(OGRSpatialReferenceH hSRS)
{
return reinterpret_cast<OGRSpatialReference *>(hSRS);
}
};
/*! @cond Doxygen_Suppress */
struct CPL_DLL OGRSpatialReferenceReleaser
{
void operator()(OGRSpatialReference *poSRS) const
{
if (poSRS)
poSRS->Release();
}
};
/*! @endcond */
/************************************************************************/
/* OGRCoordinateTransformation */
/* */
/* This is really just used as a base class for a private */
/* implementation. */
/************************************************************************/
/**
* Interface for transforming between coordinate systems.
*
* Currently, the only implementation within OGR is OGRProjCT, which
* requires the PROJ library.
*
* Also, see OGRCreateCoordinateTransformation() for creating transformations.
*/
class CPL_DLL OGRCoordinateTransformation
{
public:
virtual ~OGRCoordinateTransformation()
{
}
static void DestroyCT(OGRCoordinateTransformation *poCT);
// From CT_CoordinateTransformation
/** Fetch internal source coordinate system. */
virtual const OGRSpatialReference *GetSourceCS() const = 0;
/** Fetch internal target coordinate system. */
virtual const OGRSpatialReference *GetTargetCS() const = 0;
/** Whether the transformer will emit CPLError */
virtual bool GetEmitErrors() const
{
return false;
}
/** Set if the transformer must emit CPLError */
virtual void SetEmitErrors(bool /*bEmitErrors*/)
{
}
// From CT_MathTransform
/**
* Transform points from source to destination space.
*
* This method is the same as the C function OCTTransformEx().
*
* @param nCount number of points to transform (`size_t` type since 3.9,
* `int` in previous versions).
* @param x array of nCount X vertices, modified in place. Should not be
* NULL.
* @param y array of nCount Y vertices, modified in place. Should not be
* NULL.
* @param z array of nCount Z vertices, modified in place. Might be NULL.
* @param pabSuccess array of per-point flags set to TRUE if that point
* transforms, or FALSE if it does not. Might be NULL.
*
* @return TRUE if a transformation could be found (but not all points may
* have necessarily succeed to transform), otherwise FALSE.
*/
int Transform(size_t nCount, double *x, double *y, double *z = nullptr,
int *pabSuccess = nullptr);
/**
* Transform points from source to destination space.
*
* This method is the same as the C function OCTTransform4D().
*
* @param nCount number of points to transform (`size_t` type since 3.9,
* `int` in previous versions).
* @param x array of nCount X vertices, modified in place. Should not be
* NULL.
* @param y array of nCount Y vertices, modified in place. Should not be
* NULL.
* @param z array of nCount Z vertices, modified in place. Might be NULL.
* @param t array of nCount time values, modified in place. Might be NULL.
* @param pabSuccess array of per-point flags set to TRUE if that point
* transforms, or FALSE if it does not. Might be NULL.
*
* @return TRUE if a transformation could be found (but not all points may
* have necessarily succeed to transform), otherwise FALSE.
*/
virtual int Transform(size_t nCount, double *x, double *y, double *z,
double *t, int *pabSuccess) = 0;
/**
* Transform points from source to destination space.
*
* This method is the same as the C function OCTTransform4DWithErrorCodes().
*
* @param nCount number of points to transform (`size_t` type since 3.9,
* `int` in previous versions).
* @param x array of nCount X vertices, modified in place. Should not be
* NULL.
* @param y array of nCount Y vertices, modified in place. Should not be
* NULL.
* @param z array of nCount Z vertices, modified in place. Might be NULL.
* @param t array of nCount time values, modified in place. Might be NULL.
* @param panErrorCodes Output array of nCount value that will be set to 0
* for success, or a non-zero value for failure. Refer to PROJ 8 public
* error codes. Might be NULL
* @return TRUE if a transformation could be found (but not all points may
* have necessarily succeed to transform), otherwise FALSE.
* @since GDAL 3.3, and PROJ 8 to be able to use PROJ public error codes
*/
virtual int TransformWithErrorCodes(size_t nCount, double *x, double *y,
double *z, double *t,
int *panErrorCodes);
/** \brief Transform boundary.
*
* This method is the same as the C function OCTTransformBounds().
*
* Transform boundary densifying the edges to account for nonlinear
* transformations along these edges and extracting the outermost bounds.
*
* If the destination CRS is geographic, the first axis is longitude,
* and xmax < xmin then the bounds crossed the antimeridian.
* In this scenario there are two polygons, one on each side of the
* antimeridian. The first polygon should be constructed with (xmin, ymin,
* 180, ymax) and the second with (-180, ymin, xmax, ymax).
*
* If the destination CRS is geographic, the first axis is latitude,
* and ymax < ymin then the bounds crossed the antimeridian.
* In this scenario there are two polygons, one on each side of the
* antimeridian. The first polygon should be constructed with (ymin, xmin,
* ymax, 180) and the second with (ymin, -180, ymax, xmax).
*
* @param xmin Minimum bounding coordinate of the first axis in source CRS.
* @param ymin Minimum bounding coordinate of the second axis in source CRS.
* @param xmax Maximum bounding coordinate of the first axis in source CRS.
* @param ymax Maximum bounding coordinate of the second axis in source CRS.
* @param out_xmin Minimum bounding coordinate of the first axis in target
* CRS
* @param out_ymin Minimum bounding coordinate of the second axis in target
* CRS.
* @param out_xmax Maximum bounding coordinate of the first axis in target
* CRS.
* @param out_ymax Maximum bounding coordinate of the second axis in target
* CRS.
* @param densify_pts Recommended to use 21. This is the number of points
* to use to densify the bounding polygon in the transformation.
* @return TRUE if successful. FALSE if failures encountered.
* @since 3.4
*/
virtual int TransformBounds(const double xmin, const double ymin,
const double xmax, const double ymax,
double *out_xmin, double *out_ymin,
double *out_xmax, double *out_ymax,
const int densify_pts)
{
(void)xmin;
(void)xmax;
(void)ymin;
(void)ymax;
(void)densify_pts;
*out_xmin = HUGE_VAL;
*out_ymin = HUGE_VAL;
*out_xmax = HUGE_VAL;
*out_ymax = HUGE_VAL;
CPLError(CE_Failure, CPLE_AppDefined,
"TransformBounds not implemented.");
return false;
}
/** Convert a OGRCoordinateTransformation* to a
* OGRCoordinateTransformationH.
* @since GDAL 2.3
*/
static inline OGRCoordinateTransformationH
ToHandle(OGRCoordinateTransformation *poCT)
{
return reinterpret_cast<OGRCoordinateTransformationH>(poCT);
}
/** Convert a OGRCoordinateTransformationH to a
* OGRCoordinateTransformation*.
* @since GDAL 2.3
*/
static inline OGRCoordinateTransformation *
FromHandle(OGRCoordinateTransformationH hCT)
{
return reinterpret_cast<OGRCoordinateTransformation *>(hCT);
}
/** Clone
* @since GDAL 3.1
*/
virtual OGRCoordinateTransformation *Clone() const = 0;
/** Return a coordinate transformation that performs the inverse
* transformation of the current one.
*
* In some cases, this is not possible, and this method might return
* nullptr, or fail to perform the transformations.
*
* @return the new coordinate transformation, or nullptr in case of error.
* @since GDAL 3.3
*/
virtual OGRCoordinateTransformation *GetInverse() const = 0;
};
OGRCoordinateTransformation CPL_DLL *
OGRCreateCoordinateTransformation(const OGRSpatialReference *poSource,
const OGRSpatialReference *poTarget);
/**
* Context for coordinate transformation.
*
* @since GDAL 3.0
*/
struct CPL_DLL OGRCoordinateTransformationOptions
{
/*! @cond Doxygen_Suppress */
private:
friend class OGRProjCT;
struct Private;
std::unique_ptr<Private> d;
/*! @endcond */
public:
OGRCoordinateTransformationOptions();
OGRCoordinateTransformationOptions(
const OGRCoordinateTransformationOptions &);
OGRCoordinateTransformationOptions &
operator=(const OGRCoordinateTransformationOptions &);
~OGRCoordinateTransformationOptions();
bool SetAreaOfInterest(double dfWestLongitudeDeg, double dfSouthLatitudeDeg,
double dfEastLongitudeDeg,
double dfNorthLatitudeDeg);
bool SetDesiredAccuracy(double dfAccuracy);
bool SetBallparkAllowed(bool bAllowBallpark);
bool SetOnlyBest(bool bOnlyBest);
bool SetCoordinateOperation(const char *pszCT, bool bReverseCT);
/*! @cond Doxygen_Suppress */
void SetSourceCenterLong(double dfCenterLong);
void SetTargetCenterLong(double dfCenterLong);
/*! @endcond */