GDAL
ogr_spatialref.h
Go to the documentation of this file.
1 /******************************************************************************
2  * $Id$
3  *
4  * Project: OpenGIS Simple Features Reference Implementation
5  * Purpose: Classes for manipulating spatial reference systems in a
6  * platform non-specific manner.
7  * Author: Frank Warmerdam, warmerdam@pobox.com
8  *
9  ******************************************************************************
10  * Copyright (c) 1999, Les Technologies SoftMap Inc.
11  * Copyright (c) 2008-2013, Even Rouault <even dot rouault at spatialys.com>
12  *
13  * Permission is hereby granted, free of charge, to any person obtaining a
14  * copy of this software and associated documentation files (the "Software"),
15  * to deal in the Software without restriction, including without limitation
16  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
17  * and/or sell copies of the Software, and to permit persons to whom the
18  * Software is furnished to do so, subject to the following conditions:
19  *
20  * The above copyright notice and this permission notice shall be included
21  * in all copies or substantial portions of the Software.
22  *
23  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29  * DEALINGS IN THE SOFTWARE.
30  ****************************************************************************/
31 
32 #ifndef OGR_SPATIALREF_H_INCLUDED
33 #define OGR_SPATIALREF_H_INCLUDED
34 
35 #include "cpl_string.h"
36 #include "ogr_srs_api.h"
37 
38 #include <cstddef>
39 #include <map>
40 #include <memory>
41 #include <vector>
42 
49 /************************************************************************/
50 /* OGR_SRSNode */
51 /************************************************************************/
52 
66 class CPL_DLL OGR_SRSNode
67 {
68  public:
70  struct Listener
71  {
72  virtual ~Listener();
74  virtual void notifyChange(OGR_SRSNode *) = 0;
75  };
76 
77  explicit OGR_SRSNode(const char * = nullptr);
78  ~OGR_SRSNode();
79 
81  void RegisterListener(const std::shared_ptr<Listener> &listener);
82 
86  int IsLeafNode() const
87  {
88  return nChildren == 0;
89  }
90 
91  int GetChildCount() const
92  {
93  return nChildren;
94  }
95 
96  OGR_SRSNode *GetChild(int);
97  const OGR_SRSNode *GetChild(int) const;
98 
99  OGR_SRSNode *GetNode(const char *);
100  const OGR_SRSNode *GetNode(const char *) const;
101 
102  void InsertChild(OGR_SRSNode *, int);
103  void AddChild(OGR_SRSNode *);
104  int FindChild(const char *) const;
105  void DestroyChild(int);
106  void ClearChildren();
107  void StripNodes(const char *);
108 
109  const char *GetValue() const
110  {
111  return pszValue;
112  }
113 
114  void SetValue(const char *);
115 
116  void MakeValueSafe();
117 
118  OGR_SRSNode *Clone() const;
119 
120  OGRErr importFromWkt(char **)
122  CPL_WARN_DEPRECATED("Use importFromWkt(const char**)")
124  ;
125  OGRErr importFromWkt(const char **);
126  OGRErr exportToWkt(char **) const;
127  OGRErr exportToPrettyWkt(char **, int = 1) const;
128 
129  private:
130  char *pszValue;
131 
132  OGR_SRSNode **papoChildNodes;
133  OGR_SRSNode *poParent;
134 
135  int nChildren;
136 
137  int NeedsQuoting() const;
138  OGRErr importFromWkt(const char **, int nRecLevel, int *pnNodes);
139 
140  std::weak_ptr<Listener> m_listener{};
141  void notifyChange();
142 
144 };
145 
146 /************************************************************************/
147 /* OGRSpatialReference */
148 /************************************************************************/
149 
168 class CPL_DLL OGRSpatialReference
169 {
170  struct Private;
171  std::unique_ptr<Private> d;
172 
173  void GetNormInfo() const;
174 
175  // No longer used with PROJ >= 8.1.0
176  OGRErr importFromURNPart(const char *pszAuthority, const char *pszCode,
177  const char *pszURN);
178 
179  static CPLString lookupInDict(const char *pszDictFile, const char *pszCode);
180 
181  OGRErr GetWKT2ProjectionMethod(const char **ppszMethodName,
182  const char **ppszMethodAuthName = nullptr,
183  const char **ppszMethodCode = nullptr) const;
184 
185  public:
186  explicit OGRSpatialReference(const char * = nullptr);
189 
190  virtual ~OGRSpatialReference();
191 
192  static void DestroySpatialReference(OGRSpatialReference *poSRS);
193 
194  OGRSpatialReference &operator=(const OGRSpatialReference &);
196 
197  int Reference();
198  int Dereference();
199  int GetReferenceCount() const;
200  void Release();
201 
202  const char *GetName() const;
203 
204  OGRSpatialReference *Clone() const;
205  OGRSpatialReference *CloneGeogCS() const;
206 
207  void dumpReadable();
208  OGRErr exportToWkt(char **) const;
209  OGRErr exportToWkt(char **ppszWKT, const char *const *papszOptions) const;
210  std::string exportToWkt(const char *const *papszOptions = nullptr) const;
211  OGRErr exportToPrettyWkt(char **, int = FALSE) const;
212  // cppcheck-suppress functionStatic
213  OGRErr exportToPROJJSON(char **, const char *const *papszOptions) const;
214  OGRErr exportToProj4(char **) const;
215  OGRErr exportToPCI(char **, char **, double **) const;
216  OGRErr exportToUSGS(long *, long *, double **, long *) const;
217  OGRErr exportToXML(char **, const char * = nullptr) const;
218  OGRErr exportToPanorama(long *, long *, long *, long *, double *) const;
219  OGRErr exportVertCSToPanorama(int *) const;
220  OGRErr exportToERM(char *pszProj, char *pszDatum, char *pszUnits);
221  OGRErr exportToMICoordSys(char **) const;
222  OGRErr exportToCF1(char **ppszGridMappingName, char ***ppapszKeyValues,
223  char **ppszUnits, CSLConstList papszOptions) const;
224 
225  OGRErr importFromWkt(char **)
227  CPL_WARN_DEPRECATED(
228  "Use importFromWkt(const char**) or importFromWkt(const char*)")
230  ;
231 
232  OGRErr importFromWkt(const char **);
234  OGRErr importFromWkt(const char *pszInput, CSLConstList papszOptions);
235  OGRErr importFromWkt(const char **ppszInput, CSLConstList papszOptions);
237  OGRErr importFromWkt(const char *);
238  OGRErr importFromProj4(const char *);
239  OGRErr importFromEPSG(int);
240  OGRErr importFromEPSGA(int);
241  OGRErr importFromESRI(char **);
242  OGRErr importFromPCI(const char *, const char * = nullptr,
243  const double * = nullptr);
244 
245 #define USGS_ANGLE_DECIMALDEGREES 0
246 #define USGS_ANGLE_PACKEDDMS \
247  TRUE
248 #define USGS_ANGLE_RADIANS 2
249  OGRErr importFromUSGS(long iProjSys, long iZone, double *padfPrjParams,
250  long iDatum,
251  int nUSGSAngleFormat = USGS_ANGLE_PACKEDDMS);
252  OGRErr importFromPanorama(long, long, long, double *, bool bNorth = true);
253  OGRErr importVertCSFromPanorama(int);
254  OGRErr importFromOzi(const char *const *papszLines);
255  OGRErr importFromWMSAUTO(const char *pszAutoDef);
256  OGRErr importFromXML(const char *);
257  OGRErr importFromDict(const char *pszDict, const char *pszCode);
258  OGRErr importFromURN(const char *);
259  OGRErr importFromCRSURL(const char *);
260  OGRErr importFromERM(const char *pszProj, const char *pszDatum,
261  const char *pszUnits);
262  OGRErr importFromUrl(const char *);
263  OGRErr importFromMICoordSys(const char *);
264  OGRErr importFromCF1(CSLConstList papszKeyValues, const char *pszUnits);
265 
266  OGRErr morphToESRI();
267  OGRErr morphFromESRI();
268 
270  convertToOtherProjection(const char *pszTargetProjection,
271  const char *const *papszOptions = nullptr) const;
272 
273  OGRErr Validate() const;
274  OGRErr StripVertical();
275 
276  bool StripTOWGS84IfKnownDatumAndAllowed();
277  bool StripTOWGS84IfKnownDatum();
278 
279  int EPSGTreatsAsLatLong() const;
280  int EPSGTreatsAsNorthingEasting() const;
281  int GetAxesCount() const;
282  const char *GetAxis(const char *pszTargetKey, int iAxis,
283  OGRAxisOrientation *peOrientation,
284  double *pdfConvFactor = nullptr) const;
285  OGRErr SetAxes(const char *pszTargetKey, const char *pszXAxisName,
286  OGRAxisOrientation eXAxisOrientation,
287  const char *pszYAxisName,
288  OGRAxisOrientation eYAxisOrientation);
289 
290  OSRAxisMappingStrategy GetAxisMappingStrategy() const;
291  void SetAxisMappingStrategy(OSRAxisMappingStrategy);
292  const std::vector<int> &GetDataAxisToSRSAxisMapping() const;
293  OGRErr SetDataAxisToSRSAxisMapping(const std::vector<int> &mapping);
294 
295  // Machinery for accessing parse nodes
296 
298  OGR_SRSNode *GetRoot();
300  const OGR_SRSNode *GetRoot() const;
301  void SetRoot(OGR_SRSNode *);
302 
303  OGR_SRSNode *GetAttrNode(const char *);
304  const OGR_SRSNode *GetAttrNode(const char *) const;
305  const char *GetAttrValue(const char *, int = 0) const;
306 
307  OGRErr SetNode(const char *, const char *);
308  // cppcheck-suppress functionStatic
309  OGRErr SetNode(const char *, double);
310 
311  OGRErr
312  SetLinearUnitsAndUpdateParameters(const char *pszName, double dfInMeters,
313  const char *pszUnitAuthority = nullptr,
314  const char *pszUnitCode = nullptr);
315  OGRErr SetLinearUnits(const char *pszName, double dfInMeters);
316  OGRErr SetTargetLinearUnits(const char *pszTargetKey, const char *pszName,
317  double dfInMeters,
318  const char *pszUnitAuthority = nullptr,
319  const char *pszUnitCode = nullptr);
320 
321  double GetLinearUnits(char **) const
323  CPL_WARN_DEPRECATED("Use GetLinearUnits(const char**) instead")
325  ;
326  double GetLinearUnits(const char ** = nullptr) const;
327 
329  double GetLinearUnits(std::nullptr_t) const
330  {
331  return GetLinearUnits(static_cast<const char **>(nullptr));
332  }
333 
336  double GetTargetLinearUnits(const char *pszTargetKey,
337  char **ppszRetName) const
339  CPL_WARN_DEPRECATED(
340  "Use GetTargetLinearUnits(const char*, const char**)")
342  ;
343  double GetTargetLinearUnits(const char *pszTargetKey,
344  const char **ppszRetName = nullptr) const;
345 
347  double GetTargetLinearUnits(const char *pszTargetKey, std::nullptr_t) const
348  {
349  return GetTargetLinearUnits(pszTargetKey,
350  static_cast<const char **>(nullptr));
351  }
352 
355  OGRErr SetAngularUnits(const char *pszName, double dfInRadians);
356  double GetAngularUnits(char **) const
358  CPL_WARN_DEPRECATED("Use GetAngularUnits(const char**) instead")
360  ;
361  double GetAngularUnits(const char ** = nullptr) const;
362 
364  double GetAngularUnits(std::nullptr_t) const
365  {
366  return GetAngularUnits(static_cast<const char **>(nullptr));
367  }
368 
371  double GetPrimeMeridian(char **) const
373  CPL_WARN_DEPRECATED("Use GetPrimeMeridian(const char**) instead")
375  ;
376  double GetPrimeMeridian(const char ** = nullptr) const;
377 
379  double GetPrimeMeridian(std::nullptr_t) const
380  {
381  return GetPrimeMeridian(static_cast<const char **>(nullptr));
382  }
383 
386  bool IsEmpty() const;
387  int IsGeographic() const;
388  int IsDerivedGeographic() const;
389  int IsProjected() const;
390  int IsDerivedProjected() const;
391  int IsGeocentric() const;
392  bool IsDynamic() const;
393 
394  // cppcheck-suppress functionStatic
395  bool HasPointMotionOperation() const;
396 
397  int IsLocal() const;
398  int IsVertical() const;
399  int IsCompound() const;
400  int IsSameGeogCS(const OGRSpatialReference *) const;
401  int IsSameGeogCS(const OGRSpatialReference *,
402  const char *const *papszOptions) const;
403  int IsSameVertCS(const OGRSpatialReference *) const;
404  int IsSame(const OGRSpatialReference *) const;
405  int IsSame(const OGRSpatialReference *,
406  const char *const *papszOptions) const;
407 
408  void Clear();
409  OGRErr SetLocalCS(const char *);
410  OGRErr SetProjCS(const char *);
411  OGRErr SetProjection(const char *);
412  OGRErr SetGeocCS(const char *pszGeocName);
413  OGRErr SetGeogCS(const char *pszGeogName, const char *pszDatumName,
414  const char *pszEllipsoidName, double dfSemiMajor,
415  double dfInvFlattening, const char *pszPMName = nullptr,
416  double dfPMOffset = 0.0, const char *pszUnits = nullptr,
417  double dfConvertToRadians = 0.0);
418  OGRErr SetWellKnownGeogCS(const char *);
419  OGRErr CopyGeogCSFrom(const OGRSpatialReference *poSrcSRS);
420  OGRErr SetVertCS(const char *pszVertCSName, const char *pszVertDatumName,
421  int nVertDatumClass = 2005);
422  OGRErr SetCompoundCS(const char *pszName,
423  const OGRSpatialReference *poHorizSRS,
424  const OGRSpatialReference *poVertSRS);
425 
426  void SetCoordinateEpoch(double dfCoordinateEpoch);
427  double GetCoordinateEpoch() const;
428 
429  // cppcheck-suppress functionStatic
430  OGRErr PromoteTo3D(const char *pszName);
431  // cppcheck-suppress functionStatic
432  OGRErr DemoteTo2D(const char *pszName);
433 
434  OGRErr SetFromUserInput(const char *);
435 
436  static const char *const SET_FROM_USER_INPUT_LIMITATIONS[];
437  static CSLConstList SET_FROM_USER_INPUT_LIMITATIONS_get();
438 
439  OGRErr SetFromUserInput(const char *, CSLConstList papszOptions);
440 
441  OGRErr SetTOWGS84(double, double, double, double = 0.0, double = 0.0,
442  double = 0.0, double = 0.0);
443  OGRErr GetTOWGS84(double *padfCoef, int nCoeff = 7) const;
444  OGRErr AddGuessedTOWGS84();
445 
446  double GetSemiMajor(OGRErr * = nullptr) const;
447  double GetSemiMinor(OGRErr * = nullptr) const;
448  double GetInvFlattening(OGRErr * = nullptr) const;
449  double GetEccentricity() const;
450  double GetSquaredEccentricity() const;
451 
452  OGRErr SetAuthority(const char *pszTargetKey, const char *pszAuthority,
453  int nCode);
454 
455  OGRErr AutoIdentifyEPSG();
456  OGRSpatialReferenceH *FindMatches(char **papszOptions, int *pnEntries,
457  int **ppanMatchConfidence) const;
459  FindBestMatch(int nMinimumMatchConfidence = 90,
460  const char *pszPreferredAuthority = "EPSG",
461  CSLConstList papszOptions = nullptr) const;
462 
463  int GetEPSGGeogCS() const;
464 
465  const char *GetAuthorityCode(const char *pszTargetKey) const;
466  const char *GetAuthorityName(const char *pszTargetKey) const;
467  char *GetOGCURN() const;
468 
469  bool GetAreaOfUse(double *pdfWestLongitudeDeg, double *pdfSouthLatitudeDeg,
470  double *pdfEastLongitudeDeg, double *pdfNorthLatitudeDeg,
471  const char **ppszAreaName) const;
472 
473  const char *GetExtension(const char *pszTargetKey, const char *pszName,
474  const char *pszDefault = nullptr) const;
475  OGRErr SetExtension(const char *pszTargetKey, const char *pszName,
476  const char *pszValue);
477 
478  int FindProjParm(const char *pszParameter,
479  const OGR_SRSNode *poPROJCS = nullptr) const;
480  OGRErr SetProjParm(const char *, double);
481  double GetProjParm(const char *, double = 0.0, OGRErr * = nullptr) const;
482 
483  OGRErr SetNormProjParm(const char *, double);
484  double GetNormProjParm(const char *, double = 0.0,
485  OGRErr * = nullptr) const;
486 
487  static int IsAngularParameter(const char *);
488  static int IsLongitudeParameter(const char *);
489  static int IsLinearParameter(const char *);
490 
492  OGRErr SetACEA(double dfStdP1, double dfStdP2, double dfCenterLat,
493  double dfCenterLong, double dfFalseEasting,
494  double dfFalseNorthing);
495 
497  OGRErr SetAE(double dfCenterLat, double dfCenterLong, double dfFalseEasting,
498  double dfFalseNorthing);
499 
501  OGRErr SetBonne(double dfStdP1, double dfCentralMeridian,
502  double dfFalseEasting, double dfFalseNorthing);
503 
505  OGRErr SetCEA(double dfStdP1, double dfCentralMeridian,
506  double dfFalseEasting, double dfFalseNorthing);
507 
509  OGRErr SetCS(double dfCenterLat, double dfCenterLong, double dfFalseEasting,
510  double dfFalseNorthing);
511 
513  OGRErr SetEC(double dfStdP1, double dfStdP2, double dfCenterLat,
514  double dfCenterLong, double dfFalseEasting,
515  double dfFalseNorthing);
516 
518  OGRErr SetEckert(int nVariation, double dfCentralMeridian,
519  double dfFalseEasting, double dfFalseNorthing);
520 
522  OGRErr SetEckertIV(double dfCentralMeridian, double dfFalseEasting,
523  double dfFalseNorthing);
524 
526  OGRErr SetEckertVI(double dfCentralMeridian, double dfFalseEasting,
527  double dfFalseNorthing);
528 
530  OGRErr SetEquirectangular(double dfCenterLat, double dfCenterLong,
531  double dfFalseEasting, double dfFalseNorthing);
533  OGRErr SetEquirectangular2(double dfCenterLat, double dfCenterLong,
534  double dfPseudoStdParallel1,
535  double dfFalseEasting, double dfFalseNorthing);
536 
538  OGRErr SetGEOS(double dfCentralMeridian, double dfSatelliteHeight,
539  double dfFalseEasting, double dfFalseNorthing);
540 
542  OGRErr SetGH(double dfCentralMeridian, double dfFalseEasting,
543  double dfFalseNorthing);
544 
546  OGRErr SetIGH();
547 
549  OGRErr SetGS(double dfCentralMeridian, double dfFalseEasting,
550  double dfFalseNorthing);
551 
553  OGRErr SetGaussSchreiberTMercator(double dfCenterLat, double dfCenterLong,
554  double dfScale, double dfFalseEasting,
555  double dfFalseNorthing);
556 
558  OGRErr SetGnomonic(double dfCenterLat, double dfCenterLong,
559  double dfFalseEasting, double dfFalseNorthing);
560 
562  OGRErr SetHOM(double dfCenterLat, double dfCenterLong, double dfAzimuth,
563  double dfRectToSkew, double dfScale, double dfFalseEasting,
564  double dfFalseNorthing);
565 
567  OGRErr SetHOM2PNO(double dfCenterLat, double dfLat1, double dfLong1,
568  double dfLat2, double dfLong2, double dfScale,
569  double dfFalseEasting, double dfFalseNorthing);
570 
572  OGRErr SetHOMAC(double dfCenterLat, double dfCenterLong, double dfAzimuth,
573  double dfRectToSkew, double dfScale, double dfFalseEasting,
574  double dfFalseNorthing);
575 
577  OGRErr SetLOM(double dfCenterLat, double dfCenterLong, double dfAzimuth,
578  double dfScale, double dfFalseEasting,
579  double dfFalseNorthing);
580 
582  OGRErr SetIWMPolyconic(double dfLat1, double dfLat2, double dfCenterLong,
583  double dfFalseEasting, double dfFalseNorthing);
584 
586  OGRErr SetKrovak(double dfCenterLat, double dfCenterLong, double dfAzimuth,
587  double dfPseudoStdParallelLat, double dfScale,
588  double dfFalseEasting, double dfFalseNorthing);
589 
591  OGRErr SetLAEA(double dfCenterLat, double dfCenterLong,
592  double dfFalseEasting, double dfFalseNorthing);
593 
595  OGRErr SetLCC(double dfStdP1, double dfStdP2, double dfCenterLat,
596  double dfCenterLong, double dfFalseEasting,
597  double dfFalseNorthing);
598 
600  OGRErr SetLCC1SP(double dfCenterLat, double dfCenterLong, double dfScale,
601  double dfFalseEasting, double dfFalseNorthing);
602 
604  OGRErr SetLCCB(double dfStdP1, double dfStdP2, double dfCenterLat,
605  double dfCenterLong, double dfFalseEasting,
606  double dfFalseNorthing);
607 
609  OGRErr SetMC(double dfCenterLat, double dfCenterLong, double dfFalseEasting,
610  double dfFalseNorthing);
611 
613  OGRErr SetMercator(double dfCenterLat, double dfCenterLong, double dfScale,
614  double dfFalseEasting, double dfFalseNorthing);
615 
617  OGRErr SetMercator2SP(double dfStdP1, double dfCenterLat,
618  double dfCenterLong, double dfFalseEasting,
619  double dfFalseNorthing);
620 
622  OGRErr SetMollweide(double dfCentralMeridian, double dfFalseEasting,
623  double dfFalseNorthing);
624 
626  OGRErr SetNZMG(double dfCenterLat, double dfCenterLong,
627  double dfFalseEasting, double dfFalseNorthing);
628 
630  OGRErr SetOS(double dfOriginLat, double dfCMeridian, double dfScale,
631  double dfFalseEasting, double dfFalseNorthing);
632 
634  OGRErr SetOrthographic(double dfCenterLat, double dfCenterLong,
635  double dfFalseEasting, double dfFalseNorthing);
636 
638  OGRErr SetPolyconic(double dfCenterLat, double dfCenterLong,
639  double dfFalseEasting, double dfFalseNorthing);
640 
642  OGRErr SetPS(double dfCenterLat, double dfCenterLong, double dfScale,
643  double dfFalseEasting, double dfFalseNorthing);
644 
646  OGRErr SetRobinson(double dfCenterLong, double dfFalseEasting,
647  double dfFalseNorthing);
648 
650  OGRErr SetSinusoidal(double dfCenterLong, double dfFalseEasting,
651  double dfFalseNorthing);
652 
654  OGRErr SetStereographic(double dfCenterLat, double dfCenterLong,
655  double dfScale, double dfFalseEasting,
656  double dfFalseNorthing);
657 
659  OGRErr SetSOC(double dfLatitudeOfOrigin, double dfCentralMeridian,
660  double dfFalseEasting, double dfFalseNorthing);
661 
663  OGRErr SetTM(double dfCenterLat, double dfCenterLong, double dfScale,
664  double dfFalseEasting, double dfFalseNorthing);
665 
667  OGRErr SetTMVariant(const char *pszVariantName, double dfCenterLat,
668  double dfCenterLong, double dfScale,
669  double dfFalseEasting, double dfFalseNorthing);
670 
672  OGRErr SetTMG(double dfCenterLat, double dfCenterLong,
673  double dfFalseEasting, double dfFalseNorthing);
674 
676  OGRErr SetTMSO(double dfCenterLat, double dfCenterLong, double dfScale,
677  double dfFalseEasting, double dfFalseNorthing);
678 
680  OGRErr SetTPED(double dfLat1, double dfLong1, double dfLat2, double dfLong2,
681  double dfFalseEasting, double dfFalseNorthing);
682 
684  OGRErr SetVDG(double dfCenterLong, double dfFalseEasting,
685  double dfFalseNorthing);
686 
688  OGRErr SetUTM(int nZone, int bNorth = TRUE);
689  int GetUTMZone(int *pbNorth = nullptr) const;
690 
692  OGRErr SetWagner(int nVariation, double dfCenterLat, double dfFalseEasting,
693  double dfFalseNorthing);
694 
696  OGRErr SetQSC(double dfCenterLat, double dfCenterLong);
697 
699  OGRErr SetSCH(double dfPegLat, double dfPegLong, double dfPegHeading,
700  double dfPegHgt);
701 
703  OGRErr
704  SetVerticalPerspective(double dfTopoOriginLat, double dfTopoOriginLon,
705  double dfTopoOriginHeight, double dfViewPointHeight,
706  double dfFalseEasting, double dfFalseNorthing);
707 
709  OGRErr SetDerivedGeogCRSWithPoleRotationGRIBConvention(
710  const char *pszCRSName, double dfSouthPoleLat, double dfSouthPoleLon,
711  double dfAxisRotation);
712 
714  OGRErr SetDerivedGeogCRSWithPoleRotationNetCDFCFConvention(
715  const char *pszCRSName, double dfGridNorthPoleLat,
716  double dfGridNorthPoleLon, double dfNorthPoleGridLon);
717 
719  OGRErr SetStatePlane(int nZone, int bNAD83 = TRUE,
720  const char *pszOverrideUnitName = nullptr,
721  double dfOverrideUnit = 0.0);
722 
724  OGRErr ImportFromESRIStatePlaneWKT(int nCode, const char *pszDatumName,
725  const char *pszUnitsName, int nPCSCode,
726  const char *pszCRSName = nullptr);
727 
729  OGRErr ImportFromESRIWisconsinWKT(const char *pszPrjName,
730  double dfCentralMeridian,
731  double dfLatOfOrigin,
732  const char *pszUnitsName,
733  const char *pszCRSName = nullptr);
734 
736  void UpdateCoordinateSystemFromGeogCRS();
739  static OGRSpatialReference *GetWGS84SRS();
740 
745  {
746  return reinterpret_cast<OGRSpatialReferenceH>(poSRS);
747  }
748 
753  {
754  return reinterpret_cast<OGRSpatialReference *>(hSRS);
755  }
756 };
757 
759 struct CPL_DLL OGRSpatialReferenceReleaser
760 {
761  void operator()(OGRSpatialReference *poSRS) const
762  {
763  if (poSRS)
764  poSRS->Release();
765  }
766 };
767 
770 /************************************************************************/
771 /* OGRCoordinateTransformation */
772 /* */
773 /* This is really just used as a base class for a private */
774 /* implementation. */
775 /************************************************************************/
776 
787 {
788  public:
789  virtual ~OGRCoordinateTransformation()
790  {
791  }
792 
793  static void DestroyCT(OGRCoordinateTransformation *poCT);
794 
795  // From CT_CoordinateTransformation
796 
798  virtual const OGRSpatialReference *GetSourceCS() const = 0;
799 
801  virtual const OGRSpatialReference *GetTargetCS() const = 0;
802 
804  virtual bool GetEmitErrors() const
805  {
806  return false;
807  }
808 
810  virtual void SetEmitErrors(bool /*bEmitErrors*/)
811  {
812  }
813 
814  // From CT_MathTransform
815 
834  int Transform(size_t nCount, double *x, double *y, double *z = nullptr,
835  int *pabSuccess = nullptr);
836 
856  virtual int Transform(size_t nCount, double *x, double *y, double *z,
857  double *t, int *pabSuccess) = 0;
858 
879  virtual int TransformWithErrorCodes(size_t nCount, double *x, double *y,
880  double *z, double *t,
881  int *panErrorCodes);
882 
919  virtual int TransformBounds(const double xmin, const double ymin,
920  const double xmax, const double ymax,
921  double *out_xmin, double *out_ymin,
922  double *out_xmax, double *out_ymax,
923  const int densify_pts)
924  {
925  (void)xmin;
926  (void)xmax;
927  (void)ymin;
928  (void)ymax;
929  (void)densify_pts;
930  *out_xmin = HUGE_VAL;
931  *out_ymin = HUGE_VAL;
932  *out_xmax = HUGE_VAL;
933  *out_ymax = HUGE_VAL;
934  CPLError(CE_Failure, CPLE_AppDefined,
935  "TransformBounds not implemented.");
936  return false;
937  }
938 
943  static inline OGRCoordinateTransformationH
945  {
946  return reinterpret_cast<OGRCoordinateTransformationH>(poCT);
947  }
948 
953  static inline OGRCoordinateTransformation *
955  {
956  return reinterpret_cast<OGRCoordinateTransformation *>(hCT);
957  }
958 
962  virtual OGRCoordinateTransformation *Clone() const = 0;
963 
974 };
975 
978  const OGRSpatialReference *poTarget);
979 
987 {
989  private:
990  friend class OGRProjCT;
991  struct Private;
992  std::unique_ptr<Private> d;
995  public:
1000  operator=(const OGRCoordinateTransformationOptions &);
1002 
1003  bool SetAreaOfInterest(double dfWestLongitudeDeg, double dfSouthLatitudeDeg,
1004  double dfEastLongitudeDeg,
1005  double dfNorthLatitudeDeg);
1006  bool SetDesiredAccuracy(double dfAccuracy);
1007  bool SetBallparkAllowed(bool bAllowBallpark);
1008  bool SetOnlyBest(bool bOnlyBest);
1009 
1010  bool SetCoordinateOperation(const char *pszCT, bool bReverseCT);
1012  void SetSourceCenterLong(double dfCenterLong);
1013  void SetTargetCenterLong(double dfCenterLong);
1015 };
1016 
1018  const OGRSpatialReference *poSource, const OGRSpatialReference *poTarget,
1019  const OGRCoordinateTransformationOptions &options);
1020 
1021 #endif /* ndef OGR_SPATIALREF_H_INCLUDED */
Convenient string class based on std::string.
Definition: cpl_string.h:320
Interface for transforming between coordinate systems.
Definition: ogr_spatialref.h:787
virtual OGRCoordinateTransformation * GetInverse() const =0
Return a coordinate transformation that performs the inverse transformation of the current one.
virtual void SetEmitErrors(bool)
Set if the transformer must emit CPLError.
Definition: ogr_spatialref.h:810
virtual int TransformWithErrorCodes(size_t nCount, double *x, double *y, double *z, double *t, int *panErrorCodes)
Transform points from source to destination space.
int Transform(size_t nCount, double *x, double *y, double *z=nullptr, int *pabSuccess=nullptr)
Transform points from source to destination space.
virtual OGRCoordinateTransformation * Clone() const =0
Clone.
static OGRCoordinateTransformation * FromHandle(OGRCoordinateTransformationH hCT)
Convert a OGRCoordinateTransformationH to a OGRCoordinateTransformation*.
Definition: ogr_spatialref.h:954
virtual const OGRSpatialReference * GetTargetCS() const =0
Fetch internal target coordinate system.
virtual const OGRSpatialReference * GetSourceCS() const =0
Fetch internal source coordinate system.
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)
Transform boundary.
Definition: ogr_spatialref.h:919
virtual bool GetEmitErrors() const
Whether the transformer will emit CPLError.
Definition: ogr_spatialref.h:804
virtual int Transform(size_t nCount, double *x, double *y, double *z, double *t, int *pabSuccess)=0
Transform points from source to destination space.
static OGRCoordinateTransformationH ToHandle(OGRCoordinateTransformation *poCT)
Convert a OGRCoordinateTransformation* to a OGRCoordinateTransformationH.
Definition: ogr_spatialref.h:944
This class represents an OpenGIS Spatial Reference System, and contains methods for converting betwee...
Definition: ogr_spatialref.h:169
static OGRSpatialReference * FromHandle(OGRSpatialReferenceH hSRS)
Convert a OGRSpatialReferenceH to a OGRSpatialReference*.
Definition: ogr_spatialref.h:752
static OGRSpatialReferenceH ToHandle(OGRSpatialReference *poSRS)
Convert a OGRSpatialReference* to a OGRSpatialReferenceH.
Definition: ogr_spatialref.h:744
void Release()
Decrements the reference count by one, and destroy if zero.
Definition: ogrspatialreference.cpp:1094
Objects of this class are used to represent value nodes in the parsed representation of the WKT SRS f...
Definition: ogr_spatialref.h:67
int GetChildCount() const
Get number of children nodes.
Definition: ogr_spatialref.h:91
const char * GetValue() const
Fetch value string for this node.
Definition: ogr_spatialref.h:109
int IsLeafNode() const
Return whether this is a leaf node.
Definition: ogr_spatialref.h:86
#define CPLE_AppDefined
Application defined error.
Definition: cpl_error.h:100
void CPLError(CPLErr eErrClass, CPLErrorNum err_no, const char *fmt,...)
Report an error.
Definition: cpl_error.cpp:330
#define CPL_DISALLOW_COPY_ASSIGN(ClassName)
Helper to remove the copy and assignment constructors so that the compiler will not generate the defa...
Definition: cpl_port.h:1042
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition: cpl_port.h:1183
Various convenience functions for working with strings and string lists.
void * OGRCoordinateTransformationH
Opaque type for a coordinate transformation object.
Definition: ogr_api.h:83
void * OGRSpatialReferenceH
Opaque type for a spatial reference system.
Definition: ogr_api.h:81
int OGRErr
Type for a OGR error.
Definition: ogr_core.h:387
#define USGS_ANGLE_PACKEDDMS
Angle is in packed degree minute second.
Definition: ogr_spatialref.h:246
OGRCoordinateTransformation * OGRCreateCoordinateTransformation(const OGRSpatialReference *poSource, const OGRSpatialReference *poTarget)
Create transformation object.
Definition: ogrct.cpp:956
C spatial reference system services and defines.
OSRAxisMappingStrategy
Data axis to CRS axis mapping strategy.
Definition: ogr_srs_api.h:668
OGRAxisOrientation
Axis orientations (corresponds to CS_AxisOrientationEnum).
Definition: ogr_srs_api.h:51
Context for coordinate transformation.
Definition: ogr_spatialref.h:987
Listener that is notified of modification to nodes.
Definition: ogr_spatialref.h:71
virtual void notifyChange(OGR_SRSNode *)=0
Method triggered when a node is modified.