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;
104 int FindChild(
const char *)
const;
105 void DestroyChild(
int);
106 void ClearChildren();
107 void StripNodes(
const char *);
114 void SetValue(
const char *);
116 void MakeValueSafe();
120 OGRErr importFromWkt(
char **)
122 CPL_WARN_DEPRECATED(
"Use importFromWkt(const char**)")
125 OGRErr importFromWkt(
const char **);
126 OGRErr exportToWkt(
char **)
const;
127 OGRErr exportToPrettyWkt(
char **,
int = 1)
const;
137 int NeedsQuoting()
const;
138 OGRErr importFromWkt(
const char **,
int nRecLevel,
int *pnNodes);
140 std::weak_ptr<Listener> m_listener{};
171 std::unique_ptr<Private> d;
173 void GetNormInfo()
const;
176 OGRErr importFromURNPart(
const char *pszAuthority,
const char *pszCode,
179 static CPLString lookupInDict(
const char *pszDictFile,
const char *pszCode);
181 OGRErr GetWKT2ProjectionMethod(
const char **ppszMethodName,
182 const char **ppszMethodAuthName =
nullptr,
183 const char **ppszMethodCode =
nullptr)
const;
199 int GetReferenceCount()
const;
202 const char *GetName()
const;
208 OGRErr exportToWkt(
char **)
const;
209 OGRErr exportToWkt(
char **ppszWKT,
const char *
const *papszOptions)
const;
210 std::string exportToWkt(
const char *
const *papszOptions =
nullptr)
const;
211 OGRErr exportToPrettyWkt(
char **,
int = FALSE)
const;
213 OGRErr exportToPROJJSON(
char **,
const char *
const *papszOptions)
const;
214 OGRErr exportToProj4(
char **)
const;
215 OGRErr exportToPCI(
char **,
char **,
double **)
const;
216 OGRErr exportToUSGS(
long *,
long *,
double **,
long *)
const;
217 OGRErr exportToXML(
char **,
const char * =
nullptr)
const;
218 OGRErr exportToPanorama(
long *,
long *,
long *,
long *,
double *)
const;
219 OGRErr exportVertCSToPanorama(
int *)
const;
220 OGRErr exportToERM(
char *pszProj,
char *pszDatum,
char *pszUnits);
221 OGRErr exportToMICoordSys(
char **)
const;
222 OGRErr exportToCF1(
char **ppszGridMappingName,
char ***ppapszKeyValues,
225 OGRErr importFromWkt(
char **)
228 "Use importFromWkt(const char**) or importFromWkt(const char*)")
232 OGRErr importFromWkt(
const char **);
237 OGRErr importFromWkt(
const char *);
238 OGRErr importFromProj4(
const char *);
239 OGRErr importFromEPSG(
int);
240 OGRErr importFromEPSGA(
int);
241 OGRErr importFromESRI(
char **);
242 OGRErr importFromPCI(
const char *,
const char * =
nullptr,
243 const double * =
nullptr);
245 #define USGS_ANGLE_DECIMALDEGREES 0
246 #define USGS_ANGLE_PACKEDDMS \
248 #define USGS_ANGLE_RADIANS 2
249 OGRErr importFromUSGS(
long iProjSys,
long iZone,
double *padfPrjParams,
252 OGRErr importFromPanorama(
long,
long,
long,
double *,
bool bNorth =
true);
253 OGRErr importVertCSFromPanorama(
int);
254 OGRErr importFromOzi(
const char *
const *papszLines);
255 OGRErr importFromWMSAUTO(
const char *pszAutoDef);
256 OGRErr importFromXML(
const char *);
257 OGRErr importFromDict(
const char *pszDict,
const char *pszCode);
258 OGRErr importFromURN(
const char *);
259 OGRErr importFromCRSURL(
const char *);
260 OGRErr importFromERM(
const char *pszProj,
const char *pszDatum,
261 const char *pszUnits);
262 OGRErr importFromUrl(
const char *);
263 OGRErr importFromMICoordSys(
const char *);
270 convertToOtherProjection(
const char *pszTargetProjection,
271 const char *
const *papszOptions =
nullptr)
const;
276 bool StripTOWGS84IfKnownDatumAndAllowed();
277 bool StripTOWGS84IfKnownDatum();
279 int EPSGTreatsAsLatLong()
const;
280 int EPSGTreatsAsNorthingEasting()
const;
281 int GetAxesCount()
const;
282 const char *GetAxis(
const char *pszTargetKey,
int iAxis,
284 double *pdfConvFactor =
nullptr)
const;
285 OGRErr SetAxes(
const char *pszTargetKey,
const char *pszXAxisName,
287 const char *pszYAxisName,
292 const std::vector<int> &GetDataAxisToSRSAxisMapping()
const;
293 OGRErr SetDataAxisToSRSAxisMapping(
const std::vector<int> &mapping);
304 const OGR_SRSNode *GetAttrNode(
const char *)
const;
305 const char *GetAttrValue(
const char *,
int = 0)
const;
307 OGRErr SetNode(
const char *,
const char *);
309 OGRErr SetNode(
const char *,
double);
312 SetLinearUnitsAndUpdateParameters(
const char *pszName,
double dfInMeters,
313 const char *pszUnitAuthority =
nullptr,
314 const char *pszUnitCode =
nullptr);
315 OGRErr SetLinearUnits(
const char *pszName,
double dfInMeters);
316 OGRErr SetTargetLinearUnits(
const char *pszTargetKey,
const char *pszName,
318 const char *pszUnitAuthority =
nullptr,
319 const char *pszUnitCode =
nullptr);
321 double GetLinearUnits(
char **)
const
323 CPL_WARN_DEPRECATED(
"Use GetLinearUnits(const char**) instead")
326 double GetLinearUnits(
const char ** =
nullptr)
const;
329 double GetLinearUnits(std::nullptr_t)
const
331 return GetLinearUnits(
static_cast<const char **
>(
nullptr));
336 double GetTargetLinearUnits(
const char *pszTargetKey,
337 char **ppszRetName)
const
340 "Use GetTargetLinearUnits(const char*, const char**)")
343 double GetTargetLinearUnits(
const char *pszTargetKey,
344 const char **ppszRetName =
nullptr)
const;
347 double GetTargetLinearUnits(
const char *pszTargetKey, std::nullptr_t)
const
349 return GetTargetLinearUnits(pszTargetKey,
350 static_cast<const char **
>(
nullptr));
355 OGRErr SetAngularUnits(
const char *pszName,
double dfInRadians);
356 double GetAngularUnits(
char **)
const
358 CPL_WARN_DEPRECATED(
"Use GetAngularUnits(const char**) instead")
361 double GetAngularUnits(
const char ** =
nullptr)
const;
364 double GetAngularUnits(std::nullptr_t)
const
366 return GetAngularUnits(
static_cast<const char **
>(
nullptr));
371 double GetPrimeMeridian(
char **)
const
373 CPL_WARN_DEPRECATED(
"Use GetPrimeMeridian(const char**) instead")
376 double GetPrimeMeridian(
const char ** =
nullptr)
const;
379 double GetPrimeMeridian(std::nullptr_t)
const
381 return GetPrimeMeridian(
static_cast<const char **
>(
nullptr));
386 bool IsEmpty()
const;
387 int IsGeographic()
const;
388 int IsDerivedGeographic()
const;
389 int IsProjected()
const;
390 int IsDerivedProjected()
const;
391 int IsGeocentric()
const;
392 bool IsDynamic()
const;
395 bool HasPointMotionOperation()
const;
398 int IsVertical()
const;
399 int IsCompound()
const;
402 const char *
const *papszOptions)
const;
406 const char *
const *papszOptions)
const;
409 OGRErr SetLocalCS(
const char *);
410 OGRErr SetProjCS(
const char *);
411 OGRErr SetProjection(
const char *);
412 OGRErr SetGeocCS(
const char *pszGeocName);
413 OGRErr SetGeogCS(
const char *pszGeogName,
const char *pszDatumName,
414 const char *pszEllipsoidName,
double dfSemiMajor,
415 double dfInvFlattening,
const char *pszPMName =
nullptr,
416 double dfPMOffset = 0.0,
const char *pszUnits =
nullptr,
417 double dfConvertToRadians = 0.0);
418 OGRErr SetWellKnownGeogCS(
const char *);
420 OGRErr SetVertCS(
const char *pszVertCSName,
const char *pszVertDatumName,
421 int nVertDatumClass = 2005);
422 OGRErr SetCompoundCS(
const char *pszName,
426 void SetCoordinateEpoch(
double dfCoordinateEpoch);
427 double GetCoordinateEpoch()
const;
430 OGRErr PromoteTo3D(
const char *pszName);
432 OGRErr DemoteTo2D(
const char *pszName);
434 OGRErr SetFromUserInput(
const char *);
436 static const char *
const SET_FROM_USER_INPUT_LIMITATIONS[];
437 static CSLConstList SET_FROM_USER_INPUT_LIMITATIONS_get();
441 OGRErr SetTOWGS84(
double,
double,
double,
double = 0.0,
double = 0.0,
442 double = 0.0,
double = 0.0);
443 OGRErr GetTOWGS84(
double *padfCoef,
int nCoeff = 7)
const;
444 OGRErr AddGuessedTOWGS84();
446 double GetSemiMajor(
OGRErr * =
nullptr)
const;
447 double GetSemiMinor(
OGRErr * =
nullptr)
const;
448 double GetInvFlattening(
OGRErr * =
nullptr)
const;
449 double GetEccentricity()
const;
450 double GetSquaredEccentricity()
const;
452 OGRErr SetAuthority(
const char *pszTargetKey,
const char *pszAuthority,
455 OGRErr AutoIdentifyEPSG();
457 int **ppanMatchConfidence)
const;
459 FindBestMatch(
int nMinimumMatchConfidence = 90,
460 const char *pszPreferredAuthority =
"EPSG",
463 int GetEPSGGeogCS()
const;
465 const char *GetAuthorityCode(
const char *pszTargetKey)
const;
466 const char *GetAuthorityName(
const char *pszTargetKey)
const;
467 char *GetOGCURN()
const;
469 bool GetAreaOfUse(
double *pdfWestLongitudeDeg,
double *pdfSouthLatitudeDeg,
470 double *pdfEastLongitudeDeg,
double *pdfNorthLatitudeDeg,
471 const char **ppszAreaName)
const;
473 const char *GetExtension(
const char *pszTargetKey,
const char *pszName,
474 const char *pszDefault =
nullptr)
const;
475 OGRErr SetExtension(
const char *pszTargetKey,
const char *pszName,
476 const char *pszValue);
478 int FindProjParm(
const char *pszParameter,
480 OGRErr SetProjParm(
const char *,
double);
481 double GetProjParm(
const char *,
double = 0.0,
OGRErr * =
nullptr)
const;
483 OGRErr SetNormProjParm(
const char *,
double);
484 double GetNormProjParm(
const char *,
double = 0.0,
485 OGRErr * =
nullptr)
const;
487 static int IsAngularParameter(
const char *);
488 static int IsLongitudeParameter(
const char *);
489 static int IsLinearParameter(
const char *);
492 OGRErr SetACEA(
double dfStdP1,
double dfStdP2,
double dfCenterLat,
493 double dfCenterLong,
double dfFalseEasting,
494 double dfFalseNorthing);
497 OGRErr SetAE(
double dfCenterLat,
double dfCenterLong,
double dfFalseEasting,
498 double dfFalseNorthing);
501 OGRErr SetBonne(
double dfStdP1,
double dfCentralMeridian,
502 double dfFalseEasting,
double dfFalseNorthing);
505 OGRErr SetCEA(
double dfStdP1,
double dfCentralMeridian,
506 double dfFalseEasting,
double dfFalseNorthing);
509 OGRErr SetCS(
double dfCenterLat,
double dfCenterLong,
double dfFalseEasting,
510 double dfFalseNorthing);
513 OGRErr SetEC(
double dfStdP1,
double dfStdP2,
double dfCenterLat,
514 double dfCenterLong,
double dfFalseEasting,
515 double dfFalseNorthing);
518 OGRErr SetEckert(
int nVariation,
double dfCentralMeridian,
519 double dfFalseEasting,
double dfFalseNorthing);
522 OGRErr SetEckertIV(
double dfCentralMeridian,
double dfFalseEasting,
523 double dfFalseNorthing);
526 OGRErr SetEckertVI(
double dfCentralMeridian,
double dfFalseEasting,
527 double dfFalseNorthing);
530 OGRErr SetEquirectangular(
double dfCenterLat,
double dfCenterLong,
531 double dfFalseEasting,
double dfFalseNorthing);
533 OGRErr SetEquirectangular2(
double dfCenterLat,
double dfCenterLong,
534 double dfPseudoStdParallel1,
535 double dfFalseEasting,
double dfFalseNorthing);
538 OGRErr SetGEOS(
double dfCentralMeridian,
double dfSatelliteHeight,
539 double dfFalseEasting,
double dfFalseNorthing);
542 OGRErr SetGH(
double dfCentralMeridian,
double dfFalseEasting,
543 double dfFalseNorthing);
549 OGRErr SetGS(
double dfCentralMeridian,
double dfFalseEasting,
550 double dfFalseNorthing);
553 OGRErr SetGaussSchreiberTMercator(
double dfCenterLat,
double dfCenterLong,
554 double dfScale,
double dfFalseEasting,
555 double dfFalseNorthing);
558 OGRErr SetGnomonic(
double dfCenterLat,
double dfCenterLong,
559 double dfFalseEasting,
double dfFalseNorthing);
562 OGRErr SetHOM(
double dfCenterLat,
double dfCenterLong,
double dfAzimuth,
563 double dfRectToSkew,
double dfScale,
double dfFalseEasting,
564 double dfFalseNorthing);
567 OGRErr SetHOM2PNO(
double dfCenterLat,
double dfLat1,
double dfLong1,
568 double dfLat2,
double dfLong2,
double dfScale,
569 double dfFalseEasting,
double dfFalseNorthing);
572 OGRErr SetHOMAC(
double dfCenterLat,
double dfCenterLong,
double dfAzimuth,
573 double dfRectToSkew,
double dfScale,
double dfFalseEasting,
574 double dfFalseNorthing);
577 OGRErr SetLOM(
double dfCenterLat,
double dfCenterLong,
double dfAzimuth,
578 double dfScale,
double dfFalseEasting,
579 double dfFalseNorthing);
582 OGRErr SetIWMPolyconic(
double dfLat1,
double dfLat2,
double dfCenterLong,
583 double dfFalseEasting,
double dfFalseNorthing);
586 OGRErr SetKrovak(
double dfCenterLat,
double dfCenterLong,
double dfAzimuth,
587 double dfPseudoStdParallelLat,
double dfScale,
588 double dfFalseEasting,
double dfFalseNorthing);
591 OGRErr SetLAEA(
double dfCenterLat,
double dfCenterLong,
592 double dfFalseEasting,
double dfFalseNorthing);
595 OGRErr SetLCC(
double dfStdP1,
double dfStdP2,
double dfCenterLat,
596 double dfCenterLong,
double dfFalseEasting,
597 double dfFalseNorthing);
600 OGRErr SetLCC1SP(
double dfCenterLat,
double dfCenterLong,
double dfScale,
601 double dfFalseEasting,
double dfFalseNorthing);
604 OGRErr SetLCCB(
double dfStdP1,
double dfStdP2,
double dfCenterLat,
605 double dfCenterLong,
double dfFalseEasting,
606 double dfFalseNorthing);
609 OGRErr SetMC(
double dfCenterLat,
double dfCenterLong,
double dfFalseEasting,
610 double dfFalseNorthing);
613 OGRErr SetMercator(
double dfCenterLat,
double dfCenterLong,
double dfScale,
614 double dfFalseEasting,
double dfFalseNorthing);
617 OGRErr SetMercator2SP(
double dfStdP1,
double dfCenterLat,
618 double dfCenterLong,
double dfFalseEasting,
619 double dfFalseNorthing);
622 OGRErr SetMollweide(
double dfCentralMeridian,
double dfFalseEasting,
623 double dfFalseNorthing);
626 OGRErr SetNZMG(
double dfCenterLat,
double dfCenterLong,
627 double dfFalseEasting,
double dfFalseNorthing);
630 OGRErr SetOS(
double dfOriginLat,
double dfCMeridian,
double dfScale,
631 double dfFalseEasting,
double dfFalseNorthing);
634 OGRErr SetOrthographic(
double dfCenterLat,
double dfCenterLong,
635 double dfFalseEasting,
double dfFalseNorthing);
638 OGRErr SetPolyconic(
double dfCenterLat,
double dfCenterLong,
639 double dfFalseEasting,
double dfFalseNorthing);
642 OGRErr SetPS(
double dfCenterLat,
double dfCenterLong,
double dfScale,
643 double dfFalseEasting,
double dfFalseNorthing);
646 OGRErr SetRobinson(
double dfCenterLong,
double dfFalseEasting,
647 double dfFalseNorthing);
650 OGRErr SetSinusoidal(
double dfCenterLong,
double dfFalseEasting,
651 double dfFalseNorthing);
654 OGRErr SetStereographic(
double dfCenterLat,
double dfCenterLong,
655 double dfScale,
double dfFalseEasting,
656 double dfFalseNorthing);
659 OGRErr SetSOC(
double dfLatitudeOfOrigin,
double dfCentralMeridian,
660 double dfFalseEasting,
double dfFalseNorthing);
663 OGRErr SetTM(
double dfCenterLat,
double dfCenterLong,
double dfScale,
664 double dfFalseEasting,
double dfFalseNorthing);
667 OGRErr SetTMVariant(
const char *pszVariantName,
double dfCenterLat,
668 double dfCenterLong,
double dfScale,
669 double dfFalseEasting,
double dfFalseNorthing);
672 OGRErr SetTMG(
double dfCenterLat,
double dfCenterLong,
673 double dfFalseEasting,
double dfFalseNorthing);
676 OGRErr SetTMSO(
double dfCenterLat,
double dfCenterLong,
double dfScale,
677 double dfFalseEasting,
double dfFalseNorthing);
680 OGRErr SetTPED(
double dfLat1,
double dfLong1,
double dfLat2,
double dfLong2,
681 double dfFalseEasting,
double dfFalseNorthing);
684 OGRErr SetVDG(
double dfCenterLong,
double dfFalseEasting,
685 double dfFalseNorthing);
688 OGRErr SetUTM(
int nZone,
int bNorth = TRUE);
689 int GetUTMZone(
int *pbNorth =
nullptr)
const;
692 OGRErr SetWagner(
int nVariation,
double dfCenterLat,
double dfFalseEasting,
693 double dfFalseNorthing);
696 OGRErr SetQSC(
double dfCenterLat,
double dfCenterLong);
699 OGRErr SetSCH(
double dfPegLat,
double dfPegLong,
double dfPegHeading,
704 SetVerticalPerspective(
double dfTopoOriginLat,
double dfTopoOriginLon,
705 double dfTopoOriginHeight,
double dfViewPointHeight,
706 double dfFalseEasting,
double dfFalseNorthing);
709 OGRErr SetDerivedGeogCRSWithPoleRotationGRIBConvention(
710 const char *pszCRSName,
double dfSouthPoleLat,
double dfSouthPoleLon,
711 double dfAxisRotation);
714 OGRErr SetDerivedGeogCRSWithPoleRotationNetCDFCFConvention(
715 const char *pszCRSName,
double dfGridNorthPoleLat,
716 double dfGridNorthPoleLon,
double dfNorthPoleGridLon);
719 OGRErr SetStatePlane(
int nZone,
int bNAD83 = TRUE,
720 const char *pszOverrideUnitName =
nullptr,
721 double dfOverrideUnit = 0.0);
724 OGRErr ImportFromESRIStatePlaneWKT(
int nCode,
const char *pszDatumName,
725 const char *pszUnitsName,
int nPCSCode,
726 const char *pszCRSName =
nullptr);
729 OGRErr ImportFromESRIWisconsinWKT(
const char *pszPrjName,
730 double dfCentralMeridian,
731 double dfLatOfOrigin,
732 const char *pszUnitsName,
733 const char *pszCRSName =
nullptr);
736 void UpdateCoordinateSystemFromGeogCRS();
759 struct CPL_DLL OGRSpatialReferenceReleaser
834 int Transform(
size_t nCount,
double *x,
double *y,
double *z =
nullptr,
835 int *pabSuccess =
nullptr);
856 virtual int Transform(
size_t nCount,
double *x,
double *y,
double *z,
857 double *t,
int *pabSuccess) = 0;
880 double *z,
double *t,
920 const double xmax,
const double ymax,
921 double *out_xmin,
double *out_ymin,
922 double *out_xmax,
double *out_ymax,
923 const int densify_pts)
930 *out_xmin = HUGE_VAL;
931 *out_ymin = HUGE_VAL;
932 *out_xmax = HUGE_VAL;
933 *out_ymax = HUGE_VAL;
935 "TransformBounds not implemented.");
990 friend class OGRProjCT;
992 std::unique_ptr<Private> d;
1003 bool SetAreaOfInterest(
double dfWestLongitudeDeg,
double dfSouthLatitudeDeg,
1004 double dfEastLongitudeDeg,
1005 double dfNorthLatitudeDeg);
1006 bool SetDesiredAccuracy(
double dfAccuracy);
1007 bool SetBallparkAllowed(
bool bAllowBallpark);
1008 bool SetOnlyBest(
bool bOnlyBest);
1010 bool SetCoordinateOperation(
const char *pszCT,
bool bReverseCT);
1012 void SetSourceCenterLong(
double dfCenterLong);
1013 void SetTargetCenterLong(
double dfCenterLong);
Convenient string class based on std::string.
Definition: cpl_string.h:320
This class represents an OpenGIS Spatial Reference System, and contains methods for converting betwee...
Definition: ogr_spatialref.h:169
static OGRSpatialReference * FromHandle(OGRSpatialReferenceH hSRS)
Convert a OGRSpatialReferenceH to a OGRSpatialReference*.
Definition: ogr_spatialref.h:752
static OGRSpatialReferenceH ToHandle(OGRSpatialReference *poSRS)
Convert a OGRSpatialReference* to a OGRSpatialReferenceH.
Definition: ogr_spatialref.h:744
void Release()
Decrements the reference count by one, and destroy if zero.
Definition: ogrspatialreference.cpp:1094
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:91
const char * GetValue() const
Fetch value string for this node.
Definition: ogr_spatialref.h:109
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:100
void CPLError(CPLErr eErrClass, CPLErrorNum err_no, const char *fmt,...)
Report an error.
Definition: cpl_error.cpp:330
#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
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition: cpl_port.h:1183
Various convenience functions for working with strings and string lists.
void * OGRCoordinateTransformationH
Opaque type for a coordinate transformation object.
Definition: ogr_api.h:83
void * OGRSpatialReferenceH
Opaque type for a spatial reference system.
Definition: ogr_api.h:81
int OGRErr
Type for a OGR error.
Definition: ogr_core.h:387
#define USGS_ANGLE_PACKEDDMS
Angle is in packed degree minute second.
Definition: ogr_spatialref.h:246
OGRCoordinateTransformation * OGRCreateCoordinateTransformation(const OGRSpatialReference *poSource, const OGRSpatialReference *poTarget)
Create transformation object.
Definition: ogrct.cpp:956
C spatial reference system services and defines.
OSRAxisMappingStrategy
Data axis to CRS axis mapping strategy.
Definition: ogr_srs_api.h:668
OGRAxisOrientation
Axis orientations (corresponds to CS_AxisOrientationEnum).
Definition: ogr_srs_api.h:51
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.