Go to the documentation of this file.
32 #ifndef OGR_SPATIALREF_H_INCLUDED
33 #define OGR_SPATIALREF_H_INCLUDED
81 void RegisterListener(
const std::shared_ptr<Listener>& listener);
97 int FindChild(
const char * )
const;
98 void DestroyChild(
int );
100 void StripNodes(
const char * );
103 void SetValue(
const char * );
105 void MakeValueSafe();
109 OGRErr importFromWkt(
char ** )
111 CPL_WARN_DEPRECATED(
"Use importFromWkt(const char**)")
114 OGRErr importFromWkt(
const char ** );
115 OGRErr exportToWkt(
char ** )
const;
116 OGRErr exportToPrettyWkt(
char **,
int = 1)
const;
126 int NeedsQuoting()
const;
127 OGRErr importFromWkt(
const char **,
int nRecLevel,
int* pnNodes );
129 std::weak_ptr<Listener> m_listener{};
160 std::unique_ptr<Private> d;
162 void GetNormInfo()
const;
165 OGRErr importFromURNPart(
const char* pszAuthority,
169 static CPLString lookupInDict(
const char *pszDictFile,
170 const char *pszCode );
186 int GetReferenceCount()
const;
189 const char* GetName()
const;
195 OGRErr exportToWkt(
char ** )
const;
196 OGRErr exportToWkt(
char ** ppszWKT,
const char*
const* papszOptions )
const;
197 OGRErr exportToPrettyWkt(
char **,
int = FALSE)
const;
199 OGRErr exportToPROJJSON(
char **,
const char*
const* papszOptions )
const;
200 OGRErr exportToProj4(
char ** )
const;
201 OGRErr exportToPCI(
char **,
char **,
double ** )
const;
202 OGRErr exportToUSGS(
long *,
long *,
double **,
long * )
const;
203 OGRErr exportToXML(
char **,
const char * =
nullptr )
const;
204 OGRErr exportToPanorama(
long *,
long *,
long *,
long *,
206 OGRErr exportToERM(
char *pszProj,
char *pszDatum,
char *pszUnits );
207 OGRErr exportToMICoordSys(
char ** )
const;
210 OGRErr importFromWkt(
char ** )
212 CPL_WARN_DEPRECATED(
"Use importFromWkt(const char**) or importFromWkt(const char*)")
216 OGRErr importFromWkt(
const char ** );
221 OGRErr importFromWkt(
const char* );
222 OGRErr importFromProj4(
const char * );
223 OGRErr importFromEPSG(
int );
224 OGRErr importFromEPSGA(
int );
225 OGRErr importFromESRI(
char ** );
226 OGRErr importFromPCI(
const char *,
const char * =
nullptr,
227 double * =
nullptr );
229 #define USGS_ANGLE_DECIMALDEGREES 0
230 #define USGS_ANGLE_PACKEDDMS TRUE
231 #define USGS_ANGLE_RADIANS 2
232 OGRErr importFromUSGS( long iProjSys, long iZone,
233 double *padfPrjParams,
long iDatum,
235 OGRErr importFromPanorama(
long,
long,
long,
double* );
236 OGRErr importVertCSFromPanorama(
int );
237 OGRErr importFromOzi(
const char *
const* papszLines );
238 OGRErr importFromWMSAUTO(
const char *pszAutoDef );
239 OGRErr importFromXML(
const char * );
240 OGRErr importFromDict(
const char *pszDict,
const char *pszCode );
241 OGRErr importFromURN(
const char * );
242 OGRErr importFromCRSURL(
const char * );
243 OGRErr importFromERM(
const char *pszProj,
const char *pszDatum,
244 const char *pszUnits );
245 OGRErr importFromUrl(
const char * );
246 OGRErr importFromMICoordSys(
const char * );
252 const char* pszTargetProjection,
253 const char*
const* papszOptions =
nullptr )
const;
258 bool StripTOWGS84IfKnownDatumAndAllowed();
259 bool StripTOWGS84IfKnownDatum();
261 int EPSGTreatsAsLatLong()
const;
262 int EPSGTreatsAsNorthingEasting()
const;
263 int GetAxesCount()
const;
264 const char *GetAxis(
const char *pszTargetKey,
int iAxis,
266 double* pdfConvFactor =
nullptr )
const;
267 OGRErr SetAxes(
const char *pszTargetKey,
268 const char *pszXAxisName,
270 const char *pszYAxisName,
275 const std::vector<int>& GetDataAxisToSRSAxisMapping()
const;
276 OGRErr SetDataAxisToSRSAxisMapping(
const std::vector<int>& mapping);
287 const OGR_SRSNode *GetAttrNode(
const char *)
const;
288 const char *GetAttrValue(
const char *,
int = 0)
const;
290 OGRErr SetNode(
const char *,
const char * );
291 OGRErr SetNode(
const char *,
double );
293 OGRErr SetLinearUnitsAndUpdateParameters(
const char *pszName,
295 const char *pszUnitAuthority =
nullptr,
296 const char *pszUnitCode =
nullptr );
297 OGRErr SetLinearUnits(
const char *pszName,
double dfInMeters );
298 OGRErr SetTargetLinearUnits(
const char *pszTargetKey,
301 const char *pszUnitAuthority =
nullptr,
302 const char *pszUnitCode =
nullptr);
304 double GetLinearUnits(
char ** )
const
306 CPL_WARN_DEPRECATED(
"Use GetLinearUnits(const char**) instead")
309 double GetLinearUnits(
const char ** =
nullptr )
const;
311 double GetLinearUnits( std::nullptr_t )
const
312 {
return GetLinearUnits(
static_cast<const char**
>(
nullptr) ); }
315 double GetTargetLinearUnits(
const char *pszTargetKey,
316 char ** ppszRetName )
const
318 CPL_WARN_DEPRECATED(
"Use GetTargetLinearUnits(const char*, const char**)")
321 double GetTargetLinearUnits(
const char *pszTargetKey,
322 const char ** ppszRetName =
nullptr )
const;
324 double GetTargetLinearUnits(
const char *pszTargetKey, std::nullptr_t )
const
325 {
return GetTargetLinearUnits( pszTargetKey,
static_cast<const char**
>(
nullptr) ); }
328 OGRErr SetAngularUnits(
const char *pszName,
double dfInRadians );
329 double GetAngularUnits(
char ** )
const
331 CPL_WARN_DEPRECATED(
"Use GetAngularUnits(const char**) instead")
334 double GetAngularUnits(
const char ** =
nullptr )
const;
336 double GetAngularUnits( std::nullptr_t )
const
337 {
return GetAngularUnits(
static_cast<const char**
>(
nullptr) ); }
340 double GetPrimeMeridian(
char ** )
const
342 CPL_WARN_DEPRECATED(
"Use GetPrimeMeridian(const char**) instead")
345 double GetPrimeMeridian(
const char ** =
nullptr )
const;
347 double GetPrimeMeridian( std::nullptr_t )
const
348 {
return GetPrimeMeridian(
static_cast<const char**
>(
nullptr) ); }
351 bool IsEmpty()
const;
352 int IsGeographic()
const;
353 int IsDerivedGeographic()
const;
354 int IsProjected()
const;
355 int IsGeocentric()
const;
356 bool IsDynamic()
const;
358 int IsVertical()
const;
359 int IsCompound()
const;
362 const char*
const * papszOptions )
const;
366 const char*
const * papszOptions )
const;
369 OGRErr SetLocalCS(
const char * );
370 OGRErr SetProjCS(
const char * );
371 OGRErr SetProjection(
const char * );
372 OGRErr SetGeocCS(
const char * pszGeocName );
373 OGRErr SetGeogCS(
const char * pszGeogName,
374 const char * pszDatumName,
375 const char * pszEllipsoidName,
376 double dfSemiMajor,
double dfInvFlattening,
377 const char * pszPMName =
nullptr,
378 double dfPMOffset = 0.0,
379 const char * pszUnits =
nullptr,
380 double dfConvertToRadians = 0.0 );
381 OGRErr SetWellKnownGeogCS(
const char * );
383 OGRErr SetVertCS(
const char *pszVertCSName,
384 const char *pszVertDatumName,
385 int nVertDatumClass = 2005 );
386 OGRErr SetCompoundCS(
const char *pszName,
390 void SetCoordinateEpoch(
double dfCoordinateEpoch );
391 double GetCoordinateEpoch()
const;
394 OGRErr PromoteTo3D(
const char* pszName );
396 OGRErr DemoteTo2D(
const char* pszName );
398 OGRErr SetFromUserInput(
const char * );
400 static const char*
const SET_FROM_USER_INPUT_LIMITATIONS[];
401 static CSLConstList SET_FROM_USER_INPUT_LIMITATIONS_get();
405 OGRErr SetTOWGS84(
double,
double,
double,
406 double = 0.0,
double = 0.0,
double = 0.0,
408 OGRErr GetTOWGS84(
double *padfCoef,
int nCoeff = 7 )
const;
409 OGRErr AddGuessedTOWGS84();
411 double GetSemiMajor(
OGRErr * =
nullptr )
const;
412 double GetSemiMinor(
OGRErr * =
nullptr )
const;
413 double GetInvFlattening(
OGRErr * =
nullptr )
const;
414 double GetEccentricity()
const;
415 double GetSquaredEccentricity()
const;
417 OGRErr SetAuthority(
const char * pszTargetKey,
418 const char * pszAuthority,
421 OGRErr AutoIdentifyEPSG();
424 int** ppanMatchConfidence )
const;
426 const char* pszPreferredAuthority =
"EPSG",
429 int GetEPSGGeogCS()
const;
431 const char *GetAuthorityCode(
const char * pszTargetKey )
const;
432 const char *GetAuthorityName(
const char * pszTargetKey )
const;
433 char *GetOGCURN()
const;
435 bool GetAreaOfUse(
double* pdfWestLongitudeDeg,
436 double* pdfSouthLatitudeDeg,
437 double* pdfEastLongitudeDeg,
438 double* pdfNorthLatitudeDeg,
439 const char **ppszAreaName )
const;
441 const char *GetExtension(
const char *pszTargetKey,
443 const char *pszDefault =
nullptr )
const;
444 OGRErr SetExtension(
const char *pszTargetKey,
446 const char *pszValue );
448 int FindProjParm(
const char *pszParameter,
450 OGRErr SetProjParm(
const char *,
double );
451 double GetProjParm(
const char *,
double =0.0,
OGRErr* =
nullptr )
const;
453 OGRErr SetNormProjParm(
const char *,
double );
454 double GetNormProjParm(
const char *,
double=0.0,
OGRErr* =
nullptr)
const;
456 static int IsAngularParameter(
const char * );
457 static int IsLongitudeParameter(
const char * );
458 static int IsLinearParameter(
const char * );
461 OGRErr SetACEA(
double dfStdP1,
double dfStdP2,
462 double dfCenterLat,
double dfCenterLong,
463 double dfFalseEasting,
double dfFalseNorthing );
466 OGRErr SetAE(
double dfCenterLat,
double dfCenterLong,
467 double dfFalseEasting,
double dfFalseNorthing );
470 OGRErr SetBonne(
double dfStdP1,
double dfCentralMeridian,
471 double dfFalseEasting,
double dfFalseNorthing );
474 OGRErr SetCEA(
double dfStdP1,
double dfCentralMeridian,
475 double dfFalseEasting,
double dfFalseNorthing );
478 OGRErr SetCS(
double dfCenterLat,
double dfCenterLong,
479 double dfFalseEasting,
double dfFalseNorthing );
482 OGRErr SetEC(
double dfStdP1,
double dfStdP2,
483 double dfCenterLat,
double dfCenterLong,
484 double dfFalseEasting,
double dfFalseNorthing );
487 OGRErr SetEckert(
int nVariation,
double dfCentralMeridian,
488 double dfFalseEasting,
double dfFalseNorthing );
491 OGRErr SetEckertIV(
double dfCentralMeridian,
492 double dfFalseEasting,
double dfFalseNorthing );
495 OGRErr SetEckertVI(
double dfCentralMeridian,
496 double dfFalseEasting,
double dfFalseNorthing );
499 OGRErr SetEquirectangular(
double dfCenterLat,
double dfCenterLong,
500 double dfFalseEasting,
double dfFalseNorthing );
502 OGRErr SetEquirectangular2(
double dfCenterLat,
double dfCenterLong,
503 double dfPseudoStdParallel1,
504 double dfFalseEasting,
double dfFalseNorthing );
507 OGRErr SetGEOS(
double dfCentralMeridian,
double dfSatelliteHeight,
508 double dfFalseEasting,
double dfFalseNorthing );
511 OGRErr SetGH(
double dfCentralMeridian,
512 double dfFalseEasting,
double dfFalseNorthing );
518 OGRErr SetGS(
double dfCentralMeridian,
519 double dfFalseEasting,
double dfFalseNorthing );
522 OGRErr SetGaussSchreiberTMercator(
double dfCenterLat,
double dfCenterLong,
524 double dfFalseEasting,
double dfFalseNorthing );
527 OGRErr SetGnomonic(
double dfCenterLat,
double dfCenterLong,
528 double dfFalseEasting,
double dfFalseNorthing );
531 OGRErr SetHOM(
double dfCenterLat,
double dfCenterLong,
532 double dfAzimuth,
double dfRectToSkew,
534 double dfFalseEasting,
double dfFalseNorthing );
537 OGRErr SetHOM2PNO(
double dfCenterLat,
538 double dfLat1,
double dfLong1,
539 double dfLat2,
double dfLong2,
541 double dfFalseEasting,
double dfFalseNorthing );
544 OGRErr SetHOMAC(
double dfCenterLat,
double dfCenterLong,
545 double dfAzimuth,
double dfRectToSkew,
547 double dfFalseEasting,
double dfFalseNorthing );
550 OGRErr SetLOM(
double dfCenterLat,
double dfCenterLong,
553 double dfFalseEasting,
double dfFalseNorthing );
556 OGRErr SetIWMPolyconic(
double dfLat1,
double dfLat2,
558 double dfFalseEasting,
559 double dfFalseNorthing );
562 OGRErr SetKrovak(
double dfCenterLat,
double dfCenterLong,
563 double dfAzimuth,
double dfPseudoStdParallelLat,
565 double dfFalseEasting,
double dfFalseNorthing );
568 OGRErr SetLAEA(
double dfCenterLat,
double dfCenterLong,
569 double dfFalseEasting,
double dfFalseNorthing );
572 OGRErr SetLCC(
double dfStdP1,
double dfStdP2,
573 double dfCenterLat,
double dfCenterLong,
574 double dfFalseEasting,
double dfFalseNorthing );
577 OGRErr SetLCC1SP(
double dfCenterLat,
double dfCenterLong,
579 double dfFalseEasting,
double dfFalseNorthing );
582 OGRErr SetLCCB(
double dfStdP1,
double dfStdP2,
583 double dfCenterLat,
double dfCenterLong,
584 double dfFalseEasting,
double dfFalseNorthing );
587 OGRErr SetMC(
double dfCenterLat,
double dfCenterLong,
588 double dfFalseEasting,
double dfFalseNorthing );
591 OGRErr SetMercator(
double dfCenterLat,
double dfCenterLong,
593 double dfFalseEasting,
double dfFalseNorthing );
596 OGRErr SetMercator2SP(
double dfStdP1,
597 double dfCenterLat,
double dfCenterLong,
598 double dfFalseEasting,
double dfFalseNorthing );
601 OGRErr SetMollweide(
double dfCentralMeridian,
602 double dfFalseEasting,
double dfFalseNorthing );
605 OGRErr SetNZMG(
double dfCenterLat,
double dfCenterLong,
606 double dfFalseEasting,
double dfFalseNorthing );
609 OGRErr SetOS(
double dfOriginLat,
double dfCMeridian,
611 double dfFalseEasting,
double dfFalseNorthing);
614 OGRErr SetOrthographic(
double dfCenterLat,
double dfCenterLong,
615 double dfFalseEasting,
double dfFalseNorthing);
618 OGRErr SetPolyconic(
double dfCenterLat,
double dfCenterLong,
619 double dfFalseEasting,
double dfFalseNorthing );
622 OGRErr SetPS(
double dfCenterLat,
double dfCenterLong,
624 double dfFalseEasting,
double dfFalseNorthing);
627 OGRErr SetRobinson(
double dfCenterLong,
628 double dfFalseEasting,
double dfFalseNorthing );
631 OGRErr SetSinusoidal(
double dfCenterLong,
632 double dfFalseEasting,
double dfFalseNorthing );
635 OGRErr SetStereographic(
double dfCenterLat,
double dfCenterLong,
637 double dfFalseEasting,
double dfFalseNorthing);
640 OGRErr SetSOC(
double dfLatitudeOfOrigin,
double dfCentralMeridian,
641 double dfFalseEasting,
double dfFalseNorthing );
644 OGRErr SetTM(
double dfCenterLat,
double dfCenterLong,
646 double dfFalseEasting,
double dfFalseNorthing );
649 OGRErr SetTMVariant(
const char *pszVariantName,
650 double dfCenterLat,
double dfCenterLong,
652 double dfFalseEasting,
double dfFalseNorthing );
655 OGRErr SetTMG(
double dfCenterLat,
double dfCenterLong,
656 double dfFalseEasting,
double dfFalseNorthing );
659 OGRErr SetTMSO(
double dfCenterLat,
double dfCenterLong,
661 double dfFalseEasting,
double dfFalseNorthing );
664 OGRErr SetTPED(
double dfLat1,
double dfLong1,
665 double dfLat2,
double dfLong2,
666 double dfFalseEasting,
double dfFalseNorthing );
669 OGRErr SetVDG(
double dfCenterLong,
670 double dfFalseEasting,
double dfFalseNorthing );
673 OGRErr SetUTM(
int nZone,
int bNorth = TRUE );
674 int GetUTMZone(
int *pbNorth =
nullptr )
const;
677 OGRErr SetWagner(
int nVariation,
double dfCenterLat,
678 double dfFalseEasting,
double dfFalseNorthing );
681 OGRErr SetQSC(
double dfCenterLat,
double dfCenterLong);
684 OGRErr SetSCH(
double dfPegLat,
double dfPegLong,
685 double dfPegHeading,
double dfPegHgt);
688 OGRErr SetVerticalPerspective(
double dfTopoOriginLat,
689 double dfTopoOriginLon,
690 double dfTopoOriginHeight,
691 double dfViewPointHeight,
692 double dfFalseEasting,
693 double dfFalseNorthing);
696 OGRErr SetDerivedGeogCRSWithPoleRotationGRIBConvention(
697 const char* pszCRSName,
698 double dfSouthPoleLat,
699 double dfSouthPoleLon,
700 double dfAxisRotation );
703 OGRErr SetDerivedGeogCRSWithPoleRotationNetCDFCFConvention(
704 const char* pszCRSName,
705 double dfGridNorthPoleLat,
706 double dfGridNorthPoleLon,
707 double dfNorthPoleGridLon );
710 OGRErr SetStatePlane(
int nZone,
int bNAD83 = TRUE,
711 const char *pszOverrideUnitName =
nullptr,
712 double dfOverrideUnit = 0.0 );
715 OGRErr ImportFromESRIStatePlaneWKT(
716 int nCode,
const char* pszDatumName,
const char* pszUnitsName,
717 int nPCSCode,
const char* pszCRSName =
nullptr );
720 OGRErr ImportFromESRIWisconsinWKT(
721 const char* pszPrjName,
double dfCentralMeridian,
double dfLatOfOrigin,
722 const char* pszUnitsName,
const char* pszCRSName =
nullptr );
725 void UpdateCoordinateSystemFromGeogCRS();
798 int Transform(
int nCount,
799 double *x,
double *y,
double *z =
nullptr,
800 int *pabSuccess =
nullptr );
818 virtual int Transform(
int nCount,
819 double *x,
double *y,
820 double *z,
double *t,
821 int *pabSuccess ) = 0;
840 virtual int TransformWithErrorCodes(
int nCount,
841 double *x,
double *y,
842 double *z,
double *t,
843 int *panErrorCodes );
885 const int densify_pts )
892 *out_xmin = HUGE_VAL;
893 *out_ymin = HUGE_VAL;
894 *out_xmax = HUGE_VAL;
895 *out_ymax = HUGE_VAL;
944 friend class OGRProjCT;
946 std::unique_ptr<Private> d;
955 bool SetAreaOfInterest(
double dfWestLongitudeDeg,
956 double dfSouthLatitudeDeg,
957 double dfEastLongitudeDeg,
958 double dfNorthLatitudeDeg);
959 bool SetDesiredAccuracy(
double dfAccuracy);
960 bool SetBallparkAllowed(
bool bAllowBallpark);
962 bool SetCoordinateOperation(
const char* pszCT,
bool bReverseCT);
964 void SetSourceCenterLong(
double dfCenterLong);
965 void SetTargetCenterLong(
double dfCenterLong);
int GetChildCount() const
Definition: ogr_spatialref.h:88
OGRCoordinateTransformation * OGRCreateCoordinateTransformation(const OGRSpatialReference *poSource, const OGRSpatialReference *poTarget)
Create transformation object.
Definition: ogrct.cpp:864
This class represents an OpenGIS Spatial Reference System, and contains methods for converting betwee...
Definition: ogr_spatialref.h:157
int IsLeafNode() const
Return whether this is a leaf node.
Definition: ogr_spatialref.h:86
static OGRSpatialReference * FromHandle(OGRSpatialReferenceH hSRS)
Convert a OGRSpatialReferenceH to a OGRSpatialReference*.
Definition: ogr_spatialref.h:739
Convenient string class based on std::string.
Definition: cpl_string.h:320
static OGRSpatialReferenceH ToHandle(OGRSpatialReference *poSRS)
Convert a OGRSpatialReference* to a OGRSpatialReferenceH.
Definition: ogr_spatialref.h:733
OSRAxisMappingStrategy
Data axis to CRS axis mapping strategy.
Definition: ogr_srs_api.h:669
const char * GetValue() const
Definition: ogr_spatialref.h:102
void * OGRSpatialReferenceH
Opaque type for a spatial reference system.
Definition: ogr_api.h:81
Listener that is notified of modification to nodes.
Definition: ogr_spatialref.h:70
void * OGRCoordinateTransformationH
Opaque type for a coordinate transformation object.
Definition: ogr_api.h:83
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition: cpl_port.h:1056
OGRAxisOrientation
Axis orientations (corresponds to CS_AxisOrientationEnum).
Definition: ogr_srs_api.h:48
void CPLError(CPLErr eErrClass, CPLErrorNum err_no, const char *fmt,...)
Report an error.
Definition: cpl_error.cpp:309
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:230
Objects of this class are used to represent value nodes in the parsed representation of the WKT SRS f...
Definition: ogr_spatialref.h:66
#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
#define CPLE_AppDefined
Application defined error.
Definition: cpl_error.h:99