- Main Page
- Classes
- Files
- Directories
- Related Pages

- File List
- File Members

# ogr_spatialref.h

Go to the documentation of this file.

    00001 /******************************************************************************
    00002  * $Id: ogr_spatialref.h 10646 2007-01-18 02:38:10Z warmerdam $
    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  *
    00012  * Permission is hereby granted, free of charge, to any person obtaining a
    00013  * copy of this software and associated documentation files (the "Software"),
    00014  * to deal in the Software without restriction, including without limitation
    00015  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
    00016  * and/or sell copies of the Software, and to permit persons to whom the
    00017  * Software is furnished to do so, subject to the following conditions:
    00018  *
    00019  * The above copyright notice and this permission notice shall be included
    00020  * in all copies or substantial portions of the Software.
    00021  *
    00022  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
    00023  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    00024  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
    00025  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    00026  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
    00027  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
    00028  * DEALINGS IN THE SOFTWARE.
    00029  ****************************************************************************/
    00030
    00031 #ifndef _OGR_SPATIALREF_H_INCLUDED
    00032 #define _OGR_SPATIALREF_H_INCLUDED
    00033
    00034 #include "ogr_srs_api.h"
    00035
    00042 /************************************************************************/
    00043 /*                             OGR_SRSNode                              */
    00044 /************************************************************************/
    00045
    00059 class CPL_DLL OGR_SRSNode
    00060 {
    00061     char        *pszValue;
    00062
    00063     OGR_SRSNode **papoChildNodes;
    00064     OGR_SRSNode *poParent;
    00065
    00066     int         nChildren;
    00067
    00068     void        ClearChildren();
    00069     int         NeedsQuoting() const;
    00070
    00071   public:
    00072                 OGR_SRSNode(const char * = NULL);
    00073                 ~OGR_SRSNode();
    00074
    00075     int         IsLeafNode() const { return nChildren == 0; }
    00076
    00077     int         GetChildCount() const { return nChildren; }
    00078     OGR_SRSNode *GetChild( int );
    00079     const OGR_SRSNode *GetChild( int ) const;
    00080
    00081     OGR_SRSNode *GetNode( const char * );
    00082     const OGR_SRSNode *GetNode( const char * ) const;
    00083
    00084     void        InsertChild( OGR_SRSNode *, int );
    00085     void        AddChild( OGR_SRSNode * );
    00086     int         FindChild( const char * ) const;
    00087     void        DestroyChild( int );
    00088     void        StripNodes( const char * );
    00089
    00090     const char  *GetValue() const { return pszValue; }
    00091     void        SetValue( const char * );
    00092
    00093     void        MakeValueSafe();
    00094     OGRErr      FixupOrdering();
    00095
    00096     OGR_SRSNode *Clone() const;
    00097
    00098     OGRErr      importFromWkt( char ** );
    00099     OGRErr      exportToWkt( char ** ) const;
    00100     OGRErr      exportToPrettyWkt( char **, int = 1) const;
    00101
    00102     OGRErr      applyRemapper( const char *pszNode,
    00103                                char **papszSrcValues,
    00104                                char **papszDstValues,
    00105                                int nStepSize = 1,
    00106                                int bChildOfHit = FALSE );
    00107 };
    00108
    00109 /************************************************************************/
    00110 /*                         OGRSpatialReference                          */
    00111 /************************************************************************/
    00112
    00127 class CPL_DLL OGRSpatialReference
    00128 {
    00129     double      dfFromGreenwich;
    00130     double      dfToMeter;
    00131     double      dfToDegrees;
    00132
    00133     OGR_SRSNode *poRoot;
    00134
    00135     int         nRefCount;
    00136     int         bNormInfoSet;
    00137
    00138     OGRErr      ValidateProjection();
    00139     int         IsAliasFor( const char *, const char * );
    00140     void        GetNormInfo() const;
    00141
    00142   public:
    00143                 OGRSpatialReference(const OGRSpatialReference&);
    00144                 OGRSpatialReference(const char * = NULL);
    00145
    00146     virtual    ~OGRSpatialReference();
    00147
    00148     OGRSpatialReference &operator=(const OGRSpatialReference&);
    00149
    00150     int         Reference();
    00151     int         Dereference();
    00152     int         GetReferenceCount() const { return nRefCount; }
    00153     void        Release();
    00154
    00155     OGRSpatialReference *Clone() const;
    00156     OGRSpatialReference *CloneGeogCS() const;
    00157
    00158     OGRErr      exportToWkt( char ** ) const;
    00159     OGRErr      exportToPrettyWkt( char **, int = FALSE) const;
    00160     OGRErr      exportToProj4( char ** ) const;
    00161     OGRErr      exportToPCI( char **, char **, double ** ) const;
    00162     OGRErr      exportToUSGS( long *, long *, double **, long * ) const;
    00163     OGRErr      exportToPanorama( long *, long *, double **, long * ) const;
    00164     OGRErr      exportToXML( char **, const char * = NULL ) const;
    00165     OGRErr      exportToPanorama( long *, long *, long *, long *, double *,
    00166                                   double *, double *, double * ) const;
    00167     OGRErr      importFromWkt( char ** );
    00168     OGRErr      importFromProj4( const char * );
    00169     OGRErr      importFromEPSG( int );
    00170     OGRErr      importFromESRI( char ** );
    00171     OGRErr      importFromPCI( const char *, const char * = NULL,
    00172                                double * = NULL );
    00173     OGRErr      importFromUSGS( long, long, double *, long );
    00174     OGRErr      importFromPanorama( long, long, long, long,
    00175                                     double, double, double, double );
    00176     OGRErr      importFromWMSAUTO( const char *pszAutoDef );
    00177     OGRErr      importFromXML( const char * );
    00178     OGRErr      importFromDict( const char *pszDict, const char *pszCode );
    00179     OGRErr      importFromURN( const char * );
    00180
    00181     OGRErr      morphToESRI();
    00182     OGRErr      morphFromESRI();
    00183
    00184     OGRErr      Validate();
    00185     OGRErr      StripCTParms( OGR_SRSNode * = NULL );
    00186     OGRErr      FixupOrdering();
    00187     OGRErr      Fixup();
    00188
    00189     // Machinary for accessing parse nodes
    00190     OGR_SRSNode *GetRoot() { return poRoot; }
    00191     const OGR_SRSNode *GetRoot() const { return poRoot; }
    00192     void        SetRoot( OGR_SRSNode * );
    00193
    00194     OGR_SRSNode *GetAttrNode(const char *);
    00195     const OGR_SRSNode *GetAttrNode(const char *) const;
    00196     const char  *GetAttrValue(const char *, int = 0) const;
    00197
    00198     OGRErr      SetNode( const char *, const char * );
    00199     OGRErr      SetNode( const char *, double );
    00200
    00201     OGRErr      SetLinearUnitsAndUpdateParameters( const char *pszName,
    00202                                                    double dfInMeters );
    00203     OGRErr      SetLinearUnits( const char *pszName, double dfInMeters );
    00204     double      GetLinearUnits( char ** = NULL ) const;
    00205
    00206     OGRErr      SetAngularUnits( const char *pszName, double dfInRadians );
    00207     double      GetAngularUnits( char ** = NULL ) const;
    00208
    00209     double      GetPrimeMeridian( char ** = NULL ) const;
    00210
    00211     int         IsGeographic() const;
    00212     int         IsProjected() const;
    00213     int         IsLocal() const;
    00214     int         IsSameGeogCS( const OGRSpatialReference * ) const;
    00215     int         IsSame( const OGRSpatialReference * ) const;
    00216
    00217     void        Clear();
    00218     OGRErr      SetLocalCS( const char * );
    00219     OGRErr      SetProjCS( const char * );
    00220     OGRErr      SetProjection( const char * );
    00221     OGRErr      SetGeogCS( const char * pszGeogName,
    00222                            const char * pszDatumName,
    00223                            const char * pszEllipsoidName,
    00224                            double dfSemiMajor, double dfInvFlattening,
    00225                            const char * pszPMName = NULL,
    00226                            double dfPMOffset = 0.0,
    00227                            const char * pszUnits = NULL,
    00228                            double dfConvertToRadians = 0.0 );
    00229     OGRErr      SetWellKnownGeogCS( const char * );
    00230     OGRErr      CopyGeogCSFrom( const OGRSpatialReference * poSrcSRS );
    00231
    00232     OGRErr      SetFromUserInput( const char * );
    00233
    00234     OGRErr      SetTOWGS84( double, double, double,
    00235                             double = 0.0, double = 0.0, double = 0.0,
    00236                             double = 0.0 );
    00237     OGRErr      GetTOWGS84( double *padfCoef, int nCoeff = 7 ) const;
    00238
    00239     double      GetSemiMajor( OGRErr * = NULL ) const;
    00240     double      GetSemiMinor( OGRErr * = NULL ) const;
    00241     double      GetInvFlattening( OGRErr * = NULL ) const;
    00242
    00243     OGRErr      SetAuthority( const char * pszTargetKey,
    00244                               const char * pszAuthority,
    00245                               int nCode );
    00246
    00247     OGRErr      AutoIdentifyEPSG();
    00248
    00249     const char *GetAuthorityCode( const char * pszTargetKey ) const;
    00250     const char *GetAuthorityName( const char * pszTargetKey ) const;
    00251
    00252     const char *GetExtension( const char *pszTargetKey,
    00253                               const char *pszName,
    00254                               const char *pszDefault = NULL ) const;
    00255     OGRErr      SetExtension( const char *pszTargetKey,
    00256                               const char *pszName,
    00257                               const char *pszValue );
    00258
    00259     OGRErr      SetProjParm( const char *, double );
    00260     double      GetProjParm( const char *, double =0.0, OGRErr* = NULL ) const;
    00261
    00262     OGRErr      SetNormProjParm( const char *, double );
    00263     double      GetNormProjParm( const char *, double=0.0, OGRErr* =NULL)const;
    00264
    00265     static int  IsAngularParameter( const char * );
    00266     static int  IsLongitudeParameter( const char * );
    00267     static int  IsLinearParameter( const char * );
    00268
    00270     OGRErr      SetACEA( double dfStdP1, double dfStdP2,
    00271                          double dfCenterLat, double dfCenterLong,
    00272                          double dfFalseEasting, double dfFalseNorthing );
    00273
    00275     OGRErr      SetAE( double dfCenterLat, double dfCenterLong,
    00276                        double dfFalseEasting, double dfFalseNorthing );
    00277
    00279     OGRErr      SetBonne( double dfStdP1, double dfCentralMeridian,
    00280                           double dfFalseEasting, double dfFalseNorthing );
    00281
    00283     OGRErr      SetCEA( double dfStdP1, double dfCentralMeridian,
    00284                         double dfFalseEasting, double dfFalseNorthing );
    00285
    00287     OGRErr      SetCS( double dfCenterLat, double dfCenterLong,
    00288                        double dfFalseEasting, double dfFalseNorthing );
    00289
    00291     OGRErr      SetEC( double dfStdP1, double dfStdP2,
    00292                        double dfCenterLat, double dfCenterLong,
    00293                        double dfFalseEasting, double dfFalseNorthing );
    00294
    00296     OGRErr      SetEckertIV( double dfCentralMeridian,
    00297                              double dfFalseEasting, double dfFalseNorthing );
    00298
    00300     OGRErr      SetEckertVI( double dfCentralMeridian,
    00301                              double dfFalseEasting, double dfFalseNorthing );
    00302
    00304     OGRErr      SetEquirectangular(double dfCenterLat, double dfCenterLong,
    00305                             double dfFalseEasting, double dfFalseNorthing );
    00306
    00308     OGRErr      SetGEOS( double dfCentralMeridian, double dfSatelliteHeight,
    00309                          double dfFalseEasting, double dfFalseNorthing );
    00310
    00312     OGRErr      SetGH( double dfCentralMeridian,
    00313                        double dfFalseEasting, double dfFalseNorthing );
    00314
    00316     OGRErr      SetGS( double dfCentralMeridian,
    00317                        double dfFalseEasting, double dfFalseNorthing );
    00318
    00320     OGRErr      SetGnomonic(double dfCenterLat, double dfCenterLong,
    00321                             double dfFalseEasting, double dfFalseNorthing );
    00322
    00323     OGRErr      SetHOM( double dfCenterLat, double dfCenterLong,
    00324                         double dfAzimuth, double dfRectToSkew,
    00325                         double dfScale,
    00326                         double dfFalseEasting, double dfFalseNorthing );
    00327
    00328     OGRErr      SetHOM2PNO( double dfCenterLat,
    00329                             double dfLat1, double dfLong1,
    00330                             double dfLat2, double dfLong2,
    00331                             double dfScale,
    00332                             double dfFalseEasting, double dfFalseNorthing );
    00333
    00335     OGRErr      SetKrovak( double dfCenterLat, double dfCenterLong,
    00336                            double dfAzimuth, double dfPseudoStdParallelLat,
    00337                            double dfScale,
    00338                            double dfFalseEasting, double dfFalseNorthing );
    00339
    00341     OGRErr      SetLAEA( double dfCenterLat, double dfCenterLong,
    00342                          double dfFalseEasting, double dfFalseNorthing );
    00343
    00345     OGRErr      SetLCC( double dfStdP1, double dfStdP2,
    00346                         double dfCenterLat, double dfCenterLong,
    00347                         double dfFalseEasting, double dfFalseNorthing );
    00348
    00350     OGRErr      SetLCC1SP( double dfCenterLat, double dfCenterLong,
    00351                            double dfScale,
    00352                            double dfFalseEasting, double dfFalseNorthing );
    00353
    00355     OGRErr      SetLCCB( double dfStdP1, double dfStdP2,
    00356                          double dfCenterLat, double dfCenterLong,
    00357                          double dfFalseEasting, double dfFalseNorthing );
    00358
    00360     OGRErr      SetMC( double dfCenterLat, double dfCenterLong,
    00361                        double dfFalseEasting, double dfFalseNorthing );
    00362
    00364     OGRErr      SetMercator( double dfCenterLat, double dfCenterLong,
    00365                              double dfScale,
    00366                              double dfFalseEasting, double dfFalseNorthing );
    00367
    00368     OGRErr      SetMercator2SP( double dfStdP1,
    00369                                 double dfCenterLat, double dfCenterLong,
    00370                                 double dfFalseEasting, double dfFalseNorthing );
    00371
    00373     OGRErr      SetMollweide( double dfCentralMeridian,
    00374                               double dfFalseEasting, double dfFalseNorthing );
    00375
    00377     OGRErr      SetNZMG( double dfCenterLat, double dfCenterLong,
    00378                          double dfFalseEasting, double dfFalseNorthing );
    00379
    00381     OGRErr      SetOS( double dfOriginLat, double dfCMeridian,
    00382                        double dfScale,
    00383                        double dfFalseEasting,double dfFalseNorthing);
    00384
    00386     OGRErr      SetOrthographic( double dfCenterLat, double dfCenterLong,
    00387                                  double dfFalseEasting,double dfFalseNorthing);
    00388
    00390     OGRErr      SetPolyconic( double dfCenterLat, double dfCenterLong,
    00391                               double dfFalseEasting, double dfFalseNorthing );
    00392
    00394     OGRErr      SetPS( double dfCenterLat, double dfCenterLong,
    00395                        double dfScale,
    00396                        double dfFalseEasting, double dfFalseNorthing);
    00397
    00399     OGRErr      SetRobinson( double dfCenterLong,
    00400                              double dfFalseEasting, double dfFalseNorthing );
    00401
    00403     OGRErr      SetSinusoidal( double dfCenterLong,
    00404                                double dfFalseEasting, double dfFalseNorthing );
    00405
    00407     OGRErr      SetStereographic( double dfCenterLat, double dfCenterLong,
    00408                                   double dfScale,
    00409                                  double dfFalseEasting,double dfFalseNorthing);
    00410
    00412     OGRErr      SetSOC( double dfLatitudeOfOrigin, double dfCentralMeridian,
    00413                         double dfFalseEasting, double dfFalseNorthing );
    00414
    00416     OGRErr      SetTM( double dfCenterLat, double dfCenterLong,
    00417                        double dfScale,
    00418                        double dfFalseEasting, double dfFalseNorthing );
    00419
    00421     OGRErr      SetTMVariant( const char *pszVariantName,
    00422                               double dfCenterLat, double dfCenterLong,
    00423                               double dfScale,
    00424                               double dfFalseEasting, double dfFalseNorthing );
    00425
    00427     OGRErr      SetTMG( double dfCenterLat, double dfCenterLong,
    00428                         double dfFalseEasting, double dfFalseNorthing );
    00429
    00431     OGRErr      SetTMSO( double dfCenterLat, double dfCenterLong,
    00432                          double dfScale,
    00433                          double dfFalseEasting, double dfFalseNorthing );
    00434
    00436     OGRErr      SetTPED( double dfLat1, double dfLong1,
    00437                          double dfLat2, double dfLong2,
    00438                          double dfFalseEasting, double dfFalseNorthing );
    00439
    00441     OGRErr      SetVDG( double dfCenterLong,
    00442                         double dfFalseEasting, double dfFalseNorthing );
    00443
    00445     OGRErr      SetUTM( int nZone, int bNorth = TRUE );
    00446     int         GetUTMZone( int *pbNorth = NULL ) const;
    00447
    00449     OGRErr      SetStatePlane( int nZone, int bNAD83 = TRUE,
    00450                                const char *pszOverrideUnitName = NULL,
    00451                                double dfOverrideUnit = 0.0 );
    00452 };
    00453
    00454 /************************************************************************/
    00455 /*                     OGRCoordinateTransformation                      */
    00456 /*                                                                      */
    00457 /*      This is really just used as a base class for a private          */
    00458 /*      implementation.                                                 */
    00459 /************************************************************************/
    00460
    00467 class CPL_DLL OGRCoordinateTransformation
    00468 {
    00469 public:
    00470     virtual ~OGRCoordinateTransformation() {}
    00471
    00472     // From CT_CoordinateTransformation
    00473
    00475     virtual OGRSpatialReference *GetSourceCS() = 0;
    00476
    00478     virtual OGRSpatialReference *GetTargetCS() = 0;
    00479
    00480     // From CT_MathTransform
    00481
    00497     virtual int Transform( int nCount,
    00498                            double *x, double *y, double *z = NULL ) = 0;
    00499
    00515     virtual int TransformEx( int nCount,
    00516                              double *x, double *y, double *z = NULL,
    00517                              int *pabSuccess = NULL ) = 0;
    00518
    00519 };
    00520
    00521 OGRCoordinateTransformation CPL_DLL *
    00522 OGRCreateCoordinateTransformation( OGRSpatialReference *poSource,
    00523                                    OGRSpatialReference *poTarget );
    00524
    00525 #endif /* ndef _OGR_SPATIALREF_H_INCLUDED */

Generated for GDAL by 1.5.1.