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);
88 return nChildren == 0;
103 int FindChild(
const char *)
const;
104 void DestroyChild(
int);
105 void ClearChildren();
106 void StripNodes(
const char *);
112 void SetValue(
const char *);
114 void MakeValueSafe();
118 OGRErr importFromWkt(
char **)
120 CPL_WARN_DEPRECATED(
"Use importFromWkt(const char**)")
123 OGRErr importFromWkt(
const char **);
124 OGRErr exportToWkt(
char **)
const;
125 OGRErr exportToPrettyWkt(
char **,
int = 1)
const;
135 int NeedsQuoting()
const;
136 OGRErr importFromWkt(
const char **,
int nRecLevel,
int *pnNodes);
138 std::weak_ptr<Listener> m_listener{};
169 std::unique_ptr<Private> d;
171 void GetNormInfo()
const;
174 OGRErr importFromURNPart(
const char *pszAuthority,
const char *pszCode,
177 static CPLString lookupInDict(
const char *pszDictFile,
const char *pszCode);
179 OGRErr GetWKT2ProjectionMethod(
const char **ppszMethodName,
180 const char **ppszMethodAuthName =
nullptr,
181 const char **ppszMethodCode =
nullptr)
const;
197 int GetReferenceCount()
const;
200 const char *GetName()
const;
206 OGRErr exportToWkt(
char **)
const;
207 OGRErr exportToWkt(
char **ppszWKT,
const char *
const *papszOptions)
const;
208 OGRErr exportToPrettyWkt(
char **,
int = FALSE)
const;
210 OGRErr exportToPROJJSON(
char **,
const char *
const *papszOptions)
const;
211 OGRErr exportToProj4(
char **)
const;
212 OGRErr exportToPCI(
char **,
char **,
double **)
const;
213 OGRErr exportToUSGS(
long *,
long *,
double **,
long *)
const;
214 OGRErr exportToXML(
char **,
const char * =
nullptr)
const;
215 OGRErr exportToPanorama(
long *,
long *,
long *,
long *,
double *)
const;
216 OGRErr exportVertCSToPanorama(
int *)
const;
217 OGRErr exportToERM(
char *pszProj,
char *pszDatum,
char *pszUnits);
218 OGRErr exportToMICoordSys(
char **)
const;
220 OGRErr importFromWkt(
char **)
223 "Use importFromWkt(const char**) or importFromWkt(const char*)")
227 OGRErr importFromWkt(
const char **);
232 OGRErr importFromWkt(
const char *);
233 OGRErr importFromProj4(
const char *);
234 OGRErr importFromEPSG(
int);
235 OGRErr importFromEPSGA(
int);
236 OGRErr importFromESRI(
char **);
237 OGRErr importFromPCI(
const char *,
const char * =
nullptr,
238 const double * =
nullptr);
240 #define USGS_ANGLE_DECIMALDEGREES 0
241 #define USGS_ANGLE_PACKEDDMS \
243 #define USGS_ANGLE_RADIANS 2
244 OGRErr importFromUSGS(long iProjSys, long iZone, double *padfPrjParams,
247 OGRErr importFromPanorama(
long,
long,
long,
double *,
bool bNorth =
true);
248 OGRErr importVertCSFromPanorama(
int);
249 OGRErr importFromOzi(
const char *
const *papszLines);
250 OGRErr importFromWMSAUTO(
const char *pszAutoDef);
251 OGRErr importFromXML(
const char *);
252 OGRErr importFromDict(
const char *pszDict,
const char *pszCode);
253 OGRErr importFromURN(
const char *);
254 OGRErr importFromCRSURL(
const char *);
255 OGRErr importFromERM(
const char *pszProj,
const char *pszDatum,
256 const char *pszUnits);
257 OGRErr importFromUrl(
const char *);
258 OGRErr importFromMICoordSys(
const char *);
264 convertToOtherProjection(
const char *pszTargetProjection,
265 const char *
const *papszOptions =
nullptr)
const;
270 bool StripTOWGS84IfKnownDatumAndAllowed();
271 bool StripTOWGS84IfKnownDatum();
273 int EPSGTreatsAsLatLong()
const;
274 int EPSGTreatsAsNorthingEasting()
const;
275 int GetAxesCount()
const;
276 const char *GetAxis(
const char *pszTargetKey,
int iAxis,
278 double *pdfConvFactor =
nullptr)
const;
279 OGRErr SetAxes(
const char *pszTargetKey,
const char *pszXAxisName,
281 const char *pszYAxisName,
286 const std::vector<int> &GetDataAxisToSRSAxisMapping()
const;
287 OGRErr SetDataAxisToSRSAxisMapping(
const std::vector<int> &mapping);
298 const OGR_SRSNode *GetAttrNode(
const char *)
const;
299 const char *GetAttrValue(
const char *,
int = 0)
const;
301 OGRErr SetNode(
const char *,
const char *);
303 OGRErr SetNode(
const char *,
double);
306 SetLinearUnitsAndUpdateParameters(
const char *pszName,
double dfInMeters,
307 const char *pszUnitAuthority =
nullptr,
308 const char *pszUnitCode =
nullptr);
309 OGRErr SetLinearUnits(
const char *pszName,
double dfInMeters);
310 OGRErr SetTargetLinearUnits(
const char *pszTargetKey,
const char *pszName,
312 const char *pszUnitAuthority =
nullptr,
313 const char *pszUnitCode =
nullptr);
315 double GetLinearUnits(
char **)
const
317 CPL_WARN_DEPRECATED(
"Use GetLinearUnits(const char**) instead")
320 double GetLinearUnits(
const char ** =
nullptr)
const;
322 double GetLinearUnits(std::nullptr_t)
const
324 return GetLinearUnits(
static_cast<const char **
>(
nullptr));
328 double GetTargetLinearUnits(
const char *pszTargetKey,
329 char **ppszRetName)
const
332 "Use GetTargetLinearUnits(const char*, const char**)")
335 double GetTargetLinearUnits(
const char *pszTargetKey,
336 const char **ppszRetName =
nullptr)
const;
338 double GetTargetLinearUnits(
const char *pszTargetKey, std::nullptr_t)
const
340 return GetTargetLinearUnits(pszTargetKey,
341 static_cast<const char **
>(
nullptr));
345 OGRErr SetAngularUnits(
const char *pszName,
double dfInRadians);
346 double GetAngularUnits(
char **)
const
348 CPL_WARN_DEPRECATED(
"Use GetAngularUnits(const char**) instead")
351 double GetAngularUnits(
const char ** =
nullptr)
const;
353 double GetAngularUnits(std::nullptr_t)
const
355 return GetAngularUnits(
static_cast<const char **
>(
nullptr));
359 double GetPrimeMeridian(
char **)
const
361 CPL_WARN_DEPRECATED(
"Use GetPrimeMeridian(const char**) instead")
364 double GetPrimeMeridian(
const char ** =
nullptr)
const;
366 double GetPrimeMeridian(std::nullptr_t)
const
368 return GetPrimeMeridian(
static_cast<const char **
>(
nullptr));
372 bool IsEmpty()
const;
373 int IsGeographic()
const;
374 int IsDerivedGeographic()
const;
375 int IsProjected()
const;
376 int IsGeocentric()
const;
377 bool IsDynamic()
const;
380 bool HasPointMotionOperation()
const;
383 int IsVertical()
const;
384 int IsCompound()
const;
387 const char *
const *papszOptions)
const;
391 const char *
const *papszOptions)
const;
394 OGRErr SetLocalCS(
const char *);
395 OGRErr SetProjCS(
const char *);
396 OGRErr SetProjection(
const char *);
397 OGRErr SetGeocCS(
const char *pszGeocName);
398 OGRErr SetGeogCS(
const char *pszGeogName,
const char *pszDatumName,
399 const char *pszEllipsoidName,
double dfSemiMajor,
400 double dfInvFlattening,
const char *pszPMName =
nullptr,
401 double dfPMOffset = 0.0,
const char *pszUnits =
nullptr,
402 double dfConvertToRadians = 0.0);
403 OGRErr SetWellKnownGeogCS(
const char *);
405 OGRErr SetVertCS(
const char *pszVertCSName,
const char *pszVertDatumName,
406 int nVertDatumClass = 2005);
407 OGRErr SetCompoundCS(
const char *pszName,
411 void SetCoordinateEpoch(
double dfCoordinateEpoch);
412 double GetCoordinateEpoch()
const;
415 OGRErr PromoteTo3D(
const char *pszName);
417 OGRErr DemoteTo2D(
const char *pszName);
419 OGRErr SetFromUserInput(
const char *);
421 static const char *
const SET_FROM_USER_INPUT_LIMITATIONS[];
422 static CSLConstList SET_FROM_USER_INPUT_LIMITATIONS_get();
426 OGRErr SetTOWGS84(
double,
double,
double,
double = 0.0,
double = 0.0,
427 double = 0.0,
double = 0.0);
428 OGRErr GetTOWGS84(
double *padfCoef,
int nCoeff = 7)
const;
429 OGRErr AddGuessedTOWGS84();
431 double GetSemiMajor(
OGRErr * =
nullptr)
const;
432 double GetSemiMinor(
OGRErr * =
nullptr)
const;
433 double GetInvFlattening(
OGRErr * =
nullptr)
const;
434 double GetEccentricity()
const;
435 double GetSquaredEccentricity()
const;
437 OGRErr SetAuthority(
const char *pszTargetKey,
const char *pszAuthority,
440 OGRErr AutoIdentifyEPSG();
442 int **ppanMatchConfidence)
const;
444 FindBestMatch(
int nMinimumMatchConfidence = 90,
445 const char *pszPreferredAuthority =
"EPSG",
448 int GetEPSGGeogCS()
const;
450 const char *GetAuthorityCode(
const char *pszTargetKey)
const;
451 const char *GetAuthorityName(
const char *pszTargetKey)
const;
452 char *GetOGCURN()
const;
454 bool GetAreaOfUse(
double *pdfWestLongitudeDeg,
double *pdfSouthLatitudeDeg,
455 double *pdfEastLongitudeDeg,
double *pdfNorthLatitudeDeg,
456 const char **ppszAreaName)
const;
458 const char *GetExtension(
const char *pszTargetKey,
const char *pszName,
459 const char *pszDefault =
nullptr)
const;
460 OGRErr SetExtension(
const char *pszTargetKey,
const char *pszName,
461 const char *pszValue);
463 int FindProjParm(
const char *pszParameter,
465 OGRErr SetProjParm(
const char *,
double);
466 double GetProjParm(
const char *,
double = 0.0,
OGRErr * =
nullptr)
const;
468 OGRErr SetNormProjParm(
const char *,
double);
469 double GetNormProjParm(
const char *,
double = 0.0,
470 OGRErr * =
nullptr)
const;
472 static int IsAngularParameter(
const char *);
473 static int IsLongitudeParameter(
const char *);
474 static int IsLinearParameter(
const char *);
477 OGRErr SetACEA(
double dfStdP1,
double dfStdP2,
double dfCenterLat,
478 double dfCenterLong,
double dfFalseEasting,
479 double dfFalseNorthing);
482 OGRErr SetAE(
double dfCenterLat,
double dfCenterLong,
double dfFalseEasting,
483 double dfFalseNorthing);
486 OGRErr SetBonne(
double dfStdP1,
double dfCentralMeridian,
487 double dfFalseEasting,
double dfFalseNorthing);
490 OGRErr SetCEA(
double dfStdP1,
double dfCentralMeridian,
491 double dfFalseEasting,
double dfFalseNorthing);
494 OGRErr SetCS(
double dfCenterLat,
double dfCenterLong,
double dfFalseEasting,
495 double dfFalseNorthing);
498 OGRErr SetEC(
double dfStdP1,
double dfStdP2,
double dfCenterLat,
499 double dfCenterLong,
double dfFalseEasting,
500 double dfFalseNorthing);
503 OGRErr SetEckert(
int nVariation,
double dfCentralMeridian,
504 double dfFalseEasting,
double dfFalseNorthing);
507 OGRErr SetEckertIV(
double dfCentralMeridian,
double dfFalseEasting,
508 double dfFalseNorthing);
511 OGRErr SetEckertVI(
double dfCentralMeridian,
double dfFalseEasting,
512 double dfFalseNorthing);
515 OGRErr SetEquirectangular(
double dfCenterLat,
double dfCenterLong,
516 double dfFalseEasting,
double dfFalseNorthing);
518 OGRErr SetEquirectangular2(
double dfCenterLat,
double dfCenterLong,
519 double dfPseudoStdParallel1,
520 double dfFalseEasting,
double dfFalseNorthing);
523 OGRErr SetGEOS(
double dfCentralMeridian,
double dfSatelliteHeight,
524 double dfFalseEasting,
double dfFalseNorthing);
527 OGRErr SetGH(
double dfCentralMeridian,
double dfFalseEasting,
528 double dfFalseNorthing);
534 OGRErr SetGS(
double dfCentralMeridian,
double dfFalseEasting,
535 double dfFalseNorthing);
538 OGRErr SetGaussSchreiberTMercator(
double dfCenterLat,
double dfCenterLong,
539 double dfScale,
double dfFalseEasting,
540 double dfFalseNorthing);
543 OGRErr SetGnomonic(
double dfCenterLat,
double dfCenterLong,
544 double dfFalseEasting,
double dfFalseNorthing);
547 OGRErr SetHOM(
double dfCenterLat,
double dfCenterLong,
double dfAzimuth,
548 double dfRectToSkew,
double dfScale,
double dfFalseEasting,
549 double dfFalseNorthing);
552 OGRErr SetHOM2PNO(
double dfCenterLat,
double dfLat1,
double dfLong1,
553 double dfLat2,
double dfLong2,
double dfScale,
554 double dfFalseEasting,
double dfFalseNorthing);
557 OGRErr SetHOMAC(
double dfCenterLat,
double dfCenterLong,
double dfAzimuth,
558 double dfRectToSkew,
double dfScale,
double dfFalseEasting,
559 double dfFalseNorthing);
562 OGRErr SetLOM(
double dfCenterLat,
double dfCenterLong,
double dfAzimuth,
563 double dfScale,
double dfFalseEasting,
564 double dfFalseNorthing);
567 OGRErr SetIWMPolyconic(
double dfLat1,
double dfLat2,
double dfCenterLong,
568 double dfFalseEasting,
double dfFalseNorthing);
571 OGRErr SetKrovak(
double dfCenterLat,
double dfCenterLong,
double dfAzimuth,
572 double dfPseudoStdParallelLat,
double dfScale,
573 double dfFalseEasting,
double dfFalseNorthing);
576 OGRErr SetLAEA(
double dfCenterLat,
double dfCenterLong,
577 double dfFalseEasting,
double dfFalseNorthing);
580 OGRErr SetLCC(
double dfStdP1,
double dfStdP2,
double dfCenterLat,
581 double dfCenterLong,
double dfFalseEasting,
582 double dfFalseNorthing);
585 OGRErr SetLCC1SP(
double dfCenterLat,
double dfCenterLong,
double dfScale,
586 double dfFalseEasting,
double dfFalseNorthing);
589 OGRErr SetLCCB(
double dfStdP1,
double dfStdP2,
double dfCenterLat,
590 double dfCenterLong,
double dfFalseEasting,
591 double dfFalseNorthing);
594 OGRErr SetMC(
double dfCenterLat,
double dfCenterLong,
double dfFalseEasting,
595 double dfFalseNorthing);
598 OGRErr SetMercator(
double dfCenterLat,
double dfCenterLong,
double dfScale,
599 double dfFalseEasting,
double dfFalseNorthing);
602 OGRErr SetMercator2SP(
double dfStdP1,
double dfCenterLat,
603 double dfCenterLong,
double dfFalseEasting,
604 double dfFalseNorthing);
607 OGRErr SetMollweide(
double dfCentralMeridian,
double dfFalseEasting,
608 double dfFalseNorthing);
611 OGRErr SetNZMG(
double dfCenterLat,
double dfCenterLong,
612 double dfFalseEasting,
double dfFalseNorthing);
615 OGRErr SetOS(
double dfOriginLat,
double dfCMeridian,
double dfScale,
616 double dfFalseEasting,
double dfFalseNorthing);
619 OGRErr SetOrthographic(
double dfCenterLat,
double dfCenterLong,
620 double dfFalseEasting,
double dfFalseNorthing);
623 OGRErr SetPolyconic(
double dfCenterLat,
double dfCenterLong,
624 double dfFalseEasting,
double dfFalseNorthing);
627 OGRErr SetPS(
double dfCenterLat,
double dfCenterLong,
double dfScale,
628 double dfFalseEasting,
double dfFalseNorthing);
631 OGRErr SetRobinson(
double dfCenterLong,
double dfFalseEasting,
632 double dfFalseNorthing);
635 OGRErr SetSinusoidal(
double dfCenterLong,
double dfFalseEasting,
636 double dfFalseNorthing);
639 OGRErr SetStereographic(
double dfCenterLat,
double dfCenterLong,
640 double dfScale,
double dfFalseEasting,
641 double dfFalseNorthing);
644 OGRErr SetSOC(
double dfLatitudeOfOrigin,
double dfCentralMeridian,
645 double dfFalseEasting,
double dfFalseNorthing);
648 OGRErr SetTM(
double dfCenterLat,
double dfCenterLong,
double dfScale,
649 double dfFalseEasting,
double dfFalseNorthing);
652 OGRErr SetTMVariant(
const char *pszVariantName,
double dfCenterLat,
653 double dfCenterLong,
double dfScale,
654 double dfFalseEasting,
double dfFalseNorthing);
657 OGRErr SetTMG(
double dfCenterLat,
double dfCenterLong,
658 double dfFalseEasting,
double dfFalseNorthing);
661 OGRErr SetTMSO(
double dfCenterLat,
double dfCenterLong,
double dfScale,
662 double dfFalseEasting,
double dfFalseNorthing);
665 OGRErr SetTPED(
double dfLat1,
double dfLong1,
double dfLat2,
double dfLong2,
666 double dfFalseEasting,
double dfFalseNorthing);
669 OGRErr SetVDG(
double dfCenterLong,
double dfFalseEasting,
670 double dfFalseNorthing);
673 OGRErr SetUTM(
int nZone,
int bNorth = TRUE);
674 int GetUTMZone(
int *pbNorth =
nullptr)
const;
677 OGRErr SetWagner(
int nVariation,
double dfCenterLat,
double dfFalseEasting,
678 double dfFalseNorthing);
681 OGRErr SetQSC(
double dfCenterLat,
double dfCenterLong);
684 OGRErr SetSCH(
double dfPegLat,
double dfPegLong,
double dfPegHeading,
689 SetVerticalPerspective(
double dfTopoOriginLat,
double dfTopoOriginLon,
690 double dfTopoOriginHeight,
double dfViewPointHeight,
691 double dfFalseEasting,
double dfFalseNorthing);
694 OGRErr SetDerivedGeogCRSWithPoleRotationGRIBConvention(
695 const char *pszCRSName,
double dfSouthPoleLat,
double dfSouthPoleLon,
696 double dfAxisRotation);
699 OGRErr SetDerivedGeogCRSWithPoleRotationNetCDFCFConvention(
700 const char *pszCRSName,
double dfGridNorthPoleLat,
701 double dfGridNorthPoleLon,
double dfNorthPoleGridLon);
704 OGRErr SetStatePlane(
int nZone,
int bNAD83 = TRUE,
705 const char *pszOverrideUnitName =
nullptr,
706 double dfOverrideUnit = 0.0);
709 OGRErr ImportFromESRIStatePlaneWKT(
int nCode,
const char *pszDatumName,
710 const char *pszUnitsName,
int nPCSCode,
711 const char *pszCRSName =
nullptr);
714 OGRErr ImportFromESRIWisconsinWKT(
const char *pszPrjName,
715 double dfCentralMeridian,
716 double dfLatOfOrigin,
717 const char *pszUnitsName,
718 const char *pszCRSName =
nullptr);
721 void UpdateCoordinateSystemFromGeogCRS();
744 struct CPL_DLL OGRSpatialReferenceReleaser
817 int Transform(
int nCount,
double *x,
double *y,
double *z =
nullptr,
818 int *pabSuccess =
nullptr);
838 virtual int Transform(
int nCount,
double *x,
double *y,
double *z,
839 double *t,
int *pabSuccess) = 0;
860 virtual int TransformWithErrorCodes(
int nCount,
double *x,
double *y,
861 double *z,
double *t,
901 const double xmax,
const double ymax,
902 double *out_xmin,
double *out_ymin,
903 double *out_xmax,
double *out_ymax,
904 const int densify_pts)
911 *out_xmin = HUGE_VAL;
912 *out_ymin = HUGE_VAL;
913 *out_xmax = HUGE_VAL;
914 *out_ymax = HUGE_VAL;
916 "TransformBounds not implemented.");
971 friend class OGRProjCT;
973 std::unique_ptr<Private> d;
984 bool SetAreaOfInterest(
double dfWestLongitudeDeg,
double dfSouthLatitudeDeg,
985 double dfEastLongitudeDeg,
986 double dfNorthLatitudeDeg);
987 bool SetDesiredAccuracy(
double dfAccuracy);
988 bool SetBallparkAllowed(
bool bAllowBallpark);
989 bool SetOnlyBest(
bool bOnlyBest);
991 bool SetCoordinateOperation(
const char *pszCT,
bool bReverseCT);
993 void SetSourceCenterLong(
double dfCenterLong);
994 void SetTargetCenterLong(
double dfCenterLong);
int GetChildCount() const
Definition: ogr_spatialref.h:91
OGRCoordinateTransformation * OGRCreateCoordinateTransformation(const OGRSpatialReference *poSource, const OGRSpatialReference *poTarget)
Create transformation object.
Definition: ogrct.cpp:935
void Release()
Decrements the reference count by one, and destroy if zero.
Definition: ogrspatialreference.cpp:1094
This class represents an OpenGIS Spatial Reference System, and contains methods for converting betwee...
Definition: ogr_spatialref.h:166
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:737
Convenient string class based on std::string.
Definition: cpl_string.h:311
static OGRSpatialReferenceH ToHandle(OGRSpatialReference *poSRS)
Convert a OGRSpatialReference* to a OGRSpatialReferenceH.
Definition: ogr_spatialref.h:729
OSRAxisMappingStrategy
Data axis to CRS axis mapping strategy.
Definition: ogr_srs_api.h:658
const char * GetValue() const
Definition: ogr_spatialref.h:108
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:1178
OGRAxisOrientation
Axis orientations (corresponds to CS_AxisOrientationEnum).
Definition: ogr_srs_api.h:50
void CPLError(CPLErr eErrClass, CPLErrorNum err_no, const char *fmt,...)
Report an error.
Definition: cpl_error.cpp:323
int OGRErr
Type for a OGR error.
Definition: ogr_core.h:378
#define USGS_ANGLE_PACKEDDMS
Angle is in packed degree minute second.
Definition: ogr_spatialref.h:241
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:1042
#define CPLE_AppDefined
Application defined error.
Definition: cpl_error.h:100