GDAL
ogr_spatialref.h
Go to the documentation of this file.
00001 /******************************************************************************
00002  * $Id: ogr_spatialref.h 36411 2016-11-21 22:03:48Z rouault $
00003  *
00004  * Project:  OpenGIS Simple Features Reference Implementation
00005  * Purpose:  Classes for manipulating spatial reference systems in a
00006  *           platform non-specific manner.
00007  * Author:   Frank Warmerdam, warmerdam@pobox.com
00008  *
00009  ******************************************************************************
00010  * Copyright (c) 1999,  Les Technologies SoftMap Inc.
00011  * Copyright (c) 2008-2013, Even Rouault <even dot rouault at mines-paris dot org>
00012  *
00013  * Permission is hereby granted, free of charge, to any person obtaining a
00014  * copy of this software and associated documentation files (the "Software"),
00015  * to deal in the Software without restriction, including without limitation
00016  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
00017  * and/or sell copies of the Software, and to permit persons to whom the
00018  * Software is furnished to do so, subject to the following conditions:
00019  *
00020  * The above copyright notice and this permission notice shall be included
00021  * in all copies or substantial portions of the Software.
00022  *
00023  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00024  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00025  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
00026  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00027  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
00028  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
00029  * DEALINGS IN THE SOFTWARE.
00030  ****************************************************************************/
00031 
00032 #ifndef OGR_SPATIALREF_H_INCLUDED
00033 #define OGR_SPATIALREF_H_INCLUDED
00034 
00035 #include "ogr_srs_api.h"
00036 
00043 /************************************************************************/
00044 /*                             OGR_SRSNode                              */
00045 /************************************************************************/
00046 
00060 class CPL_DLL OGR_SRSNode
00061 {
00062     char        *pszValue;
00063 
00064     OGR_SRSNode **papoChildNodes;
00065     OGR_SRSNode *poParent;
00066 
00067     int         nChildren;
00068 
00069     int         NeedsQuoting() const;
00070     OGRErr      importFromWkt( char **, int nRecLevel, int* pnNodes );
00071 
00072   public:
00073     explicit     OGR_SRSNode(const char * = NULL);
00074                 ~OGR_SRSNode();
00075 
00079     int         IsLeafNode() const { return nChildren == 0; }
00080 
00081     int         GetChildCount() const { return nChildren; }
00082     OGR_SRSNode *GetChild( int );
00083     const OGR_SRSNode *GetChild( int ) const;
00084 
00085     OGR_SRSNode *GetNode( const char * );
00086     const OGR_SRSNode *GetNode( const char * ) const;
00087 
00088     void        InsertChild( OGR_SRSNode *, int );
00089     void        AddChild( OGR_SRSNode * );
00090     int         FindChild( const char * ) const;
00091     void        DestroyChild( int );
00092     void        ClearChildren();
00093     void        StripNodes( const char * );
00094 
00095     const char  *GetValue() const { return pszValue; }
00096     void        SetValue( const char * );
00097 
00098     void        MakeValueSafe();
00099     OGRErr      FixupOrdering();
00100 
00101     OGR_SRSNode *Clone() const;
00102 
00103     OGRErr      importFromWkt( char ** );
00104     OGRErr      exportToWkt( char ** ) const;
00105     OGRErr      exportToPrettyWkt( char **, int = 1) const;
00106 
00107     OGRErr      applyRemapper( const char *pszNode,
00108                                char **papszSrcValues,
00109                                char **papszDstValues,
00110                                int nStepSize = 1,
00111                                int bChildOfHit = FALSE );
00112 };
00113 
00114 /************************************************************************/
00115 /*                         OGRSpatialReference                          */
00116 /************************************************************************/
00117 
00132 class CPL_DLL OGRSpatialReference
00133 {
00134     double      dfFromGreenwich;
00135     double      dfToMeter;
00136     double      dfToDegrees;
00137 
00138     OGR_SRSNode *poRoot;
00139 
00140     int         nRefCount;
00141     int         bNormInfoSet;
00142 
00143     static OGRErr Validate(OGR_SRSNode *poRoot);
00144     static OGRErr ValidateAuthority(OGR_SRSNode *poRoot);
00145     static OGRErr ValidateAxis(OGR_SRSNode *poRoot);
00146     static OGRErr ValidateUnit(OGR_SRSNode *poRoot);
00147     static OGRErr ValidateVertDatum(OGR_SRSNode *poRoot);
00148     static OGRErr ValidateProjection( OGR_SRSNode* poRoot );
00149     static int  IsAliasFor( const char *, const char * );
00150     void        GetNormInfo() const;
00151 
00152     OGRErr      importFromURNPart(const char* pszAuthority,
00153                                   const char* pszCode,
00154                                   const char* pszURN);
00155   public:
00156                 OGRSpatialReference(const OGRSpatialReference&);
00157     explicit    OGRSpatialReference(const char * = NULL);
00158 
00159     virtual    ~OGRSpatialReference();
00160 
00161     static void DestroySpatialReference(OGRSpatialReference* poSRS);
00162 
00163     OGRSpatialReference &operator=(const OGRSpatialReference&);
00164 
00165     int         Reference();
00166     int         Dereference();
00167     int         GetReferenceCount() const { return nRefCount; }
00168     void        Release();
00169 
00170     OGRSpatialReference *Clone() const;
00171     OGRSpatialReference *CloneGeogCS() const;
00172 
00173     void        dumpReadable();
00174     OGRErr      exportToWkt( char ** ) const;
00175     OGRErr      exportToPrettyWkt( char **, int = FALSE) const;
00176     OGRErr      exportToProj4( char ** ) const;
00177     OGRErr      exportToPCI( char **, char **, double ** ) const;
00178     OGRErr      exportToUSGS( long *, long *, double **, long * ) const;
00179     OGRErr      exportToXML( char **, const char * = NULL ) const;
00180     OGRErr      exportToPanorama( long *, long *, long *, long *,
00181                                   double * ) const;
00182     OGRErr      exportToERM( char *pszProj, char *pszDatum, char *pszUnits );
00183     OGRErr      exportToMICoordSys( char ** ) const;
00184 
00185     OGRErr      importFromWkt( char ** );
00186     OGRErr      importFromProj4( const char * );
00187     OGRErr      importFromEPSG( int );
00188     OGRErr      importFromEPSGA( int );
00189     OGRErr      importFromESRI( char ** );
00190     OGRErr      importFromPCI( const char *, const char * = NULL,
00191                                double * = NULL );
00192 
00193 #define USGS_ANGLE_DECIMALDEGREES 0     
00194 #define USGS_ANGLE_PACKEDDMS      TRUE  
00195 #define USGS_ANGLE_RADIANS        2     
00196     OGRErr      importFromUSGS( long iProjSys, long iZone,
00197                                 double *padfPrjParams, long iDatum,
00198                                 int nUSGSAngleFormat = USGS_ANGLE_PACKEDDMS );
00199     OGRErr      importFromPanorama( long, long, long, double* );
00200     OGRErr      importFromOzi( const char * const* papszLines );
00201     OGRErr      importFromWMSAUTO( const char *pszAutoDef );
00202     OGRErr      importFromXML( const char * );
00203     OGRErr      importFromDict( const char *pszDict, const char *pszCode );
00204     OGRErr      importFromURN( const char * );
00205     OGRErr      importFromCRSURL( const char * );
00206     OGRErr      importFromERM( const char *pszProj, const char *pszDatum,
00207                                const char *pszUnits );
00208     OGRErr      importFromUrl( const char * );
00209     OGRErr      importFromMICoordSys( const char * );
00210 
00211     OGRErr      morphToESRI();
00212     OGRErr      morphFromESRI();
00213 
00214     OGRErr      Validate();
00215     OGRErr      StripCTParms( OGR_SRSNode * = NULL );
00216     OGRErr      StripVertical();
00217     OGRErr      FixupOrdering();
00218     OGRErr      Fixup();
00219 
00220     int         EPSGTreatsAsLatLong();
00221     int         EPSGTreatsAsNorthingEasting();
00222     const char *GetAxis( const char *pszTargetKey, int iAxis,
00223                          OGRAxisOrientation *peOrientation ) const;
00224     OGRErr      SetAxes( const char *pszTargetKey,
00225                          const char *pszXAxisName,
00226                          OGRAxisOrientation eXAxisOrientation,
00227                          const char *pszYAxisName,
00228                          OGRAxisOrientation eYAxisOrientation );
00229 
00230     // Machinery for accessing parse nodes
00231 
00233     OGR_SRSNode *GetRoot() { return poRoot; }
00235     const OGR_SRSNode *GetRoot() const { return poRoot; }
00236     void        SetRoot( OGR_SRSNode * );
00237 
00238     OGR_SRSNode *GetAttrNode(const char *);
00239     const OGR_SRSNode *GetAttrNode(const char *) const;
00240     const char  *GetAttrValue(const char *, int = 0) const;
00241 
00242     OGRErr      SetNode( const char *, const char * );
00243     OGRErr      SetNode( const char *, double );
00244 
00245     OGRErr      SetLinearUnitsAndUpdateParameters( const char *pszName,
00246                                                    double dfInMeters );
00247     OGRErr      SetLinearUnits( const char *pszName, double dfInMeters );
00248     OGRErr      SetTargetLinearUnits( const char *pszTargetKey,
00249                                       const char *pszName, double dfInMeters );
00250     double      GetLinearUnits( char ** = NULL ) const;
00251     double      GetTargetLinearUnits( const char *pszTargetKey,
00252                                       char ** ppszRetName = NULL ) const;
00253 
00254     OGRErr      SetAngularUnits( const char *pszName, double dfInRadians );
00255     double      GetAngularUnits( char ** = NULL ) const;
00256 
00257     double      GetPrimeMeridian( char ** = NULL ) const;
00258 
00259     int         IsGeographic() const;
00260     int         IsProjected() const;
00261     int         IsGeocentric() const;
00262     int         IsLocal() const;
00263     int         IsVertical() const;
00264     int         IsCompound() const;
00265     int         IsSameGeogCS( const OGRSpatialReference * ) const;
00266     int         IsSameVertCS( const OGRSpatialReference * ) const;
00267     int         IsSame( const OGRSpatialReference * ) const;
00268 
00269     void        Clear();
00270     OGRErr      SetLocalCS( const char * );
00271     OGRErr      SetProjCS( const char * );
00272     OGRErr      SetProjection( const char * );
00273     OGRErr      SetGeocCS( const char * pszGeocName );
00274     OGRErr      SetGeogCS( const char * pszGeogName,
00275                            const char * pszDatumName,
00276                            const char * pszEllipsoidName,
00277                            double dfSemiMajor, double dfInvFlattening,
00278                            const char * pszPMName = NULL,
00279                            double dfPMOffset = 0.0,
00280                            const char * pszUnits = NULL,
00281                            double dfConvertToRadians = 0.0 );
00282     OGRErr      SetWellKnownGeogCS( const char * );
00283     OGRErr      CopyGeogCSFrom( const OGRSpatialReference * poSrcSRS );
00284     OGRErr      SetVertCS( const char *pszVertCSName,
00285                            const char *pszVertDatumName,
00286                            int nVertDatumClass = 2005 );
00287     OGRErr      SetCompoundCS( const char *pszName,
00288                                const OGRSpatialReference *poHorizSRS,
00289                                const OGRSpatialReference *poVertSRS );
00290 
00291     OGRErr      SetFromUserInput( const char * );
00292 
00293     OGRErr      SetTOWGS84( double, double, double,
00294                             double = 0.0, double = 0.0, double = 0.0,
00295                             double = 0.0 );
00296     OGRErr      GetTOWGS84( double *padfCoef, int nCoeff = 7 ) const;
00297 
00298     double      GetSemiMajor( OGRErr * = NULL ) const;
00299     double      GetSemiMinor( OGRErr * = NULL ) const;
00300     double      GetInvFlattening( OGRErr * = NULL ) const;
00301 
00302     OGRErr      SetAuthority( const char * pszTargetKey,
00303                               const char * pszAuthority,
00304                               int nCode );
00305 
00306     OGRErr      AutoIdentifyEPSG();
00307     int         GetEPSGGeogCS();
00308 
00309     const char *GetAuthorityCode( const char * pszTargetKey ) const;
00310     const char *GetAuthorityName( const char * pszTargetKey ) const;
00311 
00312     const char *GetExtension( const char *pszTargetKey,
00313                               const char *pszName,
00314                               const char *pszDefault = NULL ) const;
00315     OGRErr      SetExtension( const char *pszTargetKey,
00316                               const char *pszName,
00317                               const char *pszValue );
00318 
00319     int         FindProjParm( const char *pszParameter,
00320                               const OGR_SRSNode *poPROJCS=NULL ) const;
00321     OGRErr      SetProjParm( const char *, double );
00322     double      GetProjParm( const char *, double =0.0, OGRErr* = NULL ) const;
00323 
00324     OGRErr      SetNormProjParm( const char *, double );
00325     double      GetNormProjParm( const char *, double=0.0, OGRErr* =NULL)const;
00326 
00327     static int  IsAngularParameter( const char * );
00328     static int  IsLongitudeParameter( const char * );
00329     static int  IsLinearParameter( const char * );
00330 
00332     OGRErr      SetACEA( double dfStdP1, double dfStdP2,
00333                          double dfCenterLat, double dfCenterLong,
00334                          double dfFalseEasting, double dfFalseNorthing );
00335 
00337     OGRErr      SetAE( double dfCenterLat, double dfCenterLong,
00338                        double dfFalseEasting, double dfFalseNorthing );
00339 
00341     OGRErr      SetBonne( double dfStdP1, double dfCentralMeridian,
00342                           double dfFalseEasting, double dfFalseNorthing );
00343 
00345     OGRErr      SetCEA( double dfStdP1, double dfCentralMeridian,
00346                         double dfFalseEasting, double dfFalseNorthing );
00347 
00349     OGRErr      SetCS( double dfCenterLat, double dfCenterLong,
00350                        double dfFalseEasting, double dfFalseNorthing );
00351 
00353     OGRErr      SetEC( double dfStdP1, double dfStdP2,
00354                        double dfCenterLat, double dfCenterLong,
00355                        double dfFalseEasting, double dfFalseNorthing );
00356 
00358     OGRErr      SetEckert( int nVariation, double dfCentralMeridian,
00359                            double dfFalseEasting, double dfFalseNorthing );
00360 
00362     OGRErr      SetEckertIV( double dfCentralMeridian,
00363                              double dfFalseEasting, double dfFalseNorthing );
00364 
00366     OGRErr      SetEckertVI( double dfCentralMeridian,
00367                              double dfFalseEasting, double dfFalseNorthing );
00368 
00370     OGRErr      SetEquirectangular(double dfCenterLat, double dfCenterLong,
00371                             double dfFalseEasting, double dfFalseNorthing );
00373     OGRErr      SetEquirectangular2( double dfCenterLat, double dfCenterLong,
00374                                      double dfPseudoStdParallel1,
00375                                      double dfFalseEasting, double dfFalseNorthing );
00376 
00378     OGRErr      SetGEOS( double dfCentralMeridian, double dfSatelliteHeight,
00379                          double dfFalseEasting, double dfFalseNorthing );
00380 
00382     OGRErr      SetGH( double dfCentralMeridian,
00383                        double dfFalseEasting, double dfFalseNorthing );
00384 
00386     OGRErr      SetIGH();
00387 
00389     OGRErr      SetGS( double dfCentralMeridian,
00390                        double dfFalseEasting, double dfFalseNorthing );
00391 
00393     OGRErr      SetGaussSchreiberTMercator(double dfCenterLat, double dfCenterLong,
00394                                            double dfScale,
00395                                            double dfFalseEasting, double dfFalseNorthing );
00396 
00398     OGRErr      SetGnomonic(double dfCenterLat, double dfCenterLong,
00399                             double dfFalseEasting, double dfFalseNorthing );
00400 
00402     OGRErr      SetHOM( double dfCenterLat, double dfCenterLong,
00403                         double dfAzimuth, double dfRectToSkew,
00404                         double dfScale,
00405                         double dfFalseEasting, double dfFalseNorthing );
00406 
00408     OGRErr      SetHOM2PNO( double dfCenterLat,
00409                             double dfLat1, double dfLong1,
00410                             double dfLat2, double dfLong2,
00411                             double dfScale,
00412                             double dfFalseEasting, double dfFalseNorthing );
00413 
00415     OGRErr      SetOM( double dfCenterLat, double dfCenterLong,
00416                        double dfAzimuth, double dfRectToSkew,
00417                        double dfScale,
00418                        double dfFalseEasting, double dfFalseNorthing );
00419 
00421     OGRErr      SetHOMAC( double dfCenterLat, double dfCenterLong,
00422                           double dfAzimuth, double dfRectToSkew,
00423                           double dfScale,
00424                           double dfFalseEasting, double dfFalseNorthing );
00425 
00427     OGRErr      SetIWMPolyconic( double dfLat1, double dfLat2,
00428                                  double dfCenterLong,
00429                                  double dfFalseEasting,
00430                                  double dfFalseNorthing );
00431 
00433     OGRErr      SetKrovak( double dfCenterLat, double dfCenterLong,
00434                            double dfAzimuth, double dfPseudoStdParallelLat,
00435                            double dfScale,
00436                            double dfFalseEasting, double dfFalseNorthing );
00437 
00439     OGRErr      SetLAEA( double dfCenterLat, double dfCenterLong,
00440                          double dfFalseEasting, double dfFalseNorthing );
00441 
00443     OGRErr      SetLCC( double dfStdP1, double dfStdP2,
00444                         double dfCenterLat, double dfCenterLong,
00445                         double dfFalseEasting, double dfFalseNorthing );
00446 
00448     OGRErr      SetLCC1SP( double dfCenterLat, double dfCenterLong,
00449                            double dfScale,
00450                            double dfFalseEasting, double dfFalseNorthing );
00451 
00453     OGRErr      SetLCCB( double dfStdP1, double dfStdP2,
00454                          double dfCenterLat, double dfCenterLong,
00455                          double dfFalseEasting, double dfFalseNorthing );
00456 
00458     OGRErr      SetMC( double dfCenterLat, double dfCenterLong,
00459                        double dfFalseEasting, double dfFalseNorthing );
00460 
00462     OGRErr      SetMercator( double dfCenterLat, double dfCenterLong,
00463                              double dfScale,
00464                              double dfFalseEasting, double dfFalseNorthing );
00465 
00467     OGRErr      SetMercator2SP( double dfStdP1,
00468                                 double dfCenterLat, double dfCenterLong,
00469                                 double dfFalseEasting, double dfFalseNorthing );
00470 
00472     OGRErr      SetMollweide( double dfCentralMeridian,
00473                               double dfFalseEasting, double dfFalseNorthing );
00474 
00476     OGRErr      SetNZMG( double dfCenterLat, double dfCenterLong,
00477                          double dfFalseEasting, double dfFalseNorthing );
00478 
00480     OGRErr      SetOS( double dfOriginLat, double dfCMeridian,
00481                        double dfScale,
00482                        double dfFalseEasting,double dfFalseNorthing);
00483 
00485     OGRErr      SetOrthographic( double dfCenterLat, double dfCenterLong,
00486                                  double dfFalseEasting,double dfFalseNorthing);
00487 
00489     OGRErr      SetPolyconic( double dfCenterLat, double dfCenterLong,
00490                               double dfFalseEasting, double dfFalseNorthing );
00491 
00493     OGRErr      SetPS( double dfCenterLat, double dfCenterLong,
00494                        double dfScale,
00495                        double dfFalseEasting, double dfFalseNorthing);
00496 
00498     OGRErr      SetRobinson( double dfCenterLong,
00499                              double dfFalseEasting, double dfFalseNorthing );
00500 
00502     OGRErr      SetSinusoidal( double dfCenterLong,
00503                                double dfFalseEasting, double dfFalseNorthing );
00504 
00506     OGRErr      SetStereographic( double dfCenterLat, double dfCenterLong,
00507                                   double dfScale,
00508                                  double dfFalseEasting,double dfFalseNorthing);
00509 
00511     OGRErr      SetSOC( double dfLatitudeOfOrigin, double dfCentralMeridian,
00512                         double dfFalseEasting, double dfFalseNorthing );
00513 
00515     OGRErr      SetTM( double dfCenterLat, double dfCenterLong,
00516                        double dfScale,
00517                        double dfFalseEasting, double dfFalseNorthing );
00518 
00520     OGRErr      SetTMVariant( const char *pszVariantName,
00521                               double dfCenterLat, double dfCenterLong,
00522                               double dfScale,
00523                               double dfFalseEasting, double dfFalseNorthing );
00524 
00526     OGRErr      SetTMG( double dfCenterLat, double dfCenterLong,
00527                         double dfFalseEasting, double dfFalseNorthing );
00528 
00530     OGRErr      SetTMSO( double dfCenterLat, double dfCenterLong,
00531                          double dfScale,
00532                          double dfFalseEasting, double dfFalseNorthing );
00533 
00535     OGRErr      SetTPED( double dfLat1, double dfLong1,
00536                          double dfLat2, double dfLong2,
00537                          double dfFalseEasting, double dfFalseNorthing );
00538 
00540     OGRErr      SetVDG( double dfCenterLong,
00541                         double dfFalseEasting, double dfFalseNorthing );
00542 
00544     OGRErr      SetUTM( int nZone, int bNorth = TRUE );
00545     int         GetUTMZone( int *pbNorth = NULL ) const;
00546 
00548     OGRErr      SetWagner( int nVariation, double dfCenterLat,
00549                            double dfFalseEasting, double dfFalseNorthing );
00550 
00552     OGRErr      SetQSC(double dfCenterLat, double dfCenterLong);
00553 
00555     OGRErr      SetSCH( double dfPegLat, double dfPegLong,
00556                         double dfPegHeading, double dfPegHgt);
00558     OGRErr      SetStatePlane( int nZone, int bNAD83 = TRUE,
00559                                const char *pszOverrideUnitName = NULL,
00560                                double dfOverrideUnit = 0.0 );
00561 
00563     OGRErr      ImportFromESRIStatePlaneWKT(
00564         int nCode, const char* pszDatumName, const char* pszUnitsName,
00565         int nPCSCode, const char* pszCSName = NULL );
00566 
00568     OGRErr      ImportFromESRIWisconsinWKT(
00569         const char* pszPrjName, double dfCentralMeridian, double dfLatOfOrigin,
00570         const char* pszUnitsName, const char* pszCSName = NULL );
00571 
00572     static OGRSpatialReference* GetWGS84SRS();
00573 };
00574 
00575 /************************************************************************/
00576 /*                     OGRCoordinateTransformation                      */
00577 /*                                                                      */
00578 /*      This is really just used as a base class for a private          */
00579 /*      implementation.                                                 */
00580 /************************************************************************/
00581 
00591 class CPL_DLL OGRCoordinateTransformation
00592 {
00593 public:
00594     virtual ~OGRCoordinateTransformation() {}
00595 
00596     static void DestroyCT(OGRCoordinateTransformation* poCT);
00597 
00598     // From CT_CoordinateTransformation
00599 
00601     virtual OGRSpatialReference *GetSourceCS() = 0;
00602 
00604     virtual OGRSpatialReference *GetTargetCS() = 0;
00605 
00607     virtual bool GetEmitErrors() { return false; }
00608 
00610     virtual void SetEmitErrors(bool /*bEmitErrors*/) {}
00611 
00612     // From CT_MathTransform
00613 
00629     virtual int Transform( int nCount,
00630                            double *x, double *y, double *z = NULL ) = 0;
00631 
00647     virtual int TransformEx( int nCount,
00648                              double *x, double *y, double *z = NULL,
00649                              int *pabSuccess = NULL ) = 0;
00650 };
00651 
00652 OGRCoordinateTransformation CPL_DLL *
00653 OGRCreateCoordinateTransformation( OGRSpatialReference *poSource,
00654                                    OGRSpatialReference *poTarget );
00655 
00656 #endif /* ndef OGR_SPATIALREF_H_INCLUDED */

Generated for GDAL by doxygen 1.7.6.1.