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 #ifndef _OGR_SPATIALREF_H_INCLUDED
00119 #define _OGR_SPATIALREF_H_INCLUDED
00120
00121 #include "ogr_srs_api.h"
00122
00129
00130
00131
00132
00146 class CPL_DLL OGR_SRSNode
00147 {
00148 char *pszValue;
00149
00150 OGR_SRSNode **papoChildNodes;
00151 OGR_SRSNode *poParent;
00152
00153 int nChildren;
00154
00155 void ClearChildren();
00156 int NeedsQuoting() const;
00157
00158 public:
00159 OGR_SRSNode(const char * = NULL);
00160 ~OGR_SRSNode();
00161
00162 int IsLeafNode() const { return nChildren == 0; }
00163
00164 int GetChildCount() const { return nChildren; }
00165 OGR_SRSNode *GetChild( int );
00166 const OGR_SRSNode *GetChild( int ) const;
00167
00168 OGR_SRSNode *GetNode( const char * );
00169 const OGR_SRSNode *GetNode( const char * ) const;
00170
00171 void InsertChild( OGR_SRSNode *, int );
00172 void AddChild( OGR_SRSNode * );
00173 int FindChild( const char * ) const;
00174 void DestroyChild( int );
00175 void StripNodes( const char * );
00176
00177 const char *GetValue() const { return pszValue; }
00178 void SetValue( const char * );
00179
00180 void MakeValueSafe();
00181 OGRErr FixupOrdering();
00182
00183 OGR_SRSNode *Clone() const;
00184
00185 OGRErr importFromWkt( char ** );
00186 OGRErr exportToWkt( char ** ) const;
00187 OGRErr exportToPrettyWkt( char **, int = 1) const;
00188
00189 OGRErr applyRemapper( const char *pszNode,
00190 char **papszSrcValues,
00191 char **papszDstValues,
00192 int nStepSize = 1,
00193 int bChildOfHit = FALSE );
00194 };
00195
00196
00197
00198
00199
00214 class CPL_DLL OGRSpatialReference
00215 {
00216 double dfFromGreenwich;
00217 double dfToMeter;
00218 double dfToDegrees;
00219
00220 OGR_SRSNode *poRoot;
00221
00222 int nRefCount;
00223 int bNormInfoSet;
00224
00225 OGRErr ValidateProjection();
00226 int IsAliasFor( const char *, const char * );
00227 void GetNormInfo() const;
00228
00229 public:
00230 OGRSpatialReference(const OGRSpatialReference&);
00231 OGRSpatialReference(const char * = NULL);
00232
00233 virtual ~OGRSpatialReference();
00234
00235 OGRSpatialReference &operator=(const OGRSpatialReference&);
00236
00237 int Reference();
00238 int Dereference();
00239 int GetReferenceCount() const { return nRefCount; }
00240 void Release();
00241
00242 OGRSpatialReference *Clone() const;
00243 OGRSpatialReference *CloneGeogCS() const;
00244
00245 OGRErr exportToWkt( char ** ) const;
00246 OGRErr exportToPrettyWkt( char **, int = FALSE) const;
00247 OGRErr exportToProj4( char ** ) const;
00248 OGRErr exportToPCI( char **, char **, double ** ) const;
00249 OGRErr exportToUSGS( long *, long *, double **, long * ) const;
00250 OGRErr exportToPanorama( long *, long *, double **, long * ) const;
00251 OGRErr exportToXML( char **, const char * = NULL ) const;
00252 OGRErr exportToPanorama( long *, long *, long *, long *, double *,
00253 double *, double *, double * ) const;
00254 OGRErr importFromWkt( char ** );
00255 OGRErr importFromProj4( const char * );
00256 OGRErr importFromEPSG( int );
00257 OGRErr importFromESRI( char ** );
00258 OGRErr importFromPCI( const char *, const char * = NULL,
00259 double * = NULL );
00260 OGRErr importFromUSGS( long, long, double *, long );
00261 OGRErr importFromPanorama( long, long, long, long,
00262 double, double, double, double );
00263 OGRErr importFromWMSAUTO( const char *pszAutoDef );
00264 OGRErr importFromXML( const char * );
00265 OGRErr importFromDict( const char *pszDict, const char *pszCode );
00266 OGRErr importFromURN( const char * );
00267
00268 OGRErr morphToESRI();
00269 OGRErr morphFromESRI();
00270
00271 OGRErr Validate();
00272 OGRErr StripCTParms( OGR_SRSNode * = NULL );
00273 OGRErr FixupOrdering();
00274 OGRErr Fixup();
00275
00276
00277 OGR_SRSNode *GetRoot() { return poRoot; }
00278 const OGR_SRSNode *GetRoot() const { return poRoot; }
00279 void SetRoot( OGR_SRSNode * );
00280
00281 OGR_SRSNode *GetAttrNode(const char *);
00282 const OGR_SRSNode *GetAttrNode(const char *) const;
00283 const char *GetAttrValue(const char *, int = 0) const;
00284
00285 OGRErr SetNode( const char *, const char * );
00286 OGRErr SetNode( const char *, double );
00287
00288 OGRErr SetLinearUnitsAndUpdateParameters( const char *pszName,
00289 double dfInMeters );
00290 OGRErr SetLinearUnits( const char *pszName, double dfInMeters );
00291 double GetLinearUnits( char ** = NULL ) const;
00292
00293 OGRErr SetAngularUnits( const char *pszName, double dfInRadians );
00294 double GetAngularUnits( char ** = NULL ) const;
00295
00296 double GetPrimeMeridian( char ** = NULL ) const;
00297
00298 int IsGeographic() const;
00299 int IsProjected() const;
00300 int IsLocal() const;
00301 int IsSameGeogCS( const OGRSpatialReference * ) const;
00302 int IsSame( const OGRSpatialReference * ) const;
00303
00304 void Clear();
00305 OGRErr SetLocalCS( const char * );
00306 OGRErr SetProjCS( const char * );
00307 OGRErr SetProjection( const char * );
00308 OGRErr SetGeogCS( const char * pszGeogName,
00309 const char * pszDatumName,
00310 const char * pszEllipsoidName,
00311 double dfSemiMajor, double dfInvFlattening,
00312 const char * pszPMName = NULL,
00313 double dfPMOffset = 0.0,
00314 const char * pszUnits = NULL,
00315 double dfConvertToRadians = 0.0 );
00316 OGRErr SetWellKnownGeogCS( const char * );
00317 OGRErr CopyGeogCSFrom( const OGRSpatialReference * poSrcSRS );
00318
00319 OGRErr SetFromUserInput( const char * );
00320
00321 OGRErr SetTOWGS84( double, double, double,
00322 double = 0.0, double = 0.0, double = 0.0,
00323 double = 0.0 );
00324 OGRErr GetTOWGS84( double *padfCoef, int nCoeff = 7 ) const;
00325
00326 double GetSemiMajor( OGRErr * = NULL ) const;
00327 double GetSemiMinor( OGRErr * = NULL ) const;
00328 double GetInvFlattening( OGRErr * = NULL ) const;
00329
00330 OGRErr SetAuthority( const char * pszTargetKey,
00331 const char * pszAuthority,
00332 int nCode );
00333
00334 OGRErr AutoIdentifyEPSG();
00335
00336 const char *GetAuthorityCode( const char * pszTargetKey ) const;
00337 const char *GetAuthorityName( const char * pszTargetKey ) const;
00338
00339 const char *GetExtension( const char *pszTargetKey,
00340 const char *pszName,
00341 const char *pszDefault = NULL ) const;
00342 OGRErr SetExtension( const char *pszTargetKey,
00343 const char *pszName,
00344 const char *pszValue );
00345
00346 OGRErr SetProjParm( const char *, double );
00347 double GetProjParm( const char *, double =0.0, OGRErr* = NULL ) const;
00348
00349 OGRErr SetNormProjParm( const char *, double );
00350 double GetNormProjParm( const char *, double=0.0, OGRErr* =NULL)const;
00351
00352 static int IsAngularParameter( const char * );
00353 static int IsLongitudeParameter( const char * );
00354 static int IsLinearParameter( const char * );
00355
00357 OGRErr SetACEA( double dfStdP1, double dfStdP2,
00358 double dfCenterLat, double dfCenterLong,
00359 double dfFalseEasting, double dfFalseNorthing );
00360
00362 OGRErr SetAE( double dfCenterLat, double dfCenterLong,
00363 double dfFalseEasting, double dfFalseNorthing );
00364
00366 OGRErr SetBonne( double dfStdP1, double dfCentralMeridian,
00367 double dfFalseEasting, double dfFalseNorthing );
00368
00370 OGRErr SetCEA( double dfStdP1, double dfCentralMeridian,
00371 double dfFalseEasting, double dfFalseNorthing );
00372
00374 OGRErr SetCS( double dfCenterLat, double dfCenterLong,
00375 double dfFalseEasting, double dfFalseNorthing );
00376
00378 OGRErr SetEC( double dfStdP1, double dfStdP2,
00379 double dfCenterLat, double dfCenterLong,
00380 double dfFalseEasting, double dfFalseNorthing );
00381
00383 OGRErr SetEckertIV( double dfCentralMeridian,
00384 double dfFalseEasting, double dfFalseNorthing );
00385
00387 OGRErr SetEckertVI( double dfCentralMeridian,
00388 double dfFalseEasting, double dfFalseNorthing );
00389
00391 OGRErr SetEquirectangular(double dfCenterLat, double dfCenterLong,
00392 double dfFalseEasting, double dfFalseNorthing );
00393
00395 OGRErr SetGEOS( double dfCentralMeridian, double dfSatelliteHeight,
00396 double dfFalseEasting, double dfFalseNorthing );
00397
00399 OGRErr SetGH( double dfCentralMeridian,
00400 double dfFalseEasting, double dfFalseNorthing );
00401
00403 OGRErr SetGS( double dfCentralMeridian,
00404 double dfFalseEasting, double dfFalseNorthing );
00405
00407 OGRErr SetGnomonic(double dfCenterLat, double dfCenterLong,
00408 double dfFalseEasting, double dfFalseNorthing );
00409
00410 OGRErr SetHOM( double dfCenterLat, double dfCenterLong,
00411 double dfAzimuth, double dfRectToSkew,
00412 double dfScale,
00413 double dfFalseEasting, double dfFalseNorthing );
00414
00415 OGRErr SetHOM2PNO( double dfCenterLat,
00416 double dfLat1, double dfLong1,
00417 double dfLat2, double dfLong2,
00418 double dfScale,
00419 double dfFalseEasting, double dfFalseNorthing );
00420
00422 OGRErr SetKrovak( double dfCenterLat, double dfCenterLong,
00423 double dfAzimuth, double dfPseudoStdParallelLat,
00424 double dfScale,
00425 double dfFalseEasting, double dfFalseNorthing );
00426
00428 OGRErr SetLAEA( double dfCenterLat, double dfCenterLong,
00429 double dfFalseEasting, double dfFalseNorthing );
00430
00432 OGRErr SetLCC( double dfStdP1, double dfStdP2,
00433 double dfCenterLat, double dfCenterLong,
00434 double dfFalseEasting, double dfFalseNorthing );
00435
00437 OGRErr SetLCC1SP( double dfCenterLat, double dfCenterLong,
00438 double dfScale,
00439 double dfFalseEasting, double dfFalseNorthing );
00440
00442 OGRErr SetLCCB( double dfStdP1, double dfStdP2,
00443 double dfCenterLat, double dfCenterLong,
00444 double dfFalseEasting, double dfFalseNorthing );
00445
00447 OGRErr SetMC( double dfCenterLat, double dfCenterLong,
00448 double dfFalseEasting, double dfFalseNorthing );
00449
00451 OGRErr SetMercator( double dfCenterLat, double dfCenterLong,
00452 double dfScale,
00453 double dfFalseEasting, double dfFalseNorthing );
00454
00455 OGRErr SetMercator2SP( double dfStdP1,
00456 double dfCenterLat, double dfCenterLong,
00457 double dfFalseEasting, double dfFalseNorthing );
00458
00460 OGRErr SetMollweide( double dfCentralMeridian,
00461 double dfFalseEasting, double dfFalseNorthing );
00462
00464 OGRErr SetNZMG( double dfCenterLat, double dfCenterLong,
00465 double dfFalseEasting, double dfFalseNorthing );
00466
00468 OGRErr SetOS( double dfOriginLat, double dfCMeridian,
00469 double dfScale,
00470 double dfFalseEasting,double dfFalseNorthing);
00471
00473 OGRErr SetOrthographic( double dfCenterLat, double dfCenterLong,
00474 double dfFalseEasting,double dfFalseNorthing);
00475
00477 OGRErr SetPolyconic( double dfCenterLat, double dfCenterLong,
00478 double dfFalseEasting, double dfFalseNorthing );
00479
00481 OGRErr SetPS( double dfCenterLat, double dfCenterLong,
00482 double dfScale,
00483 double dfFalseEasting, double dfFalseNorthing);
00484
00486 OGRErr SetRobinson( double dfCenterLong,
00487 double dfFalseEasting, double dfFalseNorthing );
00488
00490 OGRErr SetSinusoidal( double dfCenterLong,
00491 double dfFalseEasting, double dfFalseNorthing );
00492
00494 OGRErr SetStereographic( double dfCenterLat, double dfCenterLong,
00495 double dfScale,
00496 double dfFalseEasting,double dfFalseNorthing);
00497
00499 OGRErr SetSOC( double dfLatitudeOfOrigin, double dfCentralMeridian,
00500 double dfFalseEasting, double dfFalseNorthing );
00501
00503 OGRErr SetTM( double dfCenterLat, double dfCenterLong,
00504 double dfScale,
00505 double dfFalseEasting, double dfFalseNorthing );
00506
00508 OGRErr SetTMVariant( const char *pszVariantName,
00509 double dfCenterLat, double dfCenterLong,
00510 double dfScale,
00511 double dfFalseEasting, double dfFalseNorthing );
00512
00514 OGRErr SetTMG( double dfCenterLat, double dfCenterLong,
00515 double dfFalseEasting, double dfFalseNorthing );
00516
00518 OGRErr SetTMSO( double dfCenterLat, double dfCenterLong,
00519 double dfScale,
00520 double dfFalseEasting, double dfFalseNorthing );
00521
00523 OGRErr SetTPED( double dfLat1, double dfLong1,
00524 double dfLat2, double dfLong2,
00525 double dfFalseEasting, double dfFalseNorthing );
00526
00528 OGRErr SetVDG( double dfCenterLong,
00529 double dfFalseEasting, double dfFalseNorthing );
00530
00532 OGRErr SetUTM( int nZone, int bNorth = TRUE );
00533 int GetUTMZone( int *pbNorth = NULL ) const;
00534
00536 OGRErr SetStatePlane( int nZone, int bNAD83 = TRUE,
00537 const char *pszOverrideUnitName = NULL,
00538 double dfOverrideUnit = 0.0 );
00539 };
00540
00541
00542
00543
00544
00545
00546
00547
00554 class CPL_DLL OGRCoordinateTransformation
00555 {
00556 public:
00557 virtual ~OGRCoordinateTransformation() {}
00558
00559
00560
00562 virtual OGRSpatialReference *GetSourceCS() = 0;
00563
00565 virtual OGRSpatialReference *GetTargetCS() = 0;
00566
00567
00568
00584 virtual int Transform( int nCount,
00585 double *x, double *y, double *z = NULL ) = 0;
00586
00602 virtual int TransformEx( int nCount,
00603 double *x, double *y, double *z = NULL,
00604 int *pabSuccess = NULL ) = 0;
00605
00606 };
00607
00608 OGRCoordinateTransformation CPL_DLL *
00609 OGRCreateCoordinateTransformation( OGRSpatialReference *poSource,
00610 OGRSpatialReference *poTarget );
00611
00612 #endif