GDAL
ogr_spatialref.h
Go to the documentation of this file.
1 /******************************************************************************
2  * $Id: ogr_spatialref.h 8f0ebfd5b6f153a63b6e2186b68577937cedc02c 2020-06-14 00:21:08 +0200 Even Rouault $
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  OGRErr importFromURNPart(const char* pszAuthority,
165  const char* pszCode,
166  const char* pszURN);
167 
168  static CPLString lookupInDict( const char *pszDictFile,
169  const char *pszCode );
170 
171  public:
173  explicit OGRSpatialReference(const char * = nullptr);
174 
175  virtual ~OGRSpatialReference();
176 
177  static void DestroySpatialReference(OGRSpatialReference* poSRS);
178 
179  OGRSpatialReference &operator=(const OGRSpatialReference&);
180 
181  int Reference();
182  int Dereference();
183  int GetReferenceCount() const;
184  void Release();
185 
186  const char* GetName() const;
187 
188  OGRSpatialReference *Clone() const;
189  OGRSpatialReference *CloneGeogCS() const;
190 
191  void dumpReadable();
192  OGRErr exportToWkt( char ** ) const;
193  OGRErr exportToWkt( char ** ppszWKT, const char* const* papszOptions ) const;
194  OGRErr exportToPrettyWkt( char **, int = FALSE) const;
195  // cppcheck-suppress functionStatic
196  OGRErr exportToPROJJSON( char **, const char* const* papszOptions ) const;
197  OGRErr exportToProj4( char ** ) const;
198  OGRErr exportToPCI( char **, char **, double ** ) const;
199  OGRErr exportToUSGS( long *, long *, double **, long * ) const;
200  OGRErr exportToXML( char **, const char * = nullptr ) const;
201  OGRErr exportToPanorama( long *, long *, long *, long *,
202  double * ) const;
203  OGRErr exportToERM( char *pszProj, char *pszDatum, char *pszUnits );
204  OGRErr exportToMICoordSys( char ** ) const;
205 
206 
207  OGRErr importFromWkt( char ** )
209  CPL_WARN_DEPRECATED("Use importFromWkt(const char**) or importFromWkt(const char*)")
211  ;
212 
213  OGRErr importFromWkt( const char ** );
214  OGRErr importFromWkt( const char* );
215  OGRErr importFromProj4( const char * );
216  OGRErr importFromEPSG( int );
217  OGRErr importFromEPSGA( int );
218  OGRErr importFromESRI( char ** );
219  OGRErr importFromPCI( const char *, const char * = nullptr,
220  double * = nullptr );
221 
222 #define USGS_ANGLE_DECIMALDEGREES 0
223 #define USGS_ANGLE_PACKEDDMS TRUE
224 #define USGS_ANGLE_RADIANS 2
225  OGRErr importFromUSGS( long iProjSys, long iZone,
226  double *padfPrjParams, long iDatum,
227  int nUSGSAngleFormat = USGS_ANGLE_PACKEDDMS );
228  OGRErr importFromPanorama( long, long, long, double* );
229  OGRErr importVertCSFromPanorama( int );
230  OGRErr importFromOzi( const char * const* papszLines );
231  OGRErr importFromWMSAUTO( const char *pszAutoDef );
232  OGRErr importFromXML( const char * );
233  OGRErr importFromDict( const char *pszDict, const char *pszCode );
234  OGRErr importFromURN( const char * );
235  OGRErr importFromCRSURL( const char * );
236  OGRErr importFromERM( const char *pszProj, const char *pszDatum,
237  const char *pszUnits );
238  OGRErr importFromUrl( const char * );
239  OGRErr importFromMICoordSys( const char * );
240 
241  OGRErr morphToESRI();
242  OGRErr morphFromESRI();
243 
244  OGRSpatialReference* convertToOtherProjection(
245  const char* pszTargetProjection,
246  const char* const* papszOptions = nullptr ) const;
247 
248  OGRErr Validate() const;
249  OGRErr StripVertical();
250 
251  bool StripTOWGS84IfKnownDatumAndAllowed();
252  bool StripTOWGS84IfKnownDatum();
253 
254  int EPSGTreatsAsLatLong() const;
255  int EPSGTreatsAsNorthingEasting() const;
256  int GetAxesCount() const;
257  const char *GetAxis( const char *pszTargetKey, int iAxis,
258  OGRAxisOrientation *peOrientation ) const;
259  OGRErr SetAxes( const char *pszTargetKey,
260  const char *pszXAxisName,
261  OGRAxisOrientation eXAxisOrientation,
262  const char *pszYAxisName,
263  OGRAxisOrientation eYAxisOrientation );
264 
265  OSRAxisMappingStrategy GetAxisMappingStrategy() const;
266  void SetAxisMappingStrategy(OSRAxisMappingStrategy);
267  const std::vector<int>& GetDataAxisToSRSAxisMapping() const;
268  OGRErr SetDataAxisToSRSAxisMapping(const std::vector<int>& mapping);
269 
270  // Machinery for accessing parse nodes
271 
273  OGR_SRSNode *GetRoot();
275  const OGR_SRSNode *GetRoot() const;
276  void SetRoot( OGR_SRSNode * );
277 
278  OGR_SRSNode *GetAttrNode(const char *);
279  const OGR_SRSNode *GetAttrNode(const char *) const;
280  const char *GetAttrValue(const char *, int = 0) const;
281 
282  OGRErr SetNode( const char *, const char * );
283  OGRErr SetNode( const char *, double );
284 
285  OGRErr SetLinearUnitsAndUpdateParameters( const char *pszName,
286  double dfInMeters,
287  const char *pszUnitAuthority = nullptr,
288  const char *pszUnitCode = nullptr );
289  OGRErr SetLinearUnits( const char *pszName, double dfInMeters );
290  OGRErr SetTargetLinearUnits( const char *pszTargetKey,
291  const char *pszName,
292  double dfInMeters,
293  const char *pszUnitAuthority = nullptr,
294  const char *pszUnitCode = nullptr);
295 
296  double GetLinearUnits( char ** ) const
298  CPL_WARN_DEPRECATED("Use GetLinearUnits(const char**) instead")
300  ;
301  double GetLinearUnits( const char ** = nullptr ) const;
303  double GetLinearUnits( std::nullptr_t ) const
304  { return GetLinearUnits( static_cast<const char**>(nullptr) ); }
307  double GetTargetLinearUnits( const char *pszTargetKey,
308  char ** ppszRetName ) const
310  CPL_WARN_DEPRECATED("Use GetTargetLinearUnits(const char*, const char**)")
312  ;
313  double GetTargetLinearUnits( const char *pszTargetKey,
314  const char ** ppszRetName = nullptr ) const;
316  double GetTargetLinearUnits( const char *pszTargetKey, std::nullptr_t ) const
317  { return GetTargetLinearUnits( pszTargetKey, static_cast<const char**>(nullptr) ); }
320  OGRErr SetAngularUnits( const char *pszName, double dfInRadians );
321  double GetAngularUnits( char ** ) const
323  CPL_WARN_DEPRECATED("Use GetAngularUnits(const char**) instead")
325  ;
326  double GetAngularUnits( const char ** = nullptr ) const;
328  double GetAngularUnits( std::nullptr_t ) const
329  { return GetAngularUnits( static_cast<const char**>(nullptr) ); }
332  double GetPrimeMeridian( char ** ) const
334  CPL_WARN_DEPRECATED("Use GetPrimeMeridian(const char**) instead")
336  ;
337  double GetPrimeMeridian( const char ** = nullptr ) const;
339  double GetPrimeMeridian( std::nullptr_t ) const
340  { return GetPrimeMeridian( static_cast<const char**>(nullptr) ); }
343  bool IsEmpty() const;
344  int IsGeographic() const;
345  int IsDerivedGeographic() const;
346  int IsProjected() const;
347  int IsGeocentric() const;
348  int IsLocal() const;
349  int IsVertical() const;
350  int IsCompound() const;
351  int IsSameGeogCS( const OGRSpatialReference * ) const;
352  int IsSameGeogCS( const OGRSpatialReference *,
353  const char* const * papszOptions ) const;
354  int IsSameVertCS( const OGRSpatialReference * ) const;
355  int IsSame( const OGRSpatialReference * ) const;
356  int IsSame( const OGRSpatialReference *,
357  const char* const * papszOptions ) const;
358 
359  void Clear();
360  OGRErr SetLocalCS( const char * );
361  OGRErr SetProjCS( const char * );
362  OGRErr SetProjection( const char * );
363  OGRErr SetGeocCS( const char * pszGeocName );
364  OGRErr SetGeogCS( const char * pszGeogName,
365  const char * pszDatumName,
366  const char * pszEllipsoidName,
367  double dfSemiMajor, double dfInvFlattening,
368  const char * pszPMName = nullptr,
369  double dfPMOffset = 0.0,
370  const char * pszUnits = nullptr,
371  double dfConvertToRadians = 0.0 );
372  OGRErr SetWellKnownGeogCS( const char * );
373  OGRErr CopyGeogCSFrom( const OGRSpatialReference * poSrcSRS );
374  OGRErr SetVertCS( const char *pszVertCSName,
375  const char *pszVertDatumName,
376  int nVertDatumClass = 2005 );
377  OGRErr SetCompoundCS( const char *pszName,
378  const OGRSpatialReference *poHorizSRS,
379  const OGRSpatialReference *poVertSRS );
380 
381  // cppcheck-suppress functionStatic
382  OGRErr PromoteTo3D( const char* pszName );
383 
384  OGRErr SetFromUserInput( const char * );
385 
386  OGRErr SetTOWGS84( double, double, double,
387  double = 0.0, double = 0.0, double = 0.0,
388  double = 0.0 );
389  OGRErr GetTOWGS84( double *padfCoef, int nCoeff = 7 ) const;
390  OGRErr AddGuessedTOWGS84();
391 
392  double GetSemiMajor( OGRErr * = nullptr ) const;
393  double GetSemiMinor( OGRErr * = nullptr ) const;
394  double GetInvFlattening( OGRErr * = nullptr ) const;
395  double GetEccentricity() const;
396  double GetSquaredEccentricity() const;
397 
398  OGRErr SetAuthority( const char * pszTargetKey,
399  const char * pszAuthority,
400  int nCode );
401 
402  OGRErr AutoIdentifyEPSG();
403  OGRSpatialReferenceH* FindMatches( char** papszOptions,
404  int* pnEntries,
405  int** ppanMatchConfidence ) const;
406 
407  int GetEPSGGeogCS() const;
408 
409  const char *GetAuthorityCode( const char * pszTargetKey ) const;
410  const char *GetAuthorityName( const char * pszTargetKey ) const;
411 
412  bool GetAreaOfUse( double* pdfWestLongitudeDeg,
413  double* pdfSouthLatitudeDeg,
414  double* pdfEastLongitudeDeg,
415  double* pdfNorthLatitudeDeg,
416  const char **ppszAreaName ) const;
417 
418  const char *GetExtension( const char *pszTargetKey,
419  const char *pszName,
420  const char *pszDefault = nullptr ) const;
421  OGRErr SetExtension( const char *pszTargetKey,
422  const char *pszName,
423  const char *pszValue );
424 
425  int FindProjParm( const char *pszParameter,
426  const OGR_SRSNode *poPROJCS=nullptr ) const;
427  OGRErr SetProjParm( const char *, double );
428  double GetProjParm( const char *, double =0.0, OGRErr* = nullptr ) const;
429 
430  OGRErr SetNormProjParm( const char *, double );
431  double GetNormProjParm( const char *, double=0.0, OGRErr* =nullptr)const;
432 
433  static int IsAngularParameter( const char * );
434  static int IsLongitudeParameter( const char * );
435  static int IsLinearParameter( const char * );
436 
438  OGRErr SetACEA( double dfStdP1, double dfStdP2,
439  double dfCenterLat, double dfCenterLong,
440  double dfFalseEasting, double dfFalseNorthing );
441 
443  OGRErr SetAE( double dfCenterLat, double dfCenterLong,
444  double dfFalseEasting, double dfFalseNorthing );
445 
447  OGRErr SetBonne( double dfStdP1, double dfCentralMeridian,
448  double dfFalseEasting, double dfFalseNorthing );
449 
451  OGRErr SetCEA( double dfStdP1, double dfCentralMeridian,
452  double dfFalseEasting, double dfFalseNorthing );
453 
455  OGRErr SetCS( double dfCenterLat, double dfCenterLong,
456  double dfFalseEasting, double dfFalseNorthing );
457 
459  OGRErr SetEC( double dfStdP1, double dfStdP2,
460  double dfCenterLat, double dfCenterLong,
461  double dfFalseEasting, double dfFalseNorthing );
462 
464  OGRErr SetEckert( int nVariation, double dfCentralMeridian,
465  double dfFalseEasting, double dfFalseNorthing );
466 
468  OGRErr SetEckertIV( double dfCentralMeridian,
469  double dfFalseEasting, double dfFalseNorthing );
470 
472  OGRErr SetEckertVI( double dfCentralMeridian,
473  double dfFalseEasting, double dfFalseNorthing );
474 
476  OGRErr SetEquirectangular(double dfCenterLat, double dfCenterLong,
477  double dfFalseEasting, double dfFalseNorthing );
479  OGRErr SetEquirectangular2( double dfCenterLat, double dfCenterLong,
480  double dfPseudoStdParallel1,
481  double dfFalseEasting, double dfFalseNorthing );
482 
484  OGRErr SetGEOS( double dfCentralMeridian, double dfSatelliteHeight,
485  double dfFalseEasting, double dfFalseNorthing );
486 
488  OGRErr SetGH( double dfCentralMeridian,
489  double dfFalseEasting, double dfFalseNorthing );
490 
492  OGRErr SetIGH();
493 
495  OGRErr SetGS( double dfCentralMeridian,
496  double dfFalseEasting, double dfFalseNorthing );
497 
499  OGRErr SetGaussSchreiberTMercator(double dfCenterLat, double dfCenterLong,
500  double dfScale,
501  double dfFalseEasting, double dfFalseNorthing );
502 
504  OGRErr SetGnomonic(double dfCenterLat, double dfCenterLong,
505  double dfFalseEasting, double dfFalseNorthing );
506 
508  OGRErr SetHOM( double dfCenterLat, double dfCenterLong,
509  double dfAzimuth, double dfRectToSkew,
510  double dfScale,
511  double dfFalseEasting, double dfFalseNorthing );
512 
514  OGRErr SetHOM2PNO( double dfCenterLat,
515  double dfLat1, double dfLong1,
516  double dfLat2, double dfLong2,
517  double dfScale,
518  double dfFalseEasting, double dfFalseNorthing );
519 
521  OGRErr SetHOMAC( double dfCenterLat, double dfCenterLong,
522  double dfAzimuth, double dfRectToSkew,
523  double dfScale,
524  double dfFalseEasting, double dfFalseNorthing );
525 
527  OGRErr SetLOM( double dfCenterLat, double dfCenterLong,
528  double dfAzimuth,
529  double dfScale,
530  double dfFalseEasting, double dfFalseNorthing );
531 
533  OGRErr SetIWMPolyconic( double dfLat1, double dfLat2,
534  double dfCenterLong,
535  double dfFalseEasting,
536  double dfFalseNorthing );
537 
539  OGRErr SetKrovak( double dfCenterLat, double dfCenterLong,
540  double dfAzimuth, double dfPseudoStdParallelLat,
541  double dfScale,
542  double dfFalseEasting, double dfFalseNorthing );
543 
545  OGRErr SetLAEA( double dfCenterLat, double dfCenterLong,
546  double dfFalseEasting, double dfFalseNorthing );
547 
549  OGRErr SetLCC( double dfStdP1, double dfStdP2,
550  double dfCenterLat, double dfCenterLong,
551  double dfFalseEasting, double dfFalseNorthing );
552 
554  OGRErr SetLCC1SP( double dfCenterLat, double dfCenterLong,
555  double dfScale,
556  double dfFalseEasting, double dfFalseNorthing );
557 
559  OGRErr SetLCCB( double dfStdP1, double dfStdP2,
560  double dfCenterLat, double dfCenterLong,
561  double dfFalseEasting, double dfFalseNorthing );
562 
564  OGRErr SetMC( double dfCenterLat, double dfCenterLong,
565  double dfFalseEasting, double dfFalseNorthing );
566 
568  OGRErr SetMercator( double dfCenterLat, double dfCenterLong,
569  double dfScale,
570  double dfFalseEasting, double dfFalseNorthing );
571 
573  OGRErr SetMercator2SP( double dfStdP1,
574  double dfCenterLat, double dfCenterLong,
575  double dfFalseEasting, double dfFalseNorthing );
576 
578  OGRErr SetMollweide( double dfCentralMeridian,
579  double dfFalseEasting, double dfFalseNorthing );
580 
582  OGRErr SetNZMG( double dfCenterLat, double dfCenterLong,
583  double dfFalseEasting, double dfFalseNorthing );
584 
586  OGRErr SetOS( double dfOriginLat, double dfCMeridian,
587  double dfScale,
588  double dfFalseEasting,double dfFalseNorthing);
589 
591  OGRErr SetOrthographic( double dfCenterLat, double dfCenterLong,
592  double dfFalseEasting,double dfFalseNorthing);
593 
595  OGRErr SetPolyconic( double dfCenterLat, double dfCenterLong,
596  double dfFalseEasting, double dfFalseNorthing );
597 
599  OGRErr SetPS( double dfCenterLat, double dfCenterLong,
600  double dfScale,
601  double dfFalseEasting, double dfFalseNorthing);
602 
604  OGRErr SetRobinson( double dfCenterLong,
605  double dfFalseEasting, double dfFalseNorthing );
606 
608  OGRErr SetSinusoidal( double dfCenterLong,
609  double dfFalseEasting, double dfFalseNorthing );
610 
612  OGRErr SetStereographic( double dfCenterLat, double dfCenterLong,
613  double dfScale,
614  double dfFalseEasting,double dfFalseNorthing);
615 
617  OGRErr SetSOC( double dfLatitudeOfOrigin, double dfCentralMeridian,
618  double dfFalseEasting, double dfFalseNorthing );
619 
621  OGRErr SetTM( double dfCenterLat, double dfCenterLong,
622  double dfScale,
623  double dfFalseEasting, double dfFalseNorthing );
624 
626  OGRErr SetTMVariant( const char *pszVariantName,
627  double dfCenterLat, double dfCenterLong,
628  double dfScale,
629  double dfFalseEasting, double dfFalseNorthing );
630 
632  OGRErr SetTMG( double dfCenterLat, double dfCenterLong,
633  double dfFalseEasting, double dfFalseNorthing );
634 
636  OGRErr SetTMSO( double dfCenterLat, double dfCenterLong,
637  double dfScale,
638  double dfFalseEasting, double dfFalseNorthing );
639 
641  OGRErr SetTPED( double dfLat1, double dfLong1,
642  double dfLat2, double dfLong2,
643  double dfFalseEasting, double dfFalseNorthing );
644 
646  OGRErr SetVDG( double dfCenterLong,
647  double dfFalseEasting, double dfFalseNorthing );
648 
650  OGRErr SetUTM( int nZone, int bNorth = TRUE );
651  int GetUTMZone( int *pbNorth = nullptr ) const;
652 
654  OGRErr SetWagner( int nVariation, double dfCenterLat,
655  double dfFalseEasting, double dfFalseNorthing );
656 
658  OGRErr SetQSC(double dfCenterLat, double dfCenterLong);
659 
661  OGRErr SetSCH( double dfPegLat, double dfPegLong,
662  double dfPegHeading, double dfPegHgt);
663 
665  OGRErr SetVerticalPerspective( double dfTopoOriginLat,
666  double dfTopoOriginLon,
667  double dfTopoOriginHeight,
668  double dfViewPointHeight,
669  double dfFalseEasting,
670  double dfFalseNorthing);
671 
673  OGRErr SetDerivedGeogCRSWithPoleRotationGRIBConvention(
674  const char* pszCRSName,
675  double dfSouthPoleLat,
676  double dfSouthPoleLon,
677  double dfAxisRotation );
678 
680  OGRErr SetStatePlane( int nZone, int bNAD83 = TRUE,
681  const char *pszOverrideUnitName = nullptr,
682  double dfOverrideUnit = 0.0 );
683 
685  OGRErr ImportFromESRIStatePlaneWKT(
686  int nCode, const char* pszDatumName, const char* pszUnitsName,
687  int nPCSCode, const char* pszCRSName = nullptr );
688 
690  OGRErr ImportFromESRIWisconsinWKT(
691  const char* pszPrjName, double dfCentralMeridian, double dfLatOfOrigin,
692  const char* pszUnitsName, const char* pszCRSName = nullptr );
693 
695  void UpdateCoordinateSystemFromGeogCRS();
698  static OGRSpatialReference* GetWGS84SRS();
699 
704  { return reinterpret_cast<OGRSpatialReferenceH>(poSRS); }
705 
710  { return reinterpret_cast<OGRSpatialReference*>(hSRS); }
711 
712 };
713 
714 /************************************************************************/
715 /* OGRCoordinateTransformation */
716 /* */
717 /* This is really just used as a base class for a private */
718 /* implementation. */
719 /************************************************************************/
720 
731 {
732 public:
733  virtual ~OGRCoordinateTransformation() {}
734 
735  static void DestroyCT(OGRCoordinateTransformation* poCT);
736 
737  // From CT_CoordinateTransformation
738 
741 
744 
746  virtual bool GetEmitErrors() const { return false; }
747 
749  virtual void SetEmitErrors(bool /*bEmitErrors*/) {}
750 
751  // From CT_MathTransform
752 
768  int Transform( int nCount,
769  double *x, double *y, double *z = nullptr,
770  int *pabSuccess = nullptr );
771 
788  virtual int Transform( int nCount,
789  double *x, double *y,
790  double *z, double *t,
791  int *pabSuccess ) = 0;
792 
797  { return reinterpret_cast<OGRCoordinateTransformationH>(poCT); }
798 
803  { return reinterpret_cast<OGRCoordinateTransformation*>(hCT); }
804 
808  virtual OGRCoordinateTransformation* Clone() const = 0;
809 };
810 
813  const OGRSpatialReference *poTarget );
814 
815 
823 {
825 private:
826  friend class OGRProjCT;
827  struct Private;
828  std::unique_ptr<Private> d;
831 public:
836 
837  bool SetAreaOfInterest(double dfWestLongitudeDeg,
838  double dfSouthLatitudeDeg,
839  double dfEastLongitudeDeg,
840  double dfNorthLatitudeDeg);
841 
842  bool SetCoordinateOperation(const char* pszCT, bool bReverseCT);
844  void SetSourceCenterLong(double dfCenterLong);
845  void SetTargetCenterLong(double dfCenterLong);
847 };
848 
849 
852  const OGRSpatialReference *poTarget,
853  const OGRCoordinateTransformationOptions& options );
854 
855 #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:508
OGRCoordinateTransformationOptions
Context for coordinate transformation.
Definition: ogr_spatialref.h:823
OGRCoordinateTransformation::GetTargetCS
virtual OGRSpatialReference * GetTargetCS()=0
Fetch internal target coordinate system.
OGRSpatialReference
This class represents an OpenGIS Spatial Reference System, and contains methods for converting betwee...
Definition: ogr_spatialref.h:158
OGRCoordinateTransformation::ToHandle
static OGRCoordinateTransformationH ToHandle(OGRCoordinateTransformation *poCT)
Convert a OGRCoordinateTransformation* to a OGRCoordinateTransformationH.
Definition: ogr_spatialref.h:796
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:709
CPLString
Convenient string class based on std::string.
Definition: cpl_string.h:333
OGRSpatialReference::ToHandle
static OGRSpatialReferenceH ToHandle(OGRSpatialReference *poSRS)
Convert a OGRSpatialReference* to a OGRSpatialReferenceH.
Definition: ogr_spatialref.h:703
OSRAxisMappingStrategy
OSRAxisMappingStrategy
Data axis to CRS axis mapping strategy.
Definition: ogr_srs_api.h:659
OGR_SRSNode::GetValue
const char * GetValue() const
Definition: ogr_spatialref.h:102
OGRCoordinateTransformation::Transform
int Transform(int nCount, double *x, double *y, double *z=nullptr, int *pabSuccess=nullptr)
Transform points from source to destination space.
OGRSpatialReferenceH
void * OGRSpatialReferenceH
Opaque type for a spatial reference system.
Definition: ogr_api.h:75
OGR_SRSNode::Listener
Listener that is notified of modification to nodes.
Definition: ogr_spatialref.h:71
OGRCoordinateTransformationH
void * OGRCoordinateTransformationH
Opaque type for a coordinate transformation object.
Definition: ogr_api.h:77
OGRCoordinateTransformation::SetEmitErrors
virtual void SetEmitErrors(bool)
Set if the transformer must emit CPLError.
Definition: ogr_spatialref.h:749
OGRCoordinateTransformation::Transform
virtual int Transform(int nCount, double *x, double *y, double *z, double *t, int *pabSuccess)=0
Transform points from source to destination space.
OGR_SRSNode::Listener::notifyChange
virtual void notifyChange(OGR_SRSNode *)=0
Method triggered when a node is modified.
ogr_srs_api.h
cpl_string.h
OGRCoordinateTransformation::Clone
virtual OGRCoordinateTransformation * Clone() const =0
Clone.
OGRAxisOrientation
OGRAxisOrientation
Axis orientations (corresponds to CS_AxisOrientationEnum).
Definition: ogr_srs_api.h:48
OGRCoordinateTransformation::GetSourceCS
virtual OGRSpatialReference * GetSourceCS()=0
Fetch internal source coordinate system.
OGRCoordinateTransformation
Interface for transforming between coordinate systems.
Definition: ogr_spatialref.h:731
OGRCoordinateTransformation::FromHandle
static OGRCoordinateTransformation * FromHandle(OGRCoordinateTransformationH hCT)
Convert a OGRCoordinateTransformationH to a OGRCoordinateTransformation*.
Definition: ogr_spatialref.h:802
OGRErr
int OGRErr
Type for a OGR error.
Definition: ogr_core.h:318
OGRCoordinateTransformation::GetEmitErrors
virtual bool GetEmitErrors() const
Whether the transformer will emit CPLError.
Definition: ogr_spatialref.h:746
USGS_ANGLE_PACKEDDMS
#define USGS_ANGLE_PACKEDDMS
Angle is in packed degree minute second.
Definition: ogr_spatialref.h:223
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:67
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:1003