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);
193 int GetReferenceCount()
const;
196 const char *GetName()
const;
202 OGRErr exportToWkt(
char **)
const;
203 OGRErr exportToWkt(
char **ppszWKT,
const char *
const *papszOptions)
const;
204 OGRErr exportToPrettyWkt(
char **,
int = FALSE)
const;
206 OGRErr exportToPROJJSON(
char **,
const char *
const *papszOptions)
const;
207 OGRErr exportToProj4(
char **)
const;
208 OGRErr exportToPCI(
char **,
char **,
double **)
const;
209 OGRErr exportToUSGS(
long *,
long *,
double **,
long *)
const;
210 OGRErr exportToXML(
char **,
const char * =
nullptr)
const;
211 OGRErr exportToPanorama(
long *,
long *,
long *,
long *,
double *)
const;
212 OGRErr exportToERM(
char *pszProj,
char *pszDatum,
char *pszUnits);
213 OGRErr exportToMICoordSys(
char **)
const;
215 OGRErr importFromWkt(
char **)
218 "Use importFromWkt(const char**) or importFromWkt(const char*)")
222 OGRErr importFromWkt(
const char **);
227 OGRErr importFromWkt(
const char *);
228 OGRErr importFromProj4(
const char *);
229 OGRErr importFromEPSG(
int);
230 OGRErr importFromEPSGA(
int);
231 OGRErr importFromESRI(
char **);
232 OGRErr importFromPCI(
const char *,
const char * =
nullptr,
235#define USGS_ANGLE_DECIMALDEGREES 0
236#define USGS_ANGLE_PACKEDDMS \
238#define USGS_ANGLE_RADIANS 2
239 OGRErr importFromUSGS(
long iProjSys,
long iZone,
double *padfPrjParams,
242 OGRErr importFromPanorama(
long,
long,
long,
double *);
243 OGRErr importVertCSFromPanorama(
int);
244 OGRErr importFromOzi(
const char *
const *papszLines);
245 OGRErr importFromWMSAUTO(
const char *pszAutoDef);
246 OGRErr importFromXML(
const char *);
247 OGRErr importFromDict(
const char *pszDict,
const char *pszCode);
248 OGRErr importFromURN(
const char *);
249 OGRErr importFromCRSURL(
const char *);
250 OGRErr importFromERM(
const char *pszProj,
const char *pszDatum,
251 const char *pszUnits);
252 OGRErr importFromUrl(
const char *);
253 OGRErr importFromMICoordSys(
const char *);
259 convertToOtherProjection(
const char *pszTargetProjection,
260 const char *
const *papszOptions =
nullptr)
const;
265 bool StripTOWGS84IfKnownDatumAndAllowed();
266 bool StripTOWGS84IfKnownDatum();
268 int EPSGTreatsAsLatLong()
const;
269 int EPSGTreatsAsNorthingEasting()
const;
270 int GetAxesCount()
const;
271 const char *GetAxis(
const char *pszTargetKey,
int iAxis,
273 double *pdfConvFactor =
nullptr)
const;
274 OGRErr SetAxes(
const char *pszTargetKey,
const char *pszXAxisName,
276 const char *pszYAxisName,
281 const std::vector<int> &GetDataAxisToSRSAxisMapping()
const;
282 OGRErr SetDataAxisToSRSAxisMapping(
const std::vector<int> &mapping);
293 const OGR_SRSNode *GetAttrNode(
const char *)
const;
294 const char *GetAttrValue(
const char *,
int = 0)
const;
296 OGRErr SetNode(
const char *,
const char *);
297 OGRErr SetNode(
const char *,
double);
300 SetLinearUnitsAndUpdateParameters(
const char *pszName,
double dfInMeters,
301 const char *pszUnitAuthority =
nullptr,
302 const char *pszUnitCode =
nullptr);
303 OGRErr SetLinearUnits(
const char *pszName,
double dfInMeters);
304 OGRErr SetTargetLinearUnits(
const char *pszTargetKey,
const char *pszName,
306 const char *pszUnitAuthority =
nullptr,
307 const char *pszUnitCode =
nullptr);
309 double GetLinearUnits(
char **)
const
311 CPL_WARN_DEPRECATED(
"Use GetLinearUnits(const char**) instead")
314 double GetLinearUnits(
const char ** =
nullptr)
const;
316 double GetLinearUnits(std::nullptr_t)
const
318 return GetLinearUnits(
static_cast<const char **
>(
nullptr));
322 double GetTargetLinearUnits(
const char *pszTargetKey,
323 char **ppszRetName)
const
326 "Use GetTargetLinearUnits(const char*, const char**)")
329 double GetTargetLinearUnits(
const char *pszTargetKey,
330 const char **ppszRetName =
nullptr)
const;
332 double GetTargetLinearUnits(
const char *pszTargetKey, std::nullptr_t)
const
334 return GetTargetLinearUnits(pszTargetKey,
335 static_cast<const char **
>(
nullptr));
339 OGRErr SetAngularUnits(
const char *pszName,
double dfInRadians);
340 double GetAngularUnits(
char **)
const
342 CPL_WARN_DEPRECATED(
"Use GetAngularUnits(const char**) instead")
345 double GetAngularUnits(
const char ** =
nullptr)
const;
347 double GetAngularUnits(std::nullptr_t)
const
349 return GetAngularUnits(
static_cast<const char **
>(
nullptr));
353 double GetPrimeMeridian(
char **)
const
355 CPL_WARN_DEPRECATED(
"Use GetPrimeMeridian(const char**) instead")
358 double GetPrimeMeridian(
const char ** =
nullptr)
const;
360 double GetPrimeMeridian(std::nullptr_t)
const
362 return GetPrimeMeridian(
static_cast<const char **
>(
nullptr));
366 bool IsEmpty()
const;
367 int IsGeographic()
const;
368 int IsDerivedGeographic()
const;
369 int IsProjected()
const;
370 int IsGeocentric()
const;
371 bool IsDynamic()
const;
373 int IsVertical()
const;
374 int IsCompound()
const;
377 const char *
const *papszOptions)
const;
381 const char *
const *papszOptions)
const;
384 OGRErr SetLocalCS(
const char *);
385 OGRErr SetProjCS(
const char *);
386 OGRErr SetProjection(
const char *);
387 OGRErr SetGeocCS(
const char *pszGeocName);
388 OGRErr SetGeogCS(
const char *pszGeogName,
const char *pszDatumName,
389 const char *pszEllipsoidName,
double dfSemiMajor,
390 double dfInvFlattening,
const char *pszPMName =
nullptr,
391 double dfPMOffset = 0.0,
const char *pszUnits =
nullptr,
392 double dfConvertToRadians = 0.0);
393 OGRErr SetWellKnownGeogCS(
const char *);
395 OGRErr SetVertCS(
const char *pszVertCSName,
const char *pszVertDatumName,
396 int nVertDatumClass = 2005);
397 OGRErr SetCompoundCS(
const char *pszName,
401 void SetCoordinateEpoch(
double dfCoordinateEpoch);
402 double GetCoordinateEpoch()
const;
405 OGRErr PromoteTo3D(
const char *pszName);
407 OGRErr DemoteTo2D(
const char *pszName);
409 OGRErr SetFromUserInput(
const char *);
411 static const char *
const SET_FROM_USER_INPUT_LIMITATIONS[];
412 static CSLConstList SET_FROM_USER_INPUT_LIMITATIONS_get();
416 OGRErr SetTOWGS84(
double,
double,
double,
double = 0.0,
double = 0.0,
417 double = 0.0,
double = 0.0);
418 OGRErr GetTOWGS84(
double *padfCoef,
int nCoeff = 7)
const;
419 OGRErr AddGuessedTOWGS84();
421 double GetSemiMajor(
OGRErr * =
nullptr)
const;
422 double GetSemiMinor(
OGRErr * =
nullptr)
const;
423 double GetInvFlattening(
OGRErr * =
nullptr)
const;
424 double GetEccentricity()
const;
425 double GetSquaredEccentricity()
const;
427 OGRErr SetAuthority(
const char *pszTargetKey,
const char *pszAuthority,
430 OGRErr AutoIdentifyEPSG();
432 int **ppanMatchConfidence)
const;
434 FindBestMatch(
int nMinimumMatchConfidence = 90,
435 const char *pszPreferredAuthority =
"EPSG",
438 int GetEPSGGeogCS()
const;
440 const char *GetAuthorityCode(
const char *pszTargetKey)
const;
441 const char *GetAuthorityName(
const char *pszTargetKey)
const;
442 char *GetOGCURN()
const;
444 bool GetAreaOfUse(
double *pdfWestLongitudeDeg,
double *pdfSouthLatitudeDeg,
445 double *pdfEastLongitudeDeg,
double *pdfNorthLatitudeDeg,
446 const char **ppszAreaName)
const;
448 const char *GetExtension(
const char *pszTargetKey,
const char *pszName,
449 const char *pszDefault =
nullptr)
const;
450 OGRErr SetExtension(
const char *pszTargetKey,
const char *pszName,
451 const char *pszValue);
453 int FindProjParm(
const char *pszParameter,
455 OGRErr SetProjParm(
const char *,
double);
456 double GetProjParm(
const char *,
double = 0.0,
OGRErr * =
nullptr)
const;
458 OGRErr SetNormProjParm(
const char *,
double);
459 double GetNormProjParm(
const char *,
double = 0.0,
460 OGRErr * =
nullptr)
const;
462 static int IsAngularParameter(
const char *);
463 static int IsLongitudeParameter(
const char *);
464 static int IsLinearParameter(
const char *);
467 OGRErr SetACEA(
double dfStdP1,
double dfStdP2,
double dfCenterLat,
468 double dfCenterLong,
double dfFalseEasting,
469 double dfFalseNorthing);
472 OGRErr SetAE(
double dfCenterLat,
double dfCenterLong,
double dfFalseEasting,
473 double dfFalseNorthing);
476 OGRErr SetBonne(
double dfStdP1,
double dfCentralMeridian,
477 double dfFalseEasting,
double dfFalseNorthing);
480 OGRErr SetCEA(
double dfStdP1,
double dfCentralMeridian,
481 double dfFalseEasting,
double dfFalseNorthing);
484 OGRErr SetCS(
double dfCenterLat,
double dfCenterLong,
double dfFalseEasting,
485 double dfFalseNorthing);
488 OGRErr SetEC(
double dfStdP1,
double dfStdP2,
double dfCenterLat,
489 double dfCenterLong,
double dfFalseEasting,
490 double dfFalseNorthing);
493 OGRErr SetEckert(
int nVariation,
double dfCentralMeridian,
494 double dfFalseEasting,
double dfFalseNorthing);
497 OGRErr SetEckertIV(
double dfCentralMeridian,
double dfFalseEasting,
498 double dfFalseNorthing);
501 OGRErr SetEckertVI(
double dfCentralMeridian,
double dfFalseEasting,
502 double dfFalseNorthing);
505 OGRErr SetEquirectangular(
double dfCenterLat,
double dfCenterLong,
506 double dfFalseEasting,
double dfFalseNorthing);
508 OGRErr SetEquirectangular2(
double dfCenterLat,
double dfCenterLong,
509 double dfPseudoStdParallel1,
510 double dfFalseEasting,
double dfFalseNorthing);
513 OGRErr SetGEOS(
double dfCentralMeridian,
double dfSatelliteHeight,
514 double dfFalseEasting,
double dfFalseNorthing);
517 OGRErr SetGH(
double dfCentralMeridian,
double dfFalseEasting,
518 double dfFalseNorthing);
524 OGRErr SetGS(
double dfCentralMeridian,
double dfFalseEasting,
525 double dfFalseNorthing);
528 OGRErr SetGaussSchreiberTMercator(
double dfCenterLat,
double dfCenterLong,
529 double dfScale,
double dfFalseEasting,
530 double dfFalseNorthing);
533 OGRErr SetGnomonic(
double dfCenterLat,
double dfCenterLong,
534 double dfFalseEasting,
double dfFalseNorthing);
537 OGRErr SetHOM(
double dfCenterLat,
double dfCenterLong,
double dfAzimuth,
538 double dfRectToSkew,
double dfScale,
double dfFalseEasting,
539 double dfFalseNorthing);
542 OGRErr SetHOM2PNO(
double dfCenterLat,
double dfLat1,
double dfLong1,
543 double dfLat2,
double dfLong2,
double dfScale,
544 double dfFalseEasting,
double dfFalseNorthing);
547 OGRErr SetHOMAC(
double dfCenterLat,
double dfCenterLong,
double dfAzimuth,
548 double dfRectToSkew,
double dfScale,
double dfFalseEasting,
549 double dfFalseNorthing);
552 OGRErr SetLOM(
double dfCenterLat,
double dfCenterLong,
double dfAzimuth,
553 double dfScale,
double dfFalseEasting,
554 double dfFalseNorthing);
557 OGRErr SetIWMPolyconic(
double dfLat1,
double dfLat2,
double dfCenterLong,
558 double dfFalseEasting,
double dfFalseNorthing);
561 OGRErr SetKrovak(
double dfCenterLat,
double dfCenterLong,
double dfAzimuth,
562 double dfPseudoStdParallelLat,
double dfScale,
563 double dfFalseEasting,
double dfFalseNorthing);
566 OGRErr SetLAEA(
double dfCenterLat,
double dfCenterLong,
567 double dfFalseEasting,
double dfFalseNorthing);
570 OGRErr SetLCC(
double dfStdP1,
double dfStdP2,
double dfCenterLat,
571 double dfCenterLong,
double dfFalseEasting,
572 double dfFalseNorthing);
575 OGRErr SetLCC1SP(
double dfCenterLat,
double dfCenterLong,
double dfScale,
576 double dfFalseEasting,
double dfFalseNorthing);
579 OGRErr SetLCCB(
double dfStdP1,
double dfStdP2,
double dfCenterLat,
580 double dfCenterLong,
double dfFalseEasting,
581 double dfFalseNorthing);
584 OGRErr SetMC(
double dfCenterLat,
double dfCenterLong,
double dfFalseEasting,
585 double dfFalseNorthing);
588 OGRErr SetMercator(
double dfCenterLat,
double dfCenterLong,
double dfScale,
589 double dfFalseEasting,
double dfFalseNorthing);
592 OGRErr SetMercator2SP(
double dfStdP1,
double dfCenterLat,
593 double dfCenterLong,
double dfFalseEasting,
594 double dfFalseNorthing);
597 OGRErr SetMollweide(
double dfCentralMeridian,
double dfFalseEasting,
598 double dfFalseNorthing);
601 OGRErr SetNZMG(
double dfCenterLat,
double dfCenterLong,
602 double dfFalseEasting,
double dfFalseNorthing);
605 OGRErr SetOS(
double dfOriginLat,
double dfCMeridian,
double dfScale,
606 double dfFalseEasting,
double dfFalseNorthing);
609 OGRErr SetOrthographic(
double dfCenterLat,
double dfCenterLong,
610 double dfFalseEasting,
double dfFalseNorthing);
613 OGRErr SetPolyconic(
double dfCenterLat,
double dfCenterLong,
614 double dfFalseEasting,
double dfFalseNorthing);
617 OGRErr SetPS(
double dfCenterLat,
double dfCenterLong,
double dfScale,
618 double dfFalseEasting,
double dfFalseNorthing);
621 OGRErr SetRobinson(
double dfCenterLong,
double dfFalseEasting,
622 double dfFalseNorthing);
625 OGRErr SetSinusoidal(
double dfCenterLong,
double dfFalseEasting,
626 double dfFalseNorthing);
629 OGRErr SetStereographic(
double dfCenterLat,
double dfCenterLong,
630 double dfScale,
double dfFalseEasting,
631 double dfFalseNorthing);
634 OGRErr SetSOC(
double dfLatitudeOfOrigin,
double dfCentralMeridian,
635 double dfFalseEasting,
double dfFalseNorthing);
638 OGRErr SetTM(
double dfCenterLat,
double dfCenterLong,
double dfScale,
639 double dfFalseEasting,
double dfFalseNorthing);
642 OGRErr SetTMVariant(
const char *pszVariantName,
double dfCenterLat,
643 double dfCenterLong,
double dfScale,
644 double dfFalseEasting,
double dfFalseNorthing);
647 OGRErr SetTMG(
double dfCenterLat,
double dfCenterLong,
648 double dfFalseEasting,
double dfFalseNorthing);
651 OGRErr SetTMSO(
double dfCenterLat,
double dfCenterLong,
double dfScale,
652 double dfFalseEasting,
double dfFalseNorthing);
655 OGRErr SetTPED(
double dfLat1,
double dfLong1,
double dfLat2,
double dfLong2,
656 double dfFalseEasting,
double dfFalseNorthing);
659 OGRErr SetVDG(
double dfCenterLong,
double dfFalseEasting,
660 double dfFalseNorthing);
663 OGRErr SetUTM(
int nZone,
int bNorth = TRUE);
664 int GetUTMZone(
int *pbNorth =
nullptr)
const;
667 OGRErr SetWagner(
int nVariation,
double dfCenterLat,
double dfFalseEasting,
668 double dfFalseNorthing);
671 OGRErr SetQSC(
double dfCenterLat,
double dfCenterLong);
674 OGRErr SetSCH(
double dfPegLat,
double dfPegLong,
double dfPegHeading,
679 SetVerticalPerspective(
double dfTopoOriginLat,
double dfTopoOriginLon,
680 double dfTopoOriginHeight,
double dfViewPointHeight,
681 double dfFalseEasting,
double dfFalseNorthing);
684 OGRErr SetDerivedGeogCRSWithPoleRotationGRIBConvention(
685 const char *pszCRSName,
double dfSouthPoleLat,
double dfSouthPoleLon,
686 double dfAxisRotation);
689 OGRErr SetDerivedGeogCRSWithPoleRotationNetCDFCFConvention(
690 const char *pszCRSName,
double dfGridNorthPoleLat,
691 double dfGridNorthPoleLon,
double dfNorthPoleGridLon);
694 OGRErr SetStatePlane(
int nZone,
int bNAD83 = TRUE,
695 const char *pszOverrideUnitName =
nullptr,
696 double dfOverrideUnit = 0.0);
699 OGRErr ImportFromESRIStatePlaneWKT(
int nCode,
const char *pszDatumName,
700 const char *pszUnitsName,
int nPCSCode,
701 const char *pszCRSName =
nullptr);
704 OGRErr ImportFromESRIWisconsinWKT(
const char *pszPrjName,
705 double dfCentralMeridian,
706 double dfLatOfOrigin,
707 const char *pszUnitsName,
708 const char *pszCRSName =
nullptr);
711 void UpdateCoordinateSystemFromGeogCRS();
796 int Transform(
int nCount,
double *x,
double *y,
double *z =
nullptr,
797 int *pabSuccess =
nullptr);
817 virtual int Transform(
int nCount,
double *x,
double *y,
double *z,
818 double *t,
int *pabSuccess) = 0;
840 double *z,
double *t,
880 const double xmax,
const double ymax,
881 double *out_xmin,
double *out_ymin,
882 double *out_xmax,
double *out_ymax,
883 const int densify_pts)
890 *out_xmin = HUGE_VAL;
891 *out_ymin = HUGE_VAL;
892 *out_xmax = HUGE_VAL;
893 *out_ymax = HUGE_VAL;
895 "TransformBounds not implemented.");
950 friend class OGRProjCT;
952 std::unique_ptr<Private> d;
963 bool SetAreaOfInterest(
double dfWestLongitudeDeg,
double dfSouthLatitudeDeg,
964 double dfEastLongitudeDeg,
965 double dfNorthLatitudeDeg);
966 bool SetDesiredAccuracy(
double dfAccuracy);
967 bool SetBallparkAllowed(
bool bAllowBallpark);
969 bool SetCoordinateOperation(
const char *pszCT,
bool bReverseCT);
971 void SetSourceCenterLong(
double dfCenterLong);
972 void SetTargetCenterLong(
double dfCenterLong);
Convenient string class based on std::string.
Definition cpl_string.h:312
This class represents an OpenGIS Spatial Reference System, and contains methods for converting betwee...
Definition ogr_spatialref.h:167
static OGRSpatialReferenceH ToHandle(OGRSpatialReference *poSRS)
Convert a OGRSpatialReference* to a OGRSpatialReferenceH.
Definition ogr_spatialref.h:719
static OGRSpatialReference * FromHandle(OGRSpatialReferenceH hSRS)
Convert a OGRSpatialReferenceH to a OGRSpatialReference*.
Definition ogr_spatialref.h:727
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:108
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
#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:1049
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition cpl_port.h:1190
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:378
#define USGS_ANGLE_PACKEDDMS
Angle is in packed degree minute second.
Definition ogr_spatialref.h:236
OGRCoordinateTransformation * OGRCreateCoordinateTransformation(const OGRSpatialReference *poSource, const OGRSpatialReference *poTarget)
Create transformation object.
Definition ogrct.cpp:873
C spatial reference system services and defines.
OSRAxisMappingStrategy
Data axis to CRS axis mapping strategy.
Definition ogr_srs_api.h:656
OGRAxisOrientation
Axis orientations (corresponds to CS_AxisOrientationEnum).
Definition ogr_srs_api.h:49
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.