16#ifndef OGR_SPATIALREF_H_INCLUDED
17#define OGR_SPATIALREF_H_INCLUDED
65 void RegisterListener(
const std::shared_ptr<Listener> &listener);
72 return nChildren == 0;
88 int FindChild(
const char *)
const;
89 void DestroyChild(
int);
91 void StripNodes(
const char *);
98 void SetValue(
const char *);
100 void MakeValueSafe();
104 OGRErr importFromWkt(
char **)
106 CPL_WARN_DEPRECATED(
"Use importFromWkt(const char**)")
109 OGRErr importFromWkt(
const char **);
110 OGRErr exportToWkt(
char **)
const;
111 OGRErr exportToPrettyWkt(
char **,
int = 1)
const;
121 int NeedsQuoting()
const;
122 OGRErr importFromWkt(
const char **,
int nRecLevel,
int *pnNodes);
124 std::weak_ptr<Listener> m_listener{};
155 std::unique_ptr<Private> d;
157 void GetNormInfo()
const;
160 OGRErr importFromURNPart(
const char *pszAuthority,
const char *pszCode,
163 static CPLString lookupInDict(
const char *pszDictFile,
const char *pszCode);
165 OGRErr GetWKT2ProjectionMethod(
const char **ppszMethodName,
166 const char **ppszMethodAuthName =
nullptr,
167 const char **ppszMethodCode =
nullptr)
const;
185 int GetReferenceCount()
const;
188 const char *GetName()
const;
194 OGRErr exportToWkt(
char **)
const;
195 OGRErr exportToWkt(
char **ppszWKT,
const char *
const *papszOptions)
const;
196 std::string exportToWkt(
const char *
const *papszOptions =
nullptr)
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 *,
double *)
const;
205 OGRErr exportVertCSToPanorama(
int *)
const;
206 OGRErr exportToERM(
char *pszProj,
char *pszDatum,
char *pszUnits);
207 OGRErr exportToMICoordSys(
char **)
const;
208 OGRErr exportToCF1(
char **ppszGridMappingName,
char ***ppapszKeyValues,
211 OGRErr importFromWkt(
char **)
214 "Use importFromWkt(const char**) or importFromWkt(const char*)")
218 OGRErr importFromWkt(
const char **);
223 OGRErr importFromWkt(
const char *);
224 OGRErr importFromProj4(
const char *);
225 OGRErr importFromEPSG(
int);
226 OGRErr importFromEPSGA(
int);
227 OGRErr importFromESRI(
char **);
228 OGRErr importFromPCI(
const char *,
const char * =
nullptr,
229 const double * =
nullptr);
231#define USGS_ANGLE_DECIMALDEGREES 0
232#define USGS_ANGLE_PACKEDDMS \
234#define USGS_ANGLE_RADIANS 2
235 OGRErr importFromUSGS(
long iProjSys,
long iZone,
double *padfPrjParams,
238 OGRErr importFromPanorama(
long,
long,
long,
double *,
bool bNorth =
true);
239 OGRErr importVertCSFromPanorama(
int);
240 OGRErr importFromOzi(
const char *
const *papszLines);
241 OGRErr importFromWMSAUTO(
const char *pszAutoDef);
242 OGRErr importFromXML(
const char *);
243 OGRErr importFromDict(
const char *pszDict,
const char *pszCode);
244 OGRErr importFromURN(
const char *);
245 OGRErr importFromCRSURL(
const char *);
246 OGRErr importFromERM(
const char *pszProj,
const char *pszDatum,
247 const char *pszUnits);
248 OGRErr importFromUrl(
const char *);
249 OGRErr importFromMICoordSys(
const char *);
256 convertToOtherProjection(
const char *pszTargetProjection,
257 const char *
const *papszOptions =
nullptr)
const;
262 bool StripTOWGS84IfKnownDatumAndAllowed();
263 bool StripTOWGS84IfKnownDatum();
265 int EPSGTreatsAsLatLong()
const;
266 int EPSGTreatsAsNorthingEasting()
const;
267 int GetAxesCount()
const;
268 const char *GetAxis(
const char *pszTargetKey,
int iAxis,
270 double *pdfConvFactor =
nullptr)
const;
271 OGRErr SetAxes(
const char *pszTargetKey,
const char *pszXAxisName,
273 const char *pszYAxisName,
278 const std::vector<int> &GetDataAxisToSRSAxisMapping()
const;
279 OGRErr SetDataAxisToSRSAxisMapping(
const std::vector<int> &mapping);
290 const OGR_SRSNode *GetAttrNode(
const char *)
const;
291 const char *GetAttrValue(
const char *,
int = 0)
const;
293 OGRErr SetNode(
const char *,
const char *);
295 OGRErr SetNode(
const char *,
double);
298 SetLinearUnitsAndUpdateParameters(
const char *pszName,
double dfInMeters,
299 const char *pszUnitAuthority =
nullptr,
300 const char *pszUnitCode =
nullptr);
301 OGRErr SetLinearUnits(
const char *pszName,
double dfInMeters);
302 OGRErr SetTargetLinearUnits(
const char *pszTargetKey,
const char *pszName,
304 const char *pszUnitAuthority =
nullptr,
305 const char *pszUnitCode =
nullptr);
307 double GetLinearUnits(
char **)
const
309 CPL_WARN_DEPRECATED(
"Use GetLinearUnits(const char**) instead")
312 double GetLinearUnits(
const char ** =
nullptr)
const;
315 double GetLinearUnits(std::nullptr_t)
const
317 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;
333 double GetTargetLinearUnits(
const char *pszTargetKey, std::nullptr_t)
const
335 return GetTargetLinearUnits(pszTargetKey,
336 static_cast<const char **
>(
nullptr));
341 OGRErr SetAngularUnits(
const char *pszName,
double dfInRadians);
342 double GetAngularUnits(
char **)
const
344 CPL_WARN_DEPRECATED(
"Use GetAngularUnits(const char**) instead")
347 double GetAngularUnits(
const char ** =
nullptr)
const;
350 double GetAngularUnits(std::nullptr_t)
const
352 return GetAngularUnits(
static_cast<const char **
>(
nullptr));
357 double GetPrimeMeridian(
char **)
const
359 CPL_WARN_DEPRECATED(
"Use GetPrimeMeridian(const char**) instead")
362 double GetPrimeMeridian(
const char ** =
nullptr)
const;
365 double GetPrimeMeridian(std::nullptr_t)
const
367 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 IsDerivedProjected()
const;
377 int IsGeocentric()
const;
378 bool IsDynamic()
const;
381 bool HasPointMotionOperation()
const;
384 int IsVertical()
const;
385 int IsCompound()
const;
388 const char *
const *papszOptions)
const;
392 const char *
const *papszOptions)
const;
395 OGRErr SetLocalCS(
const char *);
396 OGRErr SetProjCS(
const char *);
397 OGRErr SetProjection(
const char *);
398 OGRErr SetGeocCS(
const char *pszGeocName);
399 OGRErr SetGeogCS(
const char *pszGeogName,
const char *pszDatumName,
400 const char *pszEllipsoidName,
double dfSemiMajor,
401 double dfInvFlattening,
const char *pszPMName =
nullptr,
402 double dfPMOffset = 0.0,
const char *pszUnits =
nullptr,
403 double dfConvertToRadians = 0.0);
404 OGRErr SetWellKnownGeogCS(
const char *);
406 OGRErr SetVertCS(
const char *pszVertCSName,
const char *pszVertDatumName,
407 int nVertDatumClass = 2005);
408 OGRErr SetCompoundCS(
const char *pszName,
412 void SetCoordinateEpoch(
double dfCoordinateEpoch);
413 double GetCoordinateEpoch()
const;
416 OGRErr PromoteTo3D(
const char *pszName);
418 OGRErr DemoteTo2D(
const char *pszName);
420 OGRErr SetFromUserInput(
const char *);
422 static const char *
const SET_FROM_USER_INPUT_LIMITATIONS[];
423 static CSLConstList SET_FROM_USER_INPUT_LIMITATIONS_get();
427 OGRErr SetTOWGS84(
double,
double,
double,
double = 0.0,
double = 0.0,
428 double = 0.0,
double = 0.0);
429 OGRErr GetTOWGS84(
double *padfCoef,
int nCoeff = 7)
const;
430 OGRErr AddGuessedTOWGS84();
432 double GetSemiMajor(
OGRErr * =
nullptr)
const;
433 double GetSemiMinor(
OGRErr * =
nullptr)
const;
434 double GetInvFlattening(
OGRErr * =
nullptr)
const;
435 double GetEccentricity()
const;
436 double GetSquaredEccentricity()
const;
438 OGRErr SetAuthority(
const char *pszTargetKey,
const char *pszAuthority,
441 OGRErr AutoIdentifyEPSG();
443 int **ppanMatchConfidence)
const;
445 FindBestMatch(
int nMinimumMatchConfidence = 90,
446 const char *pszPreferredAuthority =
"EPSG",
449 int GetEPSGGeogCS()
const;
451 const char *GetAuthorityCode(
const char *pszTargetKey)
const;
452 const char *GetAuthorityName(
const char *pszTargetKey)
const;
453 char *GetOGCURN()
const;
455 bool GetAreaOfUse(
double *pdfWestLongitudeDeg,
double *pdfSouthLatitudeDeg,
456 double *pdfEastLongitudeDeg,
double *pdfNorthLatitudeDeg,
457 const char **ppszAreaName)
const;
459 const char *GetExtension(
const char *pszTargetKey,
const char *pszName,
460 const char *pszDefault =
nullptr)
const;
461 OGRErr SetExtension(
const char *pszTargetKey,
const char *pszName,
462 const char *pszValue);
464 int FindProjParm(
const char *pszParameter,
466 OGRErr SetProjParm(
const char *,
double);
467 double GetProjParm(
const char *,
double = 0.0,
OGRErr * =
nullptr)
const;
469 OGRErr SetNormProjParm(
const char *,
double);
470 double GetNormProjParm(
const char *,
double = 0.0,
471 OGRErr * =
nullptr)
const;
473 static int IsAngularParameter(
const char *);
474 static int IsLongitudeParameter(
const char *);
475 static int IsLinearParameter(
const char *);
478 OGRErr SetACEA(
double dfStdP1,
double dfStdP2,
double dfCenterLat,
479 double dfCenterLong,
double dfFalseEasting,
480 double dfFalseNorthing);
483 OGRErr SetAE(
double dfCenterLat,
double dfCenterLong,
double dfFalseEasting,
484 double dfFalseNorthing);
487 OGRErr SetBonne(
double dfStdP1,
double dfCentralMeridian,
488 double dfFalseEasting,
double dfFalseNorthing);
491 OGRErr SetCEA(
double dfStdP1,
double dfCentralMeridian,
492 double dfFalseEasting,
double dfFalseNorthing);
495 OGRErr SetCS(
double dfCenterLat,
double dfCenterLong,
double dfFalseEasting,
496 double dfFalseNorthing);
499 OGRErr SetEC(
double dfStdP1,
double dfStdP2,
double dfCenterLat,
500 double dfCenterLong,
double dfFalseEasting,
501 double dfFalseNorthing);
504 OGRErr SetEckert(
int nVariation,
double dfCentralMeridian,
505 double dfFalseEasting,
double dfFalseNorthing);
508 OGRErr SetEckertIV(
double dfCentralMeridian,
double dfFalseEasting,
509 double dfFalseNorthing);
512 OGRErr SetEckertVI(
double dfCentralMeridian,
double dfFalseEasting,
513 double dfFalseNorthing);
516 OGRErr SetEquirectangular(
double dfCenterLat,
double dfCenterLong,
517 double dfFalseEasting,
double dfFalseNorthing);
519 OGRErr SetEquirectangular2(
double dfCenterLat,
double dfCenterLong,
520 double dfPseudoStdParallel1,
521 double dfFalseEasting,
double dfFalseNorthing);
524 OGRErr SetGEOS(
double dfCentralMeridian,
double dfSatelliteHeight,
525 double dfFalseEasting,
double dfFalseNorthing);
528 OGRErr SetGH(
double dfCentralMeridian,
double dfFalseEasting,
529 double dfFalseNorthing);
535 OGRErr SetGS(
double dfCentralMeridian,
double dfFalseEasting,
536 double dfFalseNorthing);
539 OGRErr SetGaussSchreiberTMercator(
double dfCenterLat,
double dfCenterLong,
540 double dfScale,
double dfFalseEasting,
541 double dfFalseNorthing);
544 OGRErr SetGnomonic(
double dfCenterLat,
double dfCenterLong,
545 double dfFalseEasting,
double dfFalseNorthing);
548 OGRErr SetHOM(
double dfCenterLat,
double dfCenterLong,
double dfAzimuth,
549 double dfRectToSkew,
double dfScale,
double dfFalseEasting,
550 double dfFalseNorthing);
553 OGRErr SetHOM2PNO(
double dfCenterLat,
double dfLat1,
double dfLong1,
554 double dfLat2,
double dfLong2,
double dfScale,
555 double dfFalseEasting,
double dfFalseNorthing);
558 OGRErr SetHOMAC(
double dfCenterLat,
double dfCenterLong,
double dfAzimuth,
559 double dfRectToSkew,
double dfScale,
double dfFalseEasting,
560 double dfFalseNorthing);
563 OGRErr SetLOM(
double dfCenterLat,
double dfCenterLong,
double dfAzimuth,
564 double dfScale,
double dfFalseEasting,
565 double dfFalseNorthing);
568 OGRErr SetIWMPolyconic(
double dfLat1,
double dfLat2,
double dfCenterLong,
569 double dfFalseEasting,
double dfFalseNorthing);
572 OGRErr SetKrovak(
double dfCenterLat,
double dfCenterLong,
double dfAzimuth,
573 double dfPseudoStdParallelLat,
double dfScale,
574 double dfFalseEasting,
double dfFalseNorthing);
577 OGRErr SetLAEA(
double dfCenterLat,
double dfCenterLong,
578 double dfFalseEasting,
double dfFalseNorthing);
581 OGRErr SetLCC(
double dfStdP1,
double dfStdP2,
double dfCenterLat,
582 double dfCenterLong,
double dfFalseEasting,
583 double dfFalseNorthing);
586 OGRErr SetLCC1SP(
double dfCenterLat,
double dfCenterLong,
double dfScale,
587 double dfFalseEasting,
double dfFalseNorthing);
590 OGRErr SetLCCB(
double dfStdP1,
double dfStdP2,
double dfCenterLat,
591 double dfCenterLong,
double dfFalseEasting,
592 double dfFalseNorthing);
595 OGRErr SetMC(
double dfCenterLat,
double dfCenterLong,
double dfFalseEasting,
596 double dfFalseNorthing);
599 OGRErr SetMercator(
double dfCenterLat,
double dfCenterLong,
double dfScale,
600 double dfFalseEasting,
double dfFalseNorthing);
603 OGRErr SetMercator2SP(
double dfStdP1,
double dfCenterLat,
604 double dfCenterLong,
double dfFalseEasting,
605 double dfFalseNorthing);
608 OGRErr SetMollweide(
double dfCentralMeridian,
double dfFalseEasting,
609 double dfFalseNorthing);
612 OGRErr SetNZMG(
double dfCenterLat,
double dfCenterLong,
613 double dfFalseEasting,
double dfFalseNorthing);
616 OGRErr SetOS(
double dfOriginLat,
double dfCMeridian,
double dfScale,
617 double dfFalseEasting,
double dfFalseNorthing);
620 OGRErr SetOrthographic(
double dfCenterLat,
double dfCenterLong,
621 double dfFalseEasting,
double dfFalseNorthing);
624 OGRErr SetPolyconic(
double dfCenterLat,
double dfCenterLong,
625 double dfFalseEasting,
double dfFalseNorthing);
628 OGRErr SetPS(
double dfCenterLat,
double dfCenterLong,
double dfScale,
629 double dfFalseEasting,
double dfFalseNorthing);
632 OGRErr SetRobinson(
double dfCenterLong,
double dfFalseEasting,
633 double dfFalseNorthing);
636 OGRErr SetSinusoidal(
double dfCenterLong,
double dfFalseEasting,
637 double dfFalseNorthing);
640 OGRErr SetStereographic(
double dfCenterLat,
double dfCenterLong,
641 double dfScale,
double dfFalseEasting,
642 double dfFalseNorthing);
645 OGRErr SetSOC(
double dfLatitudeOfOrigin,
double dfCentralMeridian,
646 double dfFalseEasting,
double dfFalseNorthing);
649 OGRErr SetTM(
double dfCenterLat,
double dfCenterLong,
double dfScale,
650 double dfFalseEasting,
double dfFalseNorthing);
653 OGRErr SetTMVariant(
const char *pszVariantName,
double dfCenterLat,
654 double dfCenterLong,
double dfScale,
655 double dfFalseEasting,
double dfFalseNorthing);
658 OGRErr SetTMG(
double dfCenterLat,
double dfCenterLong,
659 double dfFalseEasting,
double dfFalseNorthing);
662 OGRErr SetTMSO(
double dfCenterLat,
double dfCenterLong,
double dfScale,
663 double dfFalseEasting,
double dfFalseNorthing);
666 OGRErr SetTPED(
double dfLat1,
double dfLong1,
double dfLat2,
double dfLong2,
667 double dfFalseEasting,
double dfFalseNorthing);
670 OGRErr SetVDG(
double dfCenterLong,
double dfFalseEasting,
671 double dfFalseNorthing);
674 OGRErr SetUTM(
int nZone,
int bNorth = TRUE);
675 int GetUTMZone(
int *pbNorth =
nullptr)
const;
678 OGRErr SetWagner(
int nVariation,
double dfCenterLat,
double dfFalseEasting,
679 double dfFalseNorthing);
682 OGRErr SetQSC(
double dfCenterLat,
double dfCenterLong);
685 OGRErr SetSCH(
double dfPegLat,
double dfPegLong,
double dfPegHeading,
690 SetVerticalPerspective(
double dfTopoOriginLat,
double dfTopoOriginLon,
691 double dfTopoOriginHeight,
double dfViewPointHeight,
692 double dfFalseEasting,
double dfFalseNorthing);
695 OGRErr SetDerivedGeogCRSWithPoleRotationGRIBConvention(
696 const char *pszCRSName,
double dfSouthPoleLat,
double dfSouthPoleLon,
697 double dfAxisRotation);
700 OGRErr SetDerivedGeogCRSWithPoleRotationNetCDFCFConvention(
701 const char *pszCRSName,
double dfGridNorthPoleLat,
702 double dfGridNorthPoleLon,
double dfNorthPoleGridLon);
705 OGRErr SetStatePlane(
int nZone,
int bNAD83 = TRUE,
706 const char *pszOverrideUnitName =
nullptr,
707 double dfOverrideUnit = 0.0);
710 OGRErr ImportFromESRIStatePlaneWKT(
int nCode,
const char *pszDatumName,
711 const char *pszUnitsName,
int nPCSCode,
712 const char *pszCRSName =
nullptr);
715 OGRErr ImportFromESRIWisconsinWKT(
const char *pszPrjName,
716 double dfCentralMeridian,
717 double dfLatOfOrigin,
718 const char *pszUnitsName,
719 const char *pszCRSName =
nullptr);
722 void UpdateCoordinateSystemFromGeogCRS();
745struct CPL_DLL OGRSpatialReferenceReleaser
820 int Transform(
size_t nCount,
double *x,
double *y,
double *z =
nullptr,
821 int *pabSuccess =
nullptr);
842 virtual int Transform(
size_t nCount,
double *x,
double *y,
double *z,
843 double *t,
int *pabSuccess) = 0;
866 double *z,
double *t,
906 const double xmax,
const double ymax,
907 double *out_xmin,
double *out_ymin,
908 double *out_xmax,
double *out_ymax,
909 const int densify_pts)
916 *out_xmin = HUGE_VAL;
917 *out_ymin = HUGE_VAL;
918 *out_xmax = HUGE_VAL;
919 *out_ymax = HUGE_VAL;
921 "TransformBounds not implemented.");
976 friend class OGRProjCT;
978 std::unique_ptr<Private> d;
989 bool SetAreaOfInterest(
double dfWestLongitudeDeg,
double dfSouthLatitudeDeg,
990 double dfEastLongitudeDeg,
991 double dfNorthLatitudeDeg);
992 bool SetDesiredAccuracy(
double dfAccuracy);
993 bool SetBallparkAllowed(
bool bAllowBallpark);
994 bool SetOnlyBest(
bool bOnlyBest);
996 bool SetCoordinateOperation(
const char *pszCT,
bool bReverseCT);
998 void SetSourceCenterLong(
double dfCenterLong);
999 void SetTargetCenterLong(
double dfCenterLong);
Convenient string class based on std::string.
Definition cpl_string.h:307
This class represents an OpenGIS Spatial Reference System, and contains methods for converting betwee...
Definition ogr_spatialref.h:153
static OGRSpatialReferenceH ToHandle(OGRSpatialReference *poSRS)
Convert a OGRSpatialReference* to a OGRSpatialReferenceH.
Definition ogr_spatialref.h:730
static OGRSpatialReference * FromHandle(OGRSpatialReferenceH hSRS)
Convert a OGRSpatialReferenceH to a OGRSpatialReference*.
Definition ogr_spatialref.h:738
void Release()
Decrements the reference count by one, and destroy if zero.
Definition ogrspatialreference.cpp:1141
Objects of this class are used to represent value nodes in the parsed representation of the WKT SRS f...
Definition ogr_spatialref.h:51
int GetChildCount() const
Get number of children nodes.
Definition ogr_spatialref.h:75
const char * GetValue() const
Fetch value string for this node.
Definition ogr_spatialref.h:93
int IsLeafNode() const
Return whether this is a leaf node.
Definition ogr_spatialref.h:70
#define CPLE_AppDefined
Application defined error.
Definition cpl_error.h:84
#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:1030
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition cpl_port.h:1179
Various convenience functions for working with strings and string lists.
void * OGRCoordinateTransformationH
Opaque type for a coordinate transformation object.
Definition ogr_api.h:67
void * OGRSpatialReferenceH
Opaque type for a spatial reference system.
Definition ogr_api.h:65
int OGRErr
Type for a OGR error.
Definition ogr_core.h:371
#define USGS_ANGLE_PACKEDDMS
Angle is in packed degree minute second.
Definition ogr_spatialref.h:232
OGRCoordinateTransformation * OGRCreateCoordinateTransformation(const OGRSpatialReference *poSource, const OGRSpatialReference *poTarget)
Create transformation object.
Definition ogrct.cpp:940
C spatial reference system services and defines.
OSRAxisMappingStrategy
Data axis to CRS axis mapping strategy.
Definition ogr_srs_api.h:652
OGRAxisOrientation
Axis orientations (corresponds to CS_AxisOrientationEnum).
Definition ogr_srs_api.h:35
Listener that is notified of modification to nodes.
Definition ogr_spatialref.h:55
virtual void notifyChange(OGR_SRSNode *)=0
Method triggered when a node is modified.