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
132 CPL_DISALLOW_COPY_ASSIGN(OGR_SRSNode)
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 OGRSpatialReference(const OGRSpatialReference&);
174 explicit OGRSpatialReference(const char * = nullptr);
175
176 virtual ~OGRSpatialReference();
177
178 static void DestroySpatialReference(OGRSpatialReference* poSRS);
179
180 OGRSpatialReference &operator=(const OGRSpatialReference&);
181
182 int Reference();
183 int Dereference();
184 int GetReferenceCount() const;
185 void Release();
186
187 const char* GetName() const;
188
189 OGRSpatialReference *Clone() const;
190 OGRSpatialReference *CloneGeogCS() const;
191
192 void dumpReadable();
193 OGRErr exportToWkt( char ** ) const;
194 OGRErr exportToWkt( char ** ppszWKT, const char* const* papszOptions ) const;
195 OGRErr exportToPrettyWkt( char **, int = FALSE) const;
196 // cppcheck-suppress functionStatic
197 OGRErr exportToPROJJSON( char **, const char* const* papszOptions ) const;
198 OGRErr exportToProj4( char ** ) const;
199 OGRErr exportToPCI( char **, char **, double ** ) const;
200 OGRErr exportToUSGS( long *, long *, double **, long * ) const;
201 OGRErr exportToXML( char **, const char * = nullptr ) const;
202 OGRErr exportToPanorama( long *, long *, long *, long *,
203 double * ) const;
204 OGRErr exportToERM( char *pszProj, char *pszDatum, char *pszUnits );
205 OGRErr exportToMICoordSys( char ** ) const;
206
207
208 OGRErr importFromWkt( char ** )
210 CPL_WARN_DEPRECATED("Use importFromWkt(const char**) or importFromWkt(const char*)")
212 ;
213
214 OGRErr importFromWkt( const char ** );
215 OGRErr importFromWkt( const char* );
216 OGRErr importFromProj4( const char * );
217 OGRErr importFromEPSG( int );
218 OGRErr importFromEPSGA( int );
219 OGRErr importFromESRI( char ** );
220 OGRErr importFromPCI( const char *, const char * = nullptr,
221 double * = nullptr );
222
223 #define USGS_ANGLE_DECIMALDEGREES 0
224 #define USGS_ANGLE_PACKEDDMS TRUE
225 #define USGS_ANGLE_RADIANS 2
226 OGRErr importFromUSGS( long iProjSys, long iZone,
227 double *padfPrjParams, long iDatum,
228 int nUSGSAngleFormat = USGS_ANGLE_PACKEDDMS );
229 OGRErr importFromPanorama( long, long, long, double* );
230 OGRErr importVertCSFromPanorama( int );
231 OGRErr importFromOzi( const char * const* papszLines );
232 OGRErr importFromWMSAUTO( const char *pszAutoDef );
233 OGRErr importFromXML( const char * );
234 OGRErr importFromDict( const char *pszDict, const char *pszCode );
235 OGRErr importFromURN( const char * );
236 OGRErr importFromCRSURL( const char * );
237 OGRErr importFromERM( const char *pszProj, const char *pszDatum,
238 const char *pszUnits );
239 OGRErr importFromUrl( const char * );
240 OGRErr importFromMICoordSys( const char * );
241
242 OGRErr morphToESRI();
243 OGRErr morphFromESRI();
244
245 OGRSpatialReference* convertToOtherProjection(
246 const char* pszTargetProjection,
247 const char* const* papszOptions = nullptr ) const;
248
249 OGRErr Validate() const;
250 OGRErr StripVertical();
251
252 bool StripTOWGS84IfKnownDatumAndAllowed();
253 bool StripTOWGS84IfKnownDatum();
254
255 int EPSGTreatsAsLatLong() const;
256 int EPSGTreatsAsNorthingEasting() const;
257 int GetAxesCount() const;
258 const char *GetAxis( const char *pszTargetKey, int iAxis,
259 OGRAxisOrientation *peOrientation ) const;
260 OGRErr SetAxes( const char *pszTargetKey,
261 const char *pszXAxisName,
262 OGRAxisOrientation eXAxisOrientation,
263 const char *pszYAxisName,
264 OGRAxisOrientation eYAxisOrientation );
265
266 OSRAxisMappingStrategy GetAxisMappingStrategy() const;
267 void SetAxisMappingStrategy(OSRAxisMappingStrategy);
268 const std::vector<int>& GetDataAxisToSRSAxisMapping() const;
269 OGRErr SetDataAxisToSRSAxisMapping(const std::vector<int>& mapping);
270
271 // Machinery for accessing parse nodes
272
274 OGR_SRSNode *GetRoot();
276 const OGR_SRSNode *GetRoot() const;
277 void SetRoot( OGR_SRSNode * );
278
279 OGR_SRSNode *GetAttrNode(const char *);
280 const OGR_SRSNode *GetAttrNode(const char *) const;
281 const char *GetAttrValue(const char *, int = 0) const;
282
283 OGRErr SetNode( const char *, const char * );
284 OGRErr SetNode( const char *, double );
285
286 OGRErr SetLinearUnitsAndUpdateParameters( const char *pszName,
287 double dfInMeters,
288 const char *pszUnitAuthority = nullptr,
289 const char *pszUnitCode = nullptr );
290 OGRErr SetLinearUnits( const char *pszName, double dfInMeters );
291 OGRErr SetTargetLinearUnits( const char *pszTargetKey,
292 const char *pszName,
293 double dfInMeters,
294 const char *pszUnitAuthority = nullptr,
295 const char *pszUnitCode = nullptr);
296
297 double GetLinearUnits( char ** ) const
299 CPL_WARN_DEPRECATED("Use GetLinearUnits(const char**) instead")
301 ;
302 double GetLinearUnits( const char ** = nullptr ) const;
304 double GetLinearUnits( std::nullptr_t ) const
305 { return GetLinearUnits( static_cast<const char**>(nullptr) ); }
308 double GetTargetLinearUnits( const char *pszTargetKey,
309 char ** ppszRetName ) const
311 CPL_WARN_DEPRECATED("Use GetTargetLinearUnits(const char*, const char**)")
313 ;
314 double GetTargetLinearUnits( const char *pszTargetKey,
315 const char ** ppszRetName = nullptr ) const;
317 double GetTargetLinearUnits( const char *pszTargetKey, std::nullptr_t ) const
318 { return GetTargetLinearUnits( pszTargetKey, static_cast<const char**>(nullptr) ); }
321 OGRErr SetAngularUnits( const char *pszName, double dfInRadians );
322 double GetAngularUnits( char ** ) const
324 CPL_WARN_DEPRECATED("Use GetAngularUnits(const char**) instead")
326 ;
327 double GetAngularUnits( const char ** = nullptr ) const;
329 double GetAngularUnits( std::nullptr_t ) const
330 { return GetAngularUnits( static_cast<const char**>(nullptr) ); }
333 double GetPrimeMeridian( char ** ) const
335 CPL_WARN_DEPRECATED("Use GetPrimeMeridian(const char**) instead")
337 ;
338 double GetPrimeMeridian( const char ** = nullptr ) const;
340 double GetPrimeMeridian( std::nullptr_t ) const
341 { return GetPrimeMeridian( static_cast<const char**>(nullptr) ); }
344 bool IsEmpty() const;
345 int IsGeographic() const;
346 int IsDerivedGeographic() const;
347 int IsProjected() const;
348 int IsGeocentric() const;
349 int IsLocal() const;
350 int IsVertical() const;
351 int IsCompound() const;
352 int IsSameGeogCS( const OGRSpatialReference * ) const;
353 int IsSameGeogCS( const OGRSpatialReference *,
354 const char* const * papszOptions ) const;
355 int IsSameVertCS( const OGRSpatialReference * ) const;
356 int IsSame( const OGRSpatialReference * ) const;
357 int IsSame( const OGRSpatialReference *,
358 const char* const * papszOptions ) const;
359
360 void Clear();
361 OGRErr SetLocalCS( const char * );
362 OGRErr SetProjCS( const char * );
363 OGRErr SetProjection( const char * );
364 OGRErr SetGeocCS( const char * pszGeocName );
365 OGRErr SetGeogCS( const char * pszGeogName,
366 const char * pszDatumName,
367 const char * pszEllipsoidName,
368 double dfSemiMajor, double dfInvFlattening,
369 const char * pszPMName = nullptr,
370 double dfPMOffset = 0.0,
371 const char * pszUnits = nullptr,
372 double dfConvertToRadians = 0.0 );
373 OGRErr SetWellKnownGeogCS( const char * );
374 OGRErr CopyGeogCSFrom( const OGRSpatialReference * poSrcSRS );
375 OGRErr SetVertCS( const char *pszVertCSName,
376 const char *pszVertDatumName,
377 int nVertDatumClass = 2005 );
378 OGRErr SetCompoundCS( const char *pszName,
379 const OGRSpatialReference *poHorizSRS,
380 const OGRSpatialReference *poVertSRS );
381
382 // cppcheck-suppress functionStatic
383 OGRErr PromoteTo3D( const char* pszName );
384 // cppcheck-suppress functionStatic
385 OGRErr DemoteTo2D( const char* pszName );
386
387 OGRErr SetFromUserInput( const char * );
388
389 OGRErr SetTOWGS84( double, double, double,
390 double = 0.0, double = 0.0, double = 0.0,
391 double = 0.0 );
392 OGRErr GetTOWGS84( double *padfCoef, int nCoeff = 7 ) const;
393 OGRErr AddGuessedTOWGS84();
394
395 double GetSemiMajor( OGRErr * = nullptr ) const;
396 double GetSemiMinor( OGRErr * = nullptr ) const;
397 double GetInvFlattening( OGRErr * = nullptr ) const;
398 double GetEccentricity() const;
399 double GetSquaredEccentricity() const;
400
401 OGRErr SetAuthority( const char * pszTargetKey,
402 const char * pszAuthority,
403 int nCode );
404
405 OGRErr AutoIdentifyEPSG();
406 OGRSpatialReferenceH* FindMatches( char** papszOptions,
407 int* pnEntries,
408 int** ppanMatchConfidence ) const;
409
410 int GetEPSGGeogCS() const;
411
412 const char *GetAuthorityCode( const char * pszTargetKey ) const;
413 const char *GetAuthorityName( const char * pszTargetKey ) const;
414
415 bool GetAreaOfUse( double* pdfWestLongitudeDeg,
416 double* pdfSouthLatitudeDeg,
417 double* pdfEastLongitudeDeg,
418 double* pdfNorthLatitudeDeg,
419 const char **ppszAreaName ) const;
420
421 const char *GetExtension( const char *pszTargetKey,
422 const char *pszName,
423 const char *pszDefault = nullptr ) const;
424 OGRErr SetExtension( const char *pszTargetKey,
425 const char *pszName,
426 const char *pszValue );
427
428 int FindProjParm( const char *pszParameter,
429 const OGR_SRSNode *poPROJCS=nullptr ) const;
430 OGRErr SetProjParm( const char *, double );
431 double GetProjParm( const char *, double =0.0, OGRErr* = nullptr ) const;
432
433 OGRErr SetNormProjParm( const char *, double );
434 double GetNormProjParm( const char *, double=0.0, OGRErr* =nullptr)const;
435
436 static int IsAngularParameter( const char * );
437 static int IsLongitudeParameter( const char * );
438 static int IsLinearParameter( const char * );
439
441 OGRErr SetACEA( double dfStdP1, double dfStdP2,
442 double dfCenterLat, double dfCenterLong,
443 double dfFalseEasting, double dfFalseNorthing );
444
446 OGRErr SetAE( double dfCenterLat, double dfCenterLong,
447 double dfFalseEasting, double dfFalseNorthing );
448
450 OGRErr SetBonne( double dfStdP1, double dfCentralMeridian,
451 double dfFalseEasting, double dfFalseNorthing );
452
454 OGRErr SetCEA( double dfStdP1, double dfCentralMeridian,
455 double dfFalseEasting, double dfFalseNorthing );
456
458 OGRErr SetCS( double dfCenterLat, double dfCenterLong,
459 double dfFalseEasting, double dfFalseNorthing );
460
462 OGRErr SetEC( double dfStdP1, double dfStdP2,
463 double dfCenterLat, double dfCenterLong,
464 double dfFalseEasting, double dfFalseNorthing );
465
467 OGRErr SetEckert( int nVariation, double dfCentralMeridian,
468 double dfFalseEasting, double dfFalseNorthing );
469
471 OGRErr SetEckertIV( double dfCentralMeridian,
472 double dfFalseEasting, double dfFalseNorthing );
473
475 OGRErr SetEckertVI( double dfCentralMeridian,
476 double dfFalseEasting, double dfFalseNorthing );
477
479 OGRErr SetEquirectangular(double dfCenterLat, double dfCenterLong,
480 double dfFalseEasting, double dfFalseNorthing );
482 OGRErr SetEquirectangular2( double dfCenterLat, double dfCenterLong,
483 double dfPseudoStdParallel1,
484 double dfFalseEasting, double dfFalseNorthing );
485
487 OGRErr SetGEOS( double dfCentralMeridian, double dfSatelliteHeight,
488 double dfFalseEasting, double dfFalseNorthing );
489
491 OGRErr SetGH( double dfCentralMeridian,
492 double dfFalseEasting, double dfFalseNorthing );
493
495 OGRErr SetIGH();
496
498 OGRErr SetGS( double dfCentralMeridian,
499 double dfFalseEasting, double dfFalseNorthing );
500
502 OGRErr SetGaussSchreiberTMercator(double dfCenterLat, double dfCenterLong,
503 double dfScale,
504 double dfFalseEasting, double dfFalseNorthing );
505
507 OGRErr SetGnomonic(double dfCenterLat, double dfCenterLong,
508 double dfFalseEasting, double dfFalseNorthing );
509
511 OGRErr SetHOM( double dfCenterLat, double dfCenterLong,
512 double dfAzimuth, double dfRectToSkew,
513 double dfScale,
514 double dfFalseEasting, double dfFalseNorthing );
515
517 OGRErr SetHOM2PNO( double dfCenterLat,
518 double dfLat1, double dfLong1,
519 double dfLat2, double dfLong2,
520 double dfScale,
521 double dfFalseEasting, double dfFalseNorthing );
522
524 OGRErr SetHOMAC( double dfCenterLat, double dfCenterLong,
525 double dfAzimuth, double dfRectToSkew,
526 double dfScale,
527 double dfFalseEasting, double dfFalseNorthing );
528
530 OGRErr SetLOM( double dfCenterLat, double dfCenterLong,
531 double dfAzimuth,
532 double dfScale,
533 double dfFalseEasting, double dfFalseNorthing );
534
536 OGRErr SetIWMPolyconic( double dfLat1, double dfLat2,
537 double dfCenterLong,
538 double dfFalseEasting,
539 double dfFalseNorthing );
540
542 OGRErr SetKrovak( double dfCenterLat, double dfCenterLong,
543 double dfAzimuth, double dfPseudoStdParallelLat,
544 double dfScale,
545 double dfFalseEasting, double dfFalseNorthing );
546
548 OGRErr SetLAEA( double dfCenterLat, double dfCenterLong,
549 double dfFalseEasting, double dfFalseNorthing );
550
552 OGRErr SetLCC( double dfStdP1, double dfStdP2,
553 double dfCenterLat, double dfCenterLong,
554 double dfFalseEasting, double dfFalseNorthing );
555
557 OGRErr SetLCC1SP( double dfCenterLat, double dfCenterLong,
558 double dfScale,
559 double dfFalseEasting, double dfFalseNorthing );
560
562 OGRErr SetLCCB( double dfStdP1, double dfStdP2,
563 double dfCenterLat, double dfCenterLong,
564 double dfFalseEasting, double dfFalseNorthing );
565
567 OGRErr SetMC( double dfCenterLat, double dfCenterLong,
568 double dfFalseEasting, double dfFalseNorthing );
569
571 OGRErr SetMercator( double dfCenterLat, double dfCenterLong,
572 double dfScale,
573 double dfFalseEasting, double dfFalseNorthing );
574
576 OGRErr SetMercator2SP( double dfStdP1,
577 double dfCenterLat, double dfCenterLong,
578 double dfFalseEasting, double dfFalseNorthing );
579
581 OGRErr SetMollweide( double dfCentralMeridian,
582 double dfFalseEasting, double dfFalseNorthing );
583
585 OGRErr SetNZMG( double dfCenterLat, double dfCenterLong,
586 double dfFalseEasting, double dfFalseNorthing );
587
589 OGRErr SetOS( double dfOriginLat, double dfCMeridian,
590 double dfScale,
591 double dfFalseEasting,double dfFalseNorthing);
592
594 OGRErr SetOrthographic( double dfCenterLat, double dfCenterLong,
595 double dfFalseEasting,double dfFalseNorthing);
596
598 OGRErr SetPolyconic( double dfCenterLat, double dfCenterLong,
599 double dfFalseEasting, double dfFalseNorthing );
600
602 OGRErr SetPS( double dfCenterLat, double dfCenterLong,
603 double dfScale,
604 double dfFalseEasting, double dfFalseNorthing);
605
607 OGRErr SetRobinson( double dfCenterLong,
608 double dfFalseEasting, double dfFalseNorthing );
609
611 OGRErr SetSinusoidal( double dfCenterLong,
612 double dfFalseEasting, double dfFalseNorthing );
613
615 OGRErr SetStereographic( double dfCenterLat, double dfCenterLong,
616 double dfScale,
617 double dfFalseEasting,double dfFalseNorthing);
618
620 OGRErr SetSOC( double dfLatitudeOfOrigin, double dfCentralMeridian,
621 double dfFalseEasting, double dfFalseNorthing );
622
624 OGRErr SetTM( double dfCenterLat, double dfCenterLong,
625 double dfScale,
626 double dfFalseEasting, double dfFalseNorthing );
627
629 OGRErr SetTMVariant( const char *pszVariantName,
630 double dfCenterLat, double dfCenterLong,
631 double dfScale,
632 double dfFalseEasting, double dfFalseNorthing );
633
635 OGRErr SetTMG( double dfCenterLat, double dfCenterLong,
636 double dfFalseEasting, double dfFalseNorthing );
637
639 OGRErr SetTMSO( double dfCenterLat, double dfCenterLong,
640 double dfScale,
641 double dfFalseEasting, double dfFalseNorthing );
642
644 OGRErr SetTPED( double dfLat1, double dfLong1,
645 double dfLat2, double dfLong2,
646 double dfFalseEasting, double dfFalseNorthing );
647
649 OGRErr SetVDG( double dfCenterLong,
650 double dfFalseEasting, double dfFalseNorthing );
651
653 OGRErr SetUTM( int nZone, int bNorth = TRUE );
654 int GetUTMZone( int *pbNorth = nullptr ) const;
655
657 OGRErr SetWagner( int nVariation, double dfCenterLat,
658 double dfFalseEasting, double dfFalseNorthing );
659
661 OGRErr SetQSC(double dfCenterLat, double dfCenterLong);
662
664 OGRErr SetSCH( double dfPegLat, double dfPegLong,
665 double dfPegHeading, double dfPegHgt);
666
668 OGRErr SetVerticalPerspective( double dfTopoOriginLat,
669 double dfTopoOriginLon,
670 double dfTopoOriginHeight,
671 double dfViewPointHeight,
672 double dfFalseEasting,
673 double dfFalseNorthing);
674
676 OGRErr SetDerivedGeogCRSWithPoleRotationGRIBConvention(
677 const char* pszCRSName,
678 double dfSouthPoleLat,
679 double dfSouthPoleLon,
680 double dfAxisRotation );
681
683 OGRErr SetStatePlane( int nZone, int bNAD83 = TRUE,
684 const char *pszOverrideUnitName = nullptr,
685 double dfOverrideUnit = 0.0 );
686
688 OGRErr ImportFromESRIStatePlaneWKT(
689 int nCode, const char* pszDatumName, const char* pszUnitsName,
690 int nPCSCode, const char* pszCRSName = nullptr );
691
693 OGRErr ImportFromESRIWisconsinWKT(
694 const char* pszPrjName, double dfCentralMeridian, double dfLatOfOrigin,
695 const char* pszUnitsName, const char* pszCRSName = nullptr );
696
698 void UpdateCoordinateSystemFromGeogCRS();
701 static OGRSpatialReference* GetWGS84SRS();
702
706 static inline OGRSpatialReferenceH ToHandle(OGRSpatialReference* poSRS)
707 { return reinterpret_cast<OGRSpatialReferenceH>(poSRS); }
708
712 static inline OGRSpatialReference* FromHandle(OGRSpatialReferenceH hSRS)
713 { return reinterpret_cast<OGRSpatialReference*>(hSRS); }
714
715 };
716
717 /************************************************************************/
718 /* OGRCoordinateTransformation */
719 /* */
720 /* This is really just used as a base class for a private */
721 /* implementation. */
722 /************************************************************************/
723
733 class CPL_DLL OGRCoordinateTransformation
734 {
735 public:
736 virtual ~OGRCoordinateTransformation() {}
737
738 static void DestroyCT(OGRCoordinateTransformation* poCT);
739
740 // From CT_CoordinateTransformation
741
743 virtual OGRSpatialReference *GetSourceCS() = 0;
744
746 virtual OGRSpatialReference *GetTargetCS() = 0;
747
749 virtual bool GetEmitErrors() const { return false; }
750
752 virtual void SetEmitErrors(bool /*bEmitErrors*/) {}
753
754 // From CT_MathTransform
755
771 int Transform( int nCount,
772 double *x, double *y, double *z = nullptr,
773 int *pabSuccess = nullptr );
774
791 virtual int Transform( int nCount,
792 double *x, double *y,
793 double *z, double *t,
794 int *pabSuccess ) = 0;
795
813 virtual int TransformWithErrorCodes( int nCount,
814 double *x, double *y,
815 double *z, double *t,
816 int *panErrorCodes );
817
821 static inline OGRCoordinateTransformationH ToHandle(OGRCoordinateTransformation* poCT)
822 { return reinterpret_cast<OGRCoordinateTransformationH>(poCT); }
823
827 static inline OGRCoordinateTransformation* FromHandle(OGRCoordinateTransformationH hCT)
828 { return reinterpret_cast<OGRCoordinateTransformation*>(hCT); }
829
833 virtual OGRCoordinateTransformation* Clone() const = 0;
834
844 virtual OGRCoordinateTransformation* GetInverse() const = 0;
845 };
846
847 OGRCoordinateTransformation CPL_DLL *
848 OGRCreateCoordinateTransformation( const OGRSpatialReference *poSource,
849 const OGRSpatialReference *poTarget );
850
851
858 struct CPL_DLL OGRCoordinateTransformationOptions
859 {
861 private:
862 friend class OGRProjCT;
863 struct Private;
864 std::unique_ptr<Private> d;
867 public:
868 OGRCoordinateTransformationOptions();
869 OGRCoordinateTransformationOptions(const OGRCoordinateTransformationOptions&);
870 OGRCoordinateTransformationOptions& operator= (const OGRCoordinateTransformationOptions&);
871 ~OGRCoordinateTransformationOptions();
872
873 bool SetAreaOfInterest(double dfWestLongitudeDeg,
874 double dfSouthLatitudeDeg,
875 double dfEastLongitudeDeg,
876 double dfNorthLatitudeDeg);
877 bool SetDesiredAccuracy(double dfAccuracy);
878 bool SetBallparkAllowed(bool bAllowBallpark);
879
880 bool SetCoordinateOperation(const char* pszCT, bool bReverseCT);
882 void SetSourceCenterLong(double dfCenterLong);
883 void SetTargetCenterLong(double dfCenterLong);
885 };
886
887
888 OGRCoordinateTransformation CPL_DLL *
889 OGRCreateCoordinateTransformation( const OGRSpatialReference *poSource,
890 const OGRSpatialReference *poTarget,
891 const OGRCoordinateTransformationOptions& options );
892
893 #endif /* ndef OGR_SPATIALREF_H_INCLUDED */
CPLString
Convenient string class based on std::string.
Definition: cpl_string.h:333
OGRCoordinateTransformation
Interface for transforming between coordinate systems.
Definition: ogr_spatialref.h:734
OGRCoordinateTransformation::GetInverse
virtual OGRCoordinateTransformation * GetInverse() const =0
Return a coordinate transformation that performs the inverse transformation of the current one.
OGRCoordinateTransformation::SetEmitErrors
virtual void SetEmitErrors(bool)
Set if the transformer must emit CPLError.
Definition: ogr_spatialref.h:752
OGRCoordinateTransformation::Transform
int Transform(int nCount, double *x, double *y, double *z=nullptr, int *pabSuccess=nullptr)
Transform points from source to destination space.
OGRCoordinateTransformation::Clone
virtual OGRCoordinateTransformation * Clone() const =0
Clone.
OGRCoordinateTransformation::FromHandle
static OGRCoordinateTransformation * FromHandle(OGRCoordinateTransformationH hCT)
Convert a OGRCoordinateTransformationH to a OGRCoordinateTransformation*.
Definition: ogr_spatialref.h:827
OGRCoordinateTransformation::TransformWithErrorCodes
virtual int TransformWithErrorCodes(int nCount, double *x, double *y, double *z, double *t, int *panErrorCodes)
Transform points from source to destination space.
OGRCoordinateTransformation::GetEmitErrors
virtual bool GetEmitErrors() const
Whether the transformer will 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.
OGRCoordinateTransformation::GetTargetCS
virtual OGRSpatialReference * GetTargetCS()=0
Fetch internal target coordinate system.
OGRCoordinateTransformation::GetSourceCS
virtual OGRSpatialReference * GetSourceCS()=0
Fetch internal source coordinate system.
OGRCoordinateTransformation::ToHandle
static OGRCoordinateTransformationH ToHandle(OGRCoordinateTransformation *poCT)
Convert a OGRCoordinateTransformation* to a OGRCoordinateTransformationH.
Definition: ogr_spatialref.h:821
OGRSpatialReference
This class represents an OpenGIS Spatial Reference System, and contains methods for converting betwee...
Definition: ogr_spatialref.h:158
OGRSpatialReference::FromHandle
static OGRSpatialReference * FromHandle(OGRSpatialReferenceH hSRS)
Convert a OGRSpatialReferenceH to a OGRSpatialReference*.
Definition: ogr_spatialref.h:712
OGRSpatialReference::ToHandle
static OGRSpatialReferenceH ToHandle(OGRSpatialReference *poSRS)
Convert a OGRSpatialReference* to a OGRSpatialReferenceH.
Definition: ogr_spatialref.h:706
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
OGR_SRSNode::GetChildCount
int GetChildCount() const
Get number of children nodes.
Definition: ogr_spatialref.h:88
OGR_SRSNode::GetValue
const char * GetValue() const
Fetch value string for this node.
Definition: ogr_spatialref.h:102
OGR_SRSNode::IsLeafNode
int IsLeafNode() const
Return whether this is a leaf node.
Definition: ogr_spatialref.h:86
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:1007
cpl_string.h
Various convenience functions for working with strings and string lists.
OGRCoordinateTransformationH
void * OGRCoordinateTransformationH
Opaque type for a coordinate transformation object.
Definition: ogr_api.h:80
OGRSpatialReferenceH
void * OGRSpatialReferenceH
Opaque type for a spatial reference system.
Definition: ogr_api.h:78
OGRErr
int OGRErr
Type for a OGR error.
Definition: ogr_core.h:318
USGS_ANGLE_PACKEDDMS
#define USGS_ANGLE_PACKEDDMS
Angle is in packed degree minute second.
Definition: ogr_spatialref.h:224
OGRCreateCoordinateTransformation
OGRCoordinateTransformation * OGRCreateCoordinateTransformation(const OGRSpatialReference *poSource, const OGRSpatialReference *poTarget)
Create transformation object.
Definition: ogrct.cpp:743
ogr_srs_api.h
C spatial reference system services and defines.
OSRAxisMappingStrategy
OSRAxisMappingStrategy
Data axis to CRS axis mapping strategy.
Definition: ogr_srs_api.h:662
OGRAxisOrientation
OGRAxisOrientation
Axis orientations (corresponds to CS_AxisOrientationEnum).
Definition: ogr_srs_api.h:48
OGRCoordinateTransformationOptions
Context for coordinate transformation.
Definition: ogr_spatialref.h:859
OGR_SRSNode::Listener
Listener that is notified of modification to nodes.
Definition: ogr_spatialref.h:71
OGR_SRSNode::Listener::notifyChange
virtual void notifyChange(OGR_SRSNode *)=0
Method triggered when a node is modified.