GDAL

- Main Page
- Related Pages
- Classes
- Files
- Download
- Issue Tracker

- File List
- File Members

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 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:
172 OGRSpatialReference(const OGRSpatialReference&);
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 // cppcheck-suppress functionStatic
384 OGRErr DemoteTo2D( const char* pszName );
385
386 OGRErr SetFromUserInput( const char * );
387
388 OGRErr SetTOWGS84( double, double, double,
389 double = 0.0, double = 0.0, double = 0.0,
390 double = 0.0 );
391 OGRErr GetTOWGS84( double *padfCoef, int nCoeff = 7 ) const;
392 OGRErr AddGuessedTOWGS84();
393
394 double GetSemiMajor( OGRErr * = nullptr ) const;
395 double GetSemiMinor( OGRErr * = nullptr ) const;
396 double GetInvFlattening( OGRErr * = nullptr ) const;
397 double GetEccentricity() const;
398 double GetSquaredEccentricity() const;
399
400 OGRErr SetAuthority( const char * pszTargetKey,
401 const char * pszAuthority,
402 int nCode );
403
404 OGRErr AutoIdentifyEPSG();
405 OGRSpatialReferenceH* FindMatches( char** papszOptions,
406 int* pnEntries,
407 int** ppanMatchConfidence ) const;
408
409 int GetEPSGGeogCS() const;
410
411 const char *GetAuthorityCode( const char * pszTargetKey ) const;
412 const char *GetAuthorityName( const char * pszTargetKey ) const;
413
414 bool GetAreaOfUse( double* pdfWestLongitudeDeg,
415 double* pdfSouthLatitudeDeg,
416 double* pdfEastLongitudeDeg,
417 double* pdfNorthLatitudeDeg,
418 const char **ppszAreaName ) const;
419
420 const char *GetExtension( const char *pszTargetKey,
421 const char *pszName,
422 const char *pszDefault = nullptr ) const;
423 OGRErr SetExtension( const char *pszTargetKey,
424 const char *pszName,
425 const char *pszValue );
426
427 int FindProjParm( const char *pszParameter,
428 const OGR_SRSNode *poPROJCS=nullptr ) const;
429 OGRErr SetProjParm( const char *, double );
430 double GetProjParm( const char *, double =0.0, OGRErr* = nullptr ) const;
431
432 OGRErr SetNormProjParm( const char *, double );
433 double GetNormProjParm( const char *, double=0.0, OGRErr* =nullptr)const;
434
435 static int IsAngularParameter( const char * );
436 static int IsLongitudeParameter( const char * );
437 static int IsLinearParameter( const char * );
438
440 OGRErr SetACEA( double dfStdP1, double dfStdP2,
441 double dfCenterLat, double dfCenterLong,
442 double dfFalseEasting, double dfFalseNorthing );
443
445 OGRErr SetAE( double dfCenterLat, double dfCenterLong,
446 double dfFalseEasting, double dfFalseNorthing );
447
449 OGRErr SetBonne( double dfStdP1, double dfCentralMeridian,
450 double dfFalseEasting, double dfFalseNorthing );
451
453 OGRErr SetCEA( double dfStdP1, double dfCentralMeridian,
454 double dfFalseEasting, double dfFalseNorthing );
455
457 OGRErr SetCS( double dfCenterLat, double dfCenterLong,
458 double dfFalseEasting, double dfFalseNorthing );
459
461 OGRErr SetEC( double dfStdP1, double dfStdP2,
462 double dfCenterLat, double dfCenterLong,
463 double dfFalseEasting, double dfFalseNorthing );
464
466 OGRErr SetEckert( int nVariation, double dfCentralMeridian,
467 double dfFalseEasting, double dfFalseNorthing );
468
470 OGRErr SetEckertIV( double dfCentralMeridian,
471 double dfFalseEasting, double dfFalseNorthing );
472
474 OGRErr SetEckertVI( double dfCentralMeridian,
475 double dfFalseEasting, double dfFalseNorthing );
476
478 OGRErr SetEquirectangular(double dfCenterLat, double dfCenterLong,
479 double dfFalseEasting, double dfFalseNorthing );
481 OGRErr SetEquirectangular2( double dfCenterLat, double dfCenterLong,
482 double dfPseudoStdParallel1,
483 double dfFalseEasting, double dfFalseNorthing );
484
486 OGRErr SetGEOS( double dfCentralMeridian, double dfSatelliteHeight,
487 double dfFalseEasting, double dfFalseNorthing );
488
490 OGRErr SetGH( double dfCentralMeridian,
491 double dfFalseEasting, double dfFalseNorthing );
492
494 OGRErr SetIGH();
495
497 OGRErr SetGS( double dfCentralMeridian,
498 double dfFalseEasting, double dfFalseNorthing );
499
501 OGRErr SetGaussSchreiberTMercator(double dfCenterLat, double dfCenterLong,
502 double dfScale,
503 double dfFalseEasting, double dfFalseNorthing );
504
506 OGRErr SetGnomonic(double dfCenterLat, double dfCenterLong,
507 double dfFalseEasting, double dfFalseNorthing );
508
510 OGRErr SetHOM( double dfCenterLat, double dfCenterLong,
511 double dfAzimuth, double dfRectToSkew,
512 double dfScale,
513 double dfFalseEasting, double dfFalseNorthing );
514
516 OGRErr SetHOM2PNO( double dfCenterLat,
517 double dfLat1, double dfLong1,
518 double dfLat2, double dfLong2,
519 double dfScale,
520 double dfFalseEasting, double dfFalseNorthing );
521
523 OGRErr SetHOMAC( double dfCenterLat, double dfCenterLong,
524 double dfAzimuth, double dfRectToSkew,
525 double dfScale,
526 double dfFalseEasting, double dfFalseNorthing );
527
529 OGRErr SetLOM( double dfCenterLat, double dfCenterLong,
530 double dfAzimuth,
531 double dfScale,
532 double dfFalseEasting, double dfFalseNorthing );
533
535 OGRErr SetIWMPolyconic( double dfLat1, double dfLat2,
536 double dfCenterLong,
537 double dfFalseEasting,
538 double dfFalseNorthing );
539
541 OGRErr SetKrovak( double dfCenterLat, double dfCenterLong,
542 double dfAzimuth, double dfPseudoStdParallelLat,
543 double dfScale,
544 double dfFalseEasting, double dfFalseNorthing );
545
547 OGRErr SetLAEA( double dfCenterLat, double dfCenterLong,
548 double dfFalseEasting, double dfFalseNorthing );
549
551 OGRErr SetLCC( double dfStdP1, double dfStdP2,
552 double dfCenterLat, double dfCenterLong,
553 double dfFalseEasting, double dfFalseNorthing );
554
556 OGRErr SetLCC1SP( double dfCenterLat, double dfCenterLong,
557 double dfScale,
558 double dfFalseEasting, double dfFalseNorthing );
559
561 OGRErr SetLCCB( double dfStdP1, double dfStdP2,
562 double dfCenterLat, double dfCenterLong,
563 double dfFalseEasting, double dfFalseNorthing );
564
566 OGRErr SetMC( double dfCenterLat, double dfCenterLong,
567 double dfFalseEasting, double dfFalseNorthing );
568
570 OGRErr SetMercator( double dfCenterLat, double dfCenterLong,
571 double dfScale,
572 double dfFalseEasting, double dfFalseNorthing );
573
575 OGRErr SetMercator2SP( double dfStdP1,
576 double dfCenterLat, double dfCenterLong,
577 double dfFalseEasting, double dfFalseNorthing );
578
580 OGRErr SetMollweide( double dfCentralMeridian,
581 double dfFalseEasting, double dfFalseNorthing );
582
584 OGRErr SetNZMG( double dfCenterLat, double dfCenterLong,
585 double dfFalseEasting, double dfFalseNorthing );
586
588 OGRErr SetOS( double dfOriginLat, double dfCMeridian,
589 double dfScale,
590 double dfFalseEasting,double dfFalseNorthing);
591
593 OGRErr SetOrthographic( double dfCenterLat, double dfCenterLong,
594 double dfFalseEasting,double dfFalseNorthing);
595
597 OGRErr SetPolyconic( double dfCenterLat, double dfCenterLong,
598 double dfFalseEasting, double dfFalseNorthing );
599
601 OGRErr SetPS( double dfCenterLat, double dfCenterLong,
602 double dfScale,
603 double dfFalseEasting, double dfFalseNorthing);
604
606 OGRErr SetRobinson( double dfCenterLong,
607 double dfFalseEasting, double dfFalseNorthing );
608
610 OGRErr SetSinusoidal( double dfCenterLong,
611 double dfFalseEasting, double dfFalseNorthing );
612
614 OGRErr SetStereographic( double dfCenterLat, double dfCenterLong,
615 double dfScale,
616 double dfFalseEasting,double dfFalseNorthing);
617
619 OGRErr SetSOC( double dfLatitudeOfOrigin, double dfCentralMeridian,
620 double dfFalseEasting, double dfFalseNorthing );
621
623 OGRErr SetTM( double dfCenterLat, double dfCenterLong,
624 double dfScale,
625 double dfFalseEasting, double dfFalseNorthing );
626
628 OGRErr SetTMVariant( const char *pszVariantName,
629 double dfCenterLat, double dfCenterLong,
630 double dfScale,
631 double dfFalseEasting, double dfFalseNorthing );
632
634 OGRErr SetTMG( double dfCenterLat, double dfCenterLong,
635 double dfFalseEasting, double dfFalseNorthing );
636
638 OGRErr SetTMSO( double dfCenterLat, double dfCenterLong,
639 double dfScale,
640 double dfFalseEasting, double dfFalseNorthing );
641
643 OGRErr SetTPED( double dfLat1, double dfLong1,
644 double dfLat2, double dfLong2,
645 double dfFalseEasting, double dfFalseNorthing );
646
648 OGRErr SetVDG( double dfCenterLong,
649 double dfFalseEasting, double dfFalseNorthing );
650
652 OGRErr SetUTM( int nZone, int bNorth = TRUE );
653 int GetUTMZone( int *pbNorth = nullptr ) const;
654
656 OGRErr SetWagner( int nVariation, double dfCenterLat,
657 double dfFalseEasting, double dfFalseNorthing );
658
660 OGRErr SetQSC(double dfCenterLat, double dfCenterLong);
661
663 OGRErr SetSCH( double dfPegLat, double dfPegLong,
664 double dfPegHeading, double dfPegHgt);
665
667 OGRErr SetVerticalPerspective( double dfTopoOriginLat,
668 double dfTopoOriginLon,
669 double dfTopoOriginHeight,
670 double dfViewPointHeight,
671 double dfFalseEasting,
672 double dfFalseNorthing);
673
675 OGRErr SetDerivedGeogCRSWithPoleRotationGRIBConvention(
676 const char* pszCRSName,
677 double dfSouthPoleLat,
678 double dfSouthPoleLon,
679 double dfAxisRotation );
680
682 OGRErr SetStatePlane( int nZone, int bNAD83 = TRUE,
683 const char *pszOverrideUnitName = nullptr,
684 double dfOverrideUnit = 0.0 );
685
687 OGRErr ImportFromESRIStatePlaneWKT(
688 int nCode, const char* pszDatumName, const char* pszUnitsName,
689 int nPCSCode, const char* pszCRSName = nullptr );
690
692 OGRErr ImportFromESRIWisconsinWKT(
693 const char* pszPrjName, double dfCentralMeridian, double dfLatOfOrigin,
694 const char* pszUnitsName, const char* pszCRSName = nullptr );
695
697 void UpdateCoordinateSystemFromGeogCRS();
700 static OGRSpatialReference* GetWGS84SRS();
701
705 static inline OGRSpatialReferenceH ToHandle(OGRSpatialReference* poSRS)
706 { return reinterpret_cast<OGRSpatialReferenceH>(poSRS); }
707
711 static inline OGRSpatialReference* FromHandle(OGRSpatialReferenceH hSRS)
712 { return reinterpret_cast<OGRSpatialReference*>(hSRS); }
713
714 };
715
716 /************************************************************************/
717 /* OGRCoordinateTransformation */
718 /* */
719 /* This is really just used as a base class for a private */
720 /* implementation. */
721 /************************************************************************/
722
732 class CPL_DLL OGRCoordinateTransformation
733 {
734 public:
735 virtual ~OGRCoordinateTransformation() {}
736
737 static void DestroyCT(OGRCoordinateTransformation* poCT);
738
739 // From CT_CoordinateTransformation
740
742 virtual OGRSpatialReference *GetSourceCS() = 0;
743
745 virtual OGRSpatialReference *GetTargetCS() = 0;
746
748 virtual bool GetEmitErrors() const { return false; }
749
751 virtual void SetEmitErrors(bool /*bEmitErrors*/) {}
752
753 // From CT_MathTransform
754
770 int Transform( int nCount,
771 double *x, double *y, double *z = nullptr,
772 int *pabSuccess = nullptr );
773
790 virtual int Transform( int nCount,
791 double *x, double *y,
792 double *z, double *t,
793 int *pabSuccess ) = 0;
794
798 static inline OGRCoordinateTransformationH ToHandle(OGRCoordinateTransformation* poCT)
799 { return reinterpret_cast<OGRCoordinateTransformationH>(poCT); }
800
804 static inline OGRCoordinateTransformation* FromHandle(OGRCoordinateTransformationH hCT)
805 { return reinterpret_cast<OGRCoordinateTransformation*>(hCT); }
806
810 virtual OGRCoordinateTransformation* Clone() const = 0;
811 };
812
813 OGRCoordinateTransformation CPL_DLL *
814 OGRCreateCoordinateTransformation( const OGRSpatialReference *poSource,
815 const OGRSpatialReference *poTarget );
816
817
824 struct CPL_DLL OGRCoordinateTransformationOptions
825 {
827 private:
828 friend class OGRProjCT;
829 struct Private;
830 std::unique_ptr<Private> d;
833 public:
834 OGRCoordinateTransformationOptions();
835 OGRCoordinateTransformationOptions(const OGRCoordinateTransformationOptions&);
836 OGRCoordinateTransformationOptions& operator= (const OGRCoordinateTransformationOptions&);
837 ~OGRCoordinateTransformationOptions();
838
839 bool SetAreaOfInterest(double dfWestLongitudeDeg,
840 double dfSouthLatitudeDeg,
841 double dfEastLongitudeDeg,
842 double dfNorthLatitudeDeg);
843
844 bool SetCoordinateOperation(const char* pszCT, bool bReverseCT);
846 void SetSourceCenterLong(double dfCenterLong);
847 void SetTargetCenterLong(double dfCenterLong);
849 };
850
851
852 OGRCoordinateTransformation CPL_DLL *
853 OGRCreateCoordinateTransformation( const OGRSpatialReference *poSource,
854 const OGRSpatialReference *poTarget,
855 const OGRCoordinateTransformationOptions& options );
856
857 #endif /* ndef OGR_SPATIALREF_H_INCLUDED */
OGRCoordinateTransformation::ToHandle
static OGRCoordinateTransformationH ToHandle(OGRCoordinateTransformation *poCT)
Convert a OGRCoordinateTransformation* to a OGRCoordinateTransformationH.
Definition: ogr_spatialref.h:798
OGRCoordinateTransformation::SetEmitErrors
virtual void SetEmitErrors(bool)
Set if the transformer must emit CPLError.
Definition: ogr_spatialref.h:751
OSRAxisMappingStrategy
OSRAxisMappingStrategy
Data axis to CRS axis mapping strategy.
Definition: ogr_srs_api.h:659
OGR_SRSNode::Listener
Listener that is notified of modification to nodes.
Definition: ogr_spatialref.h:70
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
OGR_SRSNode::IsLeafNode
int IsLeafNode() const
Return whether this is a leaf node.
Definition: ogr_spatialref.h:86
CPLString
Convenient string class based on std::string.
Definition: cpl_string.h:332
OGR_SRSNode::GetValue
const char * GetValue() const
Fetch value string for this node.
Definition: ogr_spatialref.h:102
OGRCoordinateTransformation::GetEmitErrors
virtual bool GetEmitErrors() const
Whether the transformer will emit CPLError.
Definition: ogr_spatialref.h:748
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:77
USGS_ANGLE_PACKEDDMS
#define USGS_ANGLE_PACKEDDMS
Angle is in packed degree minute second.
Definition: ogr_spatialref.h:223
OGRSpatialReferenceH
void * OGRSpatialReferenceH
Opaque type for a spatial reference system.
Definition: ogr_api.h:75
ogr_srs_api.h
C spatial reference system services and defines.
OGRAxisOrientation
OGRAxisOrientation
Axis orientations (corresponds to CS_AxisOrientationEnum).
Definition: ogr_srs_api.h:48
OGRSpatialReference
This class represents an OpenGIS Spatial Reference System, and contains methods for converting betwee...
Definition: ogr_spatialref.h:157
OGRSpatialReference::ToHandle
static OGRSpatialReferenceH ToHandle(OGRSpatialReference *poSRS)
Convert a OGRSpatialReference* to a OGRSpatialReferenceH.
Definition: ogr_spatialref.h:705
OGRSpatialReference::FromHandle
static OGRSpatialReference * FromHandle(OGRSpatialReferenceH hSRS)
Convert a OGRSpatialReferenceH to a OGRSpatialReference*.
Definition: ogr_spatialref.h:711
OGRCoordinateTransformation::FromHandle
static OGRCoordinateTransformation * FromHandle(OGRCoordinateTransformationH hCT)
Convert a OGRCoordinateTransformationH to a OGRCoordinateTransformation*.
Definition: ogr_spatialref.h:804
OGRCoordinateTransformation
Interface for transforming between coordinate systems.
Definition: ogr_spatialref.h:732
OGRCreateCoordinateTransformation
OGRCoordinateTransformation * OGRCreateCoordinateTransformation(const OGRSpatialReference *poSource, const OGRSpatialReference *poTarget)
Create transformation object.
Definition: ogrct.cpp:508
OGRErr
int OGRErr
Type for a OGR error.
Definition: ogr_core.h:318
OGR_SRSNode::GetChildCount
int GetChildCount() const
Get number of children nodes.
Definition: ogr_spatialref.h:88
OGRCoordinateTransformationOptions
Context for coordinate transformation.
Definition: ogr_spatialref.h:824
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