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;
424 char *GetOGCURN()
const;
426 bool GetAreaOfUse(
double* pdfWestLongitudeDeg,
427 double* pdfSouthLatitudeDeg,
428 double* pdfEastLongitudeDeg,
429 double* pdfNorthLatitudeDeg,
430 const char **ppszAreaName )
const;
432 const char *GetExtension(
const char *pszTargetKey,
434 const char *pszDefault =
nullptr )
const;
435 OGRErr SetExtension(
const char *pszTargetKey,
437 const char *pszValue );
439 int FindProjParm(
const char *pszParameter,
441 OGRErr SetProjParm(
const char *,
double );
442 double GetProjParm(
const char *,
double =0.0,
OGRErr* =
nullptr )
const;
444 OGRErr SetNormProjParm(
const char *,
double );
445 double GetNormProjParm(
const char *,
double=0.0,
OGRErr* =
nullptr)
const;
447 static int IsAngularParameter(
const char * );
448 static int IsLongitudeParameter(
const char * );
449 static int IsLinearParameter(
const char * );
452 OGRErr SetACEA(
double dfStdP1,
double dfStdP2,
453 double dfCenterLat,
double dfCenterLong,
454 double dfFalseEasting,
double dfFalseNorthing );
457 OGRErr SetAE(
double dfCenterLat,
double dfCenterLong,
458 double dfFalseEasting,
double dfFalseNorthing );
461 OGRErr SetBonne(
double dfStdP1,
double dfCentralMeridian,
462 double dfFalseEasting,
double dfFalseNorthing );
465 OGRErr SetCEA(
double dfStdP1,
double dfCentralMeridian,
466 double dfFalseEasting,
double dfFalseNorthing );
469 OGRErr SetCS(
double dfCenterLat,
double dfCenterLong,
470 double dfFalseEasting,
double dfFalseNorthing );
473 OGRErr SetEC(
double dfStdP1,
double dfStdP2,
474 double dfCenterLat,
double dfCenterLong,
475 double dfFalseEasting,
double dfFalseNorthing );
478 OGRErr SetEckert(
int nVariation,
double dfCentralMeridian,
479 double dfFalseEasting,
double dfFalseNorthing );
482 OGRErr SetEckertIV(
double dfCentralMeridian,
483 double dfFalseEasting,
double dfFalseNorthing );
486 OGRErr SetEckertVI(
double dfCentralMeridian,
487 double dfFalseEasting,
double dfFalseNorthing );
490 OGRErr SetEquirectangular(
double dfCenterLat,
double dfCenterLong,
491 double dfFalseEasting,
double dfFalseNorthing );
493 OGRErr SetEquirectangular2(
double dfCenterLat,
double dfCenterLong,
494 double dfPseudoStdParallel1,
495 double dfFalseEasting,
double dfFalseNorthing );
498 OGRErr SetGEOS(
double dfCentralMeridian,
double dfSatelliteHeight,
499 double dfFalseEasting,
double dfFalseNorthing );
502 OGRErr SetGH(
double dfCentralMeridian,
503 double dfFalseEasting,
double dfFalseNorthing );
509 OGRErr SetGS(
double dfCentralMeridian,
510 double dfFalseEasting,
double dfFalseNorthing );
513 OGRErr SetGaussSchreiberTMercator(
double dfCenterLat,
double dfCenterLong,
515 double dfFalseEasting,
double dfFalseNorthing );
518 OGRErr SetGnomonic(
double dfCenterLat,
double dfCenterLong,
519 double dfFalseEasting,
double dfFalseNorthing );
522 OGRErr SetHOM(
double dfCenterLat,
double dfCenterLong,
523 double dfAzimuth,
double dfRectToSkew,
525 double dfFalseEasting,
double dfFalseNorthing );
528 OGRErr SetHOM2PNO(
double dfCenterLat,
529 double dfLat1,
double dfLong1,
530 double dfLat2,
double dfLong2,
532 double dfFalseEasting,
double dfFalseNorthing );
535 OGRErr SetHOMAC(
double dfCenterLat,
double dfCenterLong,
536 double dfAzimuth,
double dfRectToSkew,
538 double dfFalseEasting,
double dfFalseNorthing );
541 OGRErr SetLOM(
double dfCenterLat,
double dfCenterLong,
544 double dfFalseEasting,
double dfFalseNorthing );
547 OGRErr SetIWMPolyconic(
double dfLat1,
double dfLat2,
549 double dfFalseEasting,
550 double dfFalseNorthing );
553 OGRErr SetKrovak(
double dfCenterLat,
double dfCenterLong,
554 double dfAzimuth,
double dfPseudoStdParallelLat,
556 double dfFalseEasting,
double dfFalseNorthing );
559 OGRErr SetLAEA(
double dfCenterLat,
double dfCenterLong,
560 double dfFalseEasting,
double dfFalseNorthing );
563 OGRErr SetLCC(
double dfStdP1,
double dfStdP2,
564 double dfCenterLat,
double dfCenterLong,
565 double dfFalseEasting,
double dfFalseNorthing );
568 OGRErr SetLCC1SP(
double dfCenterLat,
double dfCenterLong,
570 double dfFalseEasting,
double dfFalseNorthing );
573 OGRErr SetLCCB(
double dfStdP1,
double dfStdP2,
574 double dfCenterLat,
double dfCenterLong,
575 double dfFalseEasting,
double dfFalseNorthing );
578 OGRErr SetMC(
double dfCenterLat,
double dfCenterLong,
579 double dfFalseEasting,
double dfFalseNorthing );
582 OGRErr SetMercator(
double dfCenterLat,
double dfCenterLong,
584 double dfFalseEasting,
double dfFalseNorthing );
587 OGRErr SetMercator2SP(
double dfStdP1,
588 double dfCenterLat,
double dfCenterLong,
589 double dfFalseEasting,
double dfFalseNorthing );
592 OGRErr SetMollweide(
double dfCentralMeridian,
593 double dfFalseEasting,
double dfFalseNorthing );
596 OGRErr SetNZMG(
double dfCenterLat,
double dfCenterLong,
597 double dfFalseEasting,
double dfFalseNorthing );
600 OGRErr SetOS(
double dfOriginLat,
double dfCMeridian,
602 double dfFalseEasting,
double dfFalseNorthing);
605 OGRErr SetOrthographic(
double dfCenterLat,
double dfCenterLong,
606 double dfFalseEasting,
double dfFalseNorthing);
609 OGRErr SetPolyconic(
double dfCenterLat,
double dfCenterLong,
610 double dfFalseEasting,
double dfFalseNorthing );
613 OGRErr SetPS(
double dfCenterLat,
double dfCenterLong,
615 double dfFalseEasting,
double dfFalseNorthing);
618 OGRErr SetRobinson(
double dfCenterLong,
619 double dfFalseEasting,
double dfFalseNorthing );
622 OGRErr SetSinusoidal(
double dfCenterLong,
623 double dfFalseEasting,
double dfFalseNorthing );
626 OGRErr SetStereographic(
double dfCenterLat,
double dfCenterLong,
628 double dfFalseEasting,
double dfFalseNorthing);
631 OGRErr SetSOC(
double dfLatitudeOfOrigin,
double dfCentralMeridian,
632 double dfFalseEasting,
double dfFalseNorthing );
635 OGRErr SetTM(
double dfCenterLat,
double dfCenterLong,
637 double dfFalseEasting,
double dfFalseNorthing );
640 OGRErr SetTMVariant(
const char *pszVariantName,
641 double dfCenterLat,
double dfCenterLong,
643 double dfFalseEasting,
double dfFalseNorthing );
646 OGRErr SetTMG(
double dfCenterLat,
double dfCenterLong,
647 double dfFalseEasting,
double dfFalseNorthing );
650 OGRErr SetTMSO(
double dfCenterLat,
double dfCenterLong,
652 double dfFalseEasting,
double dfFalseNorthing );
655 OGRErr SetTPED(
double dfLat1,
double dfLong1,
656 double dfLat2,
double dfLong2,
657 double dfFalseEasting,
double dfFalseNorthing );
660 OGRErr SetVDG(
double dfCenterLong,
661 double dfFalseEasting,
double dfFalseNorthing );
664 OGRErr SetUTM(
int nZone,
int bNorth = TRUE );
665 int GetUTMZone(
int *pbNorth =
nullptr )
const;
668 OGRErr SetWagner(
int nVariation,
double dfCenterLat,
669 double dfFalseEasting,
double dfFalseNorthing );
672 OGRErr SetQSC(
double dfCenterLat,
double dfCenterLong);
675 OGRErr SetSCH(
double dfPegLat,
double dfPegLong,
676 double dfPegHeading,
double dfPegHgt);
679 OGRErr SetVerticalPerspective(
double dfTopoOriginLat,
680 double dfTopoOriginLon,
681 double dfTopoOriginHeight,
682 double dfViewPointHeight,
683 double dfFalseEasting,
684 double dfFalseNorthing);
687 OGRErr SetDerivedGeogCRSWithPoleRotationGRIBConvention(
688 const char* pszCRSName,
689 double dfSouthPoleLat,
690 double dfSouthPoleLon,
691 double dfAxisRotation );
694 OGRErr SetDerivedGeogCRSWithPoleRotationNetCDFCFConvention(
695 const char* pszCRSName,
696 double dfGridNorthPoleLat,
697 double dfGridNorthPoleLon,
698 double dfNorthPoleGridLon );
701 OGRErr SetStatePlane(
int nZone,
int bNAD83 = TRUE,
702 const char *pszOverrideUnitName =
nullptr,
703 double dfOverrideUnit = 0.0 );
706 OGRErr ImportFromESRIStatePlaneWKT(
707 int nCode,
const char* pszDatumName,
const char* pszUnitsName,
708 int nPCSCode,
const char* pszCRSName =
nullptr );
711 OGRErr ImportFromESRIWisconsinWKT(
712 const char* pszPrjName,
double dfCentralMeridian,
double dfLatOfOrigin,
713 const char* pszUnitsName,
const char* pszCRSName =
nullptr );
716 void UpdateCoordinateSystemFromGeogCRS();
790 double *x,
double *y,
double *z =
nullptr,
791 int *pabSuccess =
nullptr );
810 double *x,
double *y,
811 double *z,
double *t,
812 int *pabSuccess ) = 0;
832 double *x,
double *y,
833 double *z,
double *t,
834 int *panErrorCodes );
876 const int densify_pts )
883 *out_xmin = HUGE_VAL;
884 *out_ymin = HUGE_VAL;
885 *out_xmax = HUGE_VAL;
886 *out_ymax = HUGE_VAL;
935 friend class OGRProjCT;
937 std::unique_ptr<Private> d;
946 bool SetAreaOfInterest(
double dfWestLongitudeDeg,
947 double dfSouthLatitudeDeg,
948 double dfEastLongitudeDeg,
949 double dfNorthLatitudeDeg);
950 bool SetDesiredAccuracy(
double dfAccuracy);
951 bool SetBallparkAllowed(
bool bAllowBallpark);
953 bool SetCoordinateOperation(
const char* pszCT,
bool bReverseCT);
955 void SetSourceCenterLong(
double dfCenterLong);
956 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:158
static OGRSpatialReference * FromHandle(OGRSpatialReferenceH hSRS)
Convert a OGRSpatialReferenceH to a OGRSpatialReference*.
Definition: ogr_spatialref.h:730
static OGRSpatialReferenceH ToHandle(OGRSpatialReference *poSRS)
Convert a OGRSpatialReference* to a OGRSpatialReferenceH.
Definition: ogr_spatialref.h:724
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:927
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition: cpl_port.h:1053
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:341
#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.