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 { return nChildren == 0; }
87 
88  int GetChildCount() const { return nChildren; }
89  OGR_SRSNode *GetChild( int );
90  const OGR_SRSNode *GetChild( int ) const;
91 
92  OGR_SRSNode *GetNode( const char * );
93  const OGR_SRSNode *GetNode( const char * ) const;
94 
95  void InsertChild( OGR_SRSNode *, int );
96  void AddChild( OGR_SRSNode * );
97  int FindChild( const char * ) const;
98  void DestroyChild( int );
99  void ClearChildren();
100  void StripNodes( const char * );
101 
102  const char *GetValue() const { return pszValue; }
103  void SetValue( const char * );
104 
105  void MakeValueSafe();
106 
107  OGR_SRSNode *Clone() const;
108 
109  OGRErr importFromWkt( char ** )
111  CPL_WARN_DEPRECATED("Use importFromWkt(const char**)")
113  ;
114  OGRErr importFromWkt( const char ** );
115  OGRErr exportToWkt( char ** ) const;
116  OGRErr exportToPrettyWkt( char **, int = 1) const;
117 
118  private:
119  char *pszValue;
120 
121  OGR_SRSNode **papoChildNodes;
122  OGR_SRSNode *poParent;
123 
124  int nChildren;
125 
126  int NeedsQuoting() const;
127  OGRErr importFromWkt( const char **, int nRecLevel, int* pnNodes );
128 
129  std::weak_ptr<Listener> m_listener{};
130  void notifyChange();
131 
133 };
134 
135 /************************************************************************/
136 /* OGRSpatialReference */
137 /************************************************************************/
138 
157 class CPL_DLL OGRSpatialReference
158 {
159  struct Private;
160  std::unique_ptr<Private> d;
161 
162  void GetNormInfo() const;
163 
164  // No longer used with PROJ >= 8.1.0
165  OGRErr importFromURNPart(const char* pszAuthority,
166  const char* pszCode,
167  const char* pszURN);
168 
169  static CPLString lookupInDict( const char *pszDictFile,
170  const char *pszCode );
171 
172  public:
173  explicit OGRSpatialReference(const char * = nullptr);
176 
177  virtual ~OGRSpatialReference();
178 
179  static void DestroySpatialReference(OGRSpatialReference* poSRS);
180 
181  OGRSpatialReference &operator=(const OGRSpatialReference&);
183 
184  int Reference();
185  int Dereference();
186  int GetReferenceCount() const;
187  void Release();
188 
189  const char* GetName() const;
190 
191  OGRSpatialReference *Clone() const;
192  OGRSpatialReference *CloneGeogCS() const;
193 
194  void dumpReadable();
195  OGRErr exportToWkt( char ** ) const;
196  OGRErr exportToWkt( char ** ppszWKT, const char* const* papszOptions ) const;
197  OGRErr exportToPrettyWkt( char **, int = FALSE) const;
198  // cppcheck-suppress functionStatic
199  OGRErr exportToPROJJSON( char **, const char* const* papszOptions ) const;
200  OGRErr exportToProj4( char ** ) const;
201  OGRErr exportToPCI( char **, char **, double ** ) const;
202  OGRErr exportToUSGS( long *, long *, double **, long * ) const;
203  OGRErr exportToXML( char **, const char * = nullptr ) const;
204  OGRErr exportToPanorama( long *, long *, long *, long *,
205  double * ) const;
206  OGRErr exportToERM( char *pszProj, char *pszDatum, char *pszUnits );
207  OGRErr exportToMICoordSys( char ** ) const;
208 
209 
210  OGRErr importFromWkt( char ** )
212  CPL_WARN_DEPRECATED("Use importFromWkt(const char**) or importFromWkt(const char*)")
214  ;
215 
216  OGRErr importFromWkt( const char ** );
218  OGRErr importFromWkt( const char * pszInput, CSLConstList papszOptions);
219  OGRErr importFromWkt( const char ** ppszInput, CSLConstList papszOptions);
221  OGRErr importFromWkt( const char* );
222  OGRErr importFromProj4( const char * );
223  OGRErr importFromEPSG( int );
224  OGRErr importFromEPSGA( int );
225  OGRErr importFromESRI( char ** );
226  OGRErr importFromPCI( const char *, const char * = nullptr,
227  double * = nullptr );
228 
229 #define USGS_ANGLE_DECIMALDEGREES 0
230 #define USGS_ANGLE_PACKEDDMS TRUE
231 #define USGS_ANGLE_RADIANS 2
232  OGRErr importFromUSGS( long iProjSys, long iZone,
233  double *padfPrjParams, long iDatum,
234  int nUSGSAngleFormat = USGS_ANGLE_PACKEDDMS );
235  OGRErr importFromPanorama( long, long, long, double* );
236  OGRErr importVertCSFromPanorama( int );
237  OGRErr importFromOzi( const char * const* papszLines );
238  OGRErr importFromWMSAUTO( const char *pszAutoDef );
239  OGRErr importFromXML( const char * );
240  OGRErr importFromDict( const char *pszDict, const char *pszCode );
241  OGRErr importFromURN( const char * );
242  OGRErr importFromCRSURL( const char * );
243  OGRErr importFromERM( const char *pszProj, const char *pszDatum,
244  const char *pszUnits );
245  OGRErr importFromUrl( const char * );
246  OGRErr importFromMICoordSys( const char * );
247 
248  OGRErr morphToESRI();
249  OGRErr morphFromESRI();
250 
251  OGRSpatialReference* convertToOtherProjection(
252  const char* pszTargetProjection,
253  const char* const* papszOptions = nullptr ) const;
254 
255  OGRErr Validate() const;
256  OGRErr StripVertical();
257 
258  bool StripTOWGS84IfKnownDatumAndAllowed();
259  bool StripTOWGS84IfKnownDatum();
260 
261  int EPSGTreatsAsLatLong() const;
262  int EPSGTreatsAsNorthingEasting() const;
263  int GetAxesCount() const;
264  const char *GetAxis( const char *pszTargetKey, int iAxis,
265  OGRAxisOrientation *peOrientation,
266  double* pdfConvFactor = nullptr ) const;
267  OGRErr SetAxes( const char *pszTargetKey,
268  const char *pszXAxisName,
269  OGRAxisOrientation eXAxisOrientation,
270  const char *pszYAxisName,
271  OGRAxisOrientation eYAxisOrientation );
272 
273  OSRAxisMappingStrategy GetAxisMappingStrategy() const;
274  void SetAxisMappingStrategy(OSRAxisMappingStrategy);
275  const std::vector<int>& GetDataAxisToSRSAxisMapping() const;
276  OGRErr SetDataAxisToSRSAxisMapping(const std::vector<int>& mapping);
277 
278  // Machinery for accessing parse nodes
279 
281  OGR_SRSNode *GetRoot();
283  const OGR_SRSNode *GetRoot() const;
284  void SetRoot( OGR_SRSNode * );
285 
286  OGR_SRSNode *GetAttrNode(const char *);
287  const OGR_SRSNode *GetAttrNode(const char *) const;
288  const char *GetAttrValue(const char *, int = 0) const;
289 
290  OGRErr SetNode( const char *, const char * );
291  OGRErr SetNode( const char *, double );
292 
293  OGRErr SetLinearUnitsAndUpdateParameters( const char *pszName,
294  double dfInMeters,
295  const char *pszUnitAuthority = nullptr,
296  const char *pszUnitCode = nullptr );
297  OGRErr SetLinearUnits( const char *pszName, double dfInMeters );
298  OGRErr SetTargetLinearUnits( const char *pszTargetKey,
299  const char *pszName,
300  double dfInMeters,
301  const char *pszUnitAuthority = nullptr,
302  const char *pszUnitCode = nullptr);
303 
304  double GetLinearUnits( char ** ) const
306  CPL_WARN_DEPRECATED("Use GetLinearUnits(const char**) instead")
308  ;
309  double GetLinearUnits( const char ** = nullptr ) const;
311  double GetLinearUnits( std::nullptr_t ) const
312  { return GetLinearUnits( static_cast<const char**>(nullptr) ); }
315  double GetTargetLinearUnits( const char *pszTargetKey,
316  char ** ppszRetName ) const
318  CPL_WARN_DEPRECATED("Use GetTargetLinearUnits(const char*, const char**)")
320  ;
321  double GetTargetLinearUnits( const char *pszTargetKey,
322  const char ** ppszRetName = nullptr ) const;
324  double GetTargetLinearUnits( const char *pszTargetKey, std::nullptr_t ) const
325  { return GetTargetLinearUnits( pszTargetKey, static_cast<const char**>(nullptr) ); }
328  OGRErr SetAngularUnits( const char *pszName, double dfInRadians );
329  double GetAngularUnits( char ** ) const
331  CPL_WARN_DEPRECATED("Use GetAngularUnits(const char**) instead")
333  ;
334  double GetAngularUnits( const char ** = nullptr ) const;
336  double GetAngularUnits( std::nullptr_t ) const
337  { return GetAngularUnits( static_cast<const char**>(nullptr) ); }
340  double GetPrimeMeridian( char ** ) const
342  CPL_WARN_DEPRECATED("Use GetPrimeMeridian(const char**) instead")
344  ;
345  double GetPrimeMeridian( const char ** = nullptr ) const;
347  double GetPrimeMeridian( std::nullptr_t ) const
348  { return GetPrimeMeridian( static_cast<const char**>(nullptr) ); }
351  bool IsEmpty() const;
352  int IsGeographic() const;
353  int IsDerivedGeographic() const;
354  int IsProjected() const;
355  int IsGeocentric() const;
356  bool IsDynamic() const;
357  int IsLocal() const;
358  int IsVertical() const;
359  int IsCompound() const;
360  int IsSameGeogCS( const OGRSpatialReference * ) const;
361  int IsSameGeogCS( const OGRSpatialReference *,
362  const char* const * papszOptions ) const;
363  int IsSameVertCS( const OGRSpatialReference * ) const;
364  int IsSame( const OGRSpatialReference * ) const;
365  int IsSame( const OGRSpatialReference *,
366  const char* const * papszOptions ) const;
367 
368  void Clear();
369  OGRErr SetLocalCS( const char * );
370  OGRErr SetProjCS( const char * );
371  OGRErr SetProjection( const char * );
372  OGRErr SetGeocCS( const char * pszGeocName );
373  OGRErr SetGeogCS( const char * pszGeogName,
374  const char * pszDatumName,
375  const char * pszEllipsoidName,
376  double dfSemiMajor, double dfInvFlattening,
377  const char * pszPMName = nullptr,
378  double dfPMOffset = 0.0,
379  const char * pszUnits = nullptr,
380  double dfConvertToRadians = 0.0 );
381  OGRErr SetWellKnownGeogCS( const char * );
382  OGRErr CopyGeogCSFrom( const OGRSpatialReference * poSrcSRS );
383  OGRErr SetVertCS( const char *pszVertCSName,
384  const char *pszVertDatumName,
385  int nVertDatumClass = 2005 );
386  OGRErr SetCompoundCS( const char *pszName,
387  const OGRSpatialReference *poHorizSRS,
388  const OGRSpatialReference *poVertSRS );
389 
390  void SetCoordinateEpoch( double dfCoordinateEpoch );
391  double GetCoordinateEpoch() const;
392 
393  // cppcheck-suppress functionStatic
394  OGRErr PromoteTo3D( const char* pszName );
395  // cppcheck-suppress functionStatic
396  OGRErr DemoteTo2D( const char* pszName );
397 
398  OGRErr SetFromUserInput( const char * );
399 
400  static const char* const SET_FROM_USER_INPUT_LIMITATIONS[];
401  static CSLConstList SET_FROM_USER_INPUT_LIMITATIONS_get();
402 
403  OGRErr SetFromUserInput( const char *, CSLConstList papszOptions );
404 
405  OGRErr SetTOWGS84( double, double, double,
406  double = 0.0, double = 0.0, double = 0.0,
407  double = 0.0 );
408  OGRErr GetTOWGS84( double *padfCoef, int nCoeff = 7 ) const;
409  OGRErr AddGuessedTOWGS84();
410 
411  double GetSemiMajor( OGRErr * = nullptr ) const;
412  double GetSemiMinor( OGRErr * = nullptr ) const;
413  double GetInvFlattening( OGRErr * = nullptr ) const;
414  double GetEccentricity() const;
415  double GetSquaredEccentricity() const;
416 
417  OGRErr SetAuthority( const char * pszTargetKey,
418  const char * pszAuthority,
419  int nCode );
420 
421  OGRErr AutoIdentifyEPSG();
422  OGRSpatialReferenceH* FindMatches( char** papszOptions,
423  int* pnEntries,
424  int** ppanMatchConfidence ) const;
425  OGRSpatialReference* FindBestMatch(int nMinimumMatchConfidence = 90,
426  const char* pszPreferredAuthority = "EPSG",
427  CSLConstList papszOptions = nullptr) const;
428 
429  int GetEPSGGeogCS() const;
430 
431  const char *GetAuthorityCode( const char * pszTargetKey ) const;
432  const char *GetAuthorityName( const char * pszTargetKey ) const;
433  char *GetOGCURN() const;
434 
435  bool GetAreaOfUse( double* pdfWestLongitudeDeg,
436  double* pdfSouthLatitudeDeg,
437  double* pdfEastLongitudeDeg,
438  double* pdfNorthLatitudeDeg,
439  const char **ppszAreaName ) const;
440 
441  const char *GetExtension( const char *pszTargetKey,
442  const char *pszName,
443  const char *pszDefault = nullptr ) const;
444  OGRErr SetExtension( const char *pszTargetKey,
445  const char *pszName,
446  const char *pszValue );
447 
448  int FindProjParm( const char *pszParameter,
449  const OGR_SRSNode *poPROJCS=nullptr ) const;
450  OGRErr SetProjParm( const char *, double );
451  double GetProjParm( const char *, double =0.0, OGRErr* = nullptr ) const;
452 
453  OGRErr SetNormProjParm( const char *, double );
454  double GetNormProjParm( const char *, double=0.0, OGRErr* =nullptr)const;
455 
456  static int IsAngularParameter( const char * );
457  static int IsLongitudeParameter( const char * );
458  static int IsLinearParameter( const char * );
459 
461  OGRErr SetACEA( double dfStdP1, double dfStdP2,
462  double dfCenterLat, double dfCenterLong,
463  double dfFalseEasting, double dfFalseNorthing );
464 
466  OGRErr SetAE( double dfCenterLat, double dfCenterLong,
467  double dfFalseEasting, double dfFalseNorthing );
468 
470  OGRErr SetBonne( double dfStdP1, double dfCentralMeridian,
471  double dfFalseEasting, double dfFalseNorthing );
472 
474  OGRErr SetCEA( double dfStdP1, double dfCentralMeridian,
475  double dfFalseEasting, double dfFalseNorthing );
476 
478  OGRErr SetCS( double dfCenterLat, double dfCenterLong,
479  double dfFalseEasting, double dfFalseNorthing );
480 
482  OGRErr SetEC( double dfStdP1, double dfStdP2,
483  double dfCenterLat, double dfCenterLong,
484  double dfFalseEasting, double dfFalseNorthing );
485 
487  OGRErr SetEckert( int nVariation, double dfCentralMeridian,
488  double dfFalseEasting, double dfFalseNorthing );
489 
491  OGRErr SetEckertIV( double dfCentralMeridian,
492  double dfFalseEasting, double dfFalseNorthing );
493 
495  OGRErr SetEckertVI( double dfCentralMeridian,
496  double dfFalseEasting, double dfFalseNorthing );
497 
499  OGRErr SetEquirectangular(double dfCenterLat, double dfCenterLong,
500  double dfFalseEasting, double dfFalseNorthing );
502  OGRErr SetEquirectangular2( double dfCenterLat, double dfCenterLong,
503  double dfPseudoStdParallel1,
504  double dfFalseEasting, double dfFalseNorthing );
505 
507  OGRErr SetGEOS( double dfCentralMeridian, double dfSatelliteHeight,
508  double dfFalseEasting, double dfFalseNorthing );
509 
511  OGRErr SetGH( double dfCentralMeridian,
512  double dfFalseEasting, double dfFalseNorthing );
513 
515  OGRErr SetIGH();
516 
518  OGRErr SetGS( double dfCentralMeridian,
519  double dfFalseEasting, double dfFalseNorthing );
520 
522  OGRErr SetGaussSchreiberTMercator(double dfCenterLat, double dfCenterLong,
523  double dfScale,
524  double dfFalseEasting, double dfFalseNorthing );
525 
527  OGRErr SetGnomonic(double dfCenterLat, double dfCenterLong,
528  double dfFalseEasting, double dfFalseNorthing );
529 
531  OGRErr SetHOM( double dfCenterLat, double dfCenterLong,
532  double dfAzimuth, double dfRectToSkew,
533  double dfScale,
534  double dfFalseEasting, double dfFalseNorthing );
535 
537  OGRErr SetHOM2PNO( double dfCenterLat,
538  double dfLat1, double dfLong1,
539  double dfLat2, double dfLong2,
540  double dfScale,
541  double dfFalseEasting, double dfFalseNorthing );
542 
544  OGRErr SetHOMAC( double dfCenterLat, double dfCenterLong,
545  double dfAzimuth, double dfRectToSkew,
546  double dfScale,
547  double dfFalseEasting, double dfFalseNorthing );
548 
550  OGRErr SetLOM( double dfCenterLat, double dfCenterLong,
551  double dfAzimuth,
552  double dfScale,
553  double dfFalseEasting, double dfFalseNorthing );
554 
556  OGRErr SetIWMPolyconic( double dfLat1, double dfLat2,
557  double dfCenterLong,
558  double dfFalseEasting,
559  double dfFalseNorthing );
560 
562  OGRErr SetKrovak( double dfCenterLat, double dfCenterLong,
563  double dfAzimuth, double dfPseudoStdParallelLat,
564  double dfScale,
565  double dfFalseEasting, double dfFalseNorthing );
566 
568  OGRErr SetLAEA( double dfCenterLat, double dfCenterLong,
569  double dfFalseEasting, double dfFalseNorthing );
570 
572  OGRErr SetLCC( double dfStdP1, double dfStdP2,
573  double dfCenterLat, double dfCenterLong,
574  double dfFalseEasting, double dfFalseNorthing );
575 
577  OGRErr SetLCC1SP( double dfCenterLat, double dfCenterLong,
578  double dfScale,
579  double dfFalseEasting, double dfFalseNorthing );
580 
582  OGRErr SetLCCB( double dfStdP1, double dfStdP2,
583  double dfCenterLat, double dfCenterLong,
584  double dfFalseEasting, double dfFalseNorthing );
585 
587  OGRErr SetMC( double dfCenterLat, double dfCenterLong,
588  double dfFalseEasting, double dfFalseNorthing );
589 
591  OGRErr SetMercator( double dfCenterLat, double dfCenterLong,
592  double dfScale,
593  double dfFalseEasting, double dfFalseNorthing );
594 
596  OGRErr SetMercator2SP( double dfStdP1,
597  double dfCenterLat, double dfCenterLong,
598  double dfFalseEasting, double dfFalseNorthing );
599 
601  OGRErr SetMollweide( double dfCentralMeridian,
602  double dfFalseEasting, double dfFalseNorthing );
603 
605  OGRErr SetNZMG( double dfCenterLat, double dfCenterLong,
606  double dfFalseEasting, double dfFalseNorthing );
607 
609  OGRErr SetOS( double dfOriginLat, double dfCMeridian,
610  double dfScale,
611  double dfFalseEasting,double dfFalseNorthing);
612 
614  OGRErr SetOrthographic( double dfCenterLat, double dfCenterLong,
615  double dfFalseEasting,double dfFalseNorthing);
616 
618  OGRErr SetPolyconic( double dfCenterLat, double dfCenterLong,
619  double dfFalseEasting, double dfFalseNorthing );
620 
622  OGRErr SetPS( double dfCenterLat, double dfCenterLong,
623  double dfScale,
624  double dfFalseEasting, double dfFalseNorthing);
625 
627  OGRErr SetRobinson( double dfCenterLong,
628  double dfFalseEasting, double dfFalseNorthing );
629 
631  OGRErr SetSinusoidal( double dfCenterLong,
632  double dfFalseEasting, double dfFalseNorthing );
633 
635  OGRErr SetStereographic( double dfCenterLat, double dfCenterLong,
636  double dfScale,
637  double dfFalseEasting,double dfFalseNorthing);
638 
640  OGRErr SetSOC( double dfLatitudeOfOrigin, double dfCentralMeridian,
641  double dfFalseEasting, double dfFalseNorthing );
642 
644  OGRErr SetTM( double dfCenterLat, double dfCenterLong,
645  double dfScale,
646  double dfFalseEasting, double dfFalseNorthing );
647 
649  OGRErr SetTMVariant( const char *pszVariantName,
650  double dfCenterLat, double dfCenterLong,
651  double dfScale,
652  double dfFalseEasting, double dfFalseNorthing );
653 
655  OGRErr SetTMG( double dfCenterLat, double dfCenterLong,
656  double dfFalseEasting, double dfFalseNorthing );
657 
659  OGRErr SetTMSO( double dfCenterLat, double dfCenterLong,
660  double dfScale,
661  double dfFalseEasting, double dfFalseNorthing );
662 
664  OGRErr SetTPED( double dfLat1, double dfLong1,
665  double dfLat2, double dfLong2,
666  double dfFalseEasting, double dfFalseNorthing );
667 
669  OGRErr SetVDG( double dfCenterLong,
670  double dfFalseEasting, double dfFalseNorthing );
671 
673  OGRErr SetUTM( int nZone, int bNorth = TRUE );
674  int GetUTMZone( int *pbNorth = nullptr ) const;
675 
677  OGRErr SetWagner( int nVariation, double dfCenterLat,
678  double dfFalseEasting, double dfFalseNorthing );
679 
681  OGRErr SetQSC(double dfCenterLat, double dfCenterLong);
682 
684  OGRErr SetSCH( double dfPegLat, double dfPegLong,
685  double dfPegHeading, double dfPegHgt);
686 
688  OGRErr SetVerticalPerspective( double dfTopoOriginLat,
689  double dfTopoOriginLon,
690  double dfTopoOriginHeight,
691  double dfViewPointHeight,
692  double dfFalseEasting,
693  double dfFalseNorthing);
694 
696  OGRErr SetDerivedGeogCRSWithPoleRotationGRIBConvention(
697  const char* pszCRSName,
698  double dfSouthPoleLat,
699  double dfSouthPoleLon,
700  double dfAxisRotation );
701 
703  OGRErr SetDerivedGeogCRSWithPoleRotationNetCDFCFConvention(
704  const char* pszCRSName,
705  double dfGridNorthPoleLat,
706  double dfGridNorthPoleLon,
707  double dfNorthPoleGridLon );
708 
710  OGRErr SetStatePlane( int nZone, int bNAD83 = TRUE,
711  const char *pszOverrideUnitName = nullptr,
712  double dfOverrideUnit = 0.0 );
713 
715  OGRErr ImportFromESRIStatePlaneWKT(
716  int nCode, const char* pszDatumName, const char* pszUnitsName,
717  int nPCSCode, const char* pszCRSName = nullptr );
718 
720  OGRErr ImportFromESRIWisconsinWKT(
721  const char* pszPrjName, double dfCentralMeridian, double dfLatOfOrigin,
722  const char* pszUnitsName, const char* pszCRSName = nullptr );
723 
725  void UpdateCoordinateSystemFromGeogCRS();
728  static OGRSpatialReference* GetWGS84SRS();
729 
734  { return reinterpret_cast<OGRSpatialReferenceH>(poSRS); }
735 
740  { return reinterpret_cast<OGRSpatialReference*>(hSRS); }
741 
742 };
743 
744 /************************************************************************/
745 /* OGRCoordinateTransformation */
746 /* */
747 /* This is really just used as a base class for a private */
748 /* implementation. */
749 /************************************************************************/
750 
761 {
762 public:
763  virtual ~OGRCoordinateTransformation() {}
764 
765  static void DestroyCT(OGRCoordinateTransformation* poCT);
766 
767  // From CT_CoordinateTransformation
768 
770  virtual OGRSpatialReference *GetSourceCS() = 0;
771 
773  virtual OGRSpatialReference *GetTargetCS() = 0;
774 
776  virtual bool GetEmitErrors() const { return false; }
777 
779  virtual void SetEmitErrors(bool /*bEmitErrors*/) {}
780 
781  // From CT_MathTransform
782 
798  int Transform( int nCount,
799  double *x, double *y, double *z = nullptr,
800  int *pabSuccess = nullptr );
801 
818  virtual int Transform( int nCount,
819  double *x, double *y,
820  double *z, double *t,
821  int *pabSuccess ) = 0;
822 
840  virtual int TransformWithErrorCodes( int nCount,
841  double *x, double *y,
842  double *z, double *t,
843  int *panErrorCodes );
844 
877  virtual int TransformBounds( const double xmin,
878  const double ymin,
879  const double xmax,
880  const double ymax,
881  double* out_xmin,
882  double* out_ymin,
883  double* out_xmax,
884  double* out_ymax,
885  const int densify_pts )
886  {
887  (void)xmin;
888  (void)xmax;
889  (void)ymin;
890  (void)ymax;
891  (void)densify_pts;
892  *out_xmin = HUGE_VAL;
893  *out_ymin = HUGE_VAL;
894  *out_xmax = HUGE_VAL;
895  *out_ymax = HUGE_VAL;
896  CPLError(CE_Failure, CPLE_AppDefined, "TransformBounds not implemented.");
897  return false;
898  }
899 
904  { return reinterpret_cast<OGRCoordinateTransformationH>(poCT); }
905 
910  { return reinterpret_cast<OGRCoordinateTransformation*>(hCT); }
911 
915  virtual OGRCoordinateTransformation* Clone() const = 0;
916 
926  virtual OGRCoordinateTransformation* GetInverse() const = 0;
927 };
928 
931  const OGRSpatialReference *poTarget );
932 
933 
941 {
943 private:
944  friend class OGRProjCT;
945  struct Private;
946  std::unique_ptr<Private> d;
949 public:
954 
955  bool SetAreaOfInterest(double dfWestLongitudeDeg,
956  double dfSouthLatitudeDeg,
957  double dfEastLongitudeDeg,
958  double dfNorthLatitudeDeg);
959  bool SetDesiredAccuracy(double dfAccuracy);
960  bool SetBallparkAllowed(bool bAllowBallpark);
961 
962  bool SetCoordinateOperation(const char* pszCT, bool bReverseCT);
964  void SetSourceCenterLong(double dfCenterLong);
965  void SetTargetCenterLong(double dfCenterLong);
967 };
968 
969 
972  const OGRSpatialReference *poTarget,
973  const OGRCoordinateTransformationOptions& options );
974 
975 #endif /* ndef OGR_SPATIALREF_H_INCLUDED */
OGR_SRSNode::GetChildCount
int GetChildCount() const
Definition: ogr_spatialref.h:88
OGRCreateCoordinateTransformation
OGRCoordinateTransformation * OGRCreateCoordinateTransformation(const OGRSpatialReference *poSource, const OGRSpatialReference *poTarget)
Create transformation object.
Definition: ogrct.cpp:864
OGRCoordinateTransformationOptions
Context for coordinate transformation.
Definition: ogr_spatialref.h:940
OGRCoordinateTransformation::TransformBounds
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:877
OGRSpatialReference
This class represents an OpenGIS Spatial Reference System, and contains methods for converting betwee...
Definition: ogr_spatialref.h:157
OGRCoordinateTransformation::ToHandle
static OGRCoordinateTransformationH ToHandle(OGRCoordinateTransformation *poCT)
Convert a OGRCoordinateTransformation* to a OGRCoordinateTransformationH.
Definition: ogr_spatialref.h:903
OGR_SRSNode::IsLeafNode
int IsLeafNode() const
Return whether this is a leaf node.
Definition: ogr_spatialref.h:86
OGRSpatialReference::FromHandle
static OGRSpatialReference * FromHandle(OGRSpatialReferenceH hSRS)
Convert a OGRSpatialReferenceH to a OGRSpatialReference*.
Definition: ogr_spatialref.h:739
CPLString
Convenient string class based on std::string.
Definition: cpl_string.h:320
OGRSpatialReference::ToHandle
static OGRSpatialReferenceH ToHandle(OGRSpatialReference *poSRS)
Convert a OGRSpatialReference* to a OGRSpatialReferenceH.
Definition: ogr_spatialref.h:733
OSRAxisMappingStrategy
OSRAxisMappingStrategy
Data axis to CRS axis mapping strategy.
Definition: ogr_srs_api.h:669
OGR_SRSNode::GetValue
const char * GetValue() const
Definition: ogr_spatialref.h:102
OGRSpatialReferenceH
void * OGRSpatialReferenceH
Opaque type for a spatial reference system.
Definition: ogr_api.h:81
OGR_SRSNode::Listener
Listener that is notified of modification to nodes.
Definition: ogr_spatialref.h:70
OGRCoordinateTransformationH
void * OGRCoordinateTransformationH
Opaque type for a coordinate transformation object.
Definition: ogr_api.h:83
OGRCoordinateTransformation::SetEmitErrors
virtual void SetEmitErrors(bool)
Set if the transformer must emit CPLError.
Definition: ogr_spatialref.h:779
CSLConstList
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition: cpl_port.h:1056
ogr_srs_api.h
cpl_string.h
OGRAxisOrientation
OGRAxisOrientation
Axis orientations (corresponds to CS_AxisOrientationEnum).
Definition: ogr_srs_api.h:48
CPLError
void CPLError(CPLErr eErrClass, CPLErrorNum err_no, const char *fmt,...)
Report an error.
Definition: cpl_error.cpp:309
OGRCoordinateTransformation
Interface for transforming between coordinate systems.
Definition: ogr_spatialref.h:760
OGRCoordinateTransformation::FromHandle
static OGRCoordinateTransformation * FromHandle(OGRCoordinateTransformationH hCT)
Convert a OGRCoordinateTransformationH to a OGRCoordinateTransformation*.
Definition: ogr_spatialref.h:909
OGRErr
int OGRErr
Type for a OGR error.
Definition: ogr_core.h:341
OGRCoordinateTransformation::GetEmitErrors
virtual bool GetEmitErrors() const
Whether the transformer will emit CPLError.
Definition: ogr_spatialref.h:776
USGS_ANGLE_PACKEDDMS
#define USGS_ANGLE_PACKEDDMS
Angle is in packed degree minute second.
Definition: ogr_spatialref.h:230
OGR_SRSNode
Objects of this class are used to represent value nodes in the parsed representation of the WKT SRS f...
Definition: ogr_spatialref.h:66
CPL_DISALLOW_COPY_ASSIGN
#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:930
CPLE_AppDefined
#define CPLE_AppDefined
Application defined error.
Definition: cpl_error.h:99