- 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,v 1.73 2006/11/24 17:58:15 fwarmerdam Exp $
    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  * $Log: ogr_spatialref.h,v $
    00032  * Revision 1.73  2006/11/24 17:58:15  fwarmerdam
    00033  * added extension management methods
    00034  *
    00035  * Revision 1.72  2006/11/07 18:55:07  fwarmerdam
    00036  * added OGC importFromURN()
    00037  *
    00038  * Revision 1.71  2006/10/14 12:15:44  mloskot
    00039  * Fixed missing declaration of OGRSpatialReference::SetMercator2SP().
    00040  *
    00041  * Revision 1.70  2006/01/30 17:42:29  fwarmerdam
    00042  * Reorganize data members to be less suseptable to packing oddities,
    00043  * per suggestion from Ray Gardener.
    00044  *
    00045  * Revision 1.69  2005/12/01 04:59:45  fwarmerdam
    00046  * added two point equidistant support
    00047  *
    00048  * Revision 1.68  2005/10/10 14:44:52  dron
    00049  * Added exportToPanorama()/importFromPanorama() methods.
    00050  *
    00051  * Revision 1.67  2005/09/21 00:50:08  fwarmerdam
    00052  * Added Release
    00053  *
    00054  * Revision 1.66  2005/03/03 04:55:42  fwarmerdam
    00055  * make exportToWkt() const
    00056  *
    00057  * Revision 1.65  2005/02/11 14:21:28  fwarmerdam
    00058  * added GEOS projection support
    00059  *
    00060  * Revision 1.64  2005/01/13 05:17:37  fwarmerdam
    00061  * added SetLinearUnitsAndUpdateParameters
    00062  *
    00063  * Revision 1.63  2005/01/05 21:02:33  fwarmerdam
    00064  * added Goode Homolosine
    00065  *
    00066  * Revision 1.62  2004/11/11 18:28:45  fwarmerdam
    00067  * added Bonne projection support
    00068  *
    00069  * Revision 1.61  2004/05/10 17:05:14  warmerda
    00070  * added AutoIdentifyEPSG()
    00071  *
    00072  * Revision 1.60  2004/03/04 18:04:45  warmerda
    00073  * added importFromDict() support
    00074  *
    00075  * Revision 1.59  2004/02/07 17:31:21  dron
    00076  * Added OSRExportToUSGS() method.
    00077  *
    00078  * Revision 1.58  2004/02/05 17:07:59  dron
    00079  * Support for HOM projection, specified by two points on centerline.
    00080  *
    00081  * Revision 1.57  2004/02/01 14:24:09  dron
    00082  * Added OGRSpatialReference::importFromUSGS().
    00083  *
    00084  * Revision 1.56  2004/01/24 09:34:59  warmerda
    00085  * added TransformEx support to capture per point reprojection failure
    00086  *
    00087  * Revision 1.55  2003/10/07 04:20:50  warmerda
    00088  * added WMS AUTO: support
    00089  *
    00090  * Revision 1.54  2003/09/09 07:49:19  dron
    00091  * Added exportToPCI() method.
    00092  *
    00093  * Revision 1.53  2003/08/31 14:51:30  dron
    00094  * Added importFromPCI() method.
    00095  *
    00096  * Revision 1.52  2003/08/18 13:26:01  warmerda
    00097  * added SetTMVariant() and related definitions
    00098  *
    00099  * Revision 1.51  2003/05/30 15:39:53  warmerda
    00100  * Added override units capability for SetStatePlane()
    00101  *
    00102  * Revision 1.50  2003/05/28 19:16:42  warmerda
    00103  * fixed up argument names and stuff for docs
    00104  *
    00105  * Revision 1.49  2003/03/12 14:25:01  warmerda
    00106  * added NeedsQuoting() method
    00107  *
    00108  * Revision 1.48  2003/02/25 04:53:51  warmerda
    00109  * added CopyGeogCSFrom() method
    00110  *
    00111  * Revision 1.47  2003/02/06 04:53:12  warmerda
    00112  * added Fixup() method
    00113  *
    00114  * Revision 1.46  2003/01/08 18:14:28  warmerda
    00115  * added FixupOrdering()
    00116  */
    00117
    00118 #ifndef _OGR_SPATIALREF_H_INCLUDED
    00119 #define _OGR_SPATIALREF_H_INCLUDED
    00120
    00121 #include "ogr_srs_api.h"
    00122
    00129 /************************************************************************/
    00130 /*                             OGR_SRSNode                              */
    00131 /************************************************************************/
    00132
    00146 class CPL_DLL OGR_SRSNode
    00147 {
    00148     char        *pszValue;
    00149
    00150     OGR_SRSNode **papoChildNodes;
    00151     OGR_SRSNode *poParent;
    00152
    00153     int         nChildren;
    00154
    00155     void        ClearChildren();
    00156     int         NeedsQuoting() const;
    00157
    00158   public:
    00159                 OGR_SRSNode(const char * = NULL);
    00160                 ~OGR_SRSNode();
    00161
    00162     int         IsLeafNode() const { return nChildren == 0; }
    00163
    00164     int         GetChildCount() const { return nChildren; }
    00165     OGR_SRSNode *GetChild( int );
    00166     const OGR_SRSNode *GetChild( int ) const;
    00167
    00168     OGR_SRSNode *GetNode( const char * );
    00169     const OGR_SRSNode *GetNode( const char * ) const;
    00170
    00171     void        InsertChild( OGR_SRSNode *, int );
    00172     void        AddChild( OGR_SRSNode * );
    00173     int         FindChild( const char * ) const;
    00174     void        DestroyChild( int );
    00175     void        StripNodes( const char * );
    00176
    00177     const char  *GetValue() const { return pszValue; }
    00178     void        SetValue( const char * );
    00179
    00180     void        MakeValueSafe();
    00181     OGRErr      FixupOrdering();
    00182
    00183     OGR_SRSNode *Clone() const;
    00184
    00185     OGRErr      importFromWkt( char ** );
    00186     OGRErr      exportToWkt( char ** ) const;
    00187     OGRErr      exportToPrettyWkt( char **, int = 1) const;
    00188
    00189     OGRErr      applyRemapper( const char *pszNode,
    00190                                char **papszSrcValues,
    00191                                char **papszDstValues,
    00192                                int nStepSize = 1,
    00193                                int bChildOfHit = FALSE );
    00194 };
    00195
    00196 /************************************************************************/
    00197 /*                         OGRSpatialReference                          */
    00198 /************************************************************************/
    00199
    00214 class CPL_DLL OGRSpatialReference
    00215 {
    00216     double      dfFromGreenwich;
    00217     double      dfToMeter;
    00218     double      dfToDegrees;
    00219
    00220     OGR_SRSNode *poRoot;
    00221
    00222     int         nRefCount;
    00223     int         bNormInfoSet;
    00224
    00225     OGRErr      ValidateProjection();
    00226     int         IsAliasFor( const char *, const char * );
    00227     void        GetNormInfo() const;
    00228
    00229   public:
    00230                 OGRSpatialReference(const OGRSpatialReference&);
    00231                 OGRSpatialReference(const char * = NULL);
    00232
    00233     virtual    ~OGRSpatialReference();
    00234
    00235     OGRSpatialReference &operator=(const OGRSpatialReference&);
    00236
    00237     int         Reference();
    00238     int         Dereference();
    00239     int         GetReferenceCount() const { return nRefCount; }
    00240     void        Release();
    00241
    00242     OGRSpatialReference *Clone() const;
    00243     OGRSpatialReference *CloneGeogCS() const;
    00244
    00245     OGRErr      exportToWkt( char ** ) const;
    00246     OGRErr      exportToPrettyWkt( char **, int = FALSE) const;
    00247     OGRErr      exportToProj4( char ** ) const;
    00248     OGRErr      exportToPCI( char **, char **, double ** ) const;
    00249     OGRErr      exportToUSGS( long *, long *, double **, long * ) const;
    00250     OGRErr      exportToPanorama( long *, long *, double **, long * ) const;
    00251     OGRErr      exportToXML( char **, const char * = NULL ) const;
    00252     OGRErr      exportToPanorama( long *, long *, long *, long *, double *,
    00253                                   double *, double *, double * ) const;
    00254     OGRErr      importFromWkt( char ** );
    00255     OGRErr      importFromProj4( const char * );
    00256     OGRErr      importFromEPSG( int );
    00257     OGRErr      importFromESRI( char ** );
    00258     OGRErr      importFromPCI( const char *, const char * = NULL,
    00259                                double * = NULL );
    00260     OGRErr      importFromUSGS( long, long, double *, long );
    00261     OGRErr      importFromPanorama( long, long, long, long,
    00262                                     double, double, double, double );
    00263     OGRErr      importFromWMSAUTO( const char *pszAutoDef );
    00264     OGRErr      importFromXML( const char * );
    00265     OGRErr      importFromDict( const char *pszDict, const char *pszCode );
    00266     OGRErr      importFromURN( const char * );
    00267
    00268     OGRErr      morphToESRI();
    00269     OGRErr      morphFromESRI();
    00270
    00271     OGRErr      Validate();
    00272     OGRErr      StripCTParms( OGR_SRSNode * = NULL );
    00273     OGRErr      FixupOrdering();
    00274     OGRErr      Fixup();
    00275
    00276     // Machinary for accessing parse nodes
    00277     OGR_SRSNode *GetRoot() { return poRoot; }
    00278     const OGR_SRSNode *GetRoot() const { return poRoot; }
    00279     void        SetRoot( OGR_SRSNode * );
    00280
    00281     OGR_SRSNode *GetAttrNode(const char *);
    00282     const OGR_SRSNode *GetAttrNode(const char *) const;
    00283     const char  *GetAttrValue(const char *, int = 0) const;
    00284
    00285     OGRErr      SetNode( const char *, const char * );
    00286     OGRErr      SetNode( const char *, double );
    00287
    00288     OGRErr      SetLinearUnitsAndUpdateParameters( const char *pszName,
    00289                                                    double dfInMeters );
    00290     OGRErr      SetLinearUnits( const char *pszName, double dfInMeters );
    00291     double      GetLinearUnits( char ** = NULL ) const;
    00292
    00293     OGRErr      SetAngularUnits( const char *pszName, double dfInRadians );
    00294     double      GetAngularUnits( char ** = NULL ) const;
    00295
    00296     double      GetPrimeMeridian( char ** = NULL ) const;
    00297
    00298     int         IsGeographic() const;
    00299     int         IsProjected() const;
    00300     int         IsLocal() const;
    00301     int         IsSameGeogCS( const OGRSpatialReference * ) const;
    00302     int         IsSame( const OGRSpatialReference * ) const;
    00303
    00304     void        Clear();
    00305     OGRErr      SetLocalCS( const char * );
    00306     OGRErr      SetProjCS( const char * );
    00307     OGRErr      SetProjection( const char * );
    00308     OGRErr      SetGeogCS( const char * pszGeogName,
    00309                            const char * pszDatumName,
    00310                            const char * pszEllipsoidName,
    00311                            double dfSemiMajor, double dfInvFlattening,
    00312                            const char * pszPMName = NULL,
    00313                            double dfPMOffset = 0.0,
    00314                            const char * pszUnits = NULL,
    00315                            double dfConvertToRadians = 0.0 );
    00316     OGRErr      SetWellKnownGeogCS( const char * );
    00317     OGRErr      CopyGeogCSFrom( const OGRSpatialReference * poSrcSRS );
    00318
    00319     OGRErr      SetFromUserInput( const char * );
    00320
    00321     OGRErr      SetTOWGS84( double, double, double,
    00322                             double = 0.0, double = 0.0, double = 0.0,
    00323                             double = 0.0 );
    00324     OGRErr      GetTOWGS84( double *padfCoef, int nCoeff = 7 ) const;
    00325
    00326     double      GetSemiMajor( OGRErr * = NULL ) const;
    00327     double      GetSemiMinor( OGRErr * = NULL ) const;
    00328     double      GetInvFlattening( OGRErr * = NULL ) const;
    00329
    00330     OGRErr      SetAuthority( const char * pszTargetKey,
    00331                               const char * pszAuthority,
    00332                               int nCode );
    00333
    00334     OGRErr      AutoIdentifyEPSG();
    00335
    00336     const char *GetAuthorityCode( const char * pszTargetKey ) const;
    00337     const char *GetAuthorityName( const char * pszTargetKey ) const;
    00338
    00339     const char *GetExtension( const char *pszTargetKey,
    00340                               const char *pszName,
    00341                               const char *pszDefault = NULL ) const;
    00342     OGRErr      SetExtension( const char *pszTargetKey,
    00343                               const char *pszName,
    00344                               const char *pszValue );
    00345
    00346     OGRErr      SetProjParm( const char *, double );
    00347     double      GetProjParm( const char *, double =0.0, OGRErr* = NULL ) const;
    00348
    00349     OGRErr      SetNormProjParm( const char *, double );
    00350     double      GetNormProjParm( const char *, double=0.0, OGRErr* =NULL)const;
    00351
    00352     static int  IsAngularParameter( const char * );
    00353     static int  IsLongitudeParameter( const char * );
    00354     static int  IsLinearParameter( const char * );
    00355
    00357     OGRErr      SetACEA( double dfStdP1, double dfStdP2,
    00358                          double dfCenterLat, double dfCenterLong,
    00359                          double dfFalseEasting, double dfFalseNorthing );
    00360
    00362     OGRErr      SetAE( double dfCenterLat, double dfCenterLong,
    00363                        double dfFalseEasting, double dfFalseNorthing );
    00364
    00366     OGRErr      SetBonne( double dfStdP1, double dfCentralMeridian,
    00367                           double dfFalseEasting, double dfFalseNorthing );
    00368
    00370     OGRErr      SetCEA( double dfStdP1, double dfCentralMeridian,
    00371                         double dfFalseEasting, double dfFalseNorthing );
    00372
    00374     OGRErr      SetCS( double dfCenterLat, double dfCenterLong,
    00375                        double dfFalseEasting, double dfFalseNorthing );
    00376
    00378     OGRErr      SetEC( double dfStdP1, double dfStdP2,
    00379                        double dfCenterLat, double dfCenterLong,
    00380                        double dfFalseEasting, double dfFalseNorthing );
    00381
    00383     OGRErr      SetEckertIV( double dfCentralMeridian,
    00384                              double dfFalseEasting, double dfFalseNorthing );
    00385
    00387     OGRErr      SetEckertVI( double dfCentralMeridian,
    00388                              double dfFalseEasting, double dfFalseNorthing );
    00389
    00391     OGRErr      SetEquirectangular(double dfCenterLat, double dfCenterLong,
    00392                             double dfFalseEasting, double dfFalseNorthing );
    00393
    00395     OGRErr      SetGEOS( double dfCentralMeridian, double dfSatelliteHeight,
    00396                          double dfFalseEasting, double dfFalseNorthing );
    00397
    00399     OGRErr      SetGH( double dfCentralMeridian,
    00400                        double dfFalseEasting, double dfFalseNorthing );
    00401
    00403     OGRErr      SetGS( double dfCentralMeridian,
    00404                        double dfFalseEasting, double dfFalseNorthing );
    00405
    00407     OGRErr      SetGnomonic(double dfCenterLat, double dfCenterLong,
    00408                             double dfFalseEasting, double dfFalseNorthing );
    00409
    00410     OGRErr      SetHOM( double dfCenterLat, double dfCenterLong,
    00411                         double dfAzimuth, double dfRectToSkew,
    00412                         double dfScale,
    00413                         double dfFalseEasting, double dfFalseNorthing );
    00414
    00415     OGRErr      SetHOM2PNO( double dfCenterLat,
    00416                             double dfLat1, double dfLong1,
    00417                             double dfLat2, double dfLong2,
    00418                             double dfScale,
    00419                             double dfFalseEasting, 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      SetStatePlane( int nZone, int bNAD83 = TRUE,
    00537                                const char *pszOverrideUnitName = NULL,
    00538                                double dfOverrideUnit = 0.0 );
    00539 };
    00540
    00541 /************************************************************************/
    00542 /*                     OGRCoordinateTransformation                      */
    00543 /*                                                                      */
    00544 /*      This is really just used as a base class for a private          */
    00545 /*      implementation.                                                 */
    00546 /************************************************************************/
    00547
    00554 class CPL_DLL OGRCoordinateTransformation
    00555 {
    00556 public:
    00557     virtual ~OGRCoordinateTransformation() {}
    00558
    00559     // From CT_CoordinateTransformation
    00560
    00562     virtual OGRSpatialReference *GetSourceCS() = 0;
    00563
    00565     virtual OGRSpatialReference *GetTargetCS() = 0;
    00566
    00567     // From CT_MathTransform
    00568
    00584     virtual int Transform( int nCount,
    00585                            double *x, double *y, double *z = NULL ) = 0;
    00586
    00602     virtual int TransformEx( int nCount,
    00603                              double *x, double *y, double *z = NULL,
    00604                              int *pabSuccess = NULL ) = 0;
    00605
    00606 };
    00607
    00608 OGRCoordinateTransformation CPL_DLL *
    00609 OGRCreateCoordinateTransformation( OGRSpatialReference *poSource,
    00610                                    OGRSpatialReference *poTarget );
    00611
    00612 #endif /* ndef _OGR_SPATIALREF_H_INCLUDED */

Generated for GDAL by 1.5.1.