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
425 bool GetAreaOfUse( double* pdfWestLongitudeDeg,
426 double* pdfSouthLatitudeDeg,
427 double* pdfEastLongitudeDeg,
428 double* pdfNorthLatitudeDeg,
429 const char **ppszAreaName ) const;
430
431 const char *GetExtension( const char *pszTargetKey,
432 const char *pszName,
433 const char *pszDefault = nullptr ) const;
434 OGRErr SetExtension( const char *pszTargetKey,
435 const char *pszName,
436 const char *pszValue );
437
438 int FindProjParm( const char *pszParameter,
439 const OGR_SRSNode *poPROJCS=nullptr ) const;
440 OGRErr SetProjParm( const char *, double );
441 double GetProjParm( const char *, double =0.0, OGRErr* = nullptr ) const;
442
443 OGRErr SetNormProjParm( const char *, double );
444 double GetNormProjParm( const char *, double=0.0, OGRErr* =nullptr)const;
445
446 static int IsAngularParameter( const char * );
447 static int IsLongitudeParameter( const char * );
448 static int IsLinearParameter( const char * );
449
451 OGRErr SetACEA( double dfStdP1, double dfStdP2,
452 double dfCenterLat, double dfCenterLong,
453 double dfFalseEasting, double dfFalseNorthing );
454
456 OGRErr SetAE( double dfCenterLat, double dfCenterLong,
457 double dfFalseEasting, double dfFalseNorthing );
458
460 OGRErr SetBonne( double dfStdP1, double dfCentralMeridian,
461 double dfFalseEasting, double dfFalseNorthing );
462
464 OGRErr SetCEA( double dfStdP1, double dfCentralMeridian,
465 double dfFalseEasting, double dfFalseNorthing );
466
468 OGRErr SetCS( double dfCenterLat, double dfCenterLong,
469 double dfFalseEasting, double dfFalseNorthing );
470
472 OGRErr SetEC( double dfStdP1, double dfStdP2,
473 double dfCenterLat, double dfCenterLong,
474 double dfFalseEasting, double dfFalseNorthing );
475
477 OGRErr SetEckert( int nVariation, double dfCentralMeridian,
478 double dfFalseEasting, double dfFalseNorthing );
479
481 OGRErr SetEckertIV( double dfCentralMeridian,
482 double dfFalseEasting, double dfFalseNorthing );
483
485 OGRErr SetEckertVI( double dfCentralMeridian,
486 double dfFalseEasting, double dfFalseNorthing );
487
489 OGRErr SetEquirectangular(double dfCenterLat, double dfCenterLong,
490 double dfFalseEasting, double dfFalseNorthing );
492 OGRErr SetEquirectangular2( double dfCenterLat, double dfCenterLong,
493 double dfPseudoStdParallel1,
494 double dfFalseEasting, double dfFalseNorthing );
495
497 OGRErr SetGEOS( double dfCentralMeridian, double dfSatelliteHeight,
498 double dfFalseEasting, double dfFalseNorthing );
499
501 OGRErr SetGH( double dfCentralMeridian,
502 double dfFalseEasting, double dfFalseNorthing );
503
505 OGRErr SetIGH();
506
508 OGRErr SetGS( double dfCentralMeridian,
509 double dfFalseEasting, double dfFalseNorthing );
510
512 OGRErr SetGaussSchreiberTMercator(double dfCenterLat, double dfCenterLong,
513 double dfScale,
514 double dfFalseEasting, double dfFalseNorthing );
515
517 OGRErr SetGnomonic(double dfCenterLat, double dfCenterLong,
518 double dfFalseEasting, double dfFalseNorthing );
519
521 OGRErr SetHOM( double dfCenterLat, double dfCenterLong,
522 double dfAzimuth, double dfRectToSkew,
523 double dfScale,
524 double dfFalseEasting, double dfFalseNorthing );
525
527 OGRErr SetHOM2PNO( double dfCenterLat,
528 double dfLat1, double dfLong1,
529 double dfLat2, double dfLong2,
530 double dfScale,
531 double dfFalseEasting, double dfFalseNorthing );
532
534 OGRErr SetHOMAC( double dfCenterLat, double dfCenterLong,
535 double dfAzimuth, double dfRectToSkew,
536 double dfScale,
537 double dfFalseEasting, double dfFalseNorthing );
538
540 OGRErr SetLOM( double dfCenterLat, double dfCenterLong,
541 double dfAzimuth,
542 double dfScale,
543 double dfFalseEasting, double dfFalseNorthing );
544
546 OGRErr SetIWMPolyconic( double dfLat1, double dfLat2,
547 double dfCenterLong,
548 double dfFalseEasting,
549 double dfFalseNorthing );
550
552 OGRErr SetKrovak( double dfCenterLat, double dfCenterLong,
553 double dfAzimuth, double dfPseudoStdParallelLat,
554 double dfScale,
555 double dfFalseEasting, double dfFalseNorthing );
556
558 OGRErr SetLAEA( double dfCenterLat, double dfCenterLong,
559 double dfFalseEasting, double dfFalseNorthing );
560
562 OGRErr SetLCC( double dfStdP1, double dfStdP2,
563 double dfCenterLat, double dfCenterLong,
564 double dfFalseEasting, double dfFalseNorthing );
565
567 OGRErr SetLCC1SP( double dfCenterLat, double dfCenterLong,
568 double dfScale,
569 double dfFalseEasting, double dfFalseNorthing );
570
572 OGRErr SetLCCB( double dfStdP1, double dfStdP2,
573 double dfCenterLat, double dfCenterLong,
574 double dfFalseEasting, double dfFalseNorthing );
575
577 OGRErr SetMC( double dfCenterLat, double dfCenterLong,
578 double dfFalseEasting, double dfFalseNorthing );
579
581 OGRErr SetMercator( double dfCenterLat, double dfCenterLong,
582 double dfScale,
583 double dfFalseEasting, double dfFalseNorthing );
584
586 OGRErr SetMercator2SP( double dfStdP1,
587 double dfCenterLat, double dfCenterLong,
588 double dfFalseEasting, double dfFalseNorthing );
589
591 OGRErr SetMollweide( double dfCentralMeridian,
592 double dfFalseEasting, double dfFalseNorthing );
593
595 OGRErr SetNZMG( double dfCenterLat, double dfCenterLong,
596 double dfFalseEasting, double dfFalseNorthing );
597
599 OGRErr SetOS( double dfOriginLat, double dfCMeridian,
600 double dfScale,
601 double dfFalseEasting,double dfFalseNorthing);
602
604 OGRErr SetOrthographic( double dfCenterLat, double dfCenterLong,
605 double dfFalseEasting,double dfFalseNorthing);
606
608 OGRErr SetPolyconic( double dfCenterLat, double dfCenterLong,
609 double dfFalseEasting, double dfFalseNorthing );
610
612 OGRErr SetPS( double dfCenterLat, double dfCenterLong,
613 double dfScale,
614 double dfFalseEasting, double dfFalseNorthing);
615
617 OGRErr SetRobinson( double dfCenterLong,
618 double dfFalseEasting, double dfFalseNorthing );
619
621 OGRErr SetSinusoidal( double dfCenterLong,
622 double dfFalseEasting, double dfFalseNorthing );
623
625 OGRErr SetStereographic( double dfCenterLat, double dfCenterLong,
626 double dfScale,
627 double dfFalseEasting,double dfFalseNorthing);
628
630 OGRErr SetSOC( double dfLatitudeOfOrigin, double dfCentralMeridian,
631 double dfFalseEasting, double dfFalseNorthing );
632
634 OGRErr SetTM( double dfCenterLat, double dfCenterLong,
635 double dfScale,
636 double dfFalseEasting, double dfFalseNorthing );
637
639 OGRErr SetTMVariant( const char *pszVariantName,
640 double dfCenterLat, double dfCenterLong,
641 double dfScale,
642 double dfFalseEasting, double dfFalseNorthing );
643
645 OGRErr SetTMG( double dfCenterLat, double dfCenterLong,
646 double dfFalseEasting, double dfFalseNorthing );
647
649 OGRErr SetTMSO( double dfCenterLat, double dfCenterLong,
650 double dfScale,
651 double dfFalseEasting, double dfFalseNorthing );
652
654 OGRErr SetTPED( double dfLat1, double dfLong1,
655 double dfLat2, double dfLong2,
656 double dfFalseEasting, double dfFalseNorthing );
657
659 OGRErr SetVDG( double dfCenterLong,
660 double dfFalseEasting, double dfFalseNorthing );
661
663 OGRErr SetUTM( int nZone, int bNorth = TRUE );
664 int GetUTMZone( int *pbNorth = nullptr ) const;
665
667 OGRErr SetWagner( int nVariation, double dfCenterLat,
668 double dfFalseEasting, double dfFalseNorthing );
669
671 OGRErr SetQSC(double dfCenterLat, double dfCenterLong);
672
674 OGRErr SetSCH( double dfPegLat, double dfPegLong,
675 double dfPegHeading, double dfPegHgt);
676
678 OGRErr SetVerticalPerspective( double dfTopoOriginLat,
679 double dfTopoOriginLon,
680 double dfTopoOriginHeight,
681 double dfViewPointHeight,
682 double dfFalseEasting,
683 double dfFalseNorthing);
684
686 OGRErr SetDerivedGeogCRSWithPoleRotationGRIBConvention(
687 const char* pszCRSName,
688 double dfSouthPoleLat,
689 double dfSouthPoleLon,
690 double dfAxisRotation );
691
693 OGRErr SetDerivedGeogCRSWithPoleRotationNetCDFCFConvention(
694 const char* pszCRSName,
695 double dfGridNorthPoleLat,
696 double dfGridNorthPoleLon,
697 double dfNorthPoleGridLon );
698
700 OGRErr SetStatePlane( int nZone, int bNAD83 = TRUE,
701 const char *pszOverrideUnitName = nullptr,
702 double dfOverrideUnit = 0.0 );
703
705 OGRErr ImportFromESRIStatePlaneWKT(
706 int nCode, const char* pszDatumName, const char* pszUnitsName,
707 int nPCSCode, const char* pszCRSName = nullptr );
708
710 OGRErr ImportFromESRIWisconsinWKT(
711 const char* pszPrjName, double dfCentralMeridian, double dfLatOfOrigin,
712 const char* pszUnitsName, const char* pszCRSName = nullptr );
713
715 void UpdateCoordinateSystemFromGeogCRS();
718 static OGRSpatialReference* GetWGS84SRS();
719
723 static inline OGRSpatialReferenceH ToHandle(OGRSpatialReference* poSRS)
724 { return reinterpret_cast<OGRSpatialReferenceH>(poSRS); }
725
729 static inline OGRSpatialReference* FromHandle(OGRSpatialReferenceH hSRS)
730 { return reinterpret_cast<OGRSpatialReference*>(hSRS); }
731
732 };
733
734 /************************************************************************/
735 /* OGRCoordinateTransformation */
736 /* */
737 /* This is really just used as a base class for a private */
738 /* implementation. */
739 /************************************************************************/
740
750 class CPL_DLL OGRCoordinateTransformation
751 {
752 public:
753 virtual ~OGRCoordinateTransformation() {}
754
755 static void DestroyCT(OGRCoordinateTransformation* poCT);
756
757 // From CT_CoordinateTransformation
758
760 virtual OGRSpatialReference *GetSourceCS() = 0;
761
763 virtual OGRSpatialReference *GetTargetCS() = 0;
764
766 virtual bool GetEmitErrors() const { return false; }
767
769 virtual void SetEmitErrors(bool /*bEmitErrors*/) {}
770
771 // From CT_MathTransform
772
788 int Transform( int nCount,
789 double *x, double *y, double *z = nullptr,
790 int *pabSuccess = nullptr );
791
808 virtual int Transform( int nCount,
809 double *x, double *y,
810 double *z, double *t,
811 int *pabSuccess ) = 0;
812
830 virtual int TransformWithErrorCodes( int nCount,
831 double *x, double *y,
832 double *z, double *t,
833 int *panErrorCodes );
834
867 virtual int TransformBounds( const double xmin,
868 const double ymin,
869 const double xmax,
870 const double ymax,
871 double* out_xmin,
872 double* out_ymin,
873 double* out_xmax,
874 double* out_ymax,
875 const int densify_pts )
876 {
877 (void)xmin;
878 (void)xmax;
879 (void)ymin;
880 (void)ymax;
881 (void)densify_pts;
882 *out_xmin = HUGE_VAL;
883 *out_ymin = HUGE_VAL;
884 *out_xmax = HUGE_VAL;
885 *out_ymax = HUGE_VAL;
886 CPLError(CE_Failure, CPLE_AppDefined, "TransformBounds not implemented.");
887 return false;
888 }
889
893 static inline OGRCoordinateTransformationH ToHandle(OGRCoordinateTransformation* poCT)
894 { return reinterpret_cast<OGRCoordinateTransformationH>(poCT); }
895
899 static inline OGRCoordinateTransformation* FromHandle(OGRCoordinateTransformationH hCT)
900 { return reinterpret_cast<OGRCoordinateTransformation*>(hCT); }
901
905 virtual OGRCoordinateTransformation* Clone() const = 0;
906
916 virtual OGRCoordinateTransformation* GetInverse() const = 0;
917 };
918
919 OGRCoordinateTransformation CPL_DLL *
920 OGRCreateCoordinateTransformation( const OGRSpatialReference *poSource,
921 const OGRSpatialReference *poTarget );
922
923
930 struct CPL_DLL OGRCoordinateTransformationOptions
931 {
933 private:
934 friend class OGRProjCT;
935 struct Private;
936 std::unique_ptr<Private> d;
939 public:
940 OGRCoordinateTransformationOptions();
941 OGRCoordinateTransformationOptions(const OGRCoordinateTransformationOptions&);
942 OGRCoordinateTransformationOptions& operator= (const OGRCoordinateTransformationOptions&);
943 ~OGRCoordinateTransformationOptions();
944
945 bool SetAreaOfInterest(double dfWestLongitudeDeg,
946 double dfSouthLatitudeDeg,
947 double dfEastLongitudeDeg,
948 double dfNorthLatitudeDeg);
949 bool SetDesiredAccuracy(double dfAccuracy);
950 bool SetBallparkAllowed(bool bAllowBallpark);
951
952 bool SetCoordinateOperation(const char* pszCT, bool bReverseCT);
954 void SetSourceCenterLong(double dfCenterLong);
955 void SetTargetCenterLong(double dfCenterLong);
957 };
958
959
960 OGRCoordinateTransformation CPL_DLL *
961 OGRCreateCoordinateTransformation( const OGRSpatialReference *poSource,
962 const OGRSpatialReference *poTarget,
963 const OGRCoordinateTransformationOptions& options );
964
965 #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:930
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:867
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:893
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:729
CPLString
Convenient string class based on std::string.
Definition: cpl_string.h:332
OGRSpatialReference::ToHandle
static OGRSpatialReferenceH ToHandle(OGRSpatialReference *poSRS)
Convert a OGRSpatialReference* to a OGRSpatialReferenceH.
Definition: ogr_spatialref.h:723
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:769
CSLConstList
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition: cpl_port.h:1169
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:750
OGRCoordinateTransformation::FromHandle
static OGRCoordinateTransformation * FromHandle(OGRCoordinateTransformationH hCT)
Convert a OGRCoordinateTransformationH to a OGRCoordinateTransformation*.
Definition: ogr_spatialref.h:899
OGRErr
int OGRErr
Type for a OGR error.
Definition: ogr_core.h:318
OGRCoordinateTransformation::GetEmitErrors
virtual bool GetEmitErrors() const
Whether the transformer will emit CPLError.
Definition: ogr_spatialref.h:766
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:955
CPLE_AppDefined
#define CPLE_AppDefined
Application defined error.
Definition: cpl_error.h:99