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

Generated on Mon Aug 9 12:08:49 2004 for OGR by doxygen 1.3.8