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,
260 double* pdfConvFactor = nullptr ) const;
261 OGRErr SetAxes( const char *pszTargetKey,
262 const char *pszXAxisName,
263 OGRAxisOrientation eXAxisOrientation,
264 const char *pszYAxisName,
265 OGRAxisOrientation eYAxisOrientation );
266
267 OSRAxisMappingStrategy GetAxisMappingStrategy() const;
268 void SetAxisMappingStrategy(OSRAxisMappingStrategy);
269 const std::vector<int>& GetDataAxisToSRSAxisMapping() const;
270 OGRErr SetDataAxisToSRSAxisMapping(const std::vector<int>& mapping);
271
272 // Machinery for accessing parse nodes
273
275 OGR_SRSNode *GetRoot();
277 const OGR_SRSNode *GetRoot() const;
278 void SetRoot( OGR_SRSNode * );
279
280 OGR_SRSNode *GetAttrNode(const char *);
281 const OGR_SRSNode *GetAttrNode(const char *) const;
282 const char *GetAttrValue(const char *, int = 0) const;
283
284 OGRErr SetNode( const char *, const char * );
285 OGRErr SetNode( const char *, double );
286
287 OGRErr SetLinearUnitsAndUpdateParameters( const char *pszName,
288 double dfInMeters,
289 const char *pszUnitAuthority = nullptr,
290 const char *pszUnitCode = nullptr );
291 OGRErr SetLinearUnits( const char *pszName, double dfInMeters );
292 OGRErr SetTargetLinearUnits( const char *pszTargetKey,
293 const char *pszName,
294 double dfInMeters,
295 const char *pszUnitAuthority = nullptr,
296 const char *pszUnitCode = nullptr);
297
298 double GetLinearUnits( char ** ) const
300 CPL_WARN_DEPRECATED("Use GetLinearUnits(const char**) instead")
302 ;
303 double GetLinearUnits( const char ** = nullptr ) const;
305 double GetLinearUnits( std::nullptr_t ) const
306 { return GetLinearUnits( static_cast<const char**>(nullptr) ); }
309 double GetTargetLinearUnits( const char *pszTargetKey,
310 char ** ppszRetName ) const
312 CPL_WARN_DEPRECATED("Use GetTargetLinearUnits(const char*, const char**)")
314 ;
315 double GetTargetLinearUnits( const char *pszTargetKey,
316 const char ** ppszRetName = nullptr ) const;
318 double GetTargetLinearUnits( const char *pszTargetKey, std::nullptr_t ) const
319 { return GetTargetLinearUnits( pszTargetKey, static_cast<const char**>(nullptr) ); }
322 OGRErr SetAngularUnits( const char *pszName, double dfInRadians );
323 double GetAngularUnits( char ** ) const
325 CPL_WARN_DEPRECATED("Use GetAngularUnits(const char**) instead")
327 ;
328 double GetAngularUnits( const char ** = nullptr ) const;
330 double GetAngularUnits( std::nullptr_t ) const
331 { return GetAngularUnits( static_cast<const char**>(nullptr) ); }
334 double GetPrimeMeridian( char ** ) const
336 CPL_WARN_DEPRECATED("Use GetPrimeMeridian(const char**) instead")
338 ;
339 double GetPrimeMeridian( const char ** = nullptr ) const;
341 double GetPrimeMeridian( std::nullptr_t ) const
342 { return GetPrimeMeridian( static_cast<const char**>(nullptr) ); }
345 bool IsEmpty() const;
346 int IsGeographic() const;
347 int IsDerivedGeographic() const;
348 int IsProjected() const;
349 int IsGeocentric() const;
350 bool IsDynamic() const;
351 int IsLocal() const;
352 int IsVertical() const;
353 int IsCompound() const;
354 int IsSameGeogCS( const OGRSpatialReference * ) const;
355 int IsSameGeogCS( const OGRSpatialReference *,
356 const char* const * papszOptions ) const;
357 int IsSameVertCS( const OGRSpatialReference * ) const;
358 int IsSame( const OGRSpatialReference * ) const;
359 int IsSame( const OGRSpatialReference *,
360 const char* const * papszOptions ) const;
361
362 void Clear();
363 OGRErr SetLocalCS( const char * );
364 OGRErr SetProjCS( const char * );
365 OGRErr SetProjection( const char * );
366 OGRErr SetGeocCS( const char * pszGeocName );
367 OGRErr SetGeogCS( const char * pszGeogName,
368 const char * pszDatumName,
369 const char * pszEllipsoidName,
370 double dfSemiMajor, double dfInvFlattening,
371 const char * pszPMName = nullptr,
372 double dfPMOffset = 0.0,
373 const char * pszUnits = nullptr,
374 double dfConvertToRadians = 0.0 );
375 OGRErr SetWellKnownGeogCS( const char * );
376 OGRErr CopyGeogCSFrom( const OGRSpatialReference * poSrcSRS );
377 OGRErr SetVertCS( const char *pszVertCSName,
378 const char *pszVertDatumName,
379 int nVertDatumClass = 2005 );
380 OGRErr SetCompoundCS( const char *pszName,
381 const OGRSpatialReference *poHorizSRS,
382 const OGRSpatialReference *poVertSRS );
383
384 void SetCoordinateEpoch( double dfCoordinateEpoch );
385 double GetCoordinateEpoch() const;
386
387 // cppcheck-suppress functionStatic
388 OGRErr PromoteTo3D( const char* pszName );
389 // cppcheck-suppress functionStatic
390 OGRErr DemoteTo2D( const char* pszName );
391
392 OGRErr SetFromUserInput( const char * );
393
394 static const char* const SET_FROM_USER_INPUT_LIMITATIONS[];
395 static CSLConstList SET_FROM_USER_INPUT_LIMITATIONS_get();
396
397 OGRErr SetFromUserInput( const char *, CSLConstList papszOptions );
398
399 OGRErr SetTOWGS84( double, double, double,
400 double = 0.0, double = 0.0, double = 0.0,
401 double = 0.0 );
402 OGRErr GetTOWGS84( double *padfCoef, int nCoeff = 7 ) const;
403 OGRErr AddGuessedTOWGS84();
404
405 double GetSemiMajor( OGRErr * = nullptr ) const;
406 double GetSemiMinor( OGRErr * = nullptr ) const;
407 double GetInvFlattening( OGRErr * = nullptr ) const;
408 double GetEccentricity() const;
409 double GetSquaredEccentricity() const;
410
411 OGRErr SetAuthority( const char * pszTargetKey,
412 const char * pszAuthority,
413 int nCode );
414
415 OGRErr AutoIdentifyEPSG();
416 OGRSpatialReferenceH* FindMatches( char** papszOptions,
417 int* pnEntries,
418 int** ppanMatchConfidence ) const;
419
420 int GetEPSGGeogCS() const;
421
422 const char *GetAuthorityCode( const char * pszTargetKey ) const;
423 const char *GetAuthorityName( const char * pszTargetKey ) const;
424 char *GetOGCURN() const;
425
426 bool GetAreaOfUse( double* pdfWestLongitudeDeg,
427 double* pdfSouthLatitudeDeg,
428 double* pdfEastLongitudeDeg,
429 double* pdfNorthLatitudeDeg,
430 const char **ppszAreaName ) const;
431
432 const char *GetExtension( const char *pszTargetKey,
433 const char *pszName,
434 const char *pszDefault = nullptr ) const;
435 OGRErr SetExtension( const char *pszTargetKey,
436 const char *pszName,
437 const char *pszValue );
438
439 int FindProjParm( const char *pszParameter,
440 const OGR_SRSNode *poPROJCS=nullptr ) const;
441 OGRErr SetProjParm( const char *, double );
442 double GetProjParm( const char *, double =0.0, OGRErr* = nullptr ) const;
443
444 OGRErr SetNormProjParm( const char *, double );
445 double GetNormProjParm( const char *, double=0.0, OGRErr* =nullptr)const;
446
447 static int IsAngularParameter( const char * );
448 static int IsLongitudeParameter( const char * );
449 static int IsLinearParameter( const char * );
450
452 OGRErr SetACEA( double dfStdP1, double dfStdP2,
453 double dfCenterLat, double dfCenterLong,
454 double dfFalseEasting, double dfFalseNorthing );
455
457 OGRErr SetAE( double dfCenterLat, double dfCenterLong,
458 double dfFalseEasting, double dfFalseNorthing );
459
461 OGRErr SetBonne( double dfStdP1, double dfCentralMeridian,
462 double dfFalseEasting, double dfFalseNorthing );
463
465 OGRErr SetCEA( double dfStdP1, double dfCentralMeridian,
466 double dfFalseEasting, double dfFalseNorthing );
467
469 OGRErr SetCS( double dfCenterLat, double dfCenterLong,
470 double dfFalseEasting, double dfFalseNorthing );
471
473 OGRErr SetEC( double dfStdP1, double dfStdP2,
474 double dfCenterLat, double dfCenterLong,
475 double dfFalseEasting, double dfFalseNorthing );
476
478 OGRErr SetEckert( int nVariation, double dfCentralMeridian,
479 double dfFalseEasting, double dfFalseNorthing );
480
482 OGRErr SetEckertIV( double dfCentralMeridian,
483 double dfFalseEasting, double dfFalseNorthing );
484
486 OGRErr SetEckertVI( double dfCentralMeridian,
487 double dfFalseEasting, double dfFalseNorthing );
488
490 OGRErr SetEquirectangular(double dfCenterLat, double dfCenterLong,
491 double dfFalseEasting, double dfFalseNorthing );
493 OGRErr SetEquirectangular2( double dfCenterLat, double dfCenterLong,
494 double dfPseudoStdParallel1,
495 double dfFalseEasting, double dfFalseNorthing );
496
498 OGRErr SetGEOS( double dfCentralMeridian, double dfSatelliteHeight,
499 double dfFalseEasting, double dfFalseNorthing );
500
502 OGRErr SetGH( double dfCentralMeridian,
503 double dfFalseEasting, double dfFalseNorthing );
504
506 OGRErr SetIGH();
507
509 OGRErr SetGS( double dfCentralMeridian,
510 double dfFalseEasting, double dfFalseNorthing );
511
513 OGRErr SetGaussSchreiberTMercator(double dfCenterLat, double dfCenterLong,
514 double dfScale,
515 double dfFalseEasting, double dfFalseNorthing );
516
518 OGRErr SetGnomonic(double dfCenterLat, double dfCenterLong,
519 double dfFalseEasting, double dfFalseNorthing );
520
522 OGRErr SetHOM( double dfCenterLat, double dfCenterLong,
523 double dfAzimuth, double dfRectToSkew,
524 double dfScale,
525 double dfFalseEasting, double dfFalseNorthing );
526
528 OGRErr SetHOM2PNO( double dfCenterLat,
529 double dfLat1, double dfLong1,
530 double dfLat2, double dfLong2,
531 double dfScale,
532 double dfFalseEasting, double dfFalseNorthing );
533
535 OGRErr SetHOMAC( double dfCenterLat, double dfCenterLong,
536 double dfAzimuth, double dfRectToSkew,
537 double dfScale,
538 double dfFalseEasting, double dfFalseNorthing );
539
541 OGRErr SetLOM( double dfCenterLat, double dfCenterLong,
542 double dfAzimuth,
543 double dfScale,
544 double dfFalseEasting, double dfFalseNorthing );
545
547 OGRErr SetIWMPolyconic( double dfLat1, double dfLat2,
548 double dfCenterLong,
549 double dfFalseEasting,
550 double dfFalseNorthing );
551
553 OGRErr SetKrovak( double dfCenterLat, double dfCenterLong,
554 double dfAzimuth, double dfPseudoStdParallelLat,
555 double dfScale,
556 double dfFalseEasting, double dfFalseNorthing );
557
559 OGRErr SetLAEA( double dfCenterLat, double dfCenterLong,
560 double dfFalseEasting, double dfFalseNorthing );
561
563 OGRErr SetLCC( double dfStdP1, double dfStdP2,
564 double dfCenterLat, double dfCenterLong,
565 double dfFalseEasting, double dfFalseNorthing );
566
568 OGRErr SetLCC1SP( double dfCenterLat, double dfCenterLong,
569 double dfScale,
570 double dfFalseEasting, double dfFalseNorthing );
571
573 OGRErr SetLCCB( double dfStdP1, double dfStdP2,
574 double dfCenterLat, double dfCenterLong,
575 double dfFalseEasting, double dfFalseNorthing );
576
578 OGRErr SetMC( double dfCenterLat, double dfCenterLong,
579 double dfFalseEasting, double dfFalseNorthing );
580
582 OGRErr SetMercator( double dfCenterLat, double dfCenterLong,
583 double dfScale,
584 double dfFalseEasting, double dfFalseNorthing );
585
587 OGRErr SetMercator2SP( double dfStdP1,
588 double dfCenterLat, double dfCenterLong,
589 double dfFalseEasting, double dfFalseNorthing );
590
592 OGRErr SetMollweide( double dfCentralMeridian,
593 double dfFalseEasting, double dfFalseNorthing );
594
596 OGRErr SetNZMG( double dfCenterLat, double dfCenterLong,
597 double dfFalseEasting, double dfFalseNorthing );
598
600 OGRErr SetOS( double dfOriginLat, double dfCMeridian,
601 double dfScale,
602 double dfFalseEasting,double dfFalseNorthing);
603
605 OGRErr SetOrthographic( double dfCenterLat, double dfCenterLong,
606 double dfFalseEasting,double dfFalseNorthing);
607
609 OGRErr SetPolyconic( double dfCenterLat, double dfCenterLong,
610 double dfFalseEasting, double dfFalseNorthing );
611
613 OGRErr SetPS( double dfCenterLat, double dfCenterLong,
614 double dfScale,
615 double dfFalseEasting, double dfFalseNorthing);
616
618 OGRErr SetRobinson( double dfCenterLong,
619 double dfFalseEasting, double dfFalseNorthing );
620
622 OGRErr SetSinusoidal( double dfCenterLong,
623 double dfFalseEasting, double dfFalseNorthing );
624
626 OGRErr SetStereographic( double dfCenterLat, double dfCenterLong,
627 double dfScale,
628 double dfFalseEasting,double dfFalseNorthing);
629
631 OGRErr SetSOC( double dfLatitudeOfOrigin, double dfCentralMeridian,
632 double dfFalseEasting, double dfFalseNorthing );
633
635 OGRErr SetTM( double dfCenterLat, double dfCenterLong,
636 double dfScale,
637 double dfFalseEasting, double dfFalseNorthing );
638
640 OGRErr SetTMVariant( const char *pszVariantName,
641 double dfCenterLat, double dfCenterLong,
642 double dfScale,
643 double dfFalseEasting, double dfFalseNorthing );
644
646 OGRErr SetTMG( double dfCenterLat, double dfCenterLong,
647 double dfFalseEasting, double dfFalseNorthing );
648
650 OGRErr SetTMSO( double dfCenterLat, double dfCenterLong,
651 double dfScale,
652 double dfFalseEasting, double dfFalseNorthing );
653
655 OGRErr SetTPED( double dfLat1, double dfLong1,
656 double dfLat2, double dfLong2,
657 double dfFalseEasting, double dfFalseNorthing );
658
660 OGRErr SetVDG( double dfCenterLong,
661 double dfFalseEasting, double dfFalseNorthing );
662
664 OGRErr SetUTM( int nZone, int bNorth = TRUE );
665 int GetUTMZone( int *pbNorth = nullptr ) const;
666
668 OGRErr SetWagner( int nVariation, double dfCenterLat,
669 double dfFalseEasting, double dfFalseNorthing );
670
672 OGRErr SetQSC(double dfCenterLat, double dfCenterLong);
673
675 OGRErr SetSCH( double dfPegLat, double dfPegLong,
676 double dfPegHeading, double dfPegHgt);
677
679 OGRErr SetVerticalPerspective( double dfTopoOriginLat,
680 double dfTopoOriginLon,
681 double dfTopoOriginHeight,
682 double dfViewPointHeight,
683 double dfFalseEasting,
684 double dfFalseNorthing);
685
687 OGRErr SetDerivedGeogCRSWithPoleRotationGRIBConvention(
688 const char* pszCRSName,
689 double dfSouthPoleLat,
690 double dfSouthPoleLon,
691 double dfAxisRotation );
692
694 OGRErr SetDerivedGeogCRSWithPoleRotationNetCDFCFConvention(
695 const char* pszCRSName,
696 double dfGridNorthPoleLat,
697 double dfGridNorthPoleLon,
698 double dfNorthPoleGridLon );
699
701 OGRErr SetStatePlane( int nZone, int bNAD83 = TRUE,
702 const char *pszOverrideUnitName = nullptr,
703 double dfOverrideUnit = 0.0 );
704
706 OGRErr ImportFromESRIStatePlaneWKT(
707 int nCode, const char* pszDatumName, const char* pszUnitsName,
708 int nPCSCode, const char* pszCRSName = nullptr );
709
711 OGRErr ImportFromESRIWisconsinWKT(
712 const char* pszPrjName, double dfCentralMeridian, double dfLatOfOrigin,
713 const char* pszUnitsName, const char* pszCRSName = nullptr );
714
716 void UpdateCoordinateSystemFromGeogCRS();
719 static OGRSpatialReference* GetWGS84SRS();
720
724 static inline OGRSpatialReferenceH ToHandle(OGRSpatialReference* poSRS)
725 { return reinterpret_cast<OGRSpatialReferenceH>(poSRS); }
726
730 static inline OGRSpatialReference* FromHandle(OGRSpatialReferenceH hSRS)
731 { return reinterpret_cast<OGRSpatialReference*>(hSRS); }
732
733 };
734
735 /************************************************************************/
736 /* OGRCoordinateTransformation */
737 /* */
738 /* This is really just used as a base class for a private */
739 /* implementation. */
740 /************************************************************************/
741
751 class CPL_DLL OGRCoordinateTransformation
752 {
753 public:
754 virtual ~OGRCoordinateTransformation() {}
755
756 static void DestroyCT(OGRCoordinateTransformation* poCT);
757
758 // From CT_CoordinateTransformation
759
761 virtual OGRSpatialReference *GetSourceCS() = 0;
762
764 virtual OGRSpatialReference *GetTargetCS() = 0;
765
767 virtual bool GetEmitErrors() const { return false; }
768
770 virtual void SetEmitErrors(bool /*bEmitErrors*/) {}
771
772 // From CT_MathTransform
773
789 int Transform( int nCount,
790 double *x, double *y, double *z = nullptr,
791 int *pabSuccess = nullptr );
792
809 virtual int Transform( int nCount,
810 double *x, double *y,
811 double *z, double *t,
812 int *pabSuccess ) = 0;
813
831 virtual int TransformWithErrorCodes( int nCount,
832 double *x, double *y,
833 double *z, double *t,
834 int *panErrorCodes );
835
868 virtual int TransformBounds( const double xmin,
869 const double ymin,
870 const double xmax,
871 const double ymax,
872 double* out_xmin,
873 double* out_ymin,
874 double* out_xmax,
875 double* out_ymax,
876 const int densify_pts )
877 {
878 (void)xmin;
879 (void)xmax;
880 (void)ymin;
881 (void)ymax;
882 (void)densify_pts;
883 *out_xmin = HUGE_VAL;
884 *out_ymin = HUGE_VAL;
885 *out_xmax = HUGE_VAL;
886 *out_ymax = HUGE_VAL;
887 CPLError(CE_Failure, CPLE_AppDefined, "TransformBounds not implemented.");
888 return false;
889 }
890
894 static inline OGRCoordinateTransformationH ToHandle(OGRCoordinateTransformation* poCT)
895 { return reinterpret_cast<OGRCoordinateTransformationH>(poCT); }
896
900 static inline OGRCoordinateTransformation* FromHandle(OGRCoordinateTransformationH hCT)
901 { return reinterpret_cast<OGRCoordinateTransformation*>(hCT); }
902
906 virtual OGRCoordinateTransformation* Clone() const = 0;
907
917 virtual OGRCoordinateTransformation* GetInverse() const = 0;
918 };
919
920 OGRCoordinateTransformation CPL_DLL *
921 OGRCreateCoordinateTransformation( const OGRSpatialReference *poSource,
922 const OGRSpatialReference *poTarget );
923
924
931 struct CPL_DLL OGRCoordinateTransformationOptions
932 {
934 private:
935 friend class OGRProjCT;
936 struct Private;
937 std::unique_ptr<Private> d;
940 public:
941 OGRCoordinateTransformationOptions();
942 OGRCoordinateTransformationOptions(const OGRCoordinateTransformationOptions&);
943 OGRCoordinateTransformationOptions& operator= (const OGRCoordinateTransformationOptions&);
944 ~OGRCoordinateTransformationOptions();
945
946 bool SetAreaOfInterest(double dfWestLongitudeDeg,
947 double dfSouthLatitudeDeg,
948 double dfEastLongitudeDeg,
949 double dfNorthLatitudeDeg);
950 bool SetDesiredAccuracy(double dfAccuracy);
951 bool SetBallparkAllowed(bool bAllowBallpark);
952
953 bool SetCoordinateOperation(const char* pszCT, bool bReverseCT);
955 void SetSourceCenterLong(double dfCenterLong);
956 void SetTargetCenterLong(double dfCenterLong);
958 };
959
960
961 OGRCoordinateTransformation CPL_DLL *
962 OGRCreateCoordinateTransformation( const OGRSpatialReference *poSource,
963 const OGRSpatialReference *poTarget,
964 const OGRCoordinateTransformationOptions& options );
965
966 #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:792
OGRCoordinateTransformationOptions
Context for coordinate transformation.
Definition: ogr_spatialref.h:931
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:868
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:894
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:730
CPLString
Convenient string class based on std::string.
Definition: cpl_string.h:319
OGRSpatialReference::ToHandle
static OGRSpatialReferenceH ToHandle(OGRSpatialReference *poSRS)
Convert a OGRSpatialReference* to a OGRSpatialReferenceH.
Definition: ogr_spatialref.h:724
OSRAxisMappingStrategy
OSRAxisMappingStrategy
Data axis to CRS axis mapping strategy.
Definition: ogr_srs_api.h:667
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:80
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:82
OGRCoordinateTransformation::SetEmitErrors
virtual void SetEmitErrors(bool)
Set if the transformer must emit CPLError.
Definition: ogr_spatialref.h:770
CSLConstList
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition: cpl_port.h:1053
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:310
OGRCoordinateTransformation
Interface for transforming between coordinate systems.
Definition: ogr_spatialref.h:751
OGRCoordinateTransformation::FromHandle
static OGRCoordinateTransformation * FromHandle(OGRCoordinateTransformationH hCT)
Convert a OGRCoordinateTransformationH to a OGRCoordinateTransformation*.
Definition: ogr_spatialref.h:900
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:767
USGS_ANGLE_PACKEDDMS
#define USGS_ANGLE_PACKEDDMS
Angle is in packed degree minute second.
Definition: ogr_spatialref.h:224
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:927
CPLE_AppDefined
#define CPLE_AppDefined
Application defined error.
Definition: cpl_error.h:99