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 #ifndef _OGR_SPATIALREF_H_INCLUDED
00085 #define _OGR_SPATIALREF_H_INCLUDED
00086
00087 #include "ogr_srs_api.h"
00088
00095
00096
00097
00098
00112 class CPL_DLL OGR_SRSNode
00113 {
00114 char *pszValue;
00115
00116 int nChildren;
00117 OGR_SRSNode **papoChildNodes;
00118
00119 OGR_SRSNode *poParent;
00120
00121 void ClearChildren();
00122 int NeedsQuoting() const;
00123
00124 public:
00125 OGR_SRSNode(const char * = NULL);
00126 ~OGR_SRSNode();
00127
00128 int IsLeafNode() const { return nChildren == 0; }
00129
00130 int GetChildCount() const { return nChildren; }
00131 OGR_SRSNode *GetChild( int );
00132 const OGR_SRSNode *GetChild( int ) const;
00133
00134 OGR_SRSNode *GetNode( const char * );
00135 const OGR_SRSNode *GetNode( const char * ) const;
00136
00137 void InsertChild( OGR_SRSNode *, int );
00138 void AddChild( OGR_SRSNode * );
00139 int FindChild( const char * ) const;
00140 void DestroyChild( int );
00141 void StripNodes( const char * );
00142
00143 const char *GetValue() const { return pszValue; }
00144 void SetValue( const char * );
00145
00146 void MakeValueSafe();
00147 OGRErr FixupOrdering();
00148
00149 OGR_SRSNode *Clone() const;
00150
00151 OGRErr importFromWkt( char ** );
00152 OGRErr exportToWkt( char ** ) const;
00153 OGRErr exportToPrettyWkt( char **, int = 1) const;
00154
00155 OGRErr applyRemapper( const char *pszNode,
00156 char **papszSrcValues,
00157 char **papszDstValues,
00158 int nStepSize = 1,
00159 int bChildOfHit = FALSE );
00160 };
00161
00162
00163
00164
00165
00180 class CPL_DLL OGRSpatialReference
00181 {
00182 int nRefCount;
00183
00184 OGR_SRSNode *poRoot;
00185
00186 int bNormInfoSet;
00187 double dfFromGreenwich;
00188 double dfToMeter;
00189 double dfToDegrees;
00190
00191 OGRErr ValidateProjection();
00192 int IsAliasFor( const char *, const char * );
00193 void GetNormInfo() const;
00194
00195 public:
00196 OGRSpatialReference(const OGRSpatialReference&);
00197 OGRSpatialReference(const char * = NULL);
00198
00199 virtual ~OGRSpatialReference();
00200
00201 OGRSpatialReference &operator=(const OGRSpatialReference&);
00202
00203 int Reference();
00204 int Dereference();
00205 int GetReferenceCount() const { return nRefCount; }
00206
00207 OGRSpatialReference *Clone() const;
00208 OGRSpatialReference *CloneGeogCS() const;
00209
00210 OGRErr exportToWkt( char ** );
00211 OGRErr exportToPrettyWkt( char **, int = FALSE) const;
00212 OGRErr exportToProj4( char ** ) const;
00213 OGRErr exportToPCI( char **, char **, double ** ) const;
00214 OGRErr exportToUSGS( long *, long *, double **, long * ) const;
00215 OGRErr exportToXML( char **, const char * = NULL ) const;
00216 OGRErr importFromWkt( char ** );
00217 OGRErr importFromProj4( const char * );
00218 OGRErr importFromEPSG( int );
00219 OGRErr importFromESRI( char ** );
00220 OGRErr importFromPCI( const char *pszProj,
00221 const char *pszUnits = NULL,
00222 double *padfPrjParams = NULL );
00223 OGRErr importFromUSGS( long iProjsys, long iZone,
00224 double *padfPrjParams, long iDatum );
00225 OGRErr importFromWMSAUTO( const char *pszAutoDef );
00226 OGRErr importFromXML( const char * );
00227 OGRErr importFromDict( const char *pszDict, const char *pszCode );
00228
00229 OGRErr morphToESRI();
00230 OGRErr morphFromESRI();
00231
00232 OGRErr Validate();
00233 OGRErr StripCTParms( OGR_SRSNode * = NULL );
00234 OGRErr FixupOrdering();
00235 OGRErr Fixup();
00236
00237
00238 OGR_SRSNode *GetRoot() { return poRoot; }
00239 const OGR_SRSNode *GetRoot() const { return poRoot; }
00240 void SetRoot( OGR_SRSNode * );
00241
00242 OGR_SRSNode *GetAttrNode(const char *);
00243 const OGR_SRSNode *GetAttrNode(const char *) const;
00244 const char *GetAttrValue(const char *, int = 0) const;
00245
00246 OGRErr SetNode( const char *, const char * );
00247 OGRErr SetNode( const char *, double );
00248
00249 OGRErr SetLinearUnits( const char *pszName, double dfInMeters );
00250 double GetLinearUnits( char ** = NULL ) const;
00251
00252 OGRErr SetAngularUnits( const char *pszName, double dfInRadians );
00253 double GetAngularUnits( char ** = NULL ) const;
00254
00255 double GetPrimeMeridian( char ** = NULL ) const;
00256
00257 int IsGeographic() const;
00258 int IsProjected() const;
00259 int IsLocal() const;
00260 int IsSameGeogCS( const OGRSpatialReference * ) const;
00261 int IsSame( const OGRSpatialReference * ) const;
00262
00263 void Clear();
00264 OGRErr SetLocalCS( const char * );
00265 OGRErr SetProjCS( const char * );
00266 OGRErr SetProjection( const char * );
00267 OGRErr SetGeogCS( const char * pszGeogName,
00268 const char * pszDatumName,
00269 const char * pszEllipsoidName,
00270 double dfSemiMajor, double dfInvFlattening,
00271 const char * pszPMName = NULL,
00272 double dfPMOffset = 0.0,
00273 const char * pszUnits = NULL,
00274 double dfConvertToRadians = 0.0 );
00275 OGRErr SetWellKnownGeogCS( const char * );
00276 OGRErr CopyGeogCSFrom( const OGRSpatialReference * poSrcSRS );
00277
00278 OGRErr SetFromUserInput( const char * );
00279
00280 OGRErr SetTOWGS84( double, double, double,
00281 double = 0.0, double = 0.0, double = 0.0,
00282 double = 0.0 );
00283 OGRErr GetTOWGS84( double *padfCoef, int nCoeff = 7 ) const;
00284
00285 double GetSemiMajor( OGRErr * = NULL ) const;
00286 double GetSemiMinor( OGRErr * = NULL ) const;
00287 double GetInvFlattening( OGRErr * = NULL ) const;
00288
00289 OGRErr SetAuthority( const char * pszTargetKey,
00290 const char * pszAuthority,
00291 int nCode );
00292
00293 OGRErr AutoIdentifyEPSG();
00294
00295 const char *GetAuthorityCode( const char * pszTargetKey ) const;
00296 const char *GetAuthorityName( const char * pszTargetKey ) const;
00297
00298 OGRErr SetProjParm( const char *, double );
00299 double GetProjParm( const char *, double =0.0, OGRErr* = NULL ) const;
00300
00301 OGRErr SetNormProjParm( const char *, double );
00302 double GetNormProjParm( const char *, double=0.0, OGRErr* =NULL)const;
00303
00304 static int IsAngularParameter( const char * );
00305 static int IsLongitudeParameter( const char * );
00306 static int IsLinearParameter( const char * );
00307
00309 OGRErr SetACEA( double dfStdP1, double dfStdP2,
00310 double dfCenterLat, double dfCenterLong,
00311 double dfFalseEasting, double dfFalseNorthing );
00312
00314 OGRErr SetAE( double dfCenterLat, double dfCenterLong,
00315 double dfFalseEasting, double dfFalseNorthing );
00316
00318 OGRErr SetBonne( double dfStdP1, double dfCentralMeridian,
00319 double dfFalseEasting, double dfFalseNorthing );
00320
00322 OGRErr SetCEA( double dfStdP1, double dfCentralMeridian,
00323 double dfFalseEasting, double dfFalseNorthing );
00324
00326 OGRErr SetCS( double dfCenterLat, double dfCenterLong,
00327 double dfFalseEasting, double dfFalseNorthing );
00328
00330 OGRErr SetEC( double dfStdP1, double dfStdP2,
00331 double dfCenterLat, double dfCenterLong,
00332 double dfFalseEasting, double dfFalseNorthing );
00333
00335 OGRErr SetEckertIV( double dfCentralMeridian,
00336 double dfFalseEasting, double dfFalseNorthing );
00337
00339 OGRErr SetEckertVI( double dfCentralMeridian,
00340 double dfFalseEasting, double dfFalseNorthing );
00341
00343 OGRErr SetEquirectangular(double dfCenterLat, double dfCenterLong,
00344 double dfFalseEasting, double dfFalseNorthing );
00345
00347 OGRErr SetGS( double dfCentralMeridian,
00348 double dfFalseEasting, double dfFalseNorthing );
00349
00351 OGRErr SetGnomonic(double dfCenterLat, double dfCenterLong,
00352 double dfFalseEasting, double dfFalseNorthing );
00353
00354 OGRErr SetHOM( double dfCenterLat, double dfCenterLong,
00355 double dfAzimuth, double dfRectToSkew,
00356 double dfScale,
00357 double dfFalseEasting, double dfFalseNorthing );
00358
00359 OGRErr SetHOM2PNO( double dfCenterLat,
00360 double dfLat1, double dfLong1,
00361 double dfLat2, double dfLong2,
00362 double dfScale,
00363 double dfFalseEasting, double dfFalseNorthing );
00364
00366 OGRErr SetKrovak( double dfCenterLat, double dfCenterLong,
00367 double dfAzimuth, double dfPseudoStdParallelLat,
00368 double dfScale,
00369 double dfFalseEasting, double dfFalseNorthing );
00370
00372 OGRErr SetLAEA( double dfCenterLat, double dfCenterLong,
00373 double dfFalseEasting, double dfFalseNorthing );
00374
00376 OGRErr SetLCC( double dfStdP1, double dfStdP2,
00377 double dfCenterLat, double dfCenterLong,
00378 double dfFalseEasting, double dfFalseNorthing );
00379
00381 OGRErr SetLCC1SP( double dfCenterLat, double dfCenterLong,
00382 double dfScale,
00383 double dfFalseEasting, double dfFalseNorthing );
00384
00386 OGRErr SetLCCB( double dfStdP1, double dfStdP2,
00387 double dfCenterLat, double dfCenterLong,
00388 double dfFalseEasting, double dfFalseNorthing );
00389
00391 OGRErr SetMC( double dfCenterLat, double dfCenterLong,
00392 double dfFalseEasting, double dfFalseNorthing );
00393
00395 OGRErr SetMercator( double dfCenterLat, double dfCenterLong,
00396 double dfScale,
00397 double dfFalseEasting, double dfFalseNorthing );
00398
00400 OGRErr SetMollweide( double dfCentralMeridian,
00401 double dfFalseEasting, double dfFalseNorthing );
00402
00404 OGRErr SetNZMG( double dfCenterLat, double dfCenterLong,
00405 double dfFalseEasting, double dfFalseNorthing );
00406
00408 OGRErr SetOS( double dfOriginLat, double dfCMeridian,
00409 double dfScale,
00410 double dfFalseEasting,double dfFalseNorthing);
00411
00413 OGRErr SetOrthographic( double dfCenterLat, double dfCenterLong,
00414 double dfFalseEasting,double dfFalseNorthing);
00415
00417 OGRErr SetPolyconic( double dfCenterLat, double dfCenterLong,
00418 double dfFalseEasting, double dfFalseNorthing );
00419
00421 OGRErr SetPS( double dfCenterLat, double dfCenterLong,
00422 double dfScale,
00423 double dfFalseEasting, double dfFalseNorthing);
00424
00426 OGRErr SetRobinson( double dfCenterLong,
00427 double dfFalseEasting, double dfFalseNorthing );
00428
00430 OGRErr SetSinusoidal( double dfCenterLong,
00431 double dfFalseEasting, double dfFalseNorthing );
00432
00434 OGRErr SetStereographic( double dfCenterLat, double dfCenterLong,
00435 double dfScale,
00436 double dfFalseEasting,double dfFalseNorthing);
00437
00439 OGRErr SetSOC( double dfLatitudeOfOrigin, double dfCentralMeridian,
00440 double dfFalseEasting, double dfFalseNorthing );
00441
00443 OGRErr SetTM( double dfCenterLat, double dfCenterLong,
00444 double dfScale,
00445 double dfFalseEasting, double dfFalseNorthing );
00446
00448 OGRErr SetTMVariant( const char *pszVariantName,
00449 double dfCenterLat, double dfCenterLong,
00450 double dfScale,
00451 double dfFalseEasting, double dfFalseNorthing );
00452
00454 OGRErr SetTMG( double dfCenterLat, double dfCenterLong,
00455 double dfFalseEasting, double dfFalseNorthing );
00456
00458 OGRErr SetTMSO( double dfCenterLat, double dfCenterLong,
00459 double dfScale,
00460 double dfFalseEasting, double dfFalseNorthing );
00461
00463 OGRErr SetVDG( double dfCenterLong,
00464 double dfFalseEasting, double dfFalseNorthing );
00465
00467 OGRErr SetUTM( int nZone, int bNorth = TRUE );
00468 int GetUTMZone( int *pbNorth = NULL ) const;
00469
00471 OGRErr SetStatePlane( int nZone, int bNAD83 = TRUE,
00472 const char *pszOverrideUnitName = NULL,
00473 double dfOverrideUnit = 0.0 );
00474 };
00475
00476
00477
00478
00479
00480
00481
00482
00489 class CPL_DLL OGRCoordinateTransformation
00490 {
00491 public:
00492 virtual ~OGRCoordinateTransformation() {}
00493
00494
00495
00497 virtual OGRSpatialReference *GetSourceCS() = 0;
00498
00500 virtual OGRSpatialReference *GetTargetCS() = 0;
00501
00502
00503
00519 virtual int Transform( int nCount,
00520 double *x, double *y, double *z = NULL ) = 0;
00521
00537 virtual int TransformEx( int nCount,
00538 double *x, double *y, double *z = NULL,
00539 int *pabSuccess = NULL ) = 0;
00540
00541 };
00542
00543 OGRCoordinateTransformation CPL_DLL *
00544 OGRCreateCoordinateTransformation( OGRSpatialReference *poSource,
00545 OGRSpatialReference *poTarget );
00546
00547 #endif