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
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198 #ifndef _OGR_SPATIALREF_H_INCLUDED
00199 #define _OGR_SPATIALREF_H_INCLUDED
00200
00201 #include "ogr_srs_api.h"
00202
00209
00210
00211
00212
00226 class CPL_DLL OGR_SRSNode
00227 {
00228 char *pszValue;
00229
00230 int nChildren;
00231 OGR_SRSNode **papoChildNodes;
00232
00233 OGR_SRSNode *poParent;
00234
00235 void ClearChildren();
00236 int NeedsQuoting() const;
00237
00238 public:
00239 OGR_SRSNode(const char * = NULL);
00240 ~OGR_SRSNode();
00241
00242 int IsLeafNode() const { return nChildren == 0; }
00243
00244 int GetChildCount() const { return nChildren; }
00245 OGR_SRSNode *GetChild( int );
00246 const OGR_SRSNode *GetChild( int ) const;
00247
00248 OGR_SRSNode *GetNode( const char * );
00249 const OGR_SRSNode *GetNode( const char * ) const;
00250
00251 void InsertChild( OGR_SRSNode *, int );
00252 void AddChild( OGR_SRSNode * );
00253 int FindChild( const char * ) const;
00254 void DestroyChild( int );
00255 void StripNodes( const char * );
00256
00257 const char *GetValue() const { return pszValue; }
00258 void SetValue( const char * );
00259
00260 void MakeValueSafe();
00261 OGRErr FixupOrdering();
00262
00263 OGR_SRSNode *Clone() const;
00264
00265 OGRErr importFromWkt( char ** );
00266 OGRErr exportToWkt( char ** ) const;
00267 OGRErr exportToPrettyWkt( char **, int = 1) const;
00268
00269 OGRErr applyRemapper( const char *pszNode,
00270 char **papszSrcValues,
00271 char **papszDstValues,
00272 int nStepSize = 1,
00273 int bChildOfHit = FALSE );
00274 };
00275
00276
00277
00278
00279
00294 class CPL_DLL OGRSpatialReference
00295 {
00296 int nRefCount;
00297
00298 OGR_SRSNode *poRoot;
00299
00300 int bNormInfoSet;
00301 double dfFromGreenwich;
00302 double dfToMeter;
00303 double dfToDegrees;
00304
00305 OGRErr ValidateProjection();
00306 int IsAliasFor( const char *, const char * );
00307 void GetNormInfo() const;
00308
00309 public:
00310 OGRSpatialReference(const OGRSpatialReference&);
00311 OGRSpatialReference(const char * = NULL);
00312
00313 virtual ~OGRSpatialReference();
00314
00315 OGRSpatialReference &operator=(const OGRSpatialReference&);
00316
00317 int Reference();
00318 int Dereference();
00319 int GetReferenceCount() const { return nRefCount; }
00320
00321 OGRSpatialReference *Clone() const;
00322 OGRSpatialReference *CloneGeogCS() const;
00323
00324 OGRErr importFromWkt( char ** );
00325 OGRErr exportToWkt( char ** );
00326 OGRErr exportToPrettyWkt( char **, int = FALSE) const;
00327 OGRErr exportToProj4( char ** ) const;
00328 OGRErr exportToPCI( char **, char **, double ** ) const;
00329
00330 OGRErr exportToXML( char **, const char * = NULL ) const;
00331 OGRErr importFromProj4( const char * );
00332 OGRErr importFromEPSG( int );
00333 OGRErr importFromESRI( char ** );
00334 OGRErr importFromPCI( const char *pszProj,
00335 const char *pszUnits = NULL,
00336 double *padfPrjParams = NULL );
00337 OGRErr importFromWMSAUTO( const char *pszAutoDef );
00338 OGRErr importFromXML( const char * );
00339
00340 OGRErr morphToESRI();
00341 OGRErr morphFromESRI();
00342
00343 OGRErr Validate();
00344 OGRErr StripCTParms( OGR_SRSNode * = NULL );
00345 OGRErr FixupOrdering();
00346 OGRErr Fixup();
00347
00348
00349 OGR_SRSNode *GetRoot() { return poRoot; }
00350 const OGR_SRSNode *GetRoot() const { return poRoot; }
00351 void SetRoot( OGR_SRSNode * );
00352
00353 OGR_SRSNode *GetAttrNode(const char *);
00354 const OGR_SRSNode *GetAttrNode(const char *) const;
00355 const char *GetAttrValue(const char *, int = 0) const;
00356
00357 OGRErr SetNode( const char *, const char * );
00358 OGRErr SetNode( const char *, double );
00359
00360 OGRErr SetLinearUnits( const char *pszName, double dfInMeters );
00361 double GetLinearUnits( char ** = NULL ) const;
00362
00363 OGRErr SetAngularUnits( const char *pszName, double dfInRadians );
00364 double GetAngularUnits( char ** = NULL ) const;
00365
00366 double GetPrimeMeridian( char ** = NULL ) const;
00367
00368 int IsGeographic() const;
00369 int IsProjected() const;
00370 int IsLocal() const;
00371 int IsSameGeogCS( const OGRSpatialReference * ) const;
00372 int IsSame( const OGRSpatialReference * ) const;
00373
00374 void Clear();
00375 OGRErr SetLocalCS( const char * );
00376 OGRErr SetProjCS( const char * );
00377 OGRErr SetProjection( const char * );
00378 OGRErr SetGeogCS( const char * pszGeogName,
00379 const char * pszDatumName,
00380 const char * pszEllipsoidName,
00381 double dfSemiMajor, double dfInvFlattening,
00382 const char * pszPMName = NULL,
00383 double dfPMOffset = 0.0,
00384 const char * pszUnits = NULL,
00385 double dfConvertToRadians = 0.0 );
00386 OGRErr SetWellKnownGeogCS( const char * );
00387 OGRErr CopyGeogCSFrom( const OGRSpatialReference * poSrcSRS );
00388
00389 OGRErr SetFromUserInput( const char * );
00390
00391 OGRErr SetTOWGS84( double, double, double,
00392 double = 0.0, double = 0.0, double = 0.0,
00393 double = 0.0 );
00394 OGRErr GetTOWGS84( double *padfCoef, int nCoeff = 7 ) const;
00395
00396 double GetSemiMajor( OGRErr * = NULL ) const;
00397 double GetSemiMinor( OGRErr * = NULL ) const;
00398 double GetInvFlattening( OGRErr * = NULL ) const;
00399
00400 OGRErr SetAuthority( const char * pszTargetKey,
00401 const char * pszAuthority,
00402 int nCode );
00403
00404 const char *GetAuthorityCode( const char * pszTargetKey ) const;
00405 const char *GetAuthorityName( const char * pszTargetKey ) const;
00406
00407 OGRErr SetProjParm( const char *, double );
00408 double GetProjParm( const char *, double =0.0, OGRErr* = NULL ) const;
00409
00410 OGRErr SetNormProjParm( const char *, double );
00411 double GetNormProjParm( const char *, double=0.0, OGRErr* =NULL)const;
00412
00413 static int IsAngularParameter( const char * );
00414 static int IsLongitudeParameter( const char * );
00415 static int IsLinearParameter( const char * );
00416
00418 OGRErr SetACEA( double dfStdP1, double dfStdP2,
00419 double dfCenterLat, double dfCenterLong,
00420 double dfFalseEasting, double dfFalseNorthing );
00421
00423 OGRErr SetAE( double dfCenterLat, double dfCenterLong,
00424 double dfFalseEasting, double dfFalseNorthing );
00425
00427 OGRErr SetCEA( double dfStdP1, double dfCentralMeridian,
00428 double dfFalseEasting, double dfFalseNorthing );
00429
00431 OGRErr SetCS( double dfCenterLat, double dfCenterLong,
00432 double dfFalseEasting, double dfFalseNorthing );
00433
00435 OGRErr SetEC( double dfStdP1, double dfStdP2,
00436 double dfCenterLat, double dfCenterLong,
00437 double dfFalseEasting, double dfFalseNorthing );
00438
00440 OGRErr SetEckertIV( double dfCentralMeridian,
00441 double dfFalseEasting, double dfFalseNorthing );
00442
00444 OGRErr SetEckertVI( double dfCentralMeridian,
00445 double dfFalseEasting, double dfFalseNorthing );
00446
00448 OGRErr SetEquirectangular(double dfCenterLat, double dfCenterLong,
00449 double dfFalseEasting, double dfFalseNorthing );
00450
00452 OGRErr SetGS( double dfCentralMeridian,
00453 double dfFalseEasting, double dfFalseNorthing );
00454
00456 OGRErr SetGnomonic(double dfCenterLat, double dfCenterLong,
00457 double dfFalseEasting, double dfFalseNorthing );
00458
00460 OGRErr SetHOM( double dfCenterLat, double dfCenterLong,
00461 double dfAzimuth, double dfRectToSkew,
00462 double dfScale,
00463 double dfFalseEasting, double dfFalseNorthing );
00464
00466 OGRErr SetKrovak( double dfCenterLat, double dfCenterLong,
00467 double dfAzimuth, double dfPseudoStdParallelLat,
00468 double dfScale,
00469 double dfFalseEasting, double dfFalseNorthing );
00470
00472 OGRErr SetLAEA( double dfCenterLat, double dfCenterLong,
00473 double dfFalseEasting, double dfFalseNorthing );
00474
00476 OGRErr SetLCC( double dfStdP1, double dfStdP2,
00477 double dfCenterLat, double dfCenterLong,
00478 double dfFalseEasting, double dfFalseNorthing );
00479
00481 OGRErr SetLCC1SP( double dfCenterLat, double dfCenterLong,
00482 double dfScale,
00483 double dfFalseEasting, double dfFalseNorthing );
00484
00486 OGRErr SetLCCB( double dfStdP1, double dfStdP2,
00487 double dfCenterLat, double dfCenterLong,
00488 double dfFalseEasting, double dfFalseNorthing );
00489
00491 OGRErr SetMC( double dfCenterLat, double dfCenterLong,
00492 double dfFalseEasting, double dfFalseNorthing );
00493
00495 OGRErr SetMercator( double dfCenterLat, double dfCenterLong,
00496 double dfScale,
00497 double dfFalseEasting, double dfFalseNorthing );
00498
00500 OGRErr SetMollweide( double dfCentralMeridian,
00501 double dfFalseEasting, double dfFalseNorthing );
00502
00504 OGRErr SetNZMG( double dfCenterLat, double dfCenterLong,
00505 double dfFalseEasting, double dfFalseNorthing );
00506
00508 OGRErr SetOS( double dfOriginLat, double dfCMeridian,
00509 double dfScale,
00510 double dfFalseEasting,double dfFalseNorthing);
00511
00513 OGRErr SetOrthographic( double dfCenterLat, double dfCenterLong,
00514 double dfFalseEasting,double dfFalseNorthing);
00515
00517 OGRErr SetPolyconic( double dfCenterLat, double dfCenterLong,
00518 double dfFalseEasting, double dfFalseNorthing );
00519
00521 OGRErr SetPS( double dfCenterLat, double dfCenterLong,
00522 double dfScale,
00523 double dfFalseEasting, double dfFalseNorthing);
00524
00526 OGRErr SetRobinson( double dfCenterLong,
00527 double dfFalseEasting, double dfFalseNorthing );
00528
00530 OGRErr SetSinusoidal( double dfCenterLong,
00531 double dfFalseEasting, double dfFalseNorthing );
00532
00534 OGRErr SetStereographic( double dfCenterLat, double dfCenterLong,
00535 double dfScale,
00536 double dfFalseEasting,double dfFalseNorthing);
00537
00539 OGRErr SetSOC( double dfLatitudeOfOrigin, double dfCentralMeridian,
00540 double dfFalseEasting, double dfFalseNorthing );
00541
00543 OGRErr SetTM( double dfCenterLat, double dfCenterLong,
00544 double dfScale,
00545 double dfFalseEasting, double dfFalseNorthing );
00546
00548 OGRErr SetTMVariant( const char *pszVariantName,
00549 double dfCenterLat, double dfCenterLong,
00550 double dfScale,
00551 double dfFalseEasting, double dfFalseNorthing );
00552
00554 OGRErr SetTMG( double dfCenterLat, double dfCenterLong,
00555 double dfFalseEasting, double dfFalseNorthing );
00556
00558 OGRErr SetTMSO( double dfCenterLat, double dfCenterLong,
00559 double dfScale,
00560 double dfFalseEasting, double dfFalseNorthing );
00561
00563 OGRErr SetVDG( double dfCenterLong,
00564 double dfFalseEasting, double dfFalseNorthing );
00565
00567 OGRErr SetUTM( int nZone, int bNorth = TRUE );
00568 int GetUTMZone( int *pbNorth = NULL ) const;
00569
00571 OGRErr SetStatePlane( int nZone, int bNAD83 = TRUE,
00572 const char *pszOverrideUnitName = NULL,
00573 double dfOverrideUnit = 0.0 );
00574 };
00575
00576
00577
00578
00579
00580
00581
00582
00589 class CPL_DLL OGRCoordinateTransformation
00590 {
00591 public:
00592 virtual ~OGRCoordinateTransformation() {}
00593
00594
00595
00597 virtual OGRSpatialReference *GetSourceCS() = 0;
00598
00600 virtual OGRSpatialReference *GetTargetCS() = 0;
00601
00602
00603
00616 virtual int Transform( int nCount,
00617 double *x, double *y, double *z = NULL ) = 0;
00618
00619 };
00620
00621 OGRCoordinateTransformation CPL_DLL *
00622 OGRCreateCoordinateTransformation( OGRSpatialReference *poSource,
00623 OGRSpatialReference *poTarget );
00624
00625 #endif