32 #ifndef OGR_SPATIALREF_H_INCLUDED
33 #define OGR_SPATIALREF_H_INCLUDED
81 void RegisterListener(
const std::shared_ptr<Listener>& listener);
97 int FindChild(
const char * )
const;
98 void DestroyChild(
int );
100 void StripNodes(
const char * );
103 void SetValue(
const char * );
105 void MakeValueSafe();
109 OGRErr importFromWkt(
char ** )
111 CPL_WARN_DEPRECATED(
"Use importFromWkt(const char**)")
114 OGRErr importFromWkt(
const char ** );
115 OGRErr exportToWkt(
char ** )
const;
116 OGRErr exportToPrettyWkt(
char **,
int = 1)
const;
126 int NeedsQuoting()
const;
127 OGRErr importFromWkt(
const char **,
int nRecLevel,
int* pnNodes );
129 std::weak_ptr<Listener> m_listener{};
160 std::unique_ptr<Private> d;
162 void GetNormInfo()
const;
165 OGRErr importFromURNPart(
const char* pszAuthority,
169 static CPLString lookupInDict(
const char *pszDictFile,
170 const char *pszCode );
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 OGRErr exportToPrettyWkt(
char **,
int = FALSE)
const;
197 OGRErr exportToPROJJSON(
char **,
const char*
const* papszOptions )
const;
198 OGRErr exportToProj4(
char ** )
const;
199 OGRErr exportToPCI(
char **,
char **,
double ** )
const;
200 OGRErr exportToUSGS(
long *,
long *,
double **,
long * )
const;
201 OGRErr exportToXML(
char **,
const char * =
nullptr )
const;
202 OGRErr exportToPanorama(
long *,
long *,
long *,
long *,
204 OGRErr exportToERM(
char *pszProj,
char *pszDatum,
char *pszUnits );
205 OGRErr exportToMICoordSys(
char ** )
const;
208 OGRErr importFromWkt(
char ** )
210 CPL_WARN_DEPRECATED(
"Use importFromWkt(const char**) or importFromWkt(const char*)")
214 OGRErr importFromWkt(
const char ** );
215 OGRErr importFromWkt(
const char* );
216 OGRErr importFromProj4(
const char * );
217 OGRErr importFromEPSG(
int );
218 OGRErr importFromEPSGA(
int );
219 OGRErr importFromESRI(
char ** );
220 OGRErr importFromPCI(
const char *,
const char * =
nullptr,
221 double * =
nullptr );
223 #define USGS_ANGLE_DECIMALDEGREES 0
224 #define USGS_ANGLE_PACKEDDMS TRUE
225 #define USGS_ANGLE_RADIANS 2
226 OGRErr importFromUSGS(
long iProjSys,
long iZone,
227 double *padfPrjParams,
long iDatum,
229 OGRErr importFromPanorama(
long,
long,
long,
double* );
230 OGRErr importVertCSFromPanorama(
int );
231 OGRErr importFromOzi(
const char *
const* papszLines );
232 OGRErr importFromWMSAUTO(
const char *pszAutoDef );
233 OGRErr importFromXML(
const char * );
234 OGRErr importFromDict(
const char *pszDict,
const char *pszCode );
235 OGRErr importFromURN(
const char * );
236 OGRErr importFromCRSURL(
const char * );
237 OGRErr importFromERM(
const char *pszProj,
const char *pszDatum,
238 const char *pszUnits );
239 OGRErr importFromUrl(
const char * );
240 OGRErr importFromMICoordSys(
const char * );
246 const char* pszTargetProjection,
247 const char*
const* papszOptions =
nullptr )
const;
252 bool StripTOWGS84IfKnownDatumAndAllowed();
253 bool StripTOWGS84IfKnownDatum();
255 int EPSGTreatsAsLatLong()
const;
256 int EPSGTreatsAsNorthingEasting()
const;
257 int GetAxesCount()
const;
258 const char *GetAxis(
const char *pszTargetKey,
int iAxis,
260 double* pdfConvFactor =
nullptr )
const;
261 OGRErr SetAxes(
const char *pszTargetKey,
262 const char *pszXAxisName,
264 const char *pszYAxisName,
269 const std::vector<int>& GetDataAxisToSRSAxisMapping()
const;
270 OGRErr SetDataAxisToSRSAxisMapping(
const std::vector<int>& mapping);
281 const OGR_SRSNode *GetAttrNode(
const char *)
const;
282 const char *GetAttrValue(
const char *,
int = 0)
const;
284 OGRErr SetNode(
const char *,
const char * );
285 OGRErr SetNode(
const char *,
double );
287 OGRErr SetLinearUnitsAndUpdateParameters(
const char *pszName,
289 const char *pszUnitAuthority =
nullptr,
290 const char *pszUnitCode =
nullptr );
291 OGRErr SetLinearUnits(
const char *pszName,
double dfInMeters );
292 OGRErr SetTargetLinearUnits(
const char *pszTargetKey,
295 const char *pszUnitAuthority =
nullptr,
296 const char *pszUnitCode =
nullptr);
298 double GetLinearUnits(
char ** )
const
300 CPL_WARN_DEPRECATED(
"Use GetLinearUnits(const char**) instead")
303 double GetLinearUnits(
const char ** =
nullptr )
const;
305 double GetLinearUnits( std::nullptr_t )
const
306 {
return GetLinearUnits(
static_cast<const char**
>(
nullptr) ); }
309 double GetTargetLinearUnits(
const char *pszTargetKey,
310 char ** ppszRetName )
const
312 CPL_WARN_DEPRECATED(
"Use GetTargetLinearUnits(const char*, const char**)")
315 double GetTargetLinearUnits(
const char *pszTargetKey,
316 const char ** ppszRetName =
nullptr )
const;
318 double GetTargetLinearUnits(
const char *pszTargetKey, std::nullptr_t )
const
319 {
return GetTargetLinearUnits( pszTargetKey,
static_cast<const char**
>(
nullptr) ); }
322 OGRErr SetAngularUnits(
const char *pszName,
double dfInRadians );
323 double GetAngularUnits(
char ** )
const
325 CPL_WARN_DEPRECATED(
"Use GetAngularUnits(const char**) instead")
328 double GetAngularUnits(
const char ** =
nullptr )
const;
330 double GetAngularUnits( std::nullptr_t )
const
331 {
return GetAngularUnits(
static_cast<const char**
>(
nullptr) ); }
334 double GetPrimeMeridian(
char ** )
const
336 CPL_WARN_DEPRECATED(
"Use GetPrimeMeridian(const char**) instead")
339 double GetPrimeMeridian(
const char ** =
nullptr )
const;
341 double GetPrimeMeridian( std::nullptr_t )
const
342 {
return GetPrimeMeridian(
static_cast<const char**
>(
nullptr) ); }
345 bool IsEmpty()
const;
346 int IsGeographic()
const;
347 int IsDerivedGeographic()
const;
348 int IsProjected()
const;
349 int IsGeocentric()
const;
350 bool IsDynamic()
const;
352 int IsVertical()
const;
353 int IsCompound()
const;
356 const char*
const * papszOptions )
const;
360 const char*
const * papszOptions )
const;
363 OGRErr SetLocalCS(
const char * );
364 OGRErr SetProjCS(
const char * );
365 OGRErr SetProjection(
const char * );
366 OGRErr SetGeocCS(
const char * pszGeocName );
367 OGRErr SetGeogCS(
const char * pszGeogName,
368 const char * pszDatumName,
369 const char * pszEllipsoidName,
370 double dfSemiMajor,
double dfInvFlattening,
371 const char * pszPMName =
nullptr,
372 double dfPMOffset = 0.0,
373 const char * pszUnits =
nullptr,
374 double dfConvertToRadians = 0.0 );
375 OGRErr SetWellKnownGeogCS(
const char * );
377 OGRErr SetVertCS(
const char *pszVertCSName,
378 const char *pszVertDatumName,
379 int nVertDatumClass = 2005 );
380 OGRErr SetCompoundCS(
const char *pszName,
384 void SetCoordinateEpoch(
double dfCoordinateEpoch );
385 double GetCoordinateEpoch()
const;
388 OGRErr PromoteTo3D(
const char* pszName );
390 OGRErr DemoteTo2D(
const char* pszName );
392 OGRErr SetFromUserInput(
const char * );
394 static const char*
const SET_FROM_USER_INPUT_LIMITATIONS[];
395 static CSLConstList SET_FROM_USER_INPUT_LIMITATIONS_get();
399 OGRErr SetTOWGS84(
double,
double,
double,
400 double = 0.0,
double = 0.0,
double = 0.0,
402 OGRErr GetTOWGS84(
double *padfCoef,
int nCoeff = 7 )
const;
403 OGRErr AddGuessedTOWGS84();
405 double GetSemiMajor(
OGRErr * =
nullptr )
const;
406 double GetSemiMinor(
OGRErr * =
nullptr )
const;
407 double GetInvFlattening(
OGRErr * =
nullptr )
const;
408 double GetEccentricity()
const;
409 double GetSquaredEccentricity()
const;
411 OGRErr SetAuthority(
const char * pszTargetKey,
412 const char * pszAuthority,
415 OGRErr AutoIdentifyEPSG();
418 int** ppanMatchConfidence )
const;
420 int GetEPSGGeogCS()
const;
422 const char *GetAuthorityCode(
const char * pszTargetKey )
const;
423 const char *GetAuthorityName(
const char * pszTargetKey )
const;
425 bool GetAreaOfUse(
double* pdfWestLongitudeDeg,
426 double* pdfSouthLatitudeDeg,
427 double* pdfEastLongitudeDeg,
428 double* pdfNorthLatitudeDeg,
429 const char **ppszAreaName )
const;
431 const char *GetExtension(
const char *pszTargetKey,
433 const char *pszDefault =
nullptr )
const;
434 OGRErr SetExtension(
const char *pszTargetKey,
436 const char *pszValue );
438 int FindProjParm(
const char *pszParameter,
440 OGRErr SetProjParm(
const char *,
double );
441 double GetProjParm(
const char *,
double =0.0,
OGRErr* =
nullptr )
const;
443 OGRErr SetNormProjParm(
const char *,
double );
444 double GetNormProjParm(
const char *,
double=0.0,
OGRErr* =
nullptr)
const;
446 static int IsAngularParameter(
const char * );
447 static int IsLongitudeParameter(
const char * );
448 static int IsLinearParameter(
const char * );
451 OGRErr SetACEA(
double dfStdP1,
double dfStdP2,
452 double dfCenterLat,
double dfCenterLong,
453 double dfFalseEasting,
double dfFalseNorthing );
456 OGRErr SetAE(
double dfCenterLat,
double dfCenterLong,
457 double dfFalseEasting,
double dfFalseNorthing );
460 OGRErr SetBonne(
double dfStdP1,
double dfCentralMeridian,
461 double dfFalseEasting,
double dfFalseNorthing );
464 OGRErr SetCEA(
double dfStdP1,
double dfCentralMeridian,
465 double dfFalseEasting,
double dfFalseNorthing );
468 OGRErr SetCS(
double dfCenterLat,
double dfCenterLong,
469 double dfFalseEasting,
double dfFalseNorthing );
472 OGRErr SetEC(
double dfStdP1,
double dfStdP2,
473 double dfCenterLat,
double dfCenterLong,
474 double dfFalseEasting,
double dfFalseNorthing );
477 OGRErr SetEckert(
int nVariation,
double dfCentralMeridian,
478 double dfFalseEasting,
double dfFalseNorthing );
481 OGRErr SetEckertIV(
double dfCentralMeridian,
482 double dfFalseEasting,
double dfFalseNorthing );
485 OGRErr SetEckertVI(
double dfCentralMeridian,
486 double dfFalseEasting,
double dfFalseNorthing );
489 OGRErr SetEquirectangular(
double dfCenterLat,
double dfCenterLong,
490 double dfFalseEasting,
double dfFalseNorthing );
492 OGRErr SetEquirectangular2(
double dfCenterLat,
double dfCenterLong,
493 double dfPseudoStdParallel1,
494 double dfFalseEasting,
double dfFalseNorthing );
497 OGRErr SetGEOS(
double dfCentralMeridian,
double dfSatelliteHeight,
498 double dfFalseEasting,
double dfFalseNorthing );
501 OGRErr SetGH(
double dfCentralMeridian,
502 double dfFalseEasting,
double dfFalseNorthing );
508 OGRErr SetGS(
double dfCentralMeridian,
509 double dfFalseEasting,
double dfFalseNorthing );
512 OGRErr SetGaussSchreiberTMercator(
double dfCenterLat,
double dfCenterLong,
514 double dfFalseEasting,
double dfFalseNorthing );
517 OGRErr SetGnomonic(
double dfCenterLat,
double dfCenterLong,
518 double dfFalseEasting,
double dfFalseNorthing );
521 OGRErr SetHOM(
double dfCenterLat,
double dfCenterLong,
522 double dfAzimuth,
double dfRectToSkew,
524 double dfFalseEasting,
double dfFalseNorthing );
527 OGRErr SetHOM2PNO(
double dfCenterLat,
528 double dfLat1,
double dfLong1,
529 double dfLat2,
double dfLong2,
531 double dfFalseEasting,
double dfFalseNorthing );
534 OGRErr SetHOMAC(
double dfCenterLat,
double dfCenterLong,
535 double dfAzimuth,
double dfRectToSkew,
537 double dfFalseEasting,
double dfFalseNorthing );
540 OGRErr SetLOM(
double dfCenterLat,
double dfCenterLong,
543 double dfFalseEasting,
double dfFalseNorthing );
546 OGRErr SetIWMPolyconic(
double dfLat1,
double dfLat2,
548 double dfFalseEasting,
549 double dfFalseNorthing );
552 OGRErr SetKrovak(
double dfCenterLat,
double dfCenterLong,
553 double dfAzimuth,
double dfPseudoStdParallelLat,
555 double dfFalseEasting,
double dfFalseNorthing );
558 OGRErr SetLAEA(
double dfCenterLat,
double dfCenterLong,
559 double dfFalseEasting,
double dfFalseNorthing );
562 OGRErr SetLCC(
double dfStdP1,
double dfStdP2,
563 double dfCenterLat,
double dfCenterLong,
564 double dfFalseEasting,
double dfFalseNorthing );
567 OGRErr SetLCC1SP(
double dfCenterLat,
double dfCenterLong,
569 double dfFalseEasting,
double dfFalseNorthing );
572 OGRErr SetLCCB(
double dfStdP1,
double dfStdP2,
573 double dfCenterLat,
double dfCenterLong,
574 double dfFalseEasting,
double dfFalseNorthing );
577 OGRErr SetMC(
double dfCenterLat,
double dfCenterLong,
578 double dfFalseEasting,
double dfFalseNorthing );
581 OGRErr SetMercator(
double dfCenterLat,
double dfCenterLong,
583 double dfFalseEasting,
double dfFalseNorthing );
586 OGRErr SetMercator2SP(
double dfStdP1,
587 double dfCenterLat,
double dfCenterLong,
588 double dfFalseEasting,
double dfFalseNorthing );
591 OGRErr SetMollweide(
double dfCentralMeridian,
592 double dfFalseEasting,
double dfFalseNorthing );
595 OGRErr SetNZMG(
double dfCenterLat,
double dfCenterLong,
596 double dfFalseEasting,
double dfFalseNorthing );
599 OGRErr SetOS(
double dfOriginLat,
double dfCMeridian,
601 double dfFalseEasting,
double dfFalseNorthing);
604 OGRErr SetOrthographic(
double dfCenterLat,
double dfCenterLong,
605 double dfFalseEasting,
double dfFalseNorthing);
608 OGRErr SetPolyconic(
double dfCenterLat,
double dfCenterLong,
609 double dfFalseEasting,
double dfFalseNorthing );
612 OGRErr SetPS(
double dfCenterLat,
double dfCenterLong,
614 double dfFalseEasting,
double dfFalseNorthing);
617 OGRErr SetRobinson(
double dfCenterLong,
618 double dfFalseEasting,
double dfFalseNorthing );
621 OGRErr SetSinusoidal(
double dfCenterLong,
622 double dfFalseEasting,
double dfFalseNorthing );
625 OGRErr SetStereographic(
double dfCenterLat,
double dfCenterLong,
627 double dfFalseEasting,
double dfFalseNorthing);
630 OGRErr SetSOC(
double dfLatitudeOfOrigin,
double dfCentralMeridian,
631 double dfFalseEasting,
double dfFalseNorthing );
634 OGRErr SetTM(
double dfCenterLat,
double dfCenterLong,
636 double dfFalseEasting,
double dfFalseNorthing );
639 OGRErr SetTMVariant(
const char *pszVariantName,
640 double dfCenterLat,
double dfCenterLong,
642 double dfFalseEasting,
double dfFalseNorthing );
645 OGRErr SetTMG(
double dfCenterLat,
double dfCenterLong,
646 double dfFalseEasting,
double dfFalseNorthing );
649 OGRErr SetTMSO(
double dfCenterLat,
double dfCenterLong,
651 double dfFalseEasting,
double dfFalseNorthing );
654 OGRErr SetTPED(
double dfLat1,
double dfLong1,
655 double dfLat2,
double dfLong2,
656 double dfFalseEasting,
double dfFalseNorthing );
659 OGRErr SetVDG(
double dfCenterLong,
660 double dfFalseEasting,
double dfFalseNorthing );
663 OGRErr SetUTM(
int nZone,
int bNorth = TRUE );
664 int GetUTMZone(
int *pbNorth =
nullptr )
const;
667 OGRErr SetWagner(
int nVariation,
double dfCenterLat,
668 double dfFalseEasting,
double dfFalseNorthing );
671 OGRErr SetQSC(
double dfCenterLat,
double dfCenterLong);
674 OGRErr SetSCH(
double dfPegLat,
double dfPegLong,
675 double dfPegHeading,
double dfPegHgt);
678 OGRErr SetVerticalPerspective(
double dfTopoOriginLat,
679 double dfTopoOriginLon,
680 double dfTopoOriginHeight,
681 double dfViewPointHeight,
682 double dfFalseEasting,
683 double dfFalseNorthing);
686 OGRErr SetDerivedGeogCRSWithPoleRotationGRIBConvention(
687 const char* pszCRSName,
688 double dfSouthPoleLat,
689 double dfSouthPoleLon,
690 double dfAxisRotation );
693 OGRErr SetDerivedGeogCRSWithPoleRotationNetCDFCFConvention(
694 const char* pszCRSName,
695 double dfGridNorthPoleLat,
696 double dfGridNorthPoleLon,
697 double dfNorthPoleGridLon );
700 OGRErr SetStatePlane(
int nZone,
int bNAD83 = TRUE,
701 const char *pszOverrideUnitName =
nullptr,
702 double dfOverrideUnit = 0.0 );
705 OGRErr ImportFromESRIStatePlaneWKT(
706 int nCode,
const char* pszDatumName,
const char* pszUnitsName,
707 int nPCSCode,
const char* pszCRSName =
nullptr );
710 OGRErr ImportFromESRIWisconsinWKT(
711 const char* pszPrjName,
double dfCentralMeridian,
double dfLatOfOrigin,
712 const char* pszUnitsName,
const char* pszCRSName =
nullptr );
715 void UpdateCoordinateSystemFromGeogCRS();
789 double *x,
double *y,
double *z =
nullptr,
790 int *pabSuccess =
nullptr );
809 double *x,
double *y,
810 double *z,
double *t,
811 int *pabSuccess ) = 0;
831 double *x,
double *y,
832 double *z,
double *t,
833 int *panErrorCodes );
875 const int densify_pts )
882 *out_xmin = HUGE_VAL;
883 *out_ymin = HUGE_VAL;
884 *out_xmax = HUGE_VAL;
885 *out_ymax = HUGE_VAL;
934 friend class OGRProjCT;
936 std::unique_ptr<Private> d;
945 bool SetAreaOfInterest(
double dfWestLongitudeDeg,
946 double dfSouthLatitudeDeg,
947 double dfEastLongitudeDeg,
948 double dfNorthLatitudeDeg);
949 bool SetDesiredAccuracy(
double dfAccuracy);
950 bool SetBallparkAllowed(
bool bAllowBallpark);
952 bool SetCoordinateOperation(
const char* pszCT,
bool bReverseCT);
954 void SetSourceCenterLong(
double dfCenterLong);
955 void SetTargetCenterLong(
double dfCenterLong);
Convenient string class based on std::string.
Definition: cpl_string.h:333
This class represents an OpenGIS Spatial Reference System, and contains methods for converting betwee...
Definition: ogr_spatialref.h:158
static OGRSpatialReference * FromHandle(OGRSpatialReferenceH hSRS)
Convert a OGRSpatialReferenceH to a OGRSpatialReference*.
Definition: ogr_spatialref.h:729
static OGRSpatialReferenceH ToHandle(OGRSpatialReference *poSRS)
Convert a OGRSpatialReference* to a OGRSpatialReferenceH.
Definition: ogr_spatialref.h:723
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:88
const char * GetValue() const
Fetch value string for this node.
Definition: ogr_spatialref.h:102
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:99
void CPLError(CPLErr eErrClass, CPLErrorNum err_no, const char *fmt,...)
Report an error.
Definition: cpl_error.cpp:310
#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:955
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition: cpl_port.h:1169
Various convenience functions for working with strings and string lists.
void * OGRCoordinateTransformationH
Opaque type for a coordinate transformation object.
Definition: ogr_api.h:82
void * OGRSpatialReferenceH
Opaque type for a spatial reference system.
Definition: ogr_api.h:80
int OGRErr
Type for a OGR error.
Definition: ogr_core.h:318
#define USGS_ANGLE_PACKEDDMS
Angle is in packed degree minute second.
Definition: ogr_spatialref.h:224
OGRCoordinateTransformation * OGRCreateCoordinateTransformation(const OGRSpatialReference *poSource, const OGRSpatialReference *poTarget)
Create transformation object.
Definition: ogrct.cpp:792
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:48
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.