GDAL
ogr_spatialref.h
Go to the documentation of this file.
00001 /******************************************************************************
00002  * $Id: ogr_spatialref.h 28972 2015-04-22 10:39:11Z 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                 OGR_SRSNode(const char * = NULL);
00074                 ~OGR_SRSNode();
00075 
00076     int         IsLeafNode() const { return nChildren == 0; }
00077     
00078     int         GetChildCount() const { return nChildren; }
00079     OGR_SRSNode *GetChild( int );
00080     const OGR_SRSNode *GetChild( int ) const;
00081 
00082     OGR_SRSNode *GetNode( const char * );
00083     const OGR_SRSNode *GetNode( const char * ) const;
00084 
00085     void        InsertChild( OGR_SRSNode *, int );
00086     void        AddChild( OGR_SRSNode * );
00087     int         FindChild( const char * ) const;
00088     void        DestroyChild( int );
00089     void        ClearChildren();
00090     void        StripNodes( const char * );
00091 
00092     const char  *GetValue() const { return pszValue; }
00093     void        SetValue( const char * );
00094 
00095     void        MakeValueSafe();
00096     OGRErr      FixupOrdering();
00097 
00098     OGR_SRSNode *Clone() const;
00099 
00100     OGRErr      importFromWkt( char ** );
00101     OGRErr      exportToWkt( char ** ) const;
00102     OGRErr      exportToPrettyWkt( char **, int = 1) const;
00103     
00104     OGRErr      applyRemapper( const char *pszNode, 
00105                                char **papszSrcValues, 
00106                                char **papszDstValues, 
00107                                int nStepSize = 1,
00108                                int bChildOfHit = FALSE );
00109 };
00110 
00111 /************************************************************************/
00112 /*                         OGRSpatialReference                          */
00113 /************************************************************************/
00114 
00129 class CPL_DLL OGRSpatialReference
00130 {
00131     double      dfFromGreenwich;
00132     double      dfToMeter;
00133     double      dfToDegrees;
00134 
00135     OGR_SRSNode *poRoot;
00136 
00137     int         nRefCount;
00138     int         bNormInfoSet;
00139 
00140     static OGRErr Validate(OGR_SRSNode *poRoot);
00141     static OGRErr ValidateAuthority(OGR_SRSNode *poRoot);
00142     static OGRErr ValidateAxis(OGR_SRSNode *poRoot);
00143     static OGRErr ValidateUnit(OGR_SRSNode *poRoot);
00144     static OGRErr ValidateVertDatum(OGR_SRSNode *poRoot);
00145     static OGRErr ValidateProjection( OGR_SRSNode* poRoot );
00146     static int  IsAliasFor( const char *, const char * );
00147     void        GetNormInfo() const;
00148 
00149     OGRErr      importFromURNPart(const char* pszAuthority,
00150                                   const char* pszCode,
00151                                   const char* pszURN);
00152   public:
00153                 OGRSpatialReference(const OGRSpatialReference&);
00154                 OGRSpatialReference(const char * = NULL);
00155                 
00156     virtual    ~OGRSpatialReference();
00157     
00158     static void DestroySpatialReference(OGRSpatialReference* poSRS);
00159                 
00160     OGRSpatialReference &operator=(const OGRSpatialReference&);
00161 
00162     int         Reference();
00163     int         Dereference();
00164     int         GetReferenceCount() const { return nRefCount; }
00165     void        Release();
00166 
00167     OGRSpatialReference *Clone() const;
00168     OGRSpatialReference *CloneGeogCS() const;
00169 
00170     void        dumpReadable();
00171     OGRErr      exportToWkt( char ** ) const;
00172     OGRErr      exportToPrettyWkt( char **, int = FALSE) const;
00173     OGRErr      exportToProj4( char ** ) const;
00174     OGRErr      exportToPCI( char **, char **, double ** ) const;
00175     OGRErr      exportToUSGS( long *, long *, double **, long * ) const;
00176     OGRErr      exportToXML( char **, const char * = NULL ) const;
00177     OGRErr      exportToPanorama( long *, long *, long *, long *,
00178                                   double * ) const;
00179     OGRErr      exportToERM( char *pszProj, char *pszDatum, char *pszUnits );
00180     OGRErr      exportToMICoordSys( char ** ) const;
00181     
00182     OGRErr      importFromWkt( char ** );
00183     OGRErr      importFromProj4( const char * );
00184     OGRErr      importFromEPSG( int );
00185     OGRErr      importFromEPSGA( int );
00186     OGRErr      importFromESRI( char ** );
00187     OGRErr      importFromPCI( const char *, const char * = NULL,
00188                                double * = NULL );
00189 #define USGS_ANGLE_DECIMALDEGREES 0
00190 #define USGS_ANGLE_PACKEDDMS      TRUE /* 1 */
00191 #define USGS_ANGLE_RADIANS        2
00192     OGRErr      importFromUSGS( long iProjSys, long iZone,
00193                                 double *padfPrjParams, long iDatum, 
00194                                 int nUSGSAngleFormat = USGS_ANGLE_PACKEDDMS );
00195     OGRErr      importFromPanorama( long, long, long, double* );
00196     OGRErr      importFromOzi( const char * const* papszLines );
00197     OGRErr      importFromWMSAUTO( const char *pszAutoDef );
00198     OGRErr      importFromXML( const char * );
00199     OGRErr      importFromDict( const char *pszDict, const char *pszCode );
00200     OGRErr      importFromURN( const char * );
00201     OGRErr      importFromCRSURL( const char * );
00202     OGRErr      importFromERM( const char *pszProj, const char *pszDatum,
00203                                const char *pszUnits );
00204     OGRErr      importFromUrl( const char * );
00205     OGRErr      importFromMICoordSys( const char * );
00206     
00207     OGRErr      morphToESRI();
00208     OGRErr      morphFromESRI();
00209 
00210     OGRErr      Validate();
00211     OGRErr      StripCTParms( OGR_SRSNode * = NULL );
00212     OGRErr      StripVertical();
00213     OGRErr      FixupOrdering();
00214     OGRErr      Fixup();
00215 
00216     int         EPSGTreatsAsLatLong();
00217     int         EPSGTreatsAsNorthingEasting();
00218     const char *GetAxis( const char *pszTargetKey, int iAxis, 
00219                          OGRAxisOrientation *peOrientation ) const;
00220     OGRErr      SetAxes( const char *pszTargetKey, 
00221                          const char *pszXAxisName, 
00222                          OGRAxisOrientation eXAxisOrientation,
00223                          const char *pszYAxisName, 
00224                          OGRAxisOrientation eYAxisOrientation );
00225 
00226     // Machinary for accessing parse nodes
00227     OGR_SRSNode *GetRoot() { return poRoot; }
00228     const OGR_SRSNode *GetRoot() const { return poRoot; }
00229     void        SetRoot( OGR_SRSNode * );
00230     
00231     OGR_SRSNode *GetAttrNode(const char *);
00232     const OGR_SRSNode *GetAttrNode(const char *) const;
00233     const char  *GetAttrValue(const char *, int = 0) const;
00234 
00235     OGRErr      SetNode( const char *, const char * );
00236     OGRErr      SetNode( const char *, double );
00237 
00238     OGRErr      SetLinearUnitsAndUpdateParameters( const char *pszName, 
00239                                                    double dfInMeters );
00240     OGRErr      SetLinearUnits( const char *pszName, double dfInMeters );
00241     OGRErr      SetTargetLinearUnits( const char *pszTargetKey,
00242                                       const char *pszName, double dfInMeters );
00243     double      GetLinearUnits( char ** = NULL ) const;
00244     double      GetTargetLinearUnits( const char *pszTargetKey,
00245                                       char ** ppszRetName = NULL ) const;
00246 
00247     OGRErr      SetAngularUnits( const char *pszName, double dfInRadians );
00248     double      GetAngularUnits( char ** = NULL ) const;
00249 
00250     double      GetPrimeMeridian( char ** = NULL ) const;
00251 
00252     int         IsGeographic() const;
00253     int         IsProjected() const;
00254     int         IsGeocentric() const;
00255     int         IsLocal() const;
00256     int         IsVertical() const;
00257     int         IsCompound() const;
00258     int         IsSameGeogCS( const OGRSpatialReference * ) const;
00259     int         IsSameVertCS( const OGRSpatialReference * ) const;
00260     int         IsSame( const OGRSpatialReference * ) const;
00261 
00262     void        Clear();
00263     OGRErr      SetLocalCS( const char * );
00264     OGRErr      SetProjCS( const char * );
00265     OGRErr      SetProjection( const char * );
00266     OGRErr      SetGeocCS( const char * pszGeocName );
00267     OGRErr      SetGeogCS( const char * pszGeogName,
00268                            const char * pszDatumName,
00269                            const char * pszEllipsoidName,
00270                            double dfSemiMajor, double dfInvFlattening,
00271                            const char * pszPMName = NULL,
00272                            double dfPMOffset = 0.0,
00273                            const char * pszUnits = NULL,
00274                            double dfConvertToRadians = 0.0 );
00275     OGRErr      SetWellKnownGeogCS( const char * );
00276     OGRErr      CopyGeogCSFrom( const OGRSpatialReference * poSrcSRS );
00277     OGRErr      SetVertCS( const char *pszVertCSName,
00278                            const char *pszVertDatumName, 
00279                            int nVertDatumClass = 2005 );
00280     OGRErr      SetCompoundCS( const char *pszName, 
00281                                const OGRSpatialReference *poHorizSRS,
00282                                const OGRSpatialReference *poVertSRS );
00283 
00284     OGRErr      SetFromUserInput( const char * );
00285 
00286     OGRErr      SetTOWGS84( double, double, double,
00287                             double = 0.0, double = 0.0, double = 0.0,
00288                             double = 0.0 );
00289     OGRErr      GetTOWGS84( double *padfCoef, int nCoeff = 7 ) const;
00290     
00291     double      GetSemiMajor( OGRErr * = NULL ) const;
00292     double      GetSemiMinor( OGRErr * = NULL ) const;
00293     double      GetInvFlattening( OGRErr * = NULL ) const;
00294 
00295     OGRErr      SetAuthority( const char * pszTargetKey, 
00296                               const char * pszAuthority, 
00297                               int nCode );
00298 
00299     OGRErr      AutoIdentifyEPSG();
00300     int         GetEPSGGeogCS();
00301 
00302     const char *GetAuthorityCode( const char * pszTargetKey ) const;
00303     const char *GetAuthorityName( const char * pszTargetKey ) const;
00304 
00305     const char *GetExtension( const char *pszTargetKey, 
00306                               const char *pszName,
00307                               const char *pszDefault = NULL ) const;
00308     OGRErr      SetExtension( const char *pszTargetKey, 
00309                               const char *pszName, 
00310                               const char *pszValue );
00311     
00312     int         FindProjParm( const char *pszParameter,
00313                               const OGR_SRSNode *poPROJCS=NULL ) const;
00314     OGRErr      SetProjParm( const char *, double );
00315     double      GetProjParm( const char *, double =0.0, OGRErr* = NULL ) const;
00316 
00317     OGRErr      SetNormProjParm( const char *, double );
00318     double      GetNormProjParm( const char *, double=0.0, OGRErr* =NULL)const;
00319 
00320     static int  IsAngularParameter( const char * );
00321     static int  IsLongitudeParameter( const char * );
00322     static int  IsLinearParameter( const char * );
00323 
00325     OGRErr      SetACEA( double dfStdP1, double dfStdP2,
00326                          double dfCenterLat, double dfCenterLong,
00327                          double dfFalseEasting, double dfFalseNorthing );
00328     
00330     OGRErr      SetAE( double dfCenterLat, double dfCenterLong,
00331                        double dfFalseEasting, double dfFalseNorthing );
00332 
00334     OGRErr      SetBonne( double dfStdP1, double dfCentralMeridian,
00335                           double dfFalseEasting, double dfFalseNorthing );
00336     
00338     OGRErr      SetCEA( double dfStdP1, double dfCentralMeridian,
00339                         double dfFalseEasting, double dfFalseNorthing );
00340 
00342     OGRErr      SetCS( double dfCenterLat, double dfCenterLong,
00343                        double dfFalseEasting, double dfFalseNorthing );
00344 
00346     OGRErr      SetEC( double dfStdP1, double dfStdP2,
00347                        double dfCenterLat, double dfCenterLong,
00348                        double dfFalseEasting, double dfFalseNorthing );
00349 
00351     OGRErr      SetEckert( int nVariation, double dfCentralMeridian,
00352                            double dfFalseEasting, double dfFalseNorthing );
00353 
00354     OGRErr      SetEckertIV( double dfCentralMeridian,
00355                              double dfFalseEasting, double dfFalseNorthing );
00356 
00357     OGRErr      SetEckertVI( double dfCentralMeridian,
00358                              double dfFalseEasting, double dfFalseNorthing );
00359 
00361     OGRErr      SetEquirectangular(double dfCenterLat, double dfCenterLong,
00362                             double dfFalseEasting, double dfFalseNorthing );
00364     OGRErr      SetEquirectangular2( double dfCenterLat, double dfCenterLong,
00365                                      double dfPseudoStdParallel1,
00366                                      double dfFalseEasting, double dfFalseNorthing );
00367 
00369     OGRErr      SetGEOS( double dfCentralMeridian, double dfSatelliteHeight, 
00370                          double dfFalseEasting, double dfFalseNorthing );
00371 
00373     OGRErr      SetGH( double dfCentralMeridian, 
00374                        double dfFalseEasting, double dfFalseNorthing );
00375 
00377     OGRErr      SetIGH();
00378 
00380     OGRErr      SetGS( double dfCentralMeridian,
00381                        double dfFalseEasting, double dfFalseNorthing );
00382  
00384     OGRErr      SetGaussSchreiberTMercator(double dfCenterLat, double dfCenterLong,
00385                                            double dfScale,
00386                                            double dfFalseEasting, double dfFalseNorthing );
00387 
00389     OGRErr      SetGnomonic(double dfCenterLat, double dfCenterLong,
00390                             double dfFalseEasting, double dfFalseNorthing );
00391 
00393     OGRErr      SetHOM( double dfCenterLat, double dfCenterLong,
00394                         double dfAzimuth, double dfRectToSkew,
00395                         double dfScale,
00396                         double dfFalseEasting, double dfFalseNorthing );
00397 
00398     OGRErr      SetHOM2PNO( double dfCenterLat,
00399                             double dfLat1, double dfLong1,
00400                             double dfLat2, double dfLong2,
00401                             double dfScale,
00402                             double dfFalseEasting, double dfFalseNorthing );
00403 
00404     OGRErr      SetOM( double dfCenterLat, double dfCenterLong,
00405                        double dfAzimuth, double dfRectToSkew,
00406                        double dfScale,
00407                        double dfFalseEasting, double dfFalseNorthing );
00408 
00410     OGRErr      SetHOMAC( double dfCenterLat, double dfCenterLong,
00411                           double dfAzimuth, double dfRectToSkew,
00412                           double dfScale,
00413                           double dfFalseEasting, double dfFalseNorthing );
00414 
00416     OGRErr      SetIWMPolyconic( double dfLat1, double dfLat2,
00417                                  double dfCenterLong,
00418                                  double dfFalseEasting,
00419                                  double dfFalseNorthing );
00420 
00422     OGRErr      SetKrovak( double dfCenterLat, double dfCenterLong,
00423                            double dfAzimuth, double dfPseudoStdParallelLat,
00424                            double dfScale, 
00425                            double dfFalseEasting, double dfFalseNorthing );
00426 
00428     OGRErr      SetLAEA( double dfCenterLat, double dfCenterLong,
00429                          double dfFalseEasting, double dfFalseNorthing );
00430 
00432     OGRErr      SetLCC( double dfStdP1, double dfStdP2,
00433                         double dfCenterLat, double dfCenterLong,
00434                         double dfFalseEasting, double dfFalseNorthing );
00435 
00437     OGRErr      SetLCC1SP( double dfCenterLat, double dfCenterLong,
00438                            double dfScale,
00439                            double dfFalseEasting, double dfFalseNorthing );
00440 
00442     OGRErr      SetLCCB( double dfStdP1, double dfStdP2,
00443                          double dfCenterLat, double dfCenterLong,
00444                          double dfFalseEasting, double dfFalseNorthing );
00445     
00447     OGRErr      SetMC( double dfCenterLat, double dfCenterLong,
00448                        double dfFalseEasting, double dfFalseNorthing );
00449 
00451     OGRErr      SetMercator( double dfCenterLat, double dfCenterLong,
00452                              double dfScale, 
00453                              double dfFalseEasting, double dfFalseNorthing );
00454 
00455     OGRErr      SetMercator2SP( double dfStdP1,
00456                                 double dfCenterLat, double dfCenterLong,
00457                                 double dfFalseEasting, double dfFalseNorthing );
00458 
00460     OGRErr      SetMollweide( double dfCentralMeridian,
00461                               double dfFalseEasting, double dfFalseNorthing );
00462 
00464     OGRErr      SetNZMG( double dfCenterLat, double dfCenterLong,
00465                          double dfFalseEasting, double dfFalseNorthing );
00466 
00468     OGRErr      SetOS( double dfOriginLat, double dfCMeridian,
00469                        double dfScale,
00470                        double dfFalseEasting,double dfFalseNorthing);
00471     
00473     OGRErr      SetOrthographic( double dfCenterLat, double dfCenterLong,
00474                                  double dfFalseEasting,double dfFalseNorthing);
00475 
00477     OGRErr      SetPolyconic( double dfCenterLat, double dfCenterLong,
00478                               double dfFalseEasting, double dfFalseNorthing );
00479 
00481     OGRErr      SetPS( double dfCenterLat, double dfCenterLong,
00482                        double dfScale,
00483                        double dfFalseEasting, double dfFalseNorthing);
00484     
00486     OGRErr      SetRobinson( double dfCenterLong, 
00487                              double dfFalseEasting, double dfFalseNorthing );
00488     
00490     OGRErr      SetSinusoidal( double dfCenterLong, 
00491                                double dfFalseEasting, double dfFalseNorthing );
00492     
00494     OGRErr      SetStereographic( double dfCenterLat, double dfCenterLong,
00495                                   double dfScale,
00496                                  double dfFalseEasting,double dfFalseNorthing);
00497 
00499     OGRErr      SetSOC( double dfLatitudeOfOrigin, double dfCentralMeridian,
00500                         double dfFalseEasting, double dfFalseNorthing );
00501     
00503     OGRErr      SetTM( double dfCenterLat, double dfCenterLong,
00504                        double dfScale,
00505                        double dfFalseEasting, double dfFalseNorthing );
00506 
00508     OGRErr      SetTMVariant( const char *pszVariantName, 
00509                               double dfCenterLat, double dfCenterLong,
00510                               double dfScale,
00511                               double dfFalseEasting, double dfFalseNorthing );
00512 
00514     OGRErr      SetTMG( double dfCenterLat, double dfCenterLong, 
00515                         double dfFalseEasting, double dfFalseNorthing );
00516 
00518     OGRErr      SetTMSO( double dfCenterLat, double dfCenterLong,
00519                          double dfScale,
00520                          double dfFalseEasting, double dfFalseNorthing );
00521 
00523     OGRErr      SetTPED( double dfLat1, double dfLong1, 
00524                          double dfLat2, double dfLong2, 
00525                          double dfFalseEasting, double dfFalseNorthing );
00526     
00528     OGRErr      SetVDG( double dfCenterLong,
00529                         double dfFalseEasting, double dfFalseNorthing );
00530 
00532     OGRErr      SetUTM( int nZone, int bNorth = TRUE );
00533     int         GetUTMZone( int *pbNorth = NULL ) const;
00534 
00536     OGRErr      SetWagner( int nVariation, double dfCenterLat,
00537                            double dfFalseEasting, double dfFalseNorthing );
00538 
00540     OGRErr      SetQSC(double dfCenterLat, double dfCenterLong);
00541 
00543     OGRErr      SetStatePlane( int nZone, int bNAD83 = TRUE,
00544                                const char *pszOverrideUnitName = NULL,
00545                                double dfOverrideUnit = 0.0 );
00546 
00547     OGRErr      ImportFromESRIStatePlaneWKT( 
00548         int nCode, const char* pszDatumName, const char* pszUnitsName, 
00549         int nPCSCode, const char* pszCSName = 0 );
00550     OGRErr      ImportFromESRIWisconsinWKT( 
00551         const char* pszPrjName, double dfCentralMeridian, double dfLatOfOrigin, 
00552         const char* pszUnitsName, const char* pszCSName = 0 );
00553 
00554     static OGRSpatialReference* GetWGS84SRS();
00555 };
00556 
00557 /************************************************************************/
00558 /*                     OGRCoordinateTransformation                      */
00559 /*                                                                      */
00560 /*      This is really just used as a base class for a private          */
00561 /*      implementation.                                                 */
00562 /************************************************************************/
00563 
00573 class CPL_DLL OGRCoordinateTransformation
00574 {
00575 public:
00576     virtual ~OGRCoordinateTransformation() {}
00577     
00578     static void DestroyCT(OGRCoordinateTransformation* poCT);
00579 
00580     // From CT_CoordinateTransformation
00581 
00583     virtual OGRSpatialReference *GetSourceCS() = 0;
00584 
00586     virtual OGRSpatialReference *GetTargetCS() = 0;
00587 
00588     // From CT_MathTransform
00589 
00605     virtual int Transform( int nCount, 
00606                            double *x, double *y, double *z = NULL ) = 0;
00607 
00623     virtual int TransformEx( int nCount, 
00624                              double *x, double *y, double *z = NULL,
00625                              int *pabSuccess = NULL ) = 0;
00626 
00627 };
00628 
00629 OGRCoordinateTransformation CPL_DLL *
00630 OGRCreateCoordinateTransformation( OGRSpatialReference *poSource, 
00631                                    OGRSpatialReference *poTarget );
00632 
00633 #endif /* ndef _OGR_SPATIALREF_H_INCLUDED */

Generated for GDAL by doxygen 1.7.6.1.