ogr_spatialref.h

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

Generated on Sun Jul 2 22:18:21 2006 for OGR by  doxygen 1.4.6