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
66class 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);
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
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:
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 ** );
216 OGRErr importFromWkt( const char * pszInput, CSLConstList papszOptions);
217 OGRErr importFromWkt( const char ** ppszInput, CSLConstList papszOptions);
219 OGRErr importFromWkt( const char* );
220 OGRErr importFromProj4( const char * );
221 OGRErr importFromEPSG( int );
222 OGRErr importFromEPSGA( int );
223 OGRErr importFromESRI( char ** );
224 OGRErr importFromPCI( const char *, const char * = nullptr,
225 double * = nullptr );
226
227#define USGS_ANGLE_DECIMALDEGREES 0
228#define USGS_ANGLE_PACKEDDMS TRUE
229#define USGS_ANGLE_RADIANS 2
230 OGRErr importFromUSGS( long iProjSys, long iZone,
231 double *padfPrjParams, long iDatum,
232 int nUSGSAngleFormat = USGS_ANGLE_PACKEDDMS );
233 OGRErr importFromPanorama( long, long, long, double* );
234 OGRErr importVertCSFromPanorama( int );
235 OGRErr importFromOzi( const char * const* papszLines );
236 OGRErr importFromWMSAUTO( const char *pszAutoDef );
237 OGRErr importFromXML( const char * );
238 OGRErr importFromDict( const char *pszDict, const char *pszCode );
239 OGRErr importFromURN( const char * );
240 OGRErr importFromCRSURL( const char * );
241 OGRErr importFromERM( const char *pszProj, const char *pszDatum,
242 const char *pszUnits );
243 OGRErr importFromUrl( const char * );
244 OGRErr importFromMICoordSys( const char * );
245
246 OGRErr morphToESRI();
247 OGRErr morphFromESRI();
248
249 OGRSpatialReference* convertToOtherProjection(
250 const char* pszTargetProjection,
251 const char* const* papszOptions = nullptr ) const;
252
253 OGRErr Validate() const;
254 OGRErr StripVertical();
255
256 bool StripTOWGS84IfKnownDatumAndAllowed();
257 bool StripTOWGS84IfKnownDatum();
258
259 int EPSGTreatsAsLatLong() const;
260 int EPSGTreatsAsNorthingEasting() const;
261 int GetAxesCount() const;
262 const char *GetAxis( const char *pszTargetKey, int iAxis,
263 OGRAxisOrientation *peOrientation,
264 double* pdfConvFactor = nullptr ) const;
265 OGRErr SetAxes( const char *pszTargetKey,
266 const char *pszXAxisName,
267 OGRAxisOrientation eXAxisOrientation,
268 const char *pszYAxisName,
269 OGRAxisOrientation eYAxisOrientation );
270
271 OSRAxisMappingStrategy GetAxisMappingStrategy() const;
272 void SetAxisMappingStrategy(OSRAxisMappingStrategy);
273 const std::vector<int>& GetDataAxisToSRSAxisMapping() const;
274 OGRErr SetDataAxisToSRSAxisMapping(const std::vector<int>& mapping);
275
276 // Machinery for accessing parse nodes
277
279 OGR_SRSNode *GetRoot();
281 const OGR_SRSNode *GetRoot() const;
282 void SetRoot( OGR_SRSNode * );
283
284 OGR_SRSNode *GetAttrNode(const char *);
285 const OGR_SRSNode *GetAttrNode(const char *) const;
286 const char *GetAttrValue(const char *, int = 0) const;
287
288 OGRErr SetNode( const char *, const char * );
289 OGRErr SetNode( const char *, double );
290
291 OGRErr SetLinearUnitsAndUpdateParameters( const char *pszName,
292 double dfInMeters,
293 const char *pszUnitAuthority = nullptr,
294 const char *pszUnitCode = nullptr );
295 OGRErr SetLinearUnits( const char *pszName, double dfInMeters );
296 OGRErr SetTargetLinearUnits( const char *pszTargetKey,
297 const char *pszName,
298 double dfInMeters,
299 const char *pszUnitAuthority = nullptr,
300 const char *pszUnitCode = nullptr);
301
302 double GetLinearUnits( char ** ) const
304 CPL_WARN_DEPRECATED("Use GetLinearUnits(const char**) instead")
306 ;
307 double GetLinearUnits( const char ** = nullptr ) const;
309 double GetLinearUnits( std::nullptr_t ) const
310 { return GetLinearUnits( static_cast<const char**>(nullptr) ); }
313 double GetTargetLinearUnits( const char *pszTargetKey,
314 char ** ppszRetName ) const
316 CPL_WARN_DEPRECATED("Use GetTargetLinearUnits(const char*, const char**)")
318 ;
319 double GetTargetLinearUnits( const char *pszTargetKey,
320 const char ** ppszRetName = nullptr ) const;
322 double GetTargetLinearUnits( const char *pszTargetKey, std::nullptr_t ) const
323 { return GetTargetLinearUnits( pszTargetKey, static_cast<const char**>(nullptr) ); }
326 OGRErr SetAngularUnits( const char *pszName, double dfInRadians );
327 double GetAngularUnits( char ** ) const
329 CPL_WARN_DEPRECATED("Use GetAngularUnits(const char**) instead")
331 ;
332 double GetAngularUnits( const char ** = nullptr ) const;
334 double GetAngularUnits( std::nullptr_t ) const
335 { return GetAngularUnits( static_cast<const char**>(nullptr) ); }
338 double GetPrimeMeridian( char ** ) const
340 CPL_WARN_DEPRECATED("Use GetPrimeMeridian(const char**) instead")
342 ;
343 double GetPrimeMeridian( const char ** = nullptr ) const;
345 double GetPrimeMeridian( std::nullptr_t ) const
346 { return GetPrimeMeridian( static_cast<const char**>(nullptr) ); }
349 bool IsEmpty() const;
350 int IsGeographic() const;
351 int IsDerivedGeographic() const;
352 int IsProjected() const;
353 int IsGeocentric() const;
354 bool IsDynamic() const;
355 int IsLocal() const;
356 int IsVertical() const;
357 int IsCompound() const;
358 int IsSameGeogCS( const OGRSpatialReference * ) const;
359 int IsSameGeogCS( const OGRSpatialReference *,
360 const char* const * papszOptions ) const;
361 int IsSameVertCS( const OGRSpatialReference * ) const;
362 int IsSame( const OGRSpatialReference * ) const;
363 int IsSame( const OGRSpatialReference *,
364 const char* const * papszOptions ) const;
365
366 void Clear();
367 OGRErr SetLocalCS( const char * );
368 OGRErr SetProjCS( const char * );
369 OGRErr SetProjection( const char * );
370 OGRErr SetGeocCS( const char * pszGeocName );
371 OGRErr SetGeogCS( const char * pszGeogName,
372 const char * pszDatumName,
373 const char * pszEllipsoidName,
374 double dfSemiMajor, double dfInvFlattening,
375 const char * pszPMName = nullptr,
376 double dfPMOffset = 0.0,
377 const char * pszUnits = nullptr,
378 double dfConvertToRadians = 0.0 );
379 OGRErr SetWellKnownGeogCS( const char * );
380 OGRErr CopyGeogCSFrom( const OGRSpatialReference * poSrcSRS );
381 OGRErr SetVertCS( const char *pszVertCSName,
382 const char *pszVertDatumName,
383 int nVertDatumClass = 2005 );
384 OGRErr SetCompoundCS( const char *pszName,
385 const OGRSpatialReference *poHorizSRS,
386 const OGRSpatialReference *poVertSRS );
387
388 void SetCoordinateEpoch( double dfCoordinateEpoch );
389 double GetCoordinateEpoch() const;
390
391 // cppcheck-suppress functionStatic
392 OGRErr PromoteTo3D( const char* pszName );
393 // cppcheck-suppress functionStatic
394 OGRErr DemoteTo2D( const char* pszName );
395
396 OGRErr SetFromUserInput( const char * );
397
398 static const char* const SET_FROM_USER_INPUT_LIMITATIONS[];
399 static CSLConstList SET_FROM_USER_INPUT_LIMITATIONS_get();
400
401 OGRErr SetFromUserInput( const char *, CSLConstList papszOptions );
402
403 OGRErr SetTOWGS84( double, double, double,
404 double = 0.0, double = 0.0, double = 0.0,
405 double = 0.0 );
406 OGRErr GetTOWGS84( double *padfCoef, int nCoeff = 7 ) const;
407 OGRErr AddGuessedTOWGS84();
408
409 double GetSemiMajor( OGRErr * = nullptr ) const;
410 double GetSemiMinor( OGRErr * = nullptr ) const;
411 double GetInvFlattening( OGRErr * = nullptr ) const;
412 double GetEccentricity() const;
413 double GetSquaredEccentricity() const;
414
415 OGRErr SetAuthority( const char * pszTargetKey,
416 const char * pszAuthority,
417 int nCode );
418
419 OGRErr AutoIdentifyEPSG();
420 OGRSpatialReferenceH* FindMatches( char** papszOptions,
421 int* pnEntries,
422 int** ppanMatchConfidence ) const;
423
424 int GetEPSGGeogCS() const;
425
426 const char *GetAuthorityCode( const char * pszTargetKey ) const;
427 const char *GetAuthorityName( const char * pszTargetKey ) const;
428 char *GetOGCURN() const;
429
430 bool GetAreaOfUse( double* pdfWestLongitudeDeg,
431 double* pdfSouthLatitudeDeg,
432 double* pdfEastLongitudeDeg,
433 double* pdfNorthLatitudeDeg,
434 const char **ppszAreaName ) const;
435
436 const char *GetExtension( const char *pszTargetKey,
437 const char *pszName,
438 const char *pszDefault = nullptr ) const;
439 OGRErr SetExtension( const char *pszTargetKey,
440 const char *pszName,
441 const char *pszValue );
442
443 int FindProjParm( const char *pszParameter,
444 const OGR_SRSNode *poPROJCS=nullptr ) const;
445 OGRErr SetProjParm( const char *, double );
446 double GetProjParm( const char *, double =0.0, OGRErr* = nullptr ) const;
447
448 OGRErr SetNormProjParm( const char *, double );
449 double GetNormProjParm( const char *, double=0.0, OGRErr* =nullptr)const;
450
451 static int IsAngularParameter( const char * );
452 static int IsLongitudeParameter( const char * );
453 static int IsLinearParameter( const char * );
454
456 OGRErr SetACEA( double dfStdP1, double dfStdP2,
457 double dfCenterLat, double dfCenterLong,
458 double dfFalseEasting, double dfFalseNorthing );
459
461 OGRErr SetAE( double dfCenterLat, double dfCenterLong,
462 double dfFalseEasting, double dfFalseNorthing );
463
465 OGRErr SetBonne( double dfStdP1, double dfCentralMeridian,
466 double dfFalseEasting, double dfFalseNorthing );
467
469 OGRErr SetCEA( double dfStdP1, double dfCentralMeridian,
470 double dfFalseEasting, double dfFalseNorthing );
471
473 OGRErr SetCS( double dfCenterLat, double dfCenterLong,
474 double dfFalseEasting, double dfFalseNorthing );
475
477 OGRErr SetEC( double dfStdP1, double dfStdP2,
478 double dfCenterLat, double dfCenterLong,
479 double dfFalseEasting, double dfFalseNorthing );
480
482 OGRErr SetEckert( int nVariation, double dfCentralMeridian,
483 double dfFalseEasting, double dfFalseNorthing );
484
486 OGRErr SetEckertIV( double dfCentralMeridian,
487 double dfFalseEasting, double dfFalseNorthing );
488
490 OGRErr SetEckertVI( double dfCentralMeridian,
491 double dfFalseEasting, double dfFalseNorthing );
492
494 OGRErr SetEquirectangular(double dfCenterLat, double dfCenterLong,
495 double dfFalseEasting, double dfFalseNorthing );
497 OGRErr SetEquirectangular2( double dfCenterLat, double dfCenterLong,
498 double dfPseudoStdParallel1,
499 double dfFalseEasting, double dfFalseNorthing );
500
502 OGRErr SetGEOS( double dfCentralMeridian, double dfSatelliteHeight,
503 double dfFalseEasting, double dfFalseNorthing );
504
506 OGRErr SetGH( double dfCentralMeridian,
507 double dfFalseEasting, double dfFalseNorthing );
508
510 OGRErr SetIGH();
511
513 OGRErr SetGS( double dfCentralMeridian,
514 double dfFalseEasting, double dfFalseNorthing );
515
517 OGRErr SetGaussSchreiberTMercator(double dfCenterLat, double dfCenterLong,
518 double dfScale,
519 double dfFalseEasting, double dfFalseNorthing );
520
522 OGRErr SetGnomonic(double dfCenterLat, double dfCenterLong,
523 double dfFalseEasting, double dfFalseNorthing );
524
526 OGRErr SetHOM( double dfCenterLat, double dfCenterLong,
527 double dfAzimuth, double dfRectToSkew,
528 double dfScale,
529 double dfFalseEasting, double dfFalseNorthing );
530
532 OGRErr SetHOM2PNO( double dfCenterLat,
533 double dfLat1, double dfLong1,
534 double dfLat2, double dfLong2,
535 double dfScale,
536 double dfFalseEasting, double dfFalseNorthing );
537
539 OGRErr SetHOMAC( double dfCenterLat, double dfCenterLong,
540 double dfAzimuth, double dfRectToSkew,
541 double dfScale,
542 double dfFalseEasting, double dfFalseNorthing );
543
545 OGRErr SetLOM( double dfCenterLat, double dfCenterLong,
546 double dfAzimuth,
547 double dfScale,
548 double dfFalseEasting, double dfFalseNorthing );
549
551 OGRErr SetIWMPolyconic( double dfLat1, double dfLat2,
552 double dfCenterLong,
553 double dfFalseEasting,
554 double dfFalseNorthing );
555
557 OGRErr SetKrovak( double dfCenterLat, double dfCenterLong,
558 double dfAzimuth, double dfPseudoStdParallelLat,
559 double dfScale,
560 double dfFalseEasting, double dfFalseNorthing );
561
563 OGRErr SetLAEA( double dfCenterLat, double dfCenterLong,
564 double dfFalseEasting, double dfFalseNorthing );
565
567 OGRErr SetLCC( double dfStdP1, double dfStdP2,
568 double dfCenterLat, double dfCenterLong,
569 double dfFalseEasting, double dfFalseNorthing );
570
572 OGRErr SetLCC1SP( double dfCenterLat, double dfCenterLong,
573 double dfScale,
574 double dfFalseEasting, double dfFalseNorthing );
575
577 OGRErr SetLCCB( double dfStdP1, double dfStdP2,
578 double dfCenterLat, double dfCenterLong,
579 double dfFalseEasting, double dfFalseNorthing );
580
582 OGRErr SetMC( double dfCenterLat, double dfCenterLong,
583 double dfFalseEasting, double dfFalseNorthing );
584
586 OGRErr SetMercator( double dfCenterLat, double dfCenterLong,
587 double dfScale,
588 double dfFalseEasting, double dfFalseNorthing );
589
591 OGRErr SetMercator2SP( double dfStdP1,
592 double dfCenterLat, double dfCenterLong,
593 double dfFalseEasting, double dfFalseNorthing );
594
596 OGRErr SetMollweide( double dfCentralMeridian,
597 double dfFalseEasting, double dfFalseNorthing );
598
600 OGRErr SetNZMG( double dfCenterLat, double dfCenterLong,
601 double dfFalseEasting, double dfFalseNorthing );
602
604 OGRErr SetOS( double dfOriginLat, double dfCMeridian,
605 double dfScale,
606 double dfFalseEasting,double dfFalseNorthing);
607
609 OGRErr SetOrthographic( double dfCenterLat, double dfCenterLong,
610 double dfFalseEasting,double dfFalseNorthing);
611
613 OGRErr SetPolyconic( double dfCenterLat, double dfCenterLong,
614 double dfFalseEasting, double dfFalseNorthing );
615
617 OGRErr SetPS( double dfCenterLat, double dfCenterLong,
618 double dfScale,
619 double dfFalseEasting, double dfFalseNorthing);
620
622 OGRErr SetRobinson( double dfCenterLong,
623 double dfFalseEasting, double dfFalseNorthing );
624
626 OGRErr SetSinusoidal( double dfCenterLong,
627 double dfFalseEasting, double dfFalseNorthing );
628
630 OGRErr SetStereographic( double dfCenterLat, double dfCenterLong,
631 double dfScale,
632 double dfFalseEasting,double dfFalseNorthing);
633
635 OGRErr SetSOC( double dfLatitudeOfOrigin, double dfCentralMeridian,
636 double dfFalseEasting, double dfFalseNorthing );
637
639 OGRErr SetTM( double dfCenterLat, double dfCenterLong,
640 double dfScale,
641 double dfFalseEasting, double dfFalseNorthing );
642
644 OGRErr SetTMVariant( const char *pszVariantName,
645 double dfCenterLat, double dfCenterLong,
646 double dfScale,
647 double dfFalseEasting, double dfFalseNorthing );
648
650 OGRErr SetTMG( double dfCenterLat, double dfCenterLong,
651 double dfFalseEasting, double dfFalseNorthing );
652
654 OGRErr SetTMSO( double dfCenterLat, double dfCenterLong,
655 double dfScale,
656 double dfFalseEasting, double dfFalseNorthing );
657
659 OGRErr SetTPED( double dfLat1, double dfLong1,
660 double dfLat2, double dfLong2,
661 double dfFalseEasting, double dfFalseNorthing );
662
664 OGRErr SetVDG( double dfCenterLong,
665 double dfFalseEasting, double dfFalseNorthing );
666
668 OGRErr SetUTM( int nZone, int bNorth = TRUE );
669 int GetUTMZone( int *pbNorth = nullptr ) const;
670
672 OGRErr SetWagner( int nVariation, double dfCenterLat,
673 double dfFalseEasting, double dfFalseNorthing );
674
676 OGRErr SetQSC(double dfCenterLat, double dfCenterLong);
677
679 OGRErr SetSCH( double dfPegLat, double dfPegLong,
680 double dfPegHeading, double dfPegHgt);
681
683 OGRErr SetVerticalPerspective( double dfTopoOriginLat,
684 double dfTopoOriginLon,
685 double dfTopoOriginHeight,
686 double dfViewPointHeight,
687 double dfFalseEasting,
688 double dfFalseNorthing);
689
691 OGRErr SetDerivedGeogCRSWithPoleRotationGRIBConvention(
692 const char* pszCRSName,
693 double dfSouthPoleLat,
694 double dfSouthPoleLon,
695 double dfAxisRotation );
696
698 OGRErr SetDerivedGeogCRSWithPoleRotationNetCDFCFConvention(
699 const char* pszCRSName,
700 double dfGridNorthPoleLat,
701 double dfGridNorthPoleLon,
702 double dfNorthPoleGridLon );
703
705 OGRErr SetStatePlane( int nZone, int bNAD83 = TRUE,
706 const char *pszOverrideUnitName = nullptr,
707 double dfOverrideUnit = 0.0 );
708
710 OGRErr ImportFromESRIStatePlaneWKT(
711 int nCode, const char* pszDatumName, const char* pszUnitsName,
712 int nPCSCode, const char* pszCRSName = nullptr );
713
715 OGRErr ImportFromESRIWisconsinWKT(
716 const char* pszPrjName, double dfCentralMeridian, double dfLatOfOrigin,
717 const char* pszUnitsName, const char* pszCRSName = nullptr );
718
720 void UpdateCoordinateSystemFromGeogCRS();
723 static OGRSpatialReference* GetWGS84SRS();
724
729 { return reinterpret_cast<OGRSpatialReferenceH>(poSRS); }
730
735 { return reinterpret_cast<OGRSpatialReference*>(hSRS); }
736
737};
738
739/************************************************************************/
740/* OGRCoordinateTransformation */
741/* */
742/* This is really just used as a base class for a private */
743/* implementation. */
744/************************************************************************/
745
756{
757public:
759
760 static void DestroyCT(OGRCoordinateTransformation* poCT);
761
762 // From CT_CoordinateTransformation
763
766
769
771 virtual bool GetEmitErrors() const { return false; }
772
774 virtual void SetEmitErrors(bool /*bEmitErrors*/) {}
775
776 // From CT_MathTransform
777
793 int Transform( int nCount,
794 double *x, double *y, double *z = nullptr,
795 int *pabSuccess = nullptr );
796
813 virtual int Transform( int nCount,
814 double *x, double *y,
815 double *z, double *t,
816 int *pabSuccess ) = 0;
817
835 virtual int TransformWithErrorCodes( int nCount,
836 double *x, double *y,
837 double *z, double *t,
838 int *panErrorCodes );
839
872 virtual int TransformBounds( const double xmin,
873 const double ymin,
874 const double xmax,
875 const double ymax,
876 double* out_xmin,
877 double* out_ymin,
878 double* out_xmax,
879 double* out_ymax,
880 const int densify_pts )
881 {
882 (void)xmin;
883 (void)xmax;
884 (void)ymin;
885 (void)ymax;
886 (void)densify_pts;
887 *out_xmin = HUGE_VAL;
888 *out_ymin = HUGE_VAL;
889 *out_xmax = HUGE_VAL;
890 *out_ymax = HUGE_VAL;
891 CPLError(CE_Failure, CPLE_AppDefined, "TransformBounds not implemented.");
892 return false;
893 }
894
899 { return reinterpret_cast<OGRCoordinateTransformationH>(poCT); }
900
905 { return reinterpret_cast<OGRCoordinateTransformation*>(hCT); }
906
910 virtual OGRCoordinateTransformation* Clone() const = 0;
911
922};
923
926 const OGRSpatialReference *poTarget );
927
928
936{
938private:
939 friend class OGRProjCT;
940 struct Private;
941 std::unique_ptr<Private> d;
944public:
949
950 bool SetAreaOfInterest(double dfWestLongitudeDeg,
951 double dfSouthLatitudeDeg,
952 double dfEastLongitudeDeg,
953 double dfNorthLatitudeDeg);
954 bool SetDesiredAccuracy(double dfAccuracy);
955 bool SetBallparkAllowed(bool bAllowBallpark);
956
957 bool SetCoordinateOperation(const char* pszCT, bool bReverseCT);
959 void SetSourceCenterLong(double dfCenterLong);
960 void SetTargetCenterLong(double dfCenterLong);
962};
963
964
967 const OGRSpatialReference *poTarget,
968 const OGRCoordinateTransformationOptions& options );
969
970#endif /* ndef OGR_SPATIALREF_H_INCLUDED */
Convenient string class based on std::string.
Definition: cpl_string.h:321
Interface for transforming between coordinate systems.
Definition: ogr_spatialref.h:756
virtual OGRSpatialReference * GetSourceCS()=0
Fetch internal source coordinate system.
virtual void SetEmitErrors(bool)
Set if the transformer must emit CPLError.
Definition: ogr_spatialref.h:774
int Transform(int nCount, double *x, double *y, double *z=nullptr, int *pabSuccess=nullptr)
Transform points from source to destination space.
virtual OGRSpatialReference * GetTargetCS()=0
Fetch internal target coordinate system.
virtual int TransformWithErrorCodes(int nCount, double *x, double *y, double *z, double *t, int *panErrorCodes)
Transform points from source to destination space.
virtual OGRCoordinateTransformation * GetInverse() const =0
Return a coordinate transformation that performs the inverse transformation of the current one.
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:872
virtual bool GetEmitErrors() const
Whether the transformer will emit CPLError.
Definition: ogr_spatialref.h:771
virtual int Transform(int nCount, double *x, double *y, double *z, double *t, int *pabSuccess)=0
Transform points from source to destination space.
static OGRCoordinateTransformation * FromHandle(OGRCoordinateTransformationH hCT)
Convert a OGRCoordinateTransformationH to a OGRCoordinateTransformation*.
Definition: ogr_spatialref.h:904
static OGRCoordinateTransformationH ToHandle(OGRCoordinateTransformation *poCT)
Convert a OGRCoordinateTransformation* to a OGRCoordinateTransformationH.
Definition: ogr_spatialref.h:898
virtual OGRCoordinateTransformation * Clone() const =0
Clone.
This class represents an OpenGIS Spatial Reference System, and contains methods for converting betwee...
Definition: ogr_spatialref.h:158
static OGRSpatialReferenceH ToHandle(OGRSpatialReference *poSRS)
Convert a OGRSpatialReference* to a OGRSpatialReferenceH.
Definition: ogr_spatialref.h:728
static OGRSpatialReference * FromHandle(OGRSpatialReferenceH hSRS)
Convert a OGRSpatialReferenceH to a OGRSpatialReference*.
Definition: ogr_spatialref.h:734
Objects of this class are used to represent value nodes in the parsed representation of the WKT SRS f...
Definition: ogr_spatialref.h:67
int GetChildCount() const
Get number of children nodes.
Definition: ogr_spatialref.h:88
const char * GetValue() const
Fetch value string for this node.
Definition: ogr_spatialref.h:102
int IsLeafNode() const
Return whether this is a leaf node.
Definition: ogr_spatialref.h:86
#define CPLE_AppDefined
Application defined error.
Definition: cpl_error.h:99
void CPLError(CPLErr eErrClass, CPLErrorNum err_no, const char *fmt,...)
Report an error.
Definition: cpl_error.cpp:310
#define CPL_DISALLOW_COPY_ASSIGN(ClassName)
Helper to remove the copy and assignment constructors so that the compiler will not generate the defa...
Definition: cpl_port.h:930
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition: cpl_port.h:1056
Various convenience functions for working with strings and string lists.
void * OGRCoordinateTransformationH
Opaque type for a coordinate transformation object.
Definition: ogr_api.h:82
void * OGRSpatialReferenceH
Opaque type for a spatial reference system.
Definition: ogr_api.h:80
int OGRErr
Type for a OGR error.
Definition: ogr_core.h:341
#define USGS_ANGLE_PACKEDDMS
Angle is in packed degree minute second.
Definition: ogr_spatialref.h:228
OGRCoordinateTransformation * OGRCreateCoordinateTransformation(const OGRSpatialReference *poSource, const OGRSpatialReference *poTarget)
Create transformation object.
Definition: ogrct.cpp:869
C spatial reference system services and defines.
OSRAxisMappingStrategy
Data axis to CRS axis mapping strategy.
Definition: ogr_srs_api.h:670
OGRAxisOrientation
Axis orientations (corresponds to CS_AxisOrientationEnum).
Definition: ogr_srs_api.h:48
Context for coordinate transformation.
Definition: ogr_spatialref.h:936
Listener that is notified of modification to nodes.
Definition: ogr_spatialref.h:71
virtual void notifyChange(OGR_SRSNode *)=0
Method triggered when a node is modified.