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 #ifndef _OGR_SPATIALREF_H_INCLUDED
00097 #define _OGR_SPATIALREF_H_INCLUDED
00098
00099 #include "ogr_srs_api.h"
00100
00107
00108
00109
00110
00124 class CPL_DLL OGR_SRSNode
00125 {
00126 char *pszValue;
00127
00128 int nChildren;
00129 OGR_SRSNode **papoChildNodes;
00130
00131 OGR_SRSNode *poParent;
00132
00133 void ClearChildren();
00134 int NeedsQuoting() const;
00135
00136 public:
00137 OGR_SRSNode(const char * = NULL);
00138 ~OGR_SRSNode();
00139
00140 int IsLeafNode() const { return nChildren == 0; }
00141
00142 int GetChildCount() const { return nChildren; }
00143 OGR_SRSNode *GetChild( int );
00144 const OGR_SRSNode *GetChild( int ) const;
00145
00146 OGR_SRSNode *GetNode( const char * );
00147 const OGR_SRSNode *GetNode( const char * ) const;
00148
00149 void InsertChild( OGR_SRSNode *, int );
00150 void AddChild( OGR_SRSNode * );
00151 int FindChild( const char * ) const;
00152 void DestroyChild( int );
00153 void StripNodes( const char * );
00154
00155 const char *GetValue() const { return pszValue; }
00156 void SetValue( const char * );
00157
00158 void MakeValueSafe();
00159 OGRErr FixupOrdering();
00160
00161 OGR_SRSNode *Clone() const;
00162
00163 OGRErr importFromWkt( char ** );
00164 OGRErr exportToWkt( char ** ) const;
00165 OGRErr exportToPrettyWkt( char **, int = 1) const;
00166
00167 OGRErr applyRemapper( const char *pszNode,
00168 char **papszSrcValues,
00169 char **papszDstValues,
00170 int nStepSize = 1,
00171 int bChildOfHit = FALSE );
00172 };
00173
00174
00175
00176
00177
00192 class CPL_DLL OGRSpatialReference
00193 {
00194 int nRefCount;
00195
00196 OGR_SRSNode *poRoot;
00197
00198 int bNormInfoSet;
00199 double dfFromGreenwich;
00200 double dfToMeter;
00201 double dfToDegrees;
00202
00203 OGRErr ValidateProjection();
00204 int IsAliasFor( const char *, const char * );
00205 void GetNormInfo() const;
00206
00207 public:
00208 OGRSpatialReference(const OGRSpatialReference&);
00209 OGRSpatialReference(const char * = NULL);
00210
00211 virtual ~OGRSpatialReference();
00212
00213 OGRSpatialReference &operator=(const OGRSpatialReference&);
00214
00215 int Reference();
00216 int Dereference();
00217 int GetReferenceCount() const { return nRefCount; }
00218
00219 OGRSpatialReference *Clone() const;
00220 OGRSpatialReference *CloneGeogCS() const;
00221
00222 OGRErr exportToWkt( char ** ) const;
00223 OGRErr exportToPrettyWkt( char **, int = FALSE) const;
00224 OGRErr exportToProj4( char ** ) const;
00225 OGRErr exportToPCI( char **, char **, double ** ) const;
00226 OGRErr exportToUSGS( long *, long *, double **, long * ) const;
00227 OGRErr exportToXML( char **, const char * = NULL ) const;
00228 OGRErr importFromWkt( char ** );
00229 OGRErr importFromProj4( const char * );
00230 OGRErr importFromEPSG( int );
00231 OGRErr importFromESRI( char ** );
00232 OGRErr importFromPCI( const char *pszProj,
00233 const char *pszUnits = NULL,
00234 double *padfPrjParams = NULL );
00235 OGRErr importFromUSGS( long iProjsys, long iZone,
00236 double *padfPrjParams, long iDatum );
00237 OGRErr importFromWMSAUTO( const char *pszAutoDef );
00238 OGRErr importFromXML( const char * );
00239 OGRErr importFromDict( const char *pszDict, const char *pszCode );
00240
00241 OGRErr morphToESRI();
00242 OGRErr morphFromESRI();
00243
00244 OGRErr Validate();
00245 OGRErr StripCTParms( OGR_SRSNode * = NULL );
00246 OGRErr FixupOrdering();
00247 OGRErr Fixup();
00248
00249
00250 OGR_SRSNode *GetRoot() { return poRoot; }
00251 const OGR_SRSNode *GetRoot() const { return poRoot; }
00252 void SetRoot( OGR_SRSNode * );
00253
00254 OGR_SRSNode *GetAttrNode(const char *);
00255 const OGR_SRSNode *GetAttrNode(const char *) const;
00256 const char *GetAttrValue(const char *, int = 0) const;
00257
00258 OGRErr SetNode( const char *, const char * );
00259 OGRErr SetNode( const char *, double );
00260
00261 OGRErr SetLinearUnitsAndUpdateParameters( const char *pszName,
00262 double dfInMeters );
00263 OGRErr SetLinearUnits( const char *pszName, double dfInMeters );
00264 double GetLinearUnits( char ** = NULL ) const;
00265
00266 OGRErr SetAngularUnits( const char *pszName, double dfInRadians );
00267 double GetAngularUnits( char ** = NULL ) const;
00268
00269 double GetPrimeMeridian( char ** = NULL ) const;
00270
00271 int IsGeographic() const;
00272 int IsProjected() const;
00273 int IsLocal() const;
00274 int IsSameGeogCS( const OGRSpatialReference * ) const;
00275 int IsSame( const OGRSpatialReference * ) const;
00276
00277 void Clear();
00278 OGRErr SetLocalCS( const char * );
00279 OGRErr SetProjCS( const char * );
00280 OGRErr SetProjection( const char * );
00281 OGRErr SetGeogCS( const char * pszGeogName,
00282 const char * pszDatumName,
00283 const char * pszEllipsoidName,
00284 double dfSemiMajor, double dfInvFlattening,
00285 const char * pszPMName = NULL,
00286 double dfPMOffset = 0.0,
00287 const char * pszUnits = NULL,
00288 double dfConvertToRadians = 0.0 );
00289 OGRErr SetWellKnownGeogCS( const char * );
00290 OGRErr CopyGeogCSFrom( const OGRSpatialReference * poSrcSRS );
00291
00292 OGRErr SetFromUserInput( const char * );
00293
00294 OGRErr SetTOWGS84( double, double, double,
00295 double = 0.0, double = 0.0, double = 0.0,
00296 double = 0.0 );
00297 OGRErr GetTOWGS84( double *padfCoef, int nCoeff = 7 ) const;
00298
00299 double GetSemiMajor( OGRErr * = NULL ) const;
00300 double GetSemiMinor( OGRErr * = NULL ) const;
00301 double GetInvFlattening( OGRErr * = NULL ) const;
00302
00303 OGRErr SetAuthority( const char * pszTargetKey,
00304 const char * pszAuthority,
00305 int nCode );
00306
00307 OGRErr AutoIdentifyEPSG();
00308
00309 const char *GetAuthorityCode( const char * pszTargetKey ) const;
00310 const char *GetAuthorityName( const char * pszTargetKey ) const;
00311
00312 OGRErr SetProjParm( const char *, double );
00313 double GetProjParm( const char *, double =0.0, OGRErr* = NULL ) const;
00314
00315 OGRErr SetNormProjParm( const char *, double );
00316 double GetNormProjParm( const char *, double=0.0, OGRErr* =NULL)const;
00317
00318 static int IsAngularParameter( const char * );
00319 static int IsLongitudeParameter( const char * );
00320 static int IsLinearParameter( const char * );
00321
00323 OGRErr SetACEA( double dfStdP1, double dfStdP2,
00324 double dfCenterLat, double dfCenterLong,
00325 double dfFalseEasting, double dfFalseNorthing );
00326
00328 OGRErr SetAE( double dfCenterLat, double dfCenterLong,
00329 double dfFalseEasting, double dfFalseNorthing );
00330
00332 OGRErr SetBonne( double dfStdP1, double dfCentralMeridian,
00333 double dfFalseEasting, double dfFalseNorthing );
00334
00336 OGRErr SetCEA( double dfStdP1, double dfCentralMeridian,
00337 double dfFalseEasting, double dfFalseNorthing );
00338
00340 OGRErr SetCS( double dfCenterLat, double dfCenterLong,
00341 double dfFalseEasting, double dfFalseNorthing );
00342
00344 OGRErr SetEC( double dfStdP1, double dfStdP2,
00345 double dfCenterLat, double dfCenterLong,
00346 double dfFalseEasting, double dfFalseNorthing );
00347
00349 OGRErr SetEckertIV( double dfCentralMeridian,
00350 double dfFalseEasting, double dfFalseNorthing );
00351
00353 OGRErr SetEckertVI( double dfCentralMeridian,
00354 double dfFalseEasting, double dfFalseNorthing );
00355
00357 OGRErr SetEquirectangular(double dfCenterLat, double dfCenterLong,
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 SetGS( double dfCentralMeridian,
00370 double dfFalseEasting, double dfFalseNorthing );
00371
00373 OGRErr SetGnomonic(double dfCenterLat, double dfCenterLong,
00374 double dfFalseEasting, double dfFalseNorthing );
00375
00376 OGRErr SetHOM( double dfCenterLat, double dfCenterLong,
00377 double dfAzimuth, double dfRectToSkew,
00378 double dfScale,
00379 double dfFalseEasting, double dfFalseNorthing );
00380
00381 OGRErr SetHOM2PNO( double dfCenterLat,
00382 double dfLat1, double dfLong1,
00383 double dfLat2, double dfLong2,
00384 double dfScale,
00385 double dfFalseEasting, double dfFalseNorthing );
00386
00388 OGRErr SetKrovak( double dfCenterLat, double dfCenterLong,
00389 double dfAzimuth, double dfPseudoStdParallelLat,
00390 double dfScale,
00391 double dfFalseEasting, double dfFalseNorthing );
00392
00394 OGRErr SetLAEA( double dfCenterLat, double dfCenterLong,
00395 double dfFalseEasting, double dfFalseNorthing );
00396
00398 OGRErr SetLCC( double dfStdP1, double dfStdP2,
00399 double dfCenterLat, double dfCenterLong,
00400 double dfFalseEasting, double dfFalseNorthing );
00401
00403 OGRErr SetLCC1SP( double dfCenterLat, double dfCenterLong,
00404 double dfScale,
00405 double dfFalseEasting, double dfFalseNorthing );
00406
00408 OGRErr SetLCCB( double dfStdP1, double dfStdP2,
00409 double dfCenterLat, double dfCenterLong,
00410 double dfFalseEasting, double dfFalseNorthing );
00411
00413 OGRErr SetMC( double dfCenterLat, double dfCenterLong,
00414 double dfFalseEasting, double dfFalseNorthing );
00415
00417 OGRErr SetMercator( double dfCenterLat, double dfCenterLong,
00418 double dfScale,
00419 double dfFalseEasting, double dfFalseNorthing );
00420
00422 OGRErr SetMollweide( double dfCentralMeridian,
00423 double dfFalseEasting, double dfFalseNorthing );
00424
00426 OGRErr SetNZMG( double dfCenterLat, double dfCenterLong,
00427 double dfFalseEasting, double dfFalseNorthing );
00428
00430 OGRErr SetOS( double dfOriginLat, double dfCMeridian,
00431 double dfScale,
00432 double dfFalseEasting,double dfFalseNorthing);
00433
00435 OGRErr SetOrthographic( double dfCenterLat, double dfCenterLong,
00436 double dfFalseEasting,double dfFalseNorthing);
00437
00439 OGRErr SetPolyconic( double dfCenterLat, double dfCenterLong,
00440 double dfFalseEasting, double dfFalseNorthing );
00441
00443 OGRErr SetPS( double dfCenterLat, double dfCenterLong,
00444 double dfScale,
00445 double dfFalseEasting, double dfFalseNorthing);
00446
00448 OGRErr SetRobinson( double dfCenterLong,
00449 double dfFalseEasting, double dfFalseNorthing );
00450
00452 OGRErr SetSinusoidal( double dfCenterLong,
00453 double dfFalseEasting, double dfFalseNorthing );
00454
00456 OGRErr SetStereographic( double dfCenterLat, double dfCenterLong,
00457 double dfScale,
00458 double dfFalseEasting,double dfFalseNorthing);
00459
00461 OGRErr SetSOC( double dfLatitudeOfOrigin, double dfCentralMeridian,
00462 double dfFalseEasting, double dfFalseNorthing );
00463
00465 OGRErr SetTM( double dfCenterLat, double dfCenterLong,
00466 double dfScale,
00467 double dfFalseEasting, double dfFalseNorthing );
00468
00470 OGRErr SetTMVariant( const char *pszVariantName,
00471 double dfCenterLat, double dfCenterLong,
00472 double dfScale,
00473 double dfFalseEasting, double dfFalseNorthing );
00474
00476 OGRErr SetTMG( double dfCenterLat, double dfCenterLong,
00477 double dfFalseEasting, double dfFalseNorthing );
00478
00480 OGRErr SetTMSO( double dfCenterLat, double dfCenterLong,
00481 double dfScale,
00482 double dfFalseEasting, double dfFalseNorthing );
00483
00485 OGRErr SetVDG( double dfCenterLong,
00486 double dfFalseEasting, double dfFalseNorthing );
00487
00489 OGRErr SetUTM( int nZone, int bNorth = TRUE );
00490 int GetUTMZone( int *pbNorth = NULL ) const;
00491
00493 OGRErr SetStatePlane( int nZone, int bNAD83 = TRUE,
00494 const char *pszOverrideUnitName = NULL,
00495 double dfOverrideUnit = 0.0 );
00496 };
00497
00498
00499
00500
00501
00502
00503
00504
00511 class CPL_DLL OGRCoordinateTransformation
00512 {
00513 public:
00514 virtual ~OGRCoordinateTransformation() {}
00515
00516
00517
00519 virtual OGRSpatialReference *GetSourceCS() = 0;
00520
00522 virtual OGRSpatialReference *GetTargetCS() = 0;
00523
00524
00525
00541 virtual int Transform( int nCount,
00542 double *x, double *y, double *z = NULL ) = 0;
00543
00559 virtual int TransformEx( int nCount,
00560 double *x, double *y, double *z = NULL,
00561 int *pabSuccess = NULL ) = 0;
00562
00563 };
00564
00565 OGRCoordinateTransformation CPL_DLL *
00566 OGRCreateCoordinateTransformation( OGRSpatialReference *poSource,
00567 OGRSpatialReference *poTarget );
00568
00569 #endif