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

Generated on Thu Jul 29 19:47:50 2004 for OGR by doxygen 1.3.7