Main Page | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

ogr_spatialref.h

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

Generated on Tue Mar 15 07:12:56 2005 for OGR by  doxygen 1.4.0