00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifndef _OGR_SPATIALREF_H_INCLUDED
00032 #define _OGR_SPATIALREF_H_INCLUDED
00033
00034 #include "ogr_srs_api.h"
00035
00042
00043
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 int NeedsQuoting() const;
00069
00070 public:
00071 OGR_SRSNode(const char * = NULL);
00072 ~OGR_SRSNode();
00073
00074 int IsLeafNode() const { return nChildren == 0; }
00075
00076 int GetChildCount() const { return nChildren; }
00077 OGR_SRSNode *GetChild( int );
00078 const OGR_SRSNode *GetChild( int ) const;
00079
00080 OGR_SRSNode *GetNode( const char * );
00081 const OGR_SRSNode *GetNode( const char * ) const;
00082
00083 void InsertChild( OGR_SRSNode *, int );
00084 void AddChild( OGR_SRSNode * );
00085 int FindChild( const char * ) const;
00086 void DestroyChild( int );
00087 void ClearChildren();
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
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 static OGRErr Validate(OGR_SRSNode *poRoot);
00139 static OGRErr ValidateAuthority(OGR_SRSNode *poRoot);
00140 static OGRErr ValidateAxis(OGR_SRSNode *poRoot);
00141 static OGRErr ValidateUnit(OGR_SRSNode *poRoot);
00142 static OGRErr ValidateVertDatum(OGR_SRSNode *poRoot);
00143 static OGRErr ValidateProjection( OGR_SRSNode* poRoot );
00144 static int IsAliasFor( const char *, const char * );
00145 void GetNormInfo() const;
00146
00147 OGRErr importFromURNPart(const char* pszAuthority,
00148 const char* pszCode,
00149 const char* pszURN);
00150 public:
00151 OGRSpatialReference(const OGRSpatialReference&);
00152 OGRSpatialReference(const char * = NULL);
00153
00154 virtual ~OGRSpatialReference();
00155
00156 static void DestroySpatialReference(OGRSpatialReference* poSRS);
00157
00158 OGRSpatialReference &operator=(const OGRSpatialReference&);
00159
00160 int Reference();
00161 int Dereference();
00162 int GetReferenceCount() const { return nRefCount; }
00163 void Release();
00164
00165 OGRSpatialReference *Clone() const;
00166 OGRSpatialReference *CloneGeogCS() const;
00167
00168 OGRErr exportToWkt( char ** ) const;
00169 OGRErr exportToPrettyWkt( char **, int = FALSE) const;
00170 OGRErr exportToProj4( char ** ) const;
00171 OGRErr exportToPCI( char **, char **, double ** ) const;
00172 OGRErr exportToUSGS( long *, long *, double **, long * ) const;
00173 OGRErr exportToXML( char **, const char * = NULL ) const;
00174 OGRErr exportToPanorama( long *, long *, long *, long *,
00175 double * ) const;
00176 OGRErr exportToERM( char *pszProj, char *pszDatum, char *pszUnits );
00177 OGRErr exportToMICoordSys( char ** ) const;
00178
00179 OGRErr importFromWkt( char ** );
00180 OGRErr importFromProj4( const char * );
00181 OGRErr importFromEPSG( int );
00182 OGRErr importFromEPSGA( int );
00183 OGRErr importFromESRI( char ** );
00184 OGRErr importFromPCI( const char *, const char * = NULL,
00185 double * = NULL );
00186 OGRErr importFromUSGS( long iProjSys, long iZone,
00187 double *padfPrjParams,
00188 long iDatum, int bAnglesInPackedDMSFormat = TRUE );
00189 OGRErr importFromPanorama( long, long, long, double* );
00190 OGRErr importFromOzi( const char *, const char *, const char * );
00191 OGRErr importFromWMSAUTO( const char *pszAutoDef );
00192 OGRErr importFromXML( const char * );
00193 OGRErr importFromDict( const char *pszDict, const char *pszCode );
00194 OGRErr importFromURN( const char * );
00195 OGRErr importFromERM( const char *pszProj, const char *pszDatum,
00196 const char *pszUnits );
00197 OGRErr importFromUrl( const char * );
00198 OGRErr importFromMICoordSys( const char * );
00199
00200 OGRErr morphToESRI();
00201 OGRErr morphFromESRI();
00202
00203 OGRErr Validate();
00204 OGRErr StripCTParms( OGR_SRSNode * = NULL );
00205 OGRErr StripVertical();
00206 OGRErr FixupOrdering();
00207 OGRErr Fixup();
00208
00209 int EPSGTreatsAsLatLong();
00210 const char *GetAxis( const char *pszTargetKey, int iAxis,
00211 OGRAxisOrientation *peOrientation ) const;
00212 OGRErr SetAxes( const char *pszTargetKey,
00213 const char *pszXAxisName,
00214 OGRAxisOrientation eXAxisOrientation,
00215 const char *pszYAxisName,
00216 OGRAxisOrientation eYAxisOrientation );
00217
00218
00219 OGR_SRSNode *GetRoot() { return poRoot; }
00220 const OGR_SRSNode *GetRoot() const { return poRoot; }
00221 void SetRoot( OGR_SRSNode * );
00222
00223 OGR_SRSNode *GetAttrNode(const char *);
00224 const OGR_SRSNode *GetAttrNode(const char *) const;
00225 const char *GetAttrValue(const char *, int = 0) const;
00226
00227 OGRErr SetNode( const char *, const char * );
00228 OGRErr SetNode( const char *, double );
00229
00230 OGRErr SetLinearUnitsAndUpdateParameters( const char *pszName,
00231 double dfInMeters );
00232 OGRErr SetLinearUnits( const char *pszName, double dfInMeters );
00233 OGRErr SetTargetLinearUnits( const char *pszTargetKey,
00234 const char *pszName, double dfInMeters );
00235 double GetLinearUnits( char ** = NULL ) const;
00236 double GetTargetLinearUnits( const char *pszTargetKey,
00237 char ** ppszRetName = NULL ) const;
00238
00239 OGRErr SetAngularUnits( const char *pszName, double dfInRadians );
00240 double GetAngularUnits( char ** = NULL ) const;
00241
00242 double GetPrimeMeridian( char ** = NULL ) const;
00243
00244 int IsGeographic() const;
00245 int IsProjected() const;
00246 int IsGeocentric() const;
00247 int IsLocal() const;
00248 int IsVertical() const;
00249 int IsCompound() const;
00250 int IsSameGeogCS( const OGRSpatialReference * ) const;
00251 int IsSameVertCS( const OGRSpatialReference * ) const;
00252 int IsSame( const OGRSpatialReference * ) const;
00253
00254 void Clear();
00255 OGRErr SetLocalCS( const char * );
00256 OGRErr SetProjCS( const char * );
00257 OGRErr SetProjection( const char * );
00258 OGRErr SetGeocCS( const char * pszGeocName );
00259 OGRErr SetGeogCS( const char * pszGeogName,
00260 const char * pszDatumName,
00261 const char * pszEllipsoidName,
00262 double dfSemiMajor, double dfInvFlattening,
00263 const char * pszPMName = NULL,
00264 double dfPMOffset = 0.0,
00265 const char * pszUnits = NULL,
00266 double dfConvertToRadians = 0.0 );
00267 OGRErr SetWellKnownGeogCS( const char * );
00268 OGRErr CopyGeogCSFrom( const OGRSpatialReference * poSrcSRS );
00269 OGRErr SetVertCS( const char *pszVertCSName,
00270 const char *pszVertDatumName,
00271 int nVertDatumClass = 2005 );
00272 OGRErr SetCompoundCS( const char *pszName,
00273 const OGRSpatialReference *poHorizSRS,
00274 const OGRSpatialReference *poVertSRS );
00275
00276 OGRErr SetFromUserInput( const char * );
00277
00278 OGRErr SetTOWGS84( double, double, double,
00279 double = 0.0, double = 0.0, double = 0.0,
00280 double = 0.0 );
00281 OGRErr GetTOWGS84( double *padfCoef, int nCoeff = 7 ) const;
00282
00283 double GetSemiMajor( OGRErr * = NULL ) const;
00284 double GetSemiMinor( OGRErr * = NULL ) const;
00285 double GetInvFlattening( OGRErr * = NULL ) const;
00286
00287 OGRErr SetAuthority( const char * pszTargetKey,
00288 const char * pszAuthority,
00289 int nCode );
00290
00291 OGRErr AutoIdentifyEPSG();
00292 int GetEPSGGeogCS();
00293
00294 const char *GetAuthorityCode( const char * pszTargetKey ) const;
00295 const char *GetAuthorityName( const char * pszTargetKey ) const;
00296
00297 const char *GetExtension( const char *pszTargetKey,
00298 const char *pszName,
00299 const char *pszDefault = NULL ) const;
00300 OGRErr SetExtension( const char *pszTargetKey,
00301 const char *pszName,
00302 const char *pszValue );
00303
00304 int FindProjParm( const char *pszParameter,
00305 const OGR_SRSNode *poPROJCS=NULL ) const;
00306 OGRErr SetProjParm( const char *, double );
00307 double GetProjParm( const char *, double =0.0, OGRErr* = NULL ) const;
00308
00309 OGRErr SetNormProjParm( const char *, double );
00310 double GetNormProjParm( const char *, double=0.0, OGRErr* =NULL)const;
00311
00312 static int IsAngularParameter( const char * );
00313 static int IsLongitudeParameter( const char * );
00314 static int IsLinearParameter( const char * );
00315
00317 OGRErr SetACEA( double dfStdP1, double dfStdP2,
00318 double dfCenterLat, double dfCenterLong,
00319 double dfFalseEasting, double dfFalseNorthing );
00320
00322 OGRErr SetAE( double dfCenterLat, double dfCenterLong,
00323 double dfFalseEasting, double dfFalseNorthing );
00324
00326 OGRErr SetBonne( double dfStdP1, double dfCentralMeridian,
00327 double dfFalseEasting, double dfFalseNorthing );
00328
00330 OGRErr SetCEA( double dfStdP1, double dfCentralMeridian,
00331 double dfFalseEasting, double dfFalseNorthing );
00332
00334 OGRErr SetCS( double dfCenterLat, double dfCenterLong,
00335 double dfFalseEasting, double dfFalseNorthing );
00336
00338 OGRErr SetEC( double dfStdP1, double dfStdP2,
00339 double dfCenterLat, double dfCenterLong,
00340 double dfFalseEasting, double dfFalseNorthing );
00341
00343 OGRErr SetEckert( int nVariation, double dfCentralMeridian,
00344 double dfFalseEasting, double dfFalseNorthing );
00345
00346 OGRErr SetEckertIV( double dfCentralMeridian,
00347 double dfFalseEasting, double dfFalseNorthing );
00348
00349 OGRErr SetEckertVI( double dfCentralMeridian,
00350 double dfFalseEasting, double dfFalseNorthing );
00351
00353 OGRErr SetEquirectangular(double dfCenterLat, double dfCenterLong,
00354 double dfFalseEasting, double dfFalseNorthing );
00356 OGRErr SetEquirectangular2( double dfCenterLat, double dfCenterLong,
00357 double dfPseudoStdParallel1,
00358 double dfFalseEasting, double dfFalseNorthing );
00359
00361 OGRErr SetGEOS( double dfCentralMeridian, double dfSatelliteHeight,
00362 double dfFalseEasting, double dfFalseNorthing );
00363
00365 OGRErr SetGH( double dfCentralMeridian,
00366 double dfFalseEasting, double dfFalseNorthing );
00367
00369 OGRErr SetIGH();
00370
00372 OGRErr SetGS( double dfCentralMeridian,
00373 double dfFalseEasting, double dfFalseNorthing );
00374
00376 OGRErr SetGaussSchreiberTMercator(double dfCenterLat, double dfCenterLong,
00377 double dfScale,
00378 double dfFalseEasting, double dfFalseNorthing );
00379
00381 OGRErr SetGnomonic(double dfCenterLat, double dfCenterLong,
00382 double dfFalseEasting, double dfFalseNorthing );
00383
00385 OGRErr SetHOM( double dfCenterLat, double dfCenterLong,
00386 double dfAzimuth, double dfRectToSkew,
00387 double dfScale,
00388 double dfFalseEasting, double dfFalseNorthing );
00389
00390 OGRErr SetHOM2PNO( double dfCenterLat,
00391 double dfLat1, double dfLong1,
00392 double dfLat2, double dfLong2,
00393 double dfScale,
00394 double dfFalseEasting, double dfFalseNorthing );
00395
00397 OGRErr SetIWMPolyconic( double dfLat1, double dfLat2,
00398 double dfCenterLong,
00399 double dfFalseEasting,
00400 double dfFalseNorthing );
00401
00403 OGRErr SetKrovak( double dfCenterLat, double dfCenterLong,
00404 double dfAzimuth, double dfPseudoStdParallelLat,
00405 double dfScale,
00406 double dfFalseEasting, double dfFalseNorthing );
00407
00409 OGRErr SetLAEA( double dfCenterLat, double dfCenterLong,
00410 double dfFalseEasting, double dfFalseNorthing );
00411
00413 OGRErr SetLCC( double dfStdP1, double dfStdP2,
00414 double dfCenterLat, double dfCenterLong,
00415 double dfFalseEasting, double dfFalseNorthing );
00416
00418 OGRErr SetLCC1SP( double dfCenterLat, double dfCenterLong,
00419 double dfScale,
00420 double dfFalseEasting, double dfFalseNorthing );
00421
00423 OGRErr SetLCCB( double dfStdP1, double dfStdP2,
00424 double dfCenterLat, double dfCenterLong,
00425 double dfFalseEasting, double dfFalseNorthing );
00426
00428 OGRErr SetMC( double dfCenterLat, double dfCenterLong,
00429 double dfFalseEasting, double dfFalseNorthing );
00430
00432 OGRErr SetMercator( double dfCenterLat, double dfCenterLong,
00433 double dfScale,
00434 double dfFalseEasting, double dfFalseNorthing );
00435
00436 OGRErr SetMercator2SP( double dfStdP1,
00437 double dfCenterLat, double dfCenterLong,
00438 double dfFalseEasting, double dfFalseNorthing );
00439
00441 OGRErr SetMollweide( double dfCentralMeridian,
00442 double dfFalseEasting, double dfFalseNorthing );
00443
00445 OGRErr SetNZMG( double dfCenterLat, double dfCenterLong,
00446 double dfFalseEasting, double dfFalseNorthing );
00447
00449 OGRErr SetOS( double dfOriginLat, double dfCMeridian,
00450 double dfScale,
00451 double dfFalseEasting,double dfFalseNorthing);
00452
00454 OGRErr SetOrthographic( double dfCenterLat, double dfCenterLong,
00455 double dfFalseEasting,double dfFalseNorthing);
00456
00458 OGRErr SetPolyconic( double dfCenterLat, double dfCenterLong,
00459 double dfFalseEasting, double dfFalseNorthing );
00460
00462 OGRErr SetPS( double dfCenterLat, double dfCenterLong,
00463 double dfScale,
00464 double dfFalseEasting, double dfFalseNorthing);
00465
00467 OGRErr SetRobinson( double dfCenterLong,
00468 double dfFalseEasting, double dfFalseNorthing );
00469
00471 OGRErr SetSinusoidal( double dfCenterLong,
00472 double dfFalseEasting, double dfFalseNorthing );
00473
00475 OGRErr SetStereographic( double dfCenterLat, double dfCenterLong,
00476 double dfScale,
00477 double dfFalseEasting,double dfFalseNorthing);
00478
00480 OGRErr SetSOC( double dfLatitudeOfOrigin, double dfCentralMeridian,
00481 double dfFalseEasting, double dfFalseNorthing );
00482
00484 OGRErr SetTM( double dfCenterLat, double dfCenterLong,
00485 double dfScale,
00486 double dfFalseEasting, double dfFalseNorthing );
00487
00489 OGRErr SetTMVariant( const char *pszVariantName,
00490 double dfCenterLat, double dfCenterLong,
00491 double dfScale,
00492 double dfFalseEasting, double dfFalseNorthing );
00493
00495 OGRErr SetTMG( double dfCenterLat, double dfCenterLong,
00496 double dfFalseEasting, double dfFalseNorthing );
00497
00499 OGRErr SetTMSO( double dfCenterLat, double dfCenterLong,
00500 double dfScale,
00501 double dfFalseEasting, double dfFalseNorthing );
00502
00504 OGRErr SetTPED( double dfLat1, double dfLong1,
00505 double dfLat2, double dfLong2,
00506 double dfFalseEasting, double dfFalseNorthing );
00507
00509 OGRErr SetVDG( double dfCenterLong,
00510 double dfFalseEasting, double dfFalseNorthing );
00511
00513 OGRErr SetUTM( int nZone, int bNorth = TRUE );
00514 int GetUTMZone( int *pbNorth = NULL ) const;
00515
00517 OGRErr SetWagner( int nVariation, double dfCenterLat,
00518 double dfFalseEasting, double dfFalseNorthing );
00519
00521 OGRErr SetStatePlane( int nZone, int bNAD83 = TRUE,
00522 const char *pszOverrideUnitName = NULL,
00523 double dfOverrideUnit = 0.0 );
00524
00525 OGRErr ImportFromESRIStatePlaneWKT(
00526 int nCode, const char* pszDatumName, const char* pszUnitsName,
00527 int nPCSCode, const char* pszCSName = 0 );
00528 OGRErr ImportFromESRIWisconsinWKT(
00529 const char* pszPrjName, double dfCentralMeridian, double dfLatOfOrigin,
00530 const char* pszUnitsName, const char* pszCSName = 0 );
00531 };
00532
00533
00534
00535
00536
00537
00538
00539
00549 class CPL_DLL OGRCoordinateTransformation
00550 {
00551 public:
00552 virtual ~OGRCoordinateTransformation() {}
00553
00554 static void DestroyCT(OGRCoordinateTransformation* poCT);
00555
00556
00557
00559 virtual OGRSpatialReference *GetSourceCS() = 0;
00560
00562 virtual OGRSpatialReference *GetTargetCS() = 0;
00563
00564
00565
00581 virtual int Transform( int nCount,
00582 double *x, double *y, double *z = NULL ) = 0;
00583
00599 virtual int TransformEx( int nCount,
00600 double *x, double *y, double *z = NULL,
00601 int *pabSuccess = NULL ) = 0;
00602
00603 };
00604
00605 OGRCoordinateTransformation CPL_DLL *
00606 OGRCreateCoordinateTransformation( OGRSpatialReference *poSource,
00607 OGRSpatialReference *poTarget );
00608
00609 #endif