Main Page | Class Hierarchy | Class List | 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.55 2003/10/07 04:20:50 warmerda 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.55  2003/10/07 04:20:50  warmerda
00033  * added WMS AUTO: support
00034  *
00035  * Revision 1.54  2003/09/09 07:49:19  dron
00036  * Added exportToPCI() method.
00037  *
00038  * Revision 1.53  2003/08/31 14:51:30  dron
00039  * Added importFromPCI() method.
00040  *
00041  * Revision 1.52  2003/08/18 13:26:01  warmerda
00042  * added SetTMVariant() and related definitions
00043  *
00044  * Revision 1.51  2003/05/30 15:39:53  warmerda
00045  * Added override units capability for SetStatePlane()
00046  *
00047  * Revision 1.50  2003/05/28 19:16:42  warmerda
00048  * fixed up argument names and stuff for docs
00049  *
00050  * Revision 1.49  2003/03/12 14:25:01  warmerda
00051  * added NeedsQuoting() method
00052  *
00053  * Revision 1.48  2003/02/25 04:53:51  warmerda
00054  * added CopyGeogCSFrom() method
00055  *
00056  * Revision 1.47  2003/02/06 04:53:12  warmerda
00057  * added Fixup() method
00058  *
00059  * Revision 1.46  2003/01/08 18:14:28  warmerda
00060  * added FixupOrdering()
00061  *
00062  * Revision 1.45  2002/12/16 17:06:51  warmerda
00063  * added GetPrimeMeridian() method
00064  *
00065  * Revision 1.44  2002/12/15 23:42:59  warmerda
00066  * added initial support for normalizing proj params
00067  *
00068  * Revision 1.43  2002/12/14 22:59:14  warmerda
00069  * added Krovak in ESRI compatible way
00070  *
00071  * Revision 1.42  2002/12/10 04:04:38  warmerda
00072  * added parent pointer to OGR_SRSNode
00073  *
00074  * Revision 1.41  2002/12/09 16:11:02  warmerda
00075  * fixed constness of get authority calls
00076  *
00077  * Revision 1.40  2002/12/01 21:16:10  warmerda
00078  * added Get/set angular units methods
00079  *
00080  * Revision 1.39  2002/11/25 16:12:54  warmerda
00081  * added GetAuthorityCode/Name
00082  *
00083  * Revision 1.38  2002/04/18 14:22:45  warmerda
00084  * made OGRSpatialReference and co 'const correct'
00085  *
00086  * Revision 1.37  2002/03/05 14:25:14  warmerda
00087  * expand tabs
00088  *
00089  * Revision 1.36  2002/01/24 16:21:45  warmerda
00090  * added StripNodes method, removed simplify flag from pretty wkt
00091  *
00092  * Revision 1.35  2001/12/06 18:18:47  warmerda
00093  * added preliminary xml srs support
00094  *
00095  * Revision 1.34  2001/10/11 19:27:12  warmerda
00096  * upgraded validation infrastructure
00097  *
00098  * Revision 1.33  2001/10/10 20:42:43  warmerda
00099  * added ESRI WKT morphing support
00100  *
00101  * Revision 1.32  2001/09/21 16:21:02  warmerda
00102  * added Clear(), and SetFromUserInput() methods
00103  *
00104  * Revision 1.31  2001/07/19 18:25:07  warmerda
00105  * expanded tabs
00106  *
00107  * Revision 1.30  2001/07/16 03:34:55  warmerda
00108  * various fixes, and improvements suggested by Ben Driscoe on gdal list
00109  *
00110  * Revision 1.29  2001/05/24 21:02:42  warmerda
00111  * moved OGRCoordinateTransform destructor defn
00112  *
00113  * Revision 1.28  2001/02/06 17:10:28  warmerda
00114  * export entry points from DLL
00115  *
00116  * Revision 1.27  2001/01/22 13:59:55  warmerda
00117  * added SetSOC
00118  *
00119  * Revision 1.26  2001/01/19 21:10:47  warmerda
00120  * replaced tabs
00121  *
00122  * Revision 1.25  2000/11/09 06:21:32  warmerda
00123  * added limited ESRI prj support
00124  *
00125  * Revision 1.24  2000/10/20 04:19:38  warmerda
00126  * added setstateplane
00127  *
00128  * Revision 1.23  2000/10/16 21:26:07  warmerda
00129  * added some level of LOCAL_CS support
00130  *
00131  * Revision 1.22  2000/08/28 20:13:23  warmerda
00132  * added importFromProj4
00133  *
00134  * Revision 1.21  2000/07/09 20:48:02  warmerda
00135  * added exportToPrettyWkt
00136  *
00137  * Revision 1.20  2000/03/24 14:49:56  warmerda
00138  * added WGS84 related methods
00139  *
00140  * Revision 1.19  2000/03/22 01:09:43  warmerda
00141  * added SetProjCS and SetWellKnownTextCS
00142  *
00143  * Revision 1.18  2000/03/20 23:33:51  warmerda
00144  * updated docs a bit
00145  *
00146  * Revision 1.17  2000/03/20 23:08:05  warmerda
00147  * Added docs.
00148  *
00149  * Revision 1.16  2000/03/20 22:59:36  warmerda
00150  * Added some documentation.
00151  *
00152  * Revision 1.15  2000/03/20 22:39:49  warmerda
00153  * Added IsSame( method.
00154  *
00155  * Revision 1.14  2000/03/20 14:59:35  warmerda
00156  * added OGRCoordinateTransformation
00157  *
00158  * Revision 1.13  2000/03/16 19:04:01  warmerda
00159  * added SetTMG, moved constants to ogr_srs_api.h
00160  *
00161  * Revision 1.12  2000/01/26 21:22:18  warmerda
00162  * added tentative MakeValueSafe implementation
00163  *
00164  * Revision 1.11  2000/01/11 22:12:13  warmerda
00165  * added InsertChild
00166  *
00167  * Revision 1.10  2000/01/06 19:46:10  warmerda
00168  * added special logic for setting, and recognising UTM
00169  *
00170  * Revision 1.9  1999/11/18 19:02:20  warmerda
00171  * expanded tabs
00172  *
00173  * Revision 1.8  1999/09/29 16:36:17  warmerda
00174  * added several new projections
00175  *
00176  * Revision 1.7  1999/09/15 20:34:21  warmerda
00177  * South_Oriented to SouthOrientated, prototype changes
00178  *
00179  * Revision 1.6  1999/09/09 13:53:47  warmerda
00180  * use lower case for degree and radian
00181  *
00182  * Revision 1.5  1999/07/29 17:29:45  warmerda
00183  * added various help methods for projections
00184  *
00185  * Revision 1.4  1999/07/14 05:23:38  warmerda
00186  * Added projection set methods, and #defined tokens
00187  *
00188  * Revision 1.3  1999/06/25 20:21:18  warmerda
00189  * fleshed out classes
00190  *
00191  * Revision 1.2  1999/05/31 17:14:34  warmerda
00192  * Fixed define.
00193  *
00194  * Revision 1.1  1999/05/20 14:35:00  warmerda
00195  * New
00196  */
00197 
00198 #ifndef _OGR_SPATIALREF_H_INCLUDED
00199 #define _OGR_SPATIALREF_H_INCLUDED
00200 
00201 #include "ogr_srs_api.h"
00202 
00209 /************************************************************************/
00210 /*                             OGR_SRSNode                              */
00211 /************************************************************************/
00212 
00226 class CPL_DLL OGR_SRSNode
00227 {
00228     char        *pszValue;
00229 
00230     int         nChildren;
00231     OGR_SRSNode **papoChildNodes;
00232 
00233     OGR_SRSNode *poParent;
00234 
00235     void        ClearChildren();
00236     int         NeedsQuoting() const;
00237     
00238   public:
00239                 OGR_SRSNode(const char * = NULL);
00240                 ~OGR_SRSNode();
00241 
00242     int         IsLeafNode() const { return nChildren == 0; }
00243     
00244     int         GetChildCount() const { return nChildren; }
00245     OGR_SRSNode *GetChild( int );
00246     const OGR_SRSNode *GetChild( int ) const;
00247 
00248     OGR_SRSNode *GetNode( const char * );
00249     const OGR_SRSNode *GetNode( const char * ) const;
00250 
00251     void        InsertChild( OGR_SRSNode *, int );
00252     void        AddChild( OGR_SRSNode * );
00253     int         FindChild( const char * ) const;
00254     void        DestroyChild( int );
00255     void        StripNodes( const char * );
00256 
00257     const char  *GetValue() const { return pszValue; }
00258     void        SetValue( const char * );
00259 
00260     void        MakeValueSafe();
00261     OGRErr      FixupOrdering();
00262 
00263     OGR_SRSNode *Clone() const;
00264 
00265     OGRErr      importFromWkt( char ** );
00266     OGRErr      exportToWkt( char ** ) const;
00267     OGRErr      exportToPrettyWkt( char **, int = 1) const;
00268     
00269     OGRErr      applyRemapper( const char *pszNode, 
00270                                char **papszSrcValues, 
00271                                char **papszDstValues, 
00272                                int nStepSize = 1,
00273                                int bChildOfHit = FALSE );
00274 };
00275 
00276 /************************************************************************/
00277 /*                         OGRSpatialReference                          */
00278 /************************************************************************/
00279 
00294 class CPL_DLL OGRSpatialReference
00295 {
00296     int         nRefCount;
00297 
00298     OGR_SRSNode *poRoot;
00299 
00300     int         bNormInfoSet;
00301     double      dfFromGreenwich;
00302     double      dfToMeter;
00303     double      dfToDegrees;
00304 
00305     OGRErr      ValidateProjection();
00306     int         IsAliasFor( const char *, const char * );
00307     void        GetNormInfo() const;
00308 
00309   public:
00310                 OGRSpatialReference(const OGRSpatialReference&);
00311                 OGRSpatialReference(const char * = NULL);
00312                 
00313     virtual    ~OGRSpatialReference();
00314                 
00315     OGRSpatialReference &operator=(const OGRSpatialReference&);
00316 
00317     int         Reference();
00318     int         Dereference();
00319     int         GetReferenceCount() const { return nRefCount; }
00320 
00321     OGRSpatialReference *Clone() const;
00322     OGRSpatialReference *CloneGeogCS() const;
00323 
00324     OGRErr      importFromWkt( char ** );
00325     OGRErr      exportToWkt( char ** );
00326     OGRErr      exportToPrettyWkt( char **, int = FALSE) const;
00327     OGRErr      exportToProj4( char ** ) const;
00328     OGRErr      exportToPCI( char **, char **, double ** ) const;
00329 
00330     OGRErr      exportToXML( char **, const char * = NULL ) const;
00331     OGRErr      importFromProj4( const char * );
00332     OGRErr      importFromEPSG( int );
00333     OGRErr      importFromESRI( char ** );
00334     OGRErr      importFromPCI( const char *pszProj,
00335                                const char *pszUnits = NULL,
00336                                double *padfPrjParams = NULL );
00337     OGRErr      importFromWMSAUTO( const char *pszAutoDef );
00338     OGRErr      importFromXML( const char * );
00339 
00340     OGRErr      morphToESRI();
00341     OGRErr      morphFromESRI();
00342 
00343     OGRErr      Validate();
00344     OGRErr      StripCTParms( OGR_SRSNode * = NULL );
00345     OGRErr      FixupOrdering();
00346     OGRErr      Fixup();
00347 
00348     // Machinary for accessing parse nodes
00349     OGR_SRSNode *GetRoot() { return poRoot; }
00350     const OGR_SRSNode *GetRoot() const { return poRoot; }
00351     void        SetRoot( OGR_SRSNode * );
00352     
00353     OGR_SRSNode *GetAttrNode(const char *);
00354     const OGR_SRSNode *GetAttrNode(const char *) const;
00355     const char  *GetAttrValue(const char *, int = 0) const;
00356 
00357     OGRErr      SetNode( const char *, const char * );
00358     OGRErr      SetNode( const char *, double );
00359 
00360     OGRErr      SetLinearUnits( const char *pszName, double dfInMeters );
00361     double      GetLinearUnits( char ** = NULL ) const;
00362 
00363     OGRErr      SetAngularUnits( const char *pszName, double dfInRadians );
00364     double      GetAngularUnits( char ** = NULL ) const;
00365 
00366     double      GetPrimeMeridian( char ** = NULL ) const;
00367 
00368     int         IsGeographic() const;
00369     int         IsProjected() const;
00370     int         IsLocal() const;
00371     int         IsSameGeogCS( const OGRSpatialReference * ) const;
00372     int         IsSame( const OGRSpatialReference * ) const;
00373 
00374     void        Clear();
00375     OGRErr      SetLocalCS( const char * );
00376     OGRErr      SetProjCS( const char * );
00377     OGRErr      SetProjection( const char * );
00378     OGRErr      SetGeogCS( const char * pszGeogName,
00379                            const char * pszDatumName,
00380                            const char * pszEllipsoidName,
00381                            double dfSemiMajor, double dfInvFlattening,
00382                            const char * pszPMName = NULL,
00383                            double dfPMOffset = 0.0,
00384                            const char * pszUnits = NULL,
00385                            double dfConvertToRadians = 0.0 );
00386     OGRErr      SetWellKnownGeogCS( const char * );
00387     OGRErr      CopyGeogCSFrom( const OGRSpatialReference * poSrcSRS );
00388 
00389     OGRErr      SetFromUserInput( const char * );
00390 
00391     OGRErr      SetTOWGS84( double, double, double,
00392                             double = 0.0, double = 0.0, double = 0.0,
00393                             double = 0.0 );
00394     OGRErr      GetTOWGS84( double *padfCoef, int nCoeff = 7 ) const;
00395     
00396     double      GetSemiMajor( OGRErr * = NULL ) const;
00397     double      GetSemiMinor( OGRErr * = NULL ) const;
00398     double      GetInvFlattening( OGRErr * = NULL ) const;
00399 
00400     OGRErr      SetAuthority( const char * pszTargetKey, 
00401                               const char * pszAuthority, 
00402                               int nCode );
00403 
00404     const char *GetAuthorityCode( const char * pszTargetKey ) const;
00405     const char *GetAuthorityName( const char * pszTargetKey ) const;
00406                            
00407     OGRErr      SetProjParm( const char *, double );
00408     double      GetProjParm( const char *, double =0.0, OGRErr* = NULL ) const;
00409 
00410     OGRErr      SetNormProjParm( const char *, double );
00411     double      GetNormProjParm( const char *, double=0.0, OGRErr* =NULL)const;
00412 
00413     static int  IsAngularParameter( const char * );
00414     static int  IsLongitudeParameter( const char * );
00415     static int  IsLinearParameter( const char * );
00416 
00418     OGRErr      SetACEA( double dfStdP1, double dfStdP2,
00419                          double dfCenterLat, double dfCenterLong,
00420                          double dfFalseEasting, double dfFalseNorthing );
00421     
00423     OGRErr      SetAE( double dfCenterLat, double dfCenterLong,
00424                        double dfFalseEasting, double dfFalseNorthing );
00425 
00427     OGRErr      SetCEA( double dfStdP1, double dfCentralMeridian,
00428                         double dfFalseEasting, double dfFalseNorthing );
00429 
00431     OGRErr      SetCS( double dfCenterLat, double dfCenterLong,
00432                        double dfFalseEasting, double dfFalseNorthing );
00433 
00435     OGRErr      SetEC( double dfStdP1, double dfStdP2,
00436                        double dfCenterLat, double dfCenterLong,
00437                        double dfFalseEasting, double dfFalseNorthing );
00438 
00440     OGRErr      SetEckertIV( double dfCentralMeridian,
00441                              double dfFalseEasting, double dfFalseNorthing );
00442 
00444     OGRErr      SetEckertVI( double dfCentralMeridian,
00445                              double dfFalseEasting, double dfFalseNorthing );
00446 
00448     OGRErr      SetEquirectangular(double dfCenterLat, double dfCenterLong,
00449                         double dfFalseEasting, double dfFalseNorthing );
00450 
00452     OGRErr      SetGS( double dfCentralMeridian,
00453                        double dfFalseEasting, double dfFalseNorthing );
00454     
00456     OGRErr      SetGnomonic(double dfCenterLat, double dfCenterLong,
00457                             double dfFalseEasting, double dfFalseNorthing );
00458 
00460     OGRErr      SetHOM( double dfCenterLat, double dfCenterLong,
00461                         double dfAzimuth, double dfRectToSkew,
00462                         double dfScale,
00463                         double dfFalseEasting, double dfFalseNorthing );
00464 
00466     OGRErr      SetKrovak( double dfCenterLat, double dfCenterLong,
00467                            double dfAzimuth, double dfPseudoStdParallelLat,
00468                            double dfScale, 
00469                            double dfFalseEasting, double dfFalseNorthing );
00470 
00472     OGRErr      SetLAEA( double dfCenterLat, double dfCenterLong,
00473                          double dfFalseEasting, double dfFalseNorthing );
00474 
00476     OGRErr      SetLCC( double dfStdP1, double dfStdP2,
00477                         double dfCenterLat, double dfCenterLong,
00478                         double dfFalseEasting, double dfFalseNorthing );
00479 
00481     OGRErr      SetLCC1SP( double dfCenterLat, double dfCenterLong,
00482                            double dfScale,
00483                            double dfFalseEasting, double dfFalseNorthing );
00484 
00486     OGRErr      SetLCCB( double dfStdP1, double dfStdP2,
00487                          double dfCenterLat, double dfCenterLong,
00488                          double dfFalseEasting, double dfFalseNorthing );
00489     
00491     OGRErr      SetMC( double dfCenterLat, double dfCenterLong,
00492                        double dfFalseEasting, double dfFalseNorthing );
00493 
00495     OGRErr      SetMercator( double dfCenterLat, double dfCenterLong,
00496                              double dfScale, 
00497                              double dfFalseEasting, double dfFalseNorthing );
00498 
00500     OGRErr      SetMollweide( double dfCentralMeridian,
00501                               double dfFalseEasting, double dfFalseNorthing );
00502 
00504     OGRErr      SetNZMG( double dfCenterLat, double dfCenterLong,
00505                          double dfFalseEasting, double dfFalseNorthing );
00506 
00508     OGRErr      SetOS( double dfOriginLat, double dfCMeridian,
00509                        double dfScale,
00510                        double dfFalseEasting,double dfFalseNorthing);
00511     
00513     OGRErr      SetOrthographic( double dfCenterLat, double dfCenterLong,
00514                                  double dfFalseEasting,double dfFalseNorthing);
00515 
00517     OGRErr      SetPolyconic( double dfCenterLat, double dfCenterLong,
00518                               double dfFalseEasting, double dfFalseNorthing );
00519 
00521     OGRErr      SetPS( double dfCenterLat, double dfCenterLong,
00522                        double dfScale,
00523                        double dfFalseEasting, double dfFalseNorthing);
00524     
00526     OGRErr      SetRobinson( double dfCenterLong, 
00527                              double dfFalseEasting, double dfFalseNorthing );
00528     
00530     OGRErr      SetSinusoidal( double dfCenterLong, 
00531                                double dfFalseEasting, double dfFalseNorthing );
00532     
00534     OGRErr      SetStereographic( double dfCenterLat, double dfCenterLong,
00535                                   double dfScale,
00536                                  double dfFalseEasting,double dfFalseNorthing);
00537     
00539     OGRErr      SetSOC( double dfLatitudeOfOrigin, double dfCentralMeridian,
00540                         double dfFalseEasting, double dfFalseNorthing );
00541     
00543     OGRErr      SetTM( double dfCenterLat, double dfCenterLong,
00544                        double dfScale,
00545                        double dfFalseEasting, double dfFalseNorthing );
00546 
00548     OGRErr      SetTMVariant( const char *pszVariantName, 
00549                               double dfCenterLat, double dfCenterLong,
00550                               double dfScale,
00551                               double dfFalseEasting, double dfFalseNorthing );
00552 
00554     OGRErr      SetTMG( double dfCenterLat, double dfCenterLong, 
00555                         double dfFalseEasting, double dfFalseNorthing );
00556 
00558     OGRErr      SetTMSO( double dfCenterLat, double dfCenterLong,
00559                          double dfScale,
00560                          double dfFalseEasting, double dfFalseNorthing );
00561 
00563     OGRErr      SetVDG( double dfCenterLong,
00564                         double dfFalseEasting, double dfFalseNorthing );
00565 
00567     OGRErr      SetUTM( int nZone, int bNorth = TRUE );
00568     int         GetUTMZone( int *pbNorth = NULL ) const;
00569 
00571     OGRErr      SetStatePlane( int nZone, int bNAD83 = TRUE,
00572                                const char *pszOverrideUnitName = NULL,
00573                                double dfOverrideUnit = 0.0 );
00574 };
00575 
00576 /************************************************************************/
00577 /*                     OGRCoordinateTransformation                      */
00578 /*                                                                      */
00579 /*      This is really just used as a base class for a private          */
00580 /*      implementation.                                                 */
00581 /************************************************************************/
00582 
00589 class CPL_DLL OGRCoordinateTransformation
00590 {
00591 public:
00592     virtual ~OGRCoordinateTransformation() {}
00593 
00594     // From CT_CoordinateTransformation
00595 
00597     virtual OGRSpatialReference *GetSourceCS() = 0;
00598 
00600     virtual OGRSpatialReference *GetTargetCS() = 0;
00601 
00602     // From CT_MathTransform
00603 
00616     virtual int Transform( int nCount, 
00617                            double *x, double *y, double *z = NULL ) = 0;
00618 
00619 };
00620 
00621 OGRCoordinateTransformation CPL_DLL *
00622 OGRCreateCoordinateTransformation( OGRSpatialReference *poSource, 
00623                                    OGRSpatialReference *poTarget );
00624 
00625 #endif /* ndef _OGR_SPATIALREF_H_INCLUDED */

Generated on Thu Nov 13 00:06:21 2003 for OGR by doxygen 1.3.4