- 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.70 2006/01/30 17:42:29 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.70  2006/01/30 17:42:29  fwarmerdam
    00033  * Reorganize data members to be less suseptable to packing oddities,
    00034  * per suggestion from Ray Gardener.
    00035  *
    00036  * Revision 1.69  2005/12/01 04:59:45  fwarmerdam
    00037  * added two point equidistant support
    00038  *
    00039  * Revision 1.68  2005/10/10 14:44:52  dron
    00040  * Added exportToPanorama()/importFromPanorama() methods.
    00041  *
    00042  * Revision 1.67  2005/09/21 00:50:08  fwarmerdam
    00043  * Added Release
    00044  *
    00045  * Revision 1.66  2005/03/03 04:55:42  fwarmerdam
    00046  * make exportToWkt() const
    00047  *
    00048  * Revision 1.65  2005/02/11 14:21:28  fwarmerdam
    00049  * added GEOS projection support
    00050  *
    00051  * Revision 1.64  2005/01/13 05:17:37  fwarmerdam
    00052  * added SetLinearUnitsAndUpdateParameters
    00053  *
    00054  * Revision 1.63  2005/01/05 21:02:33  fwarmerdam
    00055  * added Goode Homolosine
    00056  *
    00057  * Revision 1.62  2004/11/11 18:28:45  fwarmerdam
    00058  * added Bonne projection support
    00059  *
    00060  * Revision 1.61  2004/05/10 17:05:14  warmerda
    00061  * added AutoIdentifyEPSG()
    00062  *
    00063  * Revision 1.60  2004/03/04 18:04:45  warmerda
    00064  * added importFromDict() support
    00065  *
    00066  * Revision 1.59  2004/02/07 17:31:21  dron
    00067  * Added OSRExportToUSGS() method.
    00068  *
    00069  * Revision 1.58  2004/02/05 17:07:59  dron
    00070  * Support for HOM projection, specified by two points on centerline.
    00071  *
    00072  * Revision 1.57  2004/02/01 14:24:09  dron
    00073  * Added OGRSpatialReference::importFromUSGS().
    00074  *
    00075  * Revision 1.56  2004/01/24 09:34:59  warmerda
    00076  * added TransformEx support to capture per point reprojection failure
    00077  *
    00078  * Revision 1.55  2003/10/07 04:20:50  warmerda
    00079  * added WMS AUTO: support
    00080  *
    00081  * Revision 1.54  2003/09/09 07:49:19  dron
    00082  * Added exportToPCI() method.
    00083  *
    00084  * Revision 1.53  2003/08/31 14:51:30  dron
    00085  * Added importFromPCI() method.
    00086  *
    00087  * Revision 1.52  2003/08/18 13:26:01  warmerda
    00088  * added SetTMVariant() and related definitions
    00089  *
    00090  * Revision 1.51  2003/05/30 15:39:53  warmerda
    00091  * Added override units capability for SetStatePlane()
    00092  *
    00093  * Revision 1.50  2003/05/28 19:16:42  warmerda
    00094  * fixed up argument names and stuff for docs
    00095  *
    00096  * Revision 1.49  2003/03/12 14:25:01  warmerda
    00097  * added NeedsQuoting() method
    00098  *
    00099  * Revision 1.48  2003/02/25 04:53:51  warmerda
    00100  * added CopyGeogCSFrom() method
    00101  *
    00102  * Revision 1.47  2003/02/06 04:53:12  warmerda
    00103  * added Fixup() method
    00104  *
    00105  * Revision 1.46  2003/01/08 18:14:28  warmerda
    00106  * added FixupOrdering()
    00107  */
    00108
    00109 #ifndef _OGR_SPATIALREF_H_INCLUDED
    00110 #define _OGR_SPATIALREF_H_INCLUDED
    00111
    00112 #include "ogr_srs_api.h"
    00113
    00120 /************************************************************************/
    00121 /*                             OGR_SRSNode                              */
    00122 /************************************************************************/
    00123
    00137 class CPL_DLL OGR_SRSNode
    00138 {
    00139     char        *pszValue;
    00140
    00141     OGR_SRSNode **papoChildNodes;
    00142     OGR_SRSNode *poParent;
    00143
    00144     int         nChildren;
    00145
    00146     void        ClearChildren();
    00147     int         NeedsQuoting() const;
    00148
    00149   public:
    00150                 OGR_SRSNode(const char * = NULL);
    00151                 ~OGR_SRSNode();
    00152
    00153     int         IsLeafNode() const { return nChildren == 0; }
    00154
    00155     int         GetChildCount() const { return nChildren; }
    00156     OGR_SRSNode *GetChild( int );
    00157     const OGR_SRSNode *GetChild( int ) const;
    00158
    00159     OGR_SRSNode *GetNode( const char * );
    00160     const OGR_SRSNode *GetNode( const char * ) const;
    00161
    00162     void        InsertChild( OGR_SRSNode *, int );
    00163     void        AddChild( OGR_SRSNode * );
    00164     int         FindChild( const char * ) const;
    00165     void        DestroyChild( int );
    00166     void        StripNodes( const char * );
    00167
    00168     const char  *GetValue() const { return pszValue; }
    00169     void        SetValue( const char * );
    00170
    00171     void        MakeValueSafe();
    00172     OGRErr      FixupOrdering();
    00173
    00174     OGR_SRSNode *Clone() const;
    00175
    00176     OGRErr      importFromWkt( char ** );
    00177     OGRErr      exportToWkt( char ** ) const;
    00178     OGRErr      exportToPrettyWkt( char **, int = 1) const;
    00179
    00180     OGRErr      applyRemapper( const char *pszNode,
    00181                                char **papszSrcValues,
    00182                                char **papszDstValues,
    00183                                int nStepSize = 1,
    00184                                int bChildOfHit = FALSE );
    00185 };
    00186
    00187 /************************************************************************/
    00188 /*                         OGRSpatialReference                          */
    00189 /************************************************************************/
    00190
    00205 class CPL_DLL OGRSpatialReference
    00206 {
    00207     double      dfFromGreenwich;
    00208     double      dfToMeter;
    00209     double      dfToDegrees;
    00210
    00211     OGR_SRSNode *poRoot;
    00212
    00213     int         nRefCount;
    00214     int         bNormInfoSet;
    00215
    00216     OGRErr      ValidateProjection();
    00217     int         IsAliasFor( const char *, const char * );
    00218     void        GetNormInfo() const;
    00219
    00220   public:
    00221                 OGRSpatialReference(const OGRSpatialReference&);
    00222                 OGRSpatialReference(const char * = NULL);
    00223
    00224     virtual    ~OGRSpatialReference();
    00225
    00226     OGRSpatialReference &operator=(const OGRSpatialReference&);
    00227
    00228     int         Reference();
    00229     int         Dereference();
    00230     int         GetReferenceCount() const { return nRefCount; }
    00231     void        Release();
    00232
    00233     OGRSpatialReference *Clone() const;
    00234     OGRSpatialReference *CloneGeogCS() const;
    00235
    00236     OGRErr      exportToWkt( char ** ) const;
    00237     OGRErr      exportToPrettyWkt( char **, int = FALSE) const;
    00238     OGRErr      exportToProj4( char ** ) const;
    00239     OGRErr      exportToPCI( char **, char **, double ** ) const;
    00240     OGRErr      exportToUSGS( long *, long *, double **, long * ) const;
    00241     OGRErr      exportToPanorama( long *, long *, double **, long * ) const;
    00242     OGRErr      exportToXML( char **, const char * = NULL ) const;
    00243     OGRErr      exportToPanorama( long *, long *, long *, long *, double *,
    00244                                   double *, double *, double * ) const;
    00245     OGRErr      importFromWkt( char ** );
    00246     OGRErr      importFromProj4( const char * );
    00247     OGRErr      importFromEPSG( int );
    00248     OGRErr      importFromESRI( char ** );
    00249     OGRErr      importFromPCI( const char *, const char * = NULL,
    00250                                double * = NULL );
    00251     OGRErr      importFromUSGS( long, long, double *, long );
    00252     OGRErr      importFromPanorama( long, long, long, long,
    00253                                     double, double, double, double );
    00254     OGRErr      importFromWMSAUTO( const char *pszAutoDef );
    00255     OGRErr      importFromXML( const char * );
    00256     OGRErr      importFromDict( const char *pszDict, const char *pszCode );
    00257
    00258     OGRErr      morphToESRI();
    00259     OGRErr      morphFromESRI();
    00260
    00261     OGRErr      Validate();
    00262     OGRErr      StripCTParms( OGR_SRSNode * = NULL );
    00263     OGRErr      FixupOrdering();
    00264     OGRErr      Fixup();
    00265
    00266     // Machinary for accessing parse nodes
    00267     OGR_SRSNode *GetRoot() { return poRoot; }
    00268     const OGR_SRSNode *GetRoot() const { return poRoot; }
    00269     void        SetRoot( OGR_SRSNode * );
    00270
    00271     OGR_SRSNode *GetAttrNode(const char *);
    00272     const OGR_SRSNode *GetAttrNode(const char *) const;
    00273     const char  *GetAttrValue(const char *, int = 0) const;
    00274
    00275     OGRErr      SetNode( const char *, const char * );
    00276     OGRErr      SetNode( const char *, double );
    00277
    00278     OGRErr      SetLinearUnitsAndUpdateParameters( const char *pszName,
    00279                                                    double dfInMeters );
    00280     OGRErr      SetLinearUnits( const char *pszName, double dfInMeters );
    00281     double      GetLinearUnits( char ** = NULL ) const;
    00282
    00283     OGRErr      SetAngularUnits( const char *pszName, double dfInRadians );
    00284     double      GetAngularUnits( char ** = NULL ) const;
    00285
    00286     double      GetPrimeMeridian( char ** = NULL ) const;
    00287
    00288     int         IsGeographic() const;
    00289     int         IsProjected() const;
    00290     int         IsLocal() const;
    00291     int         IsSameGeogCS( const OGRSpatialReference * ) const;
    00292     int         IsSame( const OGRSpatialReference * ) const;
    00293
    00294     void        Clear();
    00295     OGRErr      SetLocalCS( const char * );
    00296     OGRErr      SetProjCS( const char * );
    00297     OGRErr      SetProjection( const char * );
    00298     OGRErr      SetGeogCS( const char * pszGeogName,
    00299                            const char * pszDatumName,
    00300                            const char * pszEllipsoidName,
    00301                            double dfSemiMajor, double dfInvFlattening,
    00302                            const char * pszPMName = NULL,
    00303                            double dfPMOffset = 0.0,
    00304                            const char * pszUnits = NULL,
    00305                            double dfConvertToRadians = 0.0 );
    00306     OGRErr      SetWellKnownGeogCS( const char * );
    00307     OGRErr      CopyGeogCSFrom( const OGRSpatialReference * poSrcSRS );
    00308
    00309     OGRErr      SetFromUserInput( const char * );
    00310
    00311     OGRErr      SetTOWGS84( double, double, double,
    00312                             double = 0.0, double = 0.0, double = 0.0,
    00313                             double = 0.0 );
    00314     OGRErr      GetTOWGS84( double *padfCoef, int nCoeff = 7 ) const;
    00315
    00316     double      GetSemiMajor( OGRErr * = NULL ) const;
    00317     double      GetSemiMinor( OGRErr * = NULL ) const;
    00318     double      GetInvFlattening( OGRErr * = NULL ) const;
    00319
    00320     OGRErr      SetAuthority( const char * pszTargetKey,
    00321                               const char * pszAuthority,
    00322                               int nCode );
    00323
    00324     OGRErr      AutoIdentifyEPSG();
    00325
    00326     const char *GetAuthorityCode( const char * pszTargetKey ) const;
    00327     const char *GetAuthorityName( const char * pszTargetKey ) const;
    00328
    00329     OGRErr      SetProjParm( const char *, double );
    00330     double      GetProjParm( const char *, double =0.0, OGRErr* = NULL ) const;
    00331
    00332     OGRErr      SetNormProjParm( const char *, double );
    00333     double      GetNormProjParm( const char *, double=0.0, OGRErr* =NULL)const;
    00334
    00335     static int  IsAngularParameter( const char * );
    00336     static int  IsLongitudeParameter( const char * );
    00337     static int  IsLinearParameter( const char * );
    00338
    00340     OGRErr      SetACEA( double dfStdP1, double dfStdP2,
    00341                          double dfCenterLat, double dfCenterLong,
    00342                          double dfFalseEasting, double dfFalseNorthing );
    00343
    00345     OGRErr      SetAE( double dfCenterLat, double dfCenterLong,
    00346                        double dfFalseEasting, double dfFalseNorthing );
    00347
    00349     OGRErr      SetBonne( double dfStdP1, double dfCentralMeridian,
    00350                           double dfFalseEasting, double dfFalseNorthing );
    00351
    00353     OGRErr      SetCEA( double dfStdP1, double dfCentralMeridian,
    00354                         double dfFalseEasting, double dfFalseNorthing );
    00355
    00357     OGRErr      SetCS( double dfCenterLat, double dfCenterLong,
    00358                        double dfFalseEasting, double dfFalseNorthing );
    00359
    00361     OGRErr      SetEC( double dfStdP1, double dfStdP2,
    00362                        double dfCenterLat, double dfCenterLong,
    00363                        double dfFalseEasting, double dfFalseNorthing );
    00364
    00366     OGRErr      SetEckertIV( double dfCentralMeridian,
    00367                              double dfFalseEasting, double dfFalseNorthing );
    00368
    00370     OGRErr      SetEckertVI( double dfCentralMeridian,
    00371                              double dfFalseEasting, double dfFalseNorthing );
    00372
    00374     OGRErr      SetEquirectangular(double dfCenterLat, double dfCenterLong,
    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      SetGS( double dfCentralMeridian,
    00387                        double dfFalseEasting, double dfFalseNorthing );
    00388
    00390     OGRErr      SetGnomonic(double dfCenterLat, double dfCenterLong,
    00391                             double dfFalseEasting, double dfFalseNorthing );
    00392
    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
    00405     OGRErr      SetKrovak( double dfCenterLat, double dfCenterLong,
    00406                            double dfAzimuth, double dfPseudoStdParallelLat,
    00407                            double dfScale,
    00408                            double dfFalseEasting, double dfFalseNorthing );
    00409
    00411     OGRErr      SetLAEA( double dfCenterLat, double dfCenterLong,
    00412                          double dfFalseEasting, double dfFalseNorthing );
    00413
    00415     OGRErr      SetLCC( double dfStdP1, double dfStdP2,
    00416                         double dfCenterLat, double dfCenterLong,
    00417                         double dfFalseEasting, double dfFalseNorthing );
    00418
    00420     OGRErr      SetLCC1SP( double dfCenterLat, double dfCenterLong,
    00421                            double dfScale,
    00422                            double dfFalseEasting, double dfFalseNorthing );
    00423
    00425     OGRErr      SetLCCB( double dfStdP1, double dfStdP2,
    00426                          double dfCenterLat, double dfCenterLong,
    00427                          double dfFalseEasting, double dfFalseNorthing );
    00428
    00430     OGRErr      SetMC( double dfCenterLat, double dfCenterLong,
    00431                        double dfFalseEasting, double dfFalseNorthing );
    00432
    00434     OGRErr      SetMercator( double dfCenterLat, double dfCenterLong,
    00435                              double dfScale,
    00436                              double dfFalseEasting, double dfFalseNorthing );
    00437
    00439     OGRErr      SetMollweide( double dfCentralMeridian,
    00440                               double dfFalseEasting, double dfFalseNorthing );
    00441
    00443     OGRErr      SetNZMG( double dfCenterLat, double dfCenterLong,
    00444                          double dfFalseEasting, double dfFalseNorthing );
    00445
    00447     OGRErr      SetOS( double dfOriginLat, double dfCMeridian,
    00448                        double dfScale,
    00449                        double dfFalseEasting,double dfFalseNorthing);
    00450
    00452     OGRErr      SetOrthographic( double dfCenterLat, double dfCenterLong,
    00453                                  double dfFalseEasting,double dfFalseNorthing);
    00454
    00456     OGRErr      SetPolyconic( double dfCenterLat, double dfCenterLong,
    00457                               double dfFalseEasting, double dfFalseNorthing );
    00458
    00460     OGRErr      SetPS( double dfCenterLat, double dfCenterLong,
    00461                        double dfScale,
    00462                        double dfFalseEasting, double dfFalseNorthing);
    00463
    00465     OGRErr      SetRobinson( double dfCenterLong,
    00466                              double dfFalseEasting, double dfFalseNorthing );
    00467
    00469     OGRErr      SetSinusoidal( double dfCenterLong,
    00470                                double dfFalseEasting, double dfFalseNorthing );
    00471
    00473     OGRErr      SetStereographic( double dfCenterLat, double dfCenterLong,
    00474                                   double dfScale,
    00475                                  double dfFalseEasting,double dfFalseNorthing);
    00476
    00478     OGRErr      SetSOC( double dfLatitudeOfOrigin, double dfCentralMeridian,
    00479                         double dfFalseEasting, double dfFalseNorthing );
    00480
    00482     OGRErr      SetTM( double dfCenterLat, double dfCenterLong,
    00483                        double dfScale,
    00484                        double dfFalseEasting, double dfFalseNorthing );
    00485
    00487     OGRErr      SetTMVariant( const char *pszVariantName,
    00488                               double dfCenterLat, double dfCenterLong,
    00489                               double dfScale,
    00490                               double dfFalseEasting, double dfFalseNorthing );
    00491
    00493     OGRErr      SetTMG( double dfCenterLat, double dfCenterLong,
    00494                         double dfFalseEasting, double dfFalseNorthing );
    00495
    00497     OGRErr      SetTMSO( double dfCenterLat, double dfCenterLong,
    00498                          double dfScale,
    00499                          double dfFalseEasting, double dfFalseNorthing );
    00500
    00502     OGRErr      SetTPED( double dfLat1, double dfLong1,
    00503                          double dfLat2, double dfLong2,
    00504                          double dfFalseEasting, double dfFalseNorthing );
    00505
    00507     OGRErr      SetVDG( double dfCenterLong,
    00508                         double dfFalseEasting, double dfFalseNorthing );
    00509
    00511     OGRErr      SetUTM( int nZone, int bNorth = TRUE );
    00512     int         GetUTMZone( int *pbNorth = NULL ) const;
    00513
    00515     OGRErr      SetStatePlane( int nZone, int bNAD83 = TRUE,
    00516                                const char *pszOverrideUnitName = NULL,
    00517                                double dfOverrideUnit = 0.0 );
    00518 };
    00519
    00520 /************************************************************************/
    00521 /*                     OGRCoordinateTransformation                      */
    00522 /*                                                                      */
    00523 /*      This is really just used as a base class for a private          */
    00524 /*      implementation.                                                 */
    00525 /************************************************************************/
    00526
    00533 class CPL_DLL OGRCoordinateTransformation
    00534 {
    00535 public:
    00536     virtual ~OGRCoordinateTransformation() {}
    00537
    00538     // From CT_CoordinateTransformation
    00539
    00541     virtual OGRSpatialReference *GetSourceCS() = 0;
    00542
    00544     virtual OGRSpatialReference *GetTargetCS() = 0;
    00545
    00546     // From CT_MathTransform
    00547
    00563     virtual int Transform( int nCount,
    00564                            double *x, double *y, double *z = NULL ) = 0;
    00565
    00581     virtual int TransformEx( int nCount,
    00582                              double *x, double *y, double *z = NULL,
    00583                              int *pabSuccess = NULL ) = 0;
    00584
    00585 };
    00586
    00587 OGRCoordinateTransformation CPL_DLL *
    00588 OGRCreateCoordinateTransformation( OGRSpatialReference *poSource,
    00589                                    OGRSpatialReference *poTarget );
    00590
    00591 #endif /* ndef _OGR_SPATIALREF_H_INCLUDED */

Generated for GDAL by 1.4.5.