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
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109 #ifndef _OGR_SPATIALREF_H_INCLUDED
00110 #define _OGR_SPATIALREF_H_INCLUDED
00111
00112 #include "ogr_srs_api.h"
00113
00120
00121
00122
00123
00137 class CPL_DLL OGR_SRSNode
00138 {
00139 char *pszValue;
00140
00141 OGR_SRSNode **papoChildNodes;
00142 OGR_SRSNode *poParent;
00143
00144 int nChildren;
00145
00146 void ClearChildren();
00147 int NeedsQuoting() const;
00148
00149 public:
00150 OGR_SRSNode(const char * = NULL);
00151 ~OGR_SRSNode();
00152
00153 int IsLeafNode() const { return nChildren == 0; }
00154
00155 int GetChildCount() const { return nChildren; }
00156 OGR_SRSNode *GetChild( int );
00157 const OGR_SRSNode *GetChild( int ) const;
00158
00159 OGR_SRSNode *GetNode( const char * );
00160 const OGR_SRSNode *GetNode( const char * ) const;
00161
00162 void InsertChild( OGR_SRSNode *, int );
00163 void AddChild( OGR_SRSNode * );
00164 int FindChild( const char * ) const;
00165 void DestroyChild( int );
00166 void StripNodes( const char * );
00167
00168 const char *GetValue() const { return pszValue; }
00169 void SetValue( const char * );
00170
00171 void MakeValueSafe();
00172 OGRErr FixupOrdering();
00173
00174 OGR_SRSNode *Clone() const;
00175
00176 OGRErr importFromWkt( char ** );
00177 OGRErr exportToWkt( char ** ) const;
00178 OGRErr exportToPrettyWkt( char **, int = 1) const;
00179
00180 OGRErr applyRemapper( const char *pszNode,
00181 char **papszSrcValues,
00182 char **papszDstValues,
00183 int nStepSize = 1,
00184 int bChildOfHit = FALSE );
00185 };
00186
00187
00188
00189
00190
00205 class CPL_DLL OGRSpatialReference
00206 {
00207 double dfFromGreenwich;
00208 double dfToMeter;
00209 double dfToDegrees;
00210
00211 OGR_SRSNode *poRoot;
00212
00213 int nRefCount;
00214 int bNormInfoSet;
00215
00216 OGRErr ValidateProjection();
00217 int IsAliasFor( const char *, const char * );
00218 void GetNormInfo() const;
00219
00220 public:
00221 OGRSpatialReference(const OGRSpatialReference&);
00222 OGRSpatialReference(const char * = NULL);
00223
00224 virtual ~OGRSpatialReference();
00225
00226 OGRSpatialReference &operator=(const OGRSpatialReference&);
00227
00228 int Reference();
00229 int Dereference();
00230 int GetReferenceCount() const { return nRefCount; }
00231 void Release();
00232
00233 OGRSpatialReference *Clone() const;
00234 OGRSpatialReference *CloneGeogCS() const;
00235
00236 OGRErr exportToWkt( char ** ) const;
00237 OGRErr exportToPrettyWkt( char **, int = FALSE) const;
00238 OGRErr exportToProj4( char ** ) const;
00239 OGRErr exportToPCI( char **, char **, double ** ) const;
00240 OGRErr exportToUSGS( long *, long *, double **, long * ) const;
00241 OGRErr exportToPanorama( long *, long *, double **, long * ) const;
00242 OGRErr exportToXML( char **, const char * = NULL ) const;
00243 OGRErr exportToPanorama( long *, long *, long *, long *, double *,
00244 double *, double *, double * ) const;
00245 OGRErr importFromWkt( char ** );
00246 OGRErr importFromProj4( const char * );
00247 OGRErr importFromEPSG( int );
00248 OGRErr importFromESRI( char ** );
00249 OGRErr importFromPCI( const char *, const char * = NULL,
00250 double * = NULL );
00251 OGRErr importFromUSGS( long, long, double *, long );
00252 OGRErr importFromPanorama( long, long, long, long,
00253 double, double, double, double );
00254 OGRErr importFromWMSAUTO( const char *pszAutoDef );
00255 OGRErr importFromXML( const char * );
00256 OGRErr importFromDict( const char *pszDict, const char *pszCode );
00257
00258 OGRErr morphToESRI();
00259 OGRErr morphFromESRI();
00260
00261 OGRErr Validate();
00262 OGRErr StripCTParms( OGR_SRSNode * = NULL );
00263 OGRErr FixupOrdering();
00264 OGRErr Fixup();
00265
00266
00267 OGR_SRSNode *GetRoot() { return poRoot; }
00268 const OGR_SRSNode *GetRoot() const { return poRoot; }
00269 void SetRoot( OGR_SRSNode * );
00270
00271 OGR_SRSNode *GetAttrNode(const char *);
00272 const OGR_SRSNode *GetAttrNode(const char *) const;
00273 const char *GetAttrValue(const char *, int = 0) const;
00274
00275 OGRErr SetNode( const char *, const char * );
00276 OGRErr SetNode( const char *, double );
00277
00278 OGRErr SetLinearUnitsAndUpdateParameters( const char *pszName,
00279 double dfInMeters );
00280 OGRErr SetLinearUnits( const char *pszName, double dfInMeters );
00281 double GetLinearUnits( char ** = NULL ) const;
00282
00283 OGRErr SetAngularUnits( const char *pszName, double dfInRadians );
00284 double GetAngularUnits( char ** = NULL ) const;
00285
00286 double GetPrimeMeridian( char ** = NULL ) const;
00287
00288 int IsGeographic() const;
00289 int IsProjected() const;
00290 int IsLocal() const;
00291 int IsSameGeogCS( const OGRSpatialReference * ) const;
00292 int IsSame( const OGRSpatialReference * ) const;
00293
00294 void Clear();
00295 OGRErr SetLocalCS( const char * );
00296 OGRErr SetProjCS( const char * );
00297 OGRErr SetProjection( const char * );
00298 OGRErr SetGeogCS( const char * pszGeogName,
00299 const char * pszDatumName,
00300 const char * pszEllipsoidName,
00301 double dfSemiMajor, double dfInvFlattening,
00302 const char * pszPMName = NULL,
00303 double dfPMOffset = 0.0,
00304 const char * pszUnits = NULL,
00305 double dfConvertToRadians = 0.0 );
00306 OGRErr SetWellKnownGeogCS( const char * );
00307 OGRErr CopyGeogCSFrom( const OGRSpatialReference * poSrcSRS );
00308
00309 OGRErr SetFromUserInput( const char * );
00310
00311 OGRErr SetTOWGS84( double, double, double,
00312 double = 0.0, double = 0.0, double = 0.0,
00313 double = 0.0 );
00314 OGRErr GetTOWGS84( double *padfCoef, int nCoeff = 7 ) const;
00315
00316 double GetSemiMajor( OGRErr * = NULL ) const;
00317 double GetSemiMinor( OGRErr * = NULL ) const;
00318 double GetInvFlattening( OGRErr * = NULL ) const;
00319
00320 OGRErr SetAuthority( const char * pszTargetKey,
00321 const char * pszAuthority,
00322 int nCode );
00323
00324 OGRErr AutoIdentifyEPSG();
00325
00326 const char *GetAuthorityCode( const char * pszTargetKey ) const;
00327 const char *GetAuthorityName( const char * pszTargetKey ) const;
00328
00329 OGRErr SetProjParm( const char *, double );
00330 double GetProjParm( const char *, double =0.0, OGRErr* = NULL ) const;
00331
00332 OGRErr SetNormProjParm( const char *, double );
00333 double GetNormProjParm( const char *, double=0.0, OGRErr* =NULL)const;
00334
00335 static int IsAngularParameter( const char * );
00336 static int IsLongitudeParameter( const char * );
00337 static int IsLinearParameter( const char * );
00338
00340 OGRErr SetACEA( double dfStdP1, double dfStdP2,
00341 double dfCenterLat, double dfCenterLong,
00342 double dfFalseEasting, double dfFalseNorthing );
00343
00345 OGRErr SetAE( double dfCenterLat, double dfCenterLong,
00346 double dfFalseEasting, double dfFalseNorthing );
00347
00349 OGRErr SetBonne( double dfStdP1, double dfCentralMeridian,
00350 double dfFalseEasting, double dfFalseNorthing );
00351
00353 OGRErr SetCEA( double dfStdP1, double dfCentralMeridian,
00354 double dfFalseEasting, double dfFalseNorthing );
00355
00357 OGRErr SetCS( double dfCenterLat, double dfCenterLong,
00358 double dfFalseEasting, double dfFalseNorthing );
00359
00361 OGRErr SetEC( double dfStdP1, double dfStdP2,
00362 double dfCenterLat, double dfCenterLong,
00363 double dfFalseEasting, double dfFalseNorthing );
00364
00366 OGRErr SetEckertIV( double dfCentralMeridian,
00367 double dfFalseEasting, double dfFalseNorthing );
00368
00370 OGRErr SetEckertVI( double dfCentralMeridian,
00371 double dfFalseEasting, double dfFalseNorthing );
00372
00374 OGRErr SetEquirectangular(double dfCenterLat, double dfCenterLong,
00375 double dfFalseEasting, double dfFalseNorthing );
00376
00378 OGRErr SetGEOS( double dfCentralMeridian, double dfSatelliteHeight,
00379 double dfFalseEasting, double dfFalseNorthing );
00380
00382 OGRErr SetGH( double dfCentralMeridian,
00383 double dfFalseEasting, double dfFalseNorthing );
00384
00386 OGRErr SetGS( double dfCentralMeridian,
00387 double dfFalseEasting, double dfFalseNorthing );
00388
00390 OGRErr SetGnomonic(double dfCenterLat, double dfCenterLong,
00391 double dfFalseEasting, double dfFalseNorthing );
00392
00393 OGRErr SetHOM( double dfCenterLat, double dfCenterLong,
00394 double dfAzimuth, double dfRectToSkew,
00395 double dfScale,
00396 double dfFalseEasting, double dfFalseNorthing );
00397
00398 OGRErr SetHOM2PNO( double dfCenterLat,
00399 double dfLat1, double dfLong1,
00400 double dfLat2, double dfLong2,
00401 double dfScale,
00402 double dfFalseEasting, double dfFalseNorthing );
00403
00405 OGRErr SetKrovak( double dfCenterLat, double dfCenterLong,
00406 double dfAzimuth, double dfPseudoStdParallelLat,
00407 double dfScale,
00408 double dfFalseEasting, double dfFalseNorthing );
00409
00411 OGRErr SetLAEA( double dfCenterLat, double dfCenterLong,
00412 double dfFalseEasting, double dfFalseNorthing );
00413
00415 OGRErr SetLCC( double dfStdP1, double dfStdP2,
00416 double dfCenterLat, double dfCenterLong,
00417 double dfFalseEasting, double dfFalseNorthing );
00418
00420 OGRErr SetLCC1SP( double dfCenterLat, double dfCenterLong,
00421 double dfScale,
00422 double dfFalseEasting, double dfFalseNorthing );
00423
00425 OGRErr SetLCCB( double dfStdP1, double dfStdP2,
00426 double dfCenterLat, double dfCenterLong,
00427 double dfFalseEasting, double dfFalseNorthing );
00428
00430 OGRErr SetMC( double dfCenterLat, double dfCenterLong,
00431 double dfFalseEasting, double dfFalseNorthing );
00432
00434 OGRErr SetMercator( double dfCenterLat, double dfCenterLong,
00435 double dfScale,
00436 double dfFalseEasting, double dfFalseNorthing );
00437
00439 OGRErr SetMollweide( double dfCentralMeridian,
00440 double dfFalseEasting, double dfFalseNorthing );
00441
00443 OGRErr SetNZMG( double dfCenterLat, double dfCenterLong,
00444 double dfFalseEasting, double dfFalseNorthing );
00445
00447 OGRErr SetOS( double dfOriginLat, double dfCMeridian,
00448 double dfScale,
00449 double dfFalseEasting,double dfFalseNorthing);
00450
00452 OGRErr SetOrthographic( double dfCenterLat, double dfCenterLong,
00453 double dfFalseEasting,double dfFalseNorthing);
00454
00456 OGRErr SetPolyconic( double dfCenterLat, double dfCenterLong,
00457 double dfFalseEasting, double dfFalseNorthing );
00458
00460 OGRErr SetPS( double dfCenterLat, double dfCenterLong,
00461 double dfScale,
00462 double dfFalseEasting, double dfFalseNorthing);
00463
00465 OGRErr SetRobinson( double dfCenterLong,
00466 double dfFalseEasting, double dfFalseNorthing );
00467
00469 OGRErr SetSinusoidal( double dfCenterLong,
00470 double dfFalseEasting, double dfFalseNorthing );
00471
00473 OGRErr SetStereographic( double dfCenterLat, double dfCenterLong,
00474 double dfScale,
00475 double dfFalseEasting,double dfFalseNorthing);
00476
00478 OGRErr SetSOC( double dfLatitudeOfOrigin, double dfCentralMeridian,
00479 double dfFalseEasting, double dfFalseNorthing );
00480
00482 OGRErr SetTM( double dfCenterLat, double dfCenterLong,
00483 double dfScale,
00484 double dfFalseEasting, double dfFalseNorthing );
00485
00487 OGRErr SetTMVariant( const char *pszVariantName,
00488 double dfCenterLat, double dfCenterLong,
00489 double dfScale,
00490 double dfFalseEasting, double dfFalseNorthing );
00491
00493 OGRErr SetTMG( double dfCenterLat, double dfCenterLong,
00494 double dfFalseEasting, double dfFalseNorthing );
00495
00497 OGRErr SetTMSO( double dfCenterLat, double dfCenterLong,
00498 double dfScale,
00499 double dfFalseEasting, double dfFalseNorthing );
00500
00502 OGRErr SetTPED( double dfLat1, double dfLong1,
00503 double dfLat2, double dfLong2,
00504 double dfFalseEasting, double dfFalseNorthing );
00505
00507 OGRErr SetVDG( double dfCenterLong,
00508 double dfFalseEasting, double dfFalseNorthing );
00509
00511 OGRErr SetUTM( int nZone, int bNorth = TRUE );
00512 int GetUTMZone( int *pbNorth = NULL ) const;
00513
00515 OGRErr SetStatePlane( int nZone, int bNAD83 = TRUE,
00516 const char *pszOverrideUnitName = NULL,
00517 double dfOverrideUnit = 0.0 );
00518 };
00519
00520
00521
00522
00523
00524
00525
00526
00533 class CPL_DLL OGRCoordinateTransformation
00534 {
00535 public:
00536 virtual ~OGRCoordinateTransformation() {}
00537
00538
00539
00541 virtual OGRSpatialReference *GetSourceCS() = 0;
00542
00544 virtual OGRSpatialReference *GetTargetCS() = 0;
00545
00546
00547
00563 virtual int Transform( int nCount,
00564 double *x, double *y, double *z = NULL ) = 0;
00565
00581 virtual int TransformEx( int nCount,
00582 double *x, double *y, double *z = NULL,
00583 int *pabSuccess = NULL ) = 0;
00584
00585 };
00586
00587 OGRCoordinateTransformation CPL_DLL *
00588 OGRCreateCoordinateTransformation( OGRSpatialReference *poSource,
00589 OGRSpatialReference *poTarget );
00590
00591 #endif