ogr_spatialref.h

Go to the documentation of this file.
00001 /******************************************************************************
00002  * $Id: ogr_spatialref.h,v 1.66 2005/03/03 04:55:42 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.66  2005/03/03 04:55:42  fwarmerdam
00033  * make exportToWkt() const
00034  *
00035  * Revision 1.65  2005/02/11 14:21:28  fwarmerdam
00036  * added GEOS projection support
00037  *
00038  * Revision 1.64  2005/01/13 05:17:37  fwarmerdam
00039  * added SetLinearUnitsAndUpdateParameters
00040  *
00041  * Revision 1.63  2005/01/05 21:02:33  fwarmerdam
00042  * added Goode Homolosine
00043  *
00044  * Revision 1.62  2004/11/11 18:28:45  fwarmerdam
00045  * added Bonne projection support
00046  *
00047  * Revision 1.61  2004/05/10 17:05:14  warmerda
00048  * added AutoIdentifyEPSG()
00049  *
00050  * Revision 1.60  2004/03/04 18:04:45  warmerda
00051  * added importFromDict() support
00052  *
00053  * Revision 1.59  2004/02/07 17:31:21  dron
00054  * Added OSRExportToUSGS() method.
00055  *
00056  * Revision 1.58  2004/02/05 17:07:59  dron
00057  * Support for HOM projection, specified by two points on centerline.
00058  *
00059  * Revision 1.57  2004/02/01 14:24:09  dron
00060  * Added OGRSpatialReference::importFromUSGS().
00061  *
00062  * Revision 1.56  2004/01/24 09:34:59  warmerda
00063  * added TransformEx support to capture per point reprojection failure
00064  *
00065  * Revision 1.55  2003/10/07 04:20:50  warmerda
00066  * added WMS AUTO: support
00067  *
00068  * Revision 1.54  2003/09/09 07:49:19  dron
00069  * Added exportToPCI() method.
00070  *
00071  * Revision 1.53  2003/08/31 14:51:30  dron
00072  * Added importFromPCI() method.
00073  *
00074  * Revision 1.52  2003/08/18 13:26:01  warmerda
00075  * added SetTMVariant() and related definitions
00076  *
00077  * Revision 1.51  2003/05/30 15:39:53  warmerda
00078  * Added override units capability for SetStatePlane()
00079  *
00080  * Revision 1.50  2003/05/28 19:16:42  warmerda
00081  * fixed up argument names and stuff for docs
00082  *
00083  * Revision 1.49  2003/03/12 14:25:01  warmerda
00084  * added NeedsQuoting() method
00085  *
00086  * Revision 1.48  2003/02/25 04:53:51  warmerda
00087  * added CopyGeogCSFrom() method
00088  *
00089  * Revision 1.47  2003/02/06 04:53:12  warmerda
00090  * added Fixup() method
00091  *
00092  * Revision 1.46  2003/01/08 18:14:28  warmerda
00093  * added FixupOrdering()
00094  */
00095 
00096 #ifndef _OGR_SPATIALREF_H_INCLUDED
00097 #define _OGR_SPATIALREF_H_INCLUDED
00098 
00099 #include "ogr_srs_api.h"
00100 
00107 /************************************************************************/
00108 /*                             OGR_SRSNode                              */
00109 /************************************************************************/
00110 
00124 class CPL_DLL OGR_SRSNode
00125 {
00126     char        *pszValue;
00127 
00128     int         nChildren;
00129     OGR_SRSNode **papoChildNodes;
00130 
00131     OGR_SRSNode *poParent;
00132 
00133     void        ClearChildren();
00134     int         NeedsQuoting() const;
00135     
00136   public:
00137                 OGR_SRSNode(const char * = NULL);
00138                 ~OGR_SRSNode();
00139 
00140     int         IsLeafNode() const { return nChildren == 0; }
00141     
00142     int         GetChildCount() const { return nChildren; }
00143     OGR_SRSNode *GetChild( int );
00144     const OGR_SRSNode *GetChild( int ) const;
00145 
00146     OGR_SRSNode *GetNode( const char * );
00147     const OGR_SRSNode *GetNode( const char * ) const;
00148 
00149     void        InsertChild( OGR_SRSNode *, int );
00150     void        AddChild( OGR_SRSNode * );
00151     int         FindChild( const char * ) const;
00152     void        DestroyChild( int );
00153     void        StripNodes( const char * );
00154 
00155     const char  *GetValue() const { return pszValue; }
00156     void        SetValue( const char * );
00157 
00158     void        MakeValueSafe();
00159     OGRErr      FixupOrdering();
00160 
00161     OGR_SRSNode *Clone() const;
00162 
00163     OGRErr      importFromWkt( char ** );
00164     OGRErr      exportToWkt( char ** ) const;
00165     OGRErr      exportToPrettyWkt( char **, int = 1) const;
00166     
00167     OGRErr      applyRemapper( const char *pszNode, 
00168                                char **papszSrcValues, 
00169                                char **papszDstValues, 
00170                                int nStepSize = 1,
00171                                int bChildOfHit = FALSE );
00172 };
00173 
00174 /************************************************************************/
00175 /*                         OGRSpatialReference                          */
00176 /************************************************************************/
00177 
00192 class CPL_DLL OGRSpatialReference
00193 {
00194     int         nRefCount;
00195 
00196     OGR_SRSNode *poRoot;
00197 
00198     int         bNormInfoSet;
00199     double      dfFromGreenwich;
00200     double      dfToMeter;
00201     double      dfToDegrees;
00202 
00203     OGRErr      ValidateProjection();
00204     int         IsAliasFor( const char *, const char * );
00205     void        GetNormInfo() const;
00206 
00207   public:
00208                 OGRSpatialReference(const OGRSpatialReference&);
00209                 OGRSpatialReference(const char * = NULL);
00210                 
00211     virtual    ~OGRSpatialReference();
00212                 
00213     OGRSpatialReference &operator=(const OGRSpatialReference&);
00214 
00215     int         Reference();
00216     int         Dereference();
00217     int         GetReferenceCount() const { return nRefCount; }
00218 
00219     OGRSpatialReference *Clone() const;
00220     OGRSpatialReference *CloneGeogCS() const;
00221 
00222     OGRErr      exportToWkt( char ** ) const;
00223     OGRErr      exportToPrettyWkt( char **, int = FALSE) const;
00224     OGRErr      exportToProj4( char ** ) const;
00225     OGRErr      exportToPCI( char **, char **, double ** ) const;
00226     OGRErr      exportToUSGS( long *, long *, double **, long * ) const;
00227     OGRErr      exportToXML( char **, const char * = NULL ) const;
00228     OGRErr      importFromWkt( char ** );
00229     OGRErr      importFromProj4( const char * );
00230     OGRErr      importFromEPSG( int );
00231     OGRErr      importFromESRI( char ** );
00232     OGRErr      importFromPCI( const char *pszProj,
00233                                const char *pszUnits = NULL,
00234                                double *padfPrjParams = NULL );
00235     OGRErr      importFromUSGS( long iProjsys, long iZone,
00236                                 double *padfPrjParams, long iDatum );
00237     OGRErr      importFromWMSAUTO( const char *pszAutoDef );
00238     OGRErr      importFromXML( const char * );
00239     OGRErr      importFromDict( const char *pszDict, const char *pszCode );
00240 
00241     OGRErr      morphToESRI();
00242     OGRErr      morphFromESRI();
00243 
00244     OGRErr      Validate();
00245     OGRErr      StripCTParms( OGR_SRSNode * = NULL );
00246     OGRErr      FixupOrdering();
00247     OGRErr      Fixup();
00248 
00249     // Machinary for accessing parse nodes
00250     OGR_SRSNode *GetRoot() { return poRoot; }
00251     const OGR_SRSNode *GetRoot() const { return poRoot; }
00252     void        SetRoot( OGR_SRSNode * );
00253     
00254     OGR_SRSNode *GetAttrNode(const char *);
00255     const OGR_SRSNode *GetAttrNode(const char *) const;
00256     const char  *GetAttrValue(const char *, int = 0) const;
00257 
00258     OGRErr      SetNode( const char *, const char * );
00259     OGRErr      SetNode( const char *, double );
00260     
00261     OGRErr      SetLinearUnitsAndUpdateParameters( const char *pszName, 
00262                                                    double dfInMeters );
00263     OGRErr      SetLinearUnits( const char *pszName, double dfInMeters );
00264     double      GetLinearUnits( char ** = NULL ) const;
00265 
00266     OGRErr      SetAngularUnits( const char *pszName, double dfInRadians );
00267     double      GetAngularUnits( char ** = NULL ) const;
00268 
00269     double      GetPrimeMeridian( char ** = NULL ) const;
00270 
00271     int         IsGeographic() const;
00272     int         IsProjected() const;
00273     int         IsLocal() const;
00274     int         IsSameGeogCS( const OGRSpatialReference * ) const;
00275     int         IsSame( const OGRSpatialReference * ) const;
00276 
00277     void        Clear();
00278     OGRErr      SetLocalCS( const char * );
00279     OGRErr      SetProjCS( const char * );
00280     OGRErr      SetProjection( const char * );
00281     OGRErr      SetGeogCS( const char * pszGeogName,
00282                            const char * pszDatumName,
00283                            const char * pszEllipsoidName,
00284                            double dfSemiMajor, double dfInvFlattening,
00285                            const char * pszPMName = NULL,
00286                            double dfPMOffset = 0.0,
00287                            const char * pszUnits = NULL,
00288                            double dfConvertToRadians = 0.0 );
00289     OGRErr      SetWellKnownGeogCS( const char * );
00290     OGRErr      CopyGeogCSFrom( const OGRSpatialReference * poSrcSRS );
00291 
00292     OGRErr      SetFromUserInput( const char * );
00293 
00294     OGRErr      SetTOWGS84( double, double, double,
00295                             double = 0.0, double = 0.0, double = 0.0,
00296                             double = 0.0 );
00297     OGRErr      GetTOWGS84( double *padfCoef, int nCoeff = 7 ) const;
00298     
00299     double      GetSemiMajor( OGRErr * = NULL ) const;
00300     double      GetSemiMinor( OGRErr * = NULL ) const;
00301     double      GetInvFlattening( OGRErr * = NULL ) const;
00302 
00303     OGRErr      SetAuthority( const char * pszTargetKey, 
00304                               const char * pszAuthority, 
00305                               int nCode );
00306 
00307     OGRErr      AutoIdentifyEPSG();
00308 
00309     const char *GetAuthorityCode( const char * pszTargetKey ) const;
00310     const char *GetAuthorityName( const char * pszTargetKey ) const;
00311                            
00312     OGRErr      SetProjParm( const char *, double );
00313     double      GetProjParm( const char *, double =0.0, OGRErr* = NULL ) const;
00314 
00315     OGRErr      SetNormProjParm( const char *, double );
00316     double      GetNormProjParm( const char *, double=0.0, OGRErr* =NULL)const;
00317 
00318     static int  IsAngularParameter( const char * );
00319     static int  IsLongitudeParameter( const char * );
00320     static int  IsLinearParameter( const char * );
00321 
00323     OGRErr      SetACEA( double dfStdP1, double dfStdP2,
00324                          double dfCenterLat, double dfCenterLong,
00325                          double dfFalseEasting, double dfFalseNorthing );
00326     
00328     OGRErr      SetAE( double dfCenterLat, double dfCenterLong,
00329                        double dfFalseEasting, double dfFalseNorthing );
00330 
00332     OGRErr      SetBonne( double dfStdP1, double dfCentralMeridian,
00333                           double dfFalseEasting, double dfFalseNorthing );
00334     
00336     OGRErr      SetCEA( double dfStdP1, double dfCentralMeridian,
00337                         double dfFalseEasting, double dfFalseNorthing );
00338 
00340     OGRErr      SetCS( double dfCenterLat, double dfCenterLong,
00341                        double dfFalseEasting, double dfFalseNorthing );
00342 
00344     OGRErr      SetEC( double dfStdP1, double dfStdP2,
00345                        double dfCenterLat, double dfCenterLong,
00346                        double dfFalseEasting, double dfFalseNorthing );
00347 
00349     OGRErr      SetEckertIV( double dfCentralMeridian,
00350                              double dfFalseEasting, double dfFalseNorthing );
00351 
00353     OGRErr      SetEckertVI( double dfCentralMeridian,
00354                              double dfFalseEasting, double dfFalseNorthing );
00355 
00357     OGRErr      SetEquirectangular(double dfCenterLat, double dfCenterLong,
00358                             double dfFalseEasting, double dfFalseNorthing );
00359 
00361     OGRErr      SetGEOS( double dfCentralMeridian, double dfSatelliteHeight, 
00362                          double dfFalseEasting, double dfFalseNorthing );
00363 
00365     OGRErr      SetGH( double dfCentralMeridian, 
00366                        double dfFalseEasting, double dfFalseNorthing );
00367 
00369     OGRErr      SetGS( double dfCentralMeridian,
00370                        double dfFalseEasting, double dfFalseNorthing );
00371     
00373     OGRErr      SetGnomonic(double dfCenterLat, double dfCenterLong,
00374                             double dfFalseEasting, double dfFalseNorthing );
00375 
00376     OGRErr      SetHOM( double dfCenterLat, double dfCenterLong,
00377                         double dfAzimuth, double dfRectToSkew,
00378                         double dfScale,
00379                         double dfFalseEasting, double dfFalseNorthing );
00380 
00381     OGRErr      SetHOM2PNO( double dfCenterLat,
00382                             double dfLat1, double dfLong1,
00383                             double dfLat2, double dfLong2,
00384                             double dfScale,
00385                             double dfFalseEasting, double dfFalseNorthing );
00386 
00388     OGRErr      SetKrovak( double dfCenterLat, double dfCenterLong,
00389                            double dfAzimuth, double dfPseudoStdParallelLat,
00390                            double dfScale, 
00391                            double dfFalseEasting, double dfFalseNorthing );
00392 
00394     OGRErr      SetLAEA( double dfCenterLat, double dfCenterLong,
00395                          double dfFalseEasting, double dfFalseNorthing );
00396 
00398     OGRErr      SetLCC( double dfStdP1, double dfStdP2,
00399                         double dfCenterLat, double dfCenterLong,
00400                         double dfFalseEasting, double dfFalseNorthing );
00401 
00403     OGRErr      SetLCC1SP( double dfCenterLat, double dfCenterLong,
00404                            double dfScale,
00405                            double dfFalseEasting, double dfFalseNorthing );
00406 
00408     OGRErr      SetLCCB( double dfStdP1, double dfStdP2,
00409                          double dfCenterLat, double dfCenterLong,
00410                          double dfFalseEasting, double dfFalseNorthing );
00411     
00413     OGRErr      SetMC( double dfCenterLat, double dfCenterLong,
00414                        double dfFalseEasting, double dfFalseNorthing );
00415 
00417     OGRErr      SetMercator( double dfCenterLat, double dfCenterLong,
00418                              double dfScale, 
00419                              double dfFalseEasting, double dfFalseNorthing );
00420 
00422     OGRErr      SetMollweide( double dfCentralMeridian,
00423                               double dfFalseEasting, double dfFalseNorthing );
00424 
00426     OGRErr      SetNZMG( double dfCenterLat, double dfCenterLong,
00427                          double dfFalseEasting, double dfFalseNorthing );
00428 
00430     OGRErr      SetOS( double dfOriginLat, double dfCMeridian,
00431                        double dfScale,
00432                        double dfFalseEasting,double dfFalseNorthing);
00433     
00435     OGRErr      SetOrthographic( double dfCenterLat, double dfCenterLong,
00436                                  double dfFalseEasting,double dfFalseNorthing);
00437 
00439     OGRErr      SetPolyconic( double dfCenterLat, double dfCenterLong,
00440                               double dfFalseEasting, double dfFalseNorthing );
00441 
00443     OGRErr      SetPS( double dfCenterLat, double dfCenterLong,
00444                        double dfScale,
00445                        double dfFalseEasting, double dfFalseNorthing);
00446     
00448     OGRErr      SetRobinson( double dfCenterLong, 
00449                              double dfFalseEasting, double dfFalseNorthing );
00450     
00452     OGRErr      SetSinusoidal( double dfCenterLong, 
00453                                double dfFalseEasting, double dfFalseNorthing );
00454     
00456     OGRErr      SetStereographic( double dfCenterLat, double dfCenterLong,
00457                                   double dfScale,
00458                                  double dfFalseEasting,double dfFalseNorthing);
00459     
00461     OGRErr      SetSOC( double dfLatitudeOfOrigin, double dfCentralMeridian,
00462                         double dfFalseEasting, double dfFalseNorthing );
00463     
00465     OGRErr      SetTM( double dfCenterLat, double dfCenterLong,
00466                        double dfScale,
00467                        double dfFalseEasting, double dfFalseNorthing );
00468 
00470     OGRErr      SetTMVariant( const char *pszVariantName, 
00471                               double dfCenterLat, double dfCenterLong,
00472                               double dfScale,
00473                               double dfFalseEasting, double dfFalseNorthing );
00474 
00476     OGRErr      SetTMG( double dfCenterLat, double dfCenterLong, 
00477                         double dfFalseEasting, double dfFalseNorthing );
00478 
00480     OGRErr      SetTMSO( double dfCenterLat, double dfCenterLong,
00481                          double dfScale,
00482                          double dfFalseEasting, double dfFalseNorthing );
00483 
00485     OGRErr      SetVDG( double dfCenterLong,
00486                         double dfFalseEasting, double dfFalseNorthing );
00487 
00489     OGRErr      SetUTM( int nZone, int bNorth = TRUE );
00490     int         GetUTMZone( int *pbNorth = NULL ) const;
00491 
00493     OGRErr      SetStatePlane( int nZone, int bNAD83 = TRUE,
00494                                const char *pszOverrideUnitName = NULL,
00495                                double dfOverrideUnit = 0.0 );
00496 };
00497 
00498 /************************************************************************/
00499 /*                     OGRCoordinateTransformation                      */
00500 /*                                                                      */
00501 /*      This is really just used as a base class for a private          */
00502 /*      implementation.                                                 */
00503 /************************************************************************/
00504 
00511 class CPL_DLL OGRCoordinateTransformation
00512 {
00513 public:
00514     virtual ~OGRCoordinateTransformation() {}
00515 
00516     // From CT_CoordinateTransformation
00517 
00519     virtual OGRSpatialReference *GetSourceCS() = 0;
00520 
00522     virtual OGRSpatialReference *GetTargetCS() = 0;
00523 
00524     // From CT_MathTransform
00525 
00541     virtual int Transform( int nCount, 
00542                            double *x, double *y, double *z = NULL ) = 0;
00543 
00559     virtual int TransformEx( int nCount, 
00560                              double *x, double *y, double *z = NULL,
00561                              int *pabSuccess = NULL ) = 0;
00562 
00563 };
00564 
00565 OGRCoordinateTransformation CPL_DLL *
00566 OGRCreateCoordinateTransformation( OGRSpatialReference *poSource, 
00567                                    OGRSpatialReference *poTarget );
00568 
00569 #endif /* ndef _OGR_SPATIALREF_H_INCLUDED */

Generated on Mon Jan 9 18:03:31 2006 for OGR by  doxygen 1.4.6