ogr_spatialref.h

Go to the documentation of this file.
00001 /******************************************************************************
00002  * $Id: ogr_spatialref.h 15182 2008-08-22 16:57:53Z warmerdam $
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 #ifndef _OGR_SPATIALREF_H_INCLUDED
00032 #define _OGR_SPATIALREF_H_INCLUDED
00033 
00034 #include "ogr_srs_api.h"
00035 
00042 /************************************************************************/
00043 /*                             OGR_SRSNode                              */
00044 /************************************************************************/
00045 
00059 class CPL_DLL OGR_SRSNode
00060 {
00061     char        *pszValue;
00062 
00063     OGR_SRSNode **papoChildNodes;
00064     OGR_SRSNode *poParent;
00065 
00066     int         nChildren;
00067 
00068     void        ClearChildren();
00069     int         NeedsQuoting() const;
00070     
00071   public:
00072                 OGR_SRSNode(const char * = NULL);
00073                 ~OGR_SRSNode();
00074 
00075     int         IsLeafNode() const { return nChildren == 0; }
00076     
00077     int         GetChildCount() const { return nChildren; }
00078     OGR_SRSNode *GetChild( int );
00079     const OGR_SRSNode *GetChild( int ) const;
00080 
00081     OGR_SRSNode *GetNode( const char * );
00082     const OGR_SRSNode *GetNode( const char * ) const;
00083 
00084     void        InsertChild( OGR_SRSNode *, int );
00085     void        AddChild( OGR_SRSNode * );
00086     int         FindChild( const char * ) const;
00087     void        DestroyChild( int );
00088     void        StripNodes( const char * );
00089 
00090     const char  *GetValue() const { return pszValue; }
00091     void        SetValue( const char * );
00092 
00093     void        MakeValueSafe();
00094     OGRErr      FixupOrdering();
00095 
00096     OGR_SRSNode *Clone() const;
00097 
00098     OGRErr      importFromWkt( char ** );
00099     OGRErr      exportToWkt( char ** ) const;
00100     OGRErr      exportToPrettyWkt( char **, int = 1) const;
00101     
00102     OGRErr      applyRemapper( const char *pszNode, 
00103                                char **papszSrcValues, 
00104                                char **papszDstValues, 
00105                                int nStepSize = 1,
00106                                int bChildOfHit = FALSE );
00107 };
00108 
00109 /************************************************************************/
00110 /*                         OGRSpatialReference                          */
00111 /************************************************************************/
00112 
00127 class CPL_DLL OGRSpatialReference
00128 {
00129     double      dfFromGreenwich;
00130     double      dfToMeter;
00131     double      dfToDegrees;
00132 
00133     OGR_SRSNode *poRoot;
00134 
00135     int         nRefCount;
00136     int         bNormInfoSet;
00137 
00138     OGRErr      ValidateProjection();
00139     int         IsAliasFor( const char *, const char * );
00140     void        GetNormInfo() const;
00141 
00142   public:
00143                 OGRSpatialReference(const OGRSpatialReference&);
00144                 OGRSpatialReference(const char * = NULL);
00145                 
00146     virtual    ~OGRSpatialReference();
00147                 
00148     OGRSpatialReference &operator=(const OGRSpatialReference&);
00149 
00150     int         Reference();
00151     int         Dereference();
00152     int         GetReferenceCount() const { return nRefCount; }
00153     void        Release();
00154 
00155     OGRSpatialReference *Clone() const;
00156     OGRSpatialReference *CloneGeogCS() const;
00157 
00158     OGRErr      exportToWkt( char ** ) const;
00159     OGRErr      exportToPrettyWkt( char **, int = FALSE) const;
00160     OGRErr      exportToProj4( char ** ) const;
00161     OGRErr      exportToPCI( char **, char **, double ** ) const;
00162     OGRErr      exportToUSGS( long *, long *, double **, long * ) const;
00163     OGRErr      exportToXML( char **, const char * = NULL ) const;
00164     OGRErr      exportToPanorama( long *, long *, long *, long *,
00165                                   double * ) const;
00166     OGRErr      exportToERM( char *pszProj, char *pszDatum, char *pszUnits );
00167     OGRErr      exportToMICoordSys( char ** ) const;
00168     
00169     OGRErr      importFromWkt( char ** );
00170     OGRErr      importFromProj4( const char * );
00171     OGRErr      importFromEPSG( int );
00172     OGRErr      importFromEPSGA( int );
00173     OGRErr      importFromESRI( char ** );
00174     OGRErr      importFromPCI( const char *, const char * = NULL,
00175                                double * = NULL );
00176     OGRErr      importFromUSGS( long iProjSys, long iZone,
00177                                 double *padfPrjParams,
00178                                 long iDatum, int bAnglesInPackedDMSFormat = TRUE );
00179     OGRErr      importFromPanorama( long, long, long, double* );
00180     OGRErr      importFromWMSAUTO( const char *pszAutoDef );
00181     OGRErr      importFromXML( const char * );
00182     OGRErr      importFromDict( const char *pszDict, const char *pszCode );
00183     OGRErr      importFromURN( const char * );
00184     OGRErr      importFromERM( const char *pszProj, const char *pszDatum,
00185                                const char *pszUnits );
00186     OGRErr      importFromUrl( const char * );
00187     OGRErr      importFromMICoordSys( const char * );
00188     
00189     OGRErr      morphToESRI();
00190     OGRErr      morphFromESRI();
00191 
00192     OGRErr      Validate();
00193     OGRErr      StripCTParms( OGR_SRSNode * = NULL );
00194     OGRErr      FixupOrdering();
00195     OGRErr      Fixup();
00196 
00197     int         EPSGTreatsAsLatLong();
00198     const char *GetAxis( const char *pszTargetKey, int iAxis, 
00199                          OGRAxisOrientation *peOrientation );
00200     OGRErr      SetAxes( const char *pszTargetKey, 
00201                          const char *pszXAxisName, 
00202                          OGRAxisOrientation eXAxisOrientation,
00203                          const char *pszYAxisName, 
00204                          OGRAxisOrientation eYAxisOrientation );
00205 
00206     // Machinary for accessing parse nodes
00207     OGR_SRSNode *GetRoot() { return poRoot; }
00208     const OGR_SRSNode *GetRoot() const { return poRoot; }
00209     void        SetRoot( OGR_SRSNode * );
00210     
00211     OGR_SRSNode *GetAttrNode(const char *);
00212     const OGR_SRSNode *GetAttrNode(const char *) const;
00213     const char  *GetAttrValue(const char *, int = 0) const;
00214 
00215     OGRErr      SetNode( const char *, const char * );
00216     OGRErr      SetNode( const char *, double );
00217     
00218     OGRErr      SetLinearUnitsAndUpdateParameters( const char *pszName, 
00219                                                    double dfInMeters );
00220     OGRErr      SetLinearUnits( const char *pszName, double dfInMeters );
00221     double      GetLinearUnits( char ** = NULL ) const;
00222 
00223     OGRErr      SetAngularUnits( const char *pszName, double dfInRadians );
00224     double      GetAngularUnits( char ** = NULL ) const;
00225 
00226     double      GetPrimeMeridian( char ** = NULL ) const;
00227 
00228     int         IsGeographic() const;
00229     int         IsProjected() const;
00230     int         IsLocal() const;
00231     int         IsSameGeogCS( const OGRSpatialReference * ) const;
00232     int         IsSame( const OGRSpatialReference * ) const;
00233 
00234     void        Clear();
00235     OGRErr      SetLocalCS( const char * );
00236     OGRErr      SetProjCS( const char * );
00237     OGRErr      SetProjection( const char * );
00238     OGRErr      SetGeogCS( const char * pszGeogName,
00239                            const char * pszDatumName,
00240                            const char * pszEllipsoidName,
00241                            double dfSemiMajor, double dfInvFlattening,
00242                            const char * pszPMName = NULL,
00243                            double dfPMOffset = 0.0,
00244                            const char * pszUnits = NULL,
00245                            double dfConvertToRadians = 0.0 );
00246     OGRErr      SetWellKnownGeogCS( const char * );
00247     OGRErr      CopyGeogCSFrom( const OGRSpatialReference * poSrcSRS );
00248 
00249     OGRErr      SetFromUserInput( const char * );
00250 
00251     OGRErr      SetTOWGS84( double, double, double,
00252                             double = 0.0, double = 0.0, double = 0.0,
00253                             double = 0.0 );
00254     OGRErr      GetTOWGS84( double *padfCoef, int nCoeff = 7 ) const;
00255     
00256     double      GetSemiMajor( OGRErr * = NULL ) const;
00257     double      GetSemiMinor( OGRErr * = NULL ) const;
00258     double      GetInvFlattening( OGRErr * = NULL ) const;
00259 
00260     OGRErr      SetAuthority( const char * pszTargetKey, 
00261                               const char * pszAuthority, 
00262                               int nCode );
00263 
00264     OGRErr      AutoIdentifyEPSG();
00265     int         GetEPSGGeogCS();
00266 
00267     const char *GetAuthorityCode( const char * pszTargetKey ) const;
00268     const char *GetAuthorityName( const char * pszTargetKey ) const;
00269 
00270     const char *GetExtension( const char *pszTargetKey, 
00271                               const char *pszName,
00272                               const char *pszDefault = NULL ) const;
00273     OGRErr      SetExtension( const char *pszTargetKey, 
00274                               const char *pszName, 
00275                               const char *pszValue );
00276                            
00277     OGRErr      SetProjParm( const char *, double );
00278     double      GetProjParm( const char *, double =0.0, OGRErr* = NULL ) const;
00279 
00280     OGRErr      SetNormProjParm( const char *, double );
00281     double      GetNormProjParm( const char *, double=0.0, OGRErr* =NULL)const;
00282 
00283     static int  IsAngularParameter( const char * );
00284     static int  IsLongitudeParameter( const char * );
00285     static int  IsLinearParameter( const char * );
00286 
00288     OGRErr      SetACEA( double dfStdP1, double dfStdP2,
00289                          double dfCenterLat, double dfCenterLong,
00290                          double dfFalseEasting, double dfFalseNorthing );
00291     
00293     OGRErr      SetAE( double dfCenterLat, double dfCenterLong,
00294                        double dfFalseEasting, double dfFalseNorthing );
00295 
00297     OGRErr      SetBonne( double dfStdP1, double dfCentralMeridian,
00298                           double dfFalseEasting, double dfFalseNorthing );
00299     
00301     OGRErr      SetCEA( double dfStdP1, double dfCentralMeridian,
00302                         double dfFalseEasting, double dfFalseNorthing );
00303 
00305     OGRErr      SetCS( double dfCenterLat, double dfCenterLong,
00306                        double dfFalseEasting, double dfFalseNorthing );
00307 
00309     OGRErr      SetEC( double dfStdP1, double dfStdP2,
00310                        double dfCenterLat, double dfCenterLong,
00311                        double dfFalseEasting, double dfFalseNorthing );
00312 
00314     OGRErr      SetEckert( int nVariation, double dfCentralMeridian,
00315                            double dfFalseEasting, double dfFalseNorthing );
00316 
00317     OGRErr      SetEckertIV( double dfCentralMeridian,
00318                              double dfFalseEasting, double dfFalseNorthing );
00319 
00320     OGRErr      SetEckertVI( double dfCentralMeridian,
00321                              double dfFalseEasting, double dfFalseNorthing );
00322 
00324     OGRErr      SetEquirectangular(double dfCenterLat, double dfCenterLong,
00325                             double dfFalseEasting, double dfFalseNorthing );
00327     OGRErr      SetEquirectangular2( double dfCenterLat, double dfCenterLong,
00328                                      double dfPseudoStdParallel1,
00329                                      double dfFalseEasting, double dfFalseNorthing );
00330 
00332     OGRErr      SetGEOS( double dfCentralMeridian, double dfSatelliteHeight, 
00333                          double dfFalseEasting, double dfFalseNorthing );
00334 
00336     OGRErr      SetGH( double dfCentralMeridian, 
00337                        double dfFalseEasting, double dfFalseNorthing );
00338 
00340     OGRErr      SetGS( double dfCentralMeridian,
00341                        double dfFalseEasting, double dfFalseNorthing );
00342  
00344     OGRErr      SetGaussLabordeReunion(double dfCenterLat, double dfCenterLong,
00345                                        double dfScale,
00346                                        double dfFalseEasting, double dfFalseNorthing );
00347 
00349     OGRErr      SetGnomonic(double dfCenterLat, double dfCenterLong,
00350                             double dfFalseEasting, double dfFalseNorthing );
00351 
00352     OGRErr      SetHOM( double dfCenterLat, double dfCenterLong,
00353                         double dfAzimuth, double dfRectToSkew,
00354                         double dfScale,
00355                         double dfFalseEasting, double dfFalseNorthing );
00356 
00357     OGRErr      SetHOM2PNO( double dfCenterLat,
00358                             double dfLat1, double dfLong1,
00359                             double dfLat2, double dfLong2,
00360                             double dfScale,
00361                             double dfFalseEasting, double dfFalseNorthing );
00362 
00364     OGRErr      SetIWMPolyconic( double dfLat1, double dfLat2,
00365                                  double dfCenterLong,
00366                                  double dfFalseEasting,
00367                                  double dfFalseNorthing );
00368 
00370     OGRErr      SetKrovak( double dfCenterLat, double dfCenterLong,
00371                            double dfAzimuth, double dfPseudoStdParallelLat,
00372                            double dfScale, 
00373                            double dfFalseEasting, double dfFalseNorthing );
00374 
00376     OGRErr      SetLAEA( double dfCenterLat, double dfCenterLong,
00377                          double dfFalseEasting, double dfFalseNorthing );
00378 
00380     OGRErr      SetLCC( double dfStdP1, double dfStdP2,
00381                         double dfCenterLat, double dfCenterLong,
00382                         double dfFalseEasting, double dfFalseNorthing );
00383 
00385     OGRErr      SetLCC1SP( double dfCenterLat, double dfCenterLong,
00386                            double dfScale,
00387                            double dfFalseEasting, double dfFalseNorthing );
00388 
00390     OGRErr      SetLCCB( double dfStdP1, double dfStdP2,
00391                          double dfCenterLat, double dfCenterLong,
00392                          double dfFalseEasting, double dfFalseNorthing );
00393     
00395     OGRErr      SetMC( double dfCenterLat, double dfCenterLong,
00396                        double dfFalseEasting, double dfFalseNorthing );
00397 
00399     OGRErr      SetMercator( double dfCenterLat, double dfCenterLong,
00400                              double dfScale, 
00401                              double dfFalseEasting, double dfFalseNorthing );
00402 
00403     OGRErr      SetMercator2SP( double dfStdP1,
00404                                 double dfCenterLat, double dfCenterLong,
00405                                 double dfFalseEasting, double dfFalseNorthing );
00406 
00408     OGRErr      SetMollweide( double dfCentralMeridian,
00409                               double dfFalseEasting, double dfFalseNorthing );
00410 
00412     OGRErr      SetNZMG( double dfCenterLat, double dfCenterLong,
00413                          double dfFalseEasting, double dfFalseNorthing );
00414 
00416     OGRErr      SetOS( double dfOriginLat, double dfCMeridian,
00417                        double dfScale,
00418                        double dfFalseEasting,double dfFalseNorthing);
00419     
00421     OGRErr      SetOrthographic( double dfCenterLat, double dfCenterLong,
00422                                  double dfFalseEasting,double dfFalseNorthing);
00423 
00425     OGRErr      SetPolyconic( double dfCenterLat, double dfCenterLong,
00426                               double dfFalseEasting, double dfFalseNorthing );
00427 
00429     OGRErr      SetPS( double dfCenterLat, double dfCenterLong,
00430                        double dfScale,
00431                        double dfFalseEasting, double dfFalseNorthing);
00432     
00434     OGRErr      SetRobinson( double dfCenterLong, 
00435                              double dfFalseEasting, double dfFalseNorthing );
00436     
00438     OGRErr      SetSinusoidal( double dfCenterLong, 
00439                                double dfFalseEasting, double dfFalseNorthing );
00440     
00442     OGRErr      SetStereographic( double dfCenterLat, double dfCenterLong,
00443                                   double dfScale,
00444                                  double dfFalseEasting,double dfFalseNorthing);
00445 
00447     OGRErr      SetSOC( double dfLatitudeOfOrigin, double dfCentralMeridian,
00448                         double dfFalseEasting, double dfFalseNorthing );
00449     
00451     OGRErr      SetTM( double dfCenterLat, double dfCenterLong,
00452                        double dfScale,
00453                        double dfFalseEasting, double dfFalseNorthing );
00454 
00456     OGRErr      SetTMVariant( const char *pszVariantName, 
00457                               double dfCenterLat, double dfCenterLong,
00458                               double dfScale,
00459                               double dfFalseEasting, double dfFalseNorthing );
00460 
00462     OGRErr      SetTMG( double dfCenterLat, double dfCenterLong, 
00463                         double dfFalseEasting, double dfFalseNorthing );
00464 
00466     OGRErr      SetTMSO( double dfCenterLat, double dfCenterLong,
00467                          double dfScale,
00468                          double dfFalseEasting, double dfFalseNorthing );
00469 
00471     OGRErr      SetTPED( double dfLat1, double dfLong1, 
00472                          double dfLat2, double dfLong2, 
00473                          double dfFalseEasting, double dfFalseNorthing );
00474     
00476     OGRErr      SetVDG( double dfCenterLong,
00477                         double dfFalseEasting, double dfFalseNorthing );
00478 
00480     OGRErr      SetUTM( int nZone, int bNorth = TRUE );
00481     int         GetUTMZone( int *pbNorth = NULL ) const;
00482 
00484     OGRErr      SetWagner( int nVariation, double dfCenterLat,
00485                            double dfFalseEasting, double dfFalseNorthing );
00486 
00488     OGRErr      SetStatePlane( int nZone, int bNAD83 = TRUE,
00489                                const char *pszOverrideUnitName = NULL,
00490                                double dfOverrideUnit = 0.0 );
00491 };
00492 
00493 /************************************************************************/
00494 /*                     OGRCoordinateTransformation                      */
00495 /*                                                                      */
00496 /*      This is really just used as a base class for a private          */
00497 /*      implementation.                                                 */
00498 /************************************************************************/
00499 
00506 class CPL_DLL OGRCoordinateTransformation
00507 {
00508 public:
00509     virtual ~OGRCoordinateTransformation() {}
00510 
00511     // From CT_CoordinateTransformation
00512 
00514     virtual OGRSpatialReference *GetSourceCS() = 0;
00515 
00517     virtual OGRSpatialReference *GetTargetCS() = 0;
00518 
00519     // From CT_MathTransform
00520 
00536     virtual int Transform( int nCount, 
00537                            double *x, double *y, double *z = NULL ) = 0;
00538 
00554     virtual int TransformEx( int nCount, 
00555                              double *x, double *y, double *z = NULL,
00556                              int *pabSuccess = NULL ) = 0;
00557 
00558 };
00559 
00560 OGRCoordinateTransformation CPL_DLL *
00561 OGRCreateCoordinateTransformation( OGRSpatialReference *poSource, 
00562                                    OGRSpatialReference *poTarget );
00563 
00564 #endif /* ndef _OGR_SPATIALREF_H_INCLUDED */

Generated for GDAL by doxygen 1.5.1.