15#ifndef OGR_SPATIALREF_H_INCLUDED
16#define OGR_SPATIALREF_H_INCLUDED
64 void RegisterListener(
const std::shared_ptr<Listener> &listener);
71 return nChildren == 0;
87 int FindChild(
const char *)
const;
88 void DestroyChild(
int);
90 void StripNodes(
const char *);
97 void SetValue(
const char *);
103 OGRErr importFromWkt(
char **)
105 CPL_WARN_DEPRECATED(
"Use importFromWkt(const char**)")
108 OGRErr importFromWkt(
const char **);
109 OGRErr exportToWkt(
char **)
const;
110 OGRErr exportToPrettyWkt(
char **,
int = 1)
const;
120 int NeedsQuoting()
const;
121 OGRErr importFromWkt(
const char **,
int nRecLevel,
int *pnNodes);
123 std::weak_ptr<Listener> m_listener{};
154 std::unique_ptr<Private> d;
156 void GetNormInfo()
const;
159 OGRErr importFromURNPart(
const char *pszAuthority,
const char *pszCode,
162 static CPLString lookupInDict(
const char *pszDictFile,
const char *pszCode);
164 OGRErr GetWKT2ProjectionMethod(
const char **ppszMethodName,
165 const char **ppszMethodAuthName =
nullptr,
166 const char **ppszMethodCode =
nullptr)
const;
184 int GetReferenceCount()
const;
187 const char *GetName()
const;
193 OGRErr exportToWkt(
char **)
const;
194 OGRErr exportToWkt(
char **ppszWKT,
const char *
const *papszOptions)
const;
195 std::string exportToWkt(
const char *
const *papszOptions =
nullptr)
const;
196 OGRErr exportToPrettyWkt(
char **,
int = FALSE)
const;
198 OGRErr exportToPROJJSON(
char **,
const char *
const *papszOptions)
const;
199 OGRErr exportToProj4(
char **)
const;
200 OGRErr exportToPCI(
char **,
char **,
double **)
const;
201 OGRErr exportToUSGS(
long *,
long *,
double **,
long *)
const;
202 OGRErr exportToXML(
char **,
const char * =
nullptr)
const;
203 OGRErr exportToPanorama(
long *,
long *,
long *,
long *,
double *)
const;
204 OGRErr exportVertCSToPanorama(
int *)
const;
205 OGRErr exportToERM(
char *pszProj,
char *pszDatum,
char *pszUnits);
206 OGRErr exportToMICoordSys(
char **)
const;
207 OGRErr exportToCF1(
char **ppszGridMappingName,
char ***ppapszKeyValues,
210 OGRErr importFromWkt(
char **)
213 "Use importFromWkt(const char**) or importFromWkt(const char*)")
217 OGRErr importFromWkt(
const char **);
222 OGRErr importFromWkt(
const char *);
223 OGRErr importFromProj4(
const char *);
224 OGRErr importFromEPSG(
int);
225 OGRErr importFromEPSGA(
int);
226 OGRErr importFromESRI(
char **);
227 OGRErr importFromPCI(
const char *,
const char * =
nullptr,
228 const double * =
nullptr);
230#define USGS_ANGLE_DECIMALDEGREES 0
231#define USGS_ANGLE_PACKEDDMS \
233#define USGS_ANGLE_RADIANS 2
234 OGRErr importFromUSGS(
long iProjSys,
long iZone,
double *padfPrjParams,
237 OGRErr importFromPanorama(
long,
long,
long,
double *,
bool bNorth =
true);
238 OGRErr importVertCSFromPanorama(
int);
239 OGRErr importFromOzi(
const char *
const *papszLines);
240 OGRErr importFromWMSAUTO(
const char *pszAutoDef);
241 OGRErr importFromXML(
const char *);
242 OGRErr importFromDict(
const char *pszDict,
const char *pszCode);
243 OGRErr importFromURN(
const char *);
244 OGRErr importFromCRSURL(
const char *);
245 OGRErr importFromERM(
const char *pszProj,
const char *pszDatum,
246 const char *pszUnits);
247 OGRErr importFromUrl(
const char *);
248 OGRErr importFromMICoordSys(
const char *);
255 convertToOtherProjection(
const char *pszTargetProjection,
256 const char *
const *papszOptions =
nullptr)
const;
261 bool StripTOWGS84IfKnownDatumAndAllowed();
262 bool StripTOWGS84IfKnownDatum();
264 int EPSGTreatsAsLatLong()
const;
265 int EPSGTreatsAsNorthingEasting()
const;
266 int GetAxesCount()
const;
267 const char *GetAxis(
const char *pszTargetKey,
int iAxis,
269 double *pdfConvFactor =
nullptr)
const;
270 OGRErr SetAxes(
const char *pszTargetKey,
const char *pszXAxisName,
272 const char *pszYAxisName,
277 const std::vector<int> &GetDataAxisToSRSAxisMapping()
const;
278 OGRErr SetDataAxisToSRSAxisMapping(
const std::vector<int> &mapping);
289 const OGR_SRSNode *GetAttrNode(
const char *)
const;
290 const char *GetAttrValue(
const char *,
int = 0)
const;
292 OGRErr SetNode(
const char *,
const char *);
294 OGRErr SetNode(
const char *,
double);
297 SetLinearUnitsAndUpdateParameters(
const char *pszName,
double dfInMeters,
298 const char *pszUnitAuthority =
nullptr,
299 const char *pszUnitCode =
nullptr);
300 OGRErr SetLinearUnits(
const char *pszName,
double dfInMeters);
301 OGRErr SetTargetLinearUnits(
const char *pszTargetKey,
const char *pszName,
303 const char *pszUnitAuthority =
nullptr,
304 const char *pszUnitCode =
nullptr);
306 double GetLinearUnits(
char **)
const
308 CPL_WARN_DEPRECATED(
"Use GetLinearUnits(const char**) instead")
311 double GetLinearUnits(
const char ** =
nullptr)
const;
314 double GetLinearUnits(std::nullptr_t)
const
316 return GetLinearUnits(
static_cast<const char **
>(
nullptr));
321 double GetTargetLinearUnits(
const char *pszTargetKey,
322 char **ppszRetName)
const
325 "Use GetTargetLinearUnits(const char*, const char**)")
328 double GetTargetLinearUnits(
const char *pszTargetKey,
329 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));
340 OGRErr SetAngularUnits(
const char *pszName,
double dfInRadians);
341 double GetAngularUnits(
char **)
const
343 CPL_WARN_DEPRECATED(
"Use GetAngularUnits(const char**) instead")
346 double GetAngularUnits(
const char ** =
nullptr)
const;
349 double GetAngularUnits(std::nullptr_t)
const
351 return GetAngularUnits(
static_cast<const char **
>(
nullptr));
356 double GetPrimeMeridian(
char **)
const
358 CPL_WARN_DEPRECATED(
"Use GetPrimeMeridian(const char**) instead")
361 double GetPrimeMeridian(
const char ** =
nullptr)
const;
364 double GetPrimeMeridian(std::nullptr_t)
const
366 return GetPrimeMeridian(
static_cast<const char **
>(
nullptr));
371 bool IsEmpty()
const;
372 int IsGeographic()
const;
373 int IsDerivedGeographic()
const;
374 int IsProjected()
const;
375 int IsDerivedProjected()
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;
393 const char *GetCelestialBodyName()
const;
396 OGRErr SetLocalCS(
const char *);
397 OGRErr SetProjCS(
const char *);
398 OGRErr SetProjection(
const char *);
399 OGRErr SetGeocCS(
const char *pszGeocName);
400 OGRErr SetGeogCS(
const char *pszGeogName,
const char *pszDatumName,
401 const char *pszEllipsoidName,
double dfSemiMajor,
402 double dfInvFlattening,
const char *pszPMName =
nullptr,
403 double dfPMOffset = 0.0,
const char *pszUnits =
nullptr,
404 double dfConvertToRadians = 0.0);
405 OGRErr SetWellKnownGeogCS(
const char *);
407 OGRErr SetVertCS(
const char *pszVertCSName,
const char *pszVertDatumName,
408 int nVertDatumClass = 2005);
409 OGRErr SetCompoundCS(
const char *pszName,
413 void SetCoordinateEpoch(
double dfCoordinateEpoch);
414 double GetCoordinateEpoch()
const;
417 OGRErr PromoteTo3D(
const char *pszName);
419 OGRErr DemoteTo2D(
const char *pszName);
421 OGRErr SetFromUserInput(
const char *);
423 static const char *
const SET_FROM_USER_INPUT_LIMITATIONS[];
424 static CSLConstList SET_FROM_USER_INPUT_LIMITATIONS_get();
428 OGRErr SetTOWGS84(
double,
double,
double,
double = 0.0,
double = 0.0,
429 double = 0.0,
double = 0.0);
430 OGRErr GetTOWGS84(
double *padfCoef,
int nCoeff = 7)
const;
431 OGRErr AddGuessedTOWGS84();
433 double GetSemiMajor(
OGRErr * =
nullptr)
const;
434 double GetSemiMinor(
OGRErr * =
nullptr)
const;
435 double GetInvFlattening(
OGRErr * =
nullptr)
const;
436 double GetEccentricity()
const;
437 double GetSquaredEccentricity()
const;
439 OGRErr SetAuthority(
const char *pszTargetKey,
const char *pszAuthority,
442 OGRErr AutoIdentifyEPSG();
444 int **ppanMatchConfidence)
const;
446 FindBestMatch(
int nMinimumMatchConfidence = 90,
447 const char *pszPreferredAuthority =
"EPSG",
450 int GetEPSGGeogCS()
const;
452 const char *GetAuthorityCode(
const char *pszTargetKey)
const;
453 const char *GetAuthorityName(
const char *pszTargetKey)
const;
454 char *GetOGCURN()
const;
456 bool GetAreaOfUse(
double *pdfWestLongitudeDeg,
double *pdfSouthLatitudeDeg,
457 double *pdfEastLongitudeDeg,
double *pdfNorthLatitudeDeg,
458 const char **ppszAreaName)
const;
460 const char *GetExtension(
const char *pszTargetKey,
const char *pszName,
461 const char *pszDefault =
nullptr)
const;
462 OGRErr SetExtension(
const char *pszTargetKey,
const char *pszName,
463 const char *pszValue);
465 int FindProjParm(
const char *pszParameter,
467 OGRErr SetProjParm(
const char *,
double);
468 double GetProjParm(
const char *,
double = 0.0,
OGRErr * =
nullptr)
const;
470 OGRErr SetNormProjParm(
const char *,
double);
471 double GetNormProjParm(
const char *,
double = 0.0,
472 OGRErr * =
nullptr)
const;
474 static int IsAngularParameter(
const char *);
475 static int IsLongitudeParameter(
const char *);
476 static int IsLinearParameter(
const char *);
479 OGRErr SetACEA(
double dfStdP1,
double dfStdP2,
double dfCenterLat,
480 double dfCenterLong,
double dfFalseEasting,
481 double dfFalseNorthing);
484 OGRErr SetAE(
double dfCenterLat,
double dfCenterLong,
double dfFalseEasting,
485 double dfFalseNorthing);
488 OGRErr SetBonne(
double dfStdP1,
double dfCentralMeridian,
489 double dfFalseEasting,
double dfFalseNorthing);
492 OGRErr SetCEA(
double dfStdP1,
double dfCentralMeridian,
493 double dfFalseEasting,
double dfFalseNorthing);
496 OGRErr SetCS(
double dfCenterLat,
double dfCenterLong,
double dfFalseEasting,
497 double dfFalseNorthing);
500 OGRErr SetEC(
double dfStdP1,
double dfStdP2,
double dfCenterLat,
501 double dfCenterLong,
double dfFalseEasting,
502 double dfFalseNorthing);
505 OGRErr SetEckert(
int nVariation,
double dfCentralMeridian,
506 double dfFalseEasting,
double dfFalseNorthing);
509 OGRErr SetEckertIV(
double dfCentralMeridian,
double dfFalseEasting,
510 double dfFalseNorthing);
513 OGRErr SetEckertVI(
double dfCentralMeridian,
double dfFalseEasting,
514 double dfFalseNorthing);
517 OGRErr SetEquirectangular(
double dfCenterLat,
double dfCenterLong,
518 double dfFalseEasting,
double dfFalseNorthing);
520 OGRErr SetEquirectangular2(
double dfCenterLat,
double dfCenterLong,
521 double dfPseudoStdParallel1,
522 double dfFalseEasting,
double dfFalseNorthing);
525 OGRErr SetGEOS(
double dfCentralMeridian,
double dfSatelliteHeight,
526 double dfFalseEasting,
double dfFalseNorthing);
529 OGRErr SetGH(
double dfCentralMeridian,
double dfFalseEasting,
530 double dfFalseNorthing);
536 OGRErr SetGS(
double dfCentralMeridian,
double dfFalseEasting,
537 double dfFalseNorthing);
540 OGRErr SetGaussSchreiberTMercator(
double dfCenterLat,
double dfCenterLong,
541 double dfScale,
double dfFalseEasting,
542 double dfFalseNorthing);
545 OGRErr SetGnomonic(
double dfCenterLat,
double dfCenterLong,
546 double dfFalseEasting,
double dfFalseNorthing);
549 OGRErr SetHOM(
double dfCenterLat,
double dfCenterLong,
double dfAzimuth,
550 double dfRectToSkew,
double dfScale,
double dfFalseEasting,
551 double dfFalseNorthing);
554 OGRErr SetHOM2PNO(
double dfCenterLat,
double dfLat1,
double dfLong1,
555 double dfLat2,
double dfLong2,
double dfScale,
556 double dfFalseEasting,
double dfFalseNorthing);
559 OGRErr SetHOMAC(
double dfCenterLat,
double dfCenterLong,
double dfAzimuth,
560 double dfRectToSkew,
double dfScale,
double dfFalseEasting,
561 double dfFalseNorthing);
564 OGRErr SetLOM(
double dfCenterLat,
double dfCenterLong,
double dfAzimuth,
565 double dfScale,
double dfFalseEasting,
566 double dfFalseNorthing);
569 OGRErr SetIWMPolyconic(
double dfLat1,
double dfLat2,
double dfCenterLong,
570 double dfFalseEasting,
double dfFalseNorthing);
573 OGRErr SetKrovak(
double dfCenterLat,
double dfCenterLong,
double dfAzimuth,
574 double dfPseudoStdParallelLat,
double dfScale,
575 double dfFalseEasting,
double dfFalseNorthing);
578 OGRErr SetLAEA(
double dfCenterLat,
double dfCenterLong,
579 double dfFalseEasting,
double dfFalseNorthing);
582 OGRErr SetLCC(
double dfStdP1,
double dfStdP2,
double dfCenterLat,
583 double dfCenterLong,
double dfFalseEasting,
584 double dfFalseNorthing);
587 OGRErr SetLCC1SP(
double dfCenterLat,
double dfCenterLong,
double dfScale,
588 double dfFalseEasting,
double dfFalseNorthing);
591 OGRErr SetLCCB(
double dfStdP1,
double dfStdP2,
double dfCenterLat,
592 double dfCenterLong,
double dfFalseEasting,
593 double dfFalseNorthing);
596 OGRErr SetMC(
double dfCenterLat,
double dfCenterLong,
double dfFalseEasting,
597 double dfFalseNorthing);
600 OGRErr SetMercator(
double dfCenterLat,
double dfCenterLong,
double dfScale,
601 double dfFalseEasting,
double dfFalseNorthing);
604 OGRErr SetMercator2SP(
double dfStdP1,
double dfCenterLat,
605 double dfCenterLong,
double dfFalseEasting,
606 double dfFalseNorthing);
609 OGRErr SetMollweide(
double dfCentralMeridian,
double dfFalseEasting,
610 double dfFalseNorthing);
613 OGRErr SetNZMG(
double dfCenterLat,
double dfCenterLong,
614 double dfFalseEasting,
double dfFalseNorthing);
617 OGRErr SetOS(
double dfOriginLat,
double dfCMeridian,
double dfScale,
618 double dfFalseEasting,
double dfFalseNorthing);
621 OGRErr SetOrthographic(
double dfCenterLat,
double dfCenterLong,
622 double dfFalseEasting,
double dfFalseNorthing);
625 OGRErr SetPolyconic(
double dfCenterLat,
double dfCenterLong,
626 double dfFalseEasting,
double dfFalseNorthing);
629 OGRErr SetPS(
double dfCenterLat,
double dfCenterLong,
double dfScale,
630 double dfFalseEasting,
double dfFalseNorthing);
633 OGRErr SetRobinson(
double dfCenterLong,
double dfFalseEasting,
634 double dfFalseNorthing);
637 OGRErr SetSinusoidal(
double dfCenterLong,
double dfFalseEasting,
638 double dfFalseNorthing);
641 OGRErr SetStereographic(
double dfCenterLat,
double dfCenterLong,
642 double dfScale,
double dfFalseEasting,
643 double dfFalseNorthing);
646 OGRErr SetSOC(
double dfLatitudeOfOrigin,
double dfCentralMeridian,
647 double dfFalseEasting,
double dfFalseNorthing);
650 OGRErr SetTM(
double dfCenterLat,
double dfCenterLong,
double dfScale,
651 double dfFalseEasting,
double dfFalseNorthing);
654 OGRErr SetTMVariant(
const char *pszVariantName,
double dfCenterLat,
655 double dfCenterLong,
double dfScale,
656 double dfFalseEasting,
double dfFalseNorthing);
659 OGRErr SetTMG(
double dfCenterLat,
double dfCenterLong,
660 double dfFalseEasting,
double dfFalseNorthing);
663 OGRErr SetTMSO(
double dfCenterLat,
double dfCenterLong,
double dfScale,
664 double dfFalseEasting,
double dfFalseNorthing);
667 OGRErr SetTPED(
double dfLat1,
double dfLong1,
double dfLat2,
double dfLong2,
668 double dfFalseEasting,
double dfFalseNorthing);
671 OGRErr SetVDG(
double dfCenterLong,
double dfFalseEasting,
672 double dfFalseNorthing);
675 OGRErr SetUTM(
int nZone,
int bNorth = TRUE);
676 int GetUTMZone(
int *pbNorth =
nullptr)
const;
679 OGRErr SetWagner(
int nVariation,
double dfCenterLat,
double dfFalseEasting,
680 double dfFalseNorthing);
683 OGRErr SetQSC(
double dfCenterLat,
double dfCenterLong);
686 OGRErr SetSCH(
double dfPegLat,
double dfPegLong,
double dfPegHeading,
691 SetVerticalPerspective(
double dfTopoOriginLat,
double dfTopoOriginLon,
692 double dfTopoOriginHeight,
double dfViewPointHeight,
693 double dfFalseEasting,
double dfFalseNorthing);
696 OGRErr SetDerivedGeogCRSWithPoleRotationGRIBConvention(
697 const char *pszCRSName,
double dfSouthPoleLat,
double dfSouthPoleLon,
698 double dfAxisRotation);
701 OGRErr SetDerivedGeogCRSWithPoleRotationNetCDFCFConvention(
702 const char *pszCRSName,
double dfGridNorthPoleLat,
703 double dfGridNorthPoleLon,
double dfNorthPoleGridLon);
706 OGRErr SetStatePlane(
int nZone,
int bNAD83 = TRUE,
707 const char *pszOverrideUnitName =
nullptr,
708 double dfOverrideUnit = 0.0);
711 OGRErr ImportFromESRIStatePlaneWKT(
int nCode,
const char *pszDatumName,
712 const char *pszUnitsName,
int nPCSCode,
713 const char *pszCRSName =
nullptr);
716 OGRErr ImportFromESRIWisconsinWKT(
const char *pszPrjName,
717 double dfCentralMeridian,
718 double dfLatOfOrigin,
719 const char *pszUnitsName,
720 const char *pszCRSName =
nullptr);
723 void UpdateCoordinateSystemFromGeogCRS();
744struct CPL_DLL OGRSpatialReferenceReleaser
819 int Transform(
size_t nCount,
double *x,
double *y,
double *z =
nullptr,
820 int *pabSuccess =
nullptr);
846 virtual int Transform(
size_t nCount,
double *x,
double *y,
double *z,
847 double *t,
int *pabSuccess) = 0;
875 double *z,
double *t,
915 const double xmax,
const double ymax,
916 double *out_xmin,
double *out_ymin,
917 double *out_xmax,
double *out_ymax,
918 const int densify_pts)
925 *out_xmin = HUGE_VAL;
926 *out_ymin = HUGE_VAL;
927 *out_xmax = HUGE_VAL;
928 *out_ymax = HUGE_VAL;
930 "TransformBounds not implemented.");
994 friend class OGRProjCT;
996 std::unique_ptr<Private> d;
1007 bool SetAreaOfInterest(
double dfWestLongitudeDeg,
double dfSouthLatitudeDeg,
1008 double dfEastLongitudeDeg,
1009 double dfNorthLatitudeDeg);
1010 bool SetDesiredAccuracy(
double dfAccuracy);
1011 bool SetBallparkAllowed(
bool bAllowBallpark);
1012 bool SetOnlyBest(
bool bOnlyBest);
1014 bool SetCoordinateOperation(
const char *pszCT,
bool bReverseCT);
1016 void SetSourceCenterLong(
double dfCenterLong);
1017 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:152
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:737
void Release()
Decrements the reference count by one, and destroy if zero.
Definition ogrspatialreference.cpp:1156
Objects of this class are used to represent value nodes in the parsed representation of the WKT SRS f...
Definition ogr_spatialref.h:50
int GetChildCount() const
Get number of children nodes.
Definition ogr_spatialref.h:74
const char * GetValue() const
Fetch value string for this node.
Definition ogr_spatialref.h:92
int IsLeafNode() const
Return whether this is a leaf node.
Definition ogr_spatialref.h:69
#define CPLE_AppDefined
Application defined error.
Definition cpl_error.h:85
#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:936
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition cpl_port.h:1087
Various convenience functions for working with strings and string lists.
void * OGRCoordinateTransformationH
Opaque type for a coordinate transformation object.
Definition gdal_fwd.h:197
void * OGRSpatialReferenceH
Opaque type for a spatial reference system.
Definition gdal_fwd.h:195
int OGRErr
Type for a OGR error.
Definition ogr_core.h:370
#define USGS_ANGLE_PACKEDDMS
Angle is in packed degree minute second.
Definition ogr_spatialref.h:231
OGRCoordinateTransformation * OGRCreateCoordinateTransformation(const OGRSpatialReference *poSource, const OGRSpatialReference *poTarget)
Create transformation object.
Definition ogrct.cpp:1027
C spatial reference system services and defines.
OSRAxisMappingStrategy
Data axis to CRS axis mapping strategy.
Definition ogr_srs_api.h:637
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:54
virtual void notifyChange(OGR_SRSNode *)=0
Method triggered when a node is modified.