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 #ifndef _OGR_SPATIALREF_H_INCLUDED
00032 #define _OGR_SPATIALREF_H_INCLUDED
00033
00034 #include "ogr_srs_api.h"
00035
00042
00043
00044
00045
00059 class CPL_DLL OGR_SRSNode
00060 {
00061 char *pszValue;
00062
00063 OGR_SRSNode **papoChildNodes;
00064 OGR_SRSNode *poParent;
00065
00066 int nChildren;
00067
00068 void ClearChildren();
00069 int NeedsQuoting() const;
00070
00071 public:
00072 OGR_SRSNode(const char * = NULL);
00073 ~OGR_SRSNode();
00074
00075 int IsLeafNode() const { return nChildren == 0; }
00076
00077 int GetChildCount() const { return nChildren; }
00078 OGR_SRSNode *GetChild( int );
00079 const OGR_SRSNode *GetChild( int ) const;
00080
00081 OGR_SRSNode *GetNode( const char * );
00082 const OGR_SRSNode *GetNode( const char * ) const;
00083
00084 void InsertChild( OGR_SRSNode *, int );
00085 void AddChild( OGR_SRSNode * );
00086 int FindChild( const char * ) const;
00087 void DestroyChild( int );
00088 void StripNodes( const char * );
00089
00090 const char *GetValue() const { return pszValue; }
00091 void SetValue( const char * );
00092
00093 void MakeValueSafe();
00094 OGRErr FixupOrdering();
00095
00096 OGR_SRSNode *Clone() const;
00097
00098 OGRErr importFromWkt( char ** );
00099 OGRErr exportToWkt( char ** ) const;
00100 OGRErr exportToPrettyWkt( char **, int = 1) const;
00101
00102 OGRErr applyRemapper( const char *pszNode,
00103 char **papszSrcValues,
00104 char **papszDstValues,
00105 int nStepSize = 1,
00106 int bChildOfHit = FALSE );
00107 };
00108
00109
00110
00111
00112
00127 class CPL_DLL OGRSpatialReference
00128 {
00129 double dfFromGreenwich;
00130 double dfToMeter;
00131 double dfToDegrees;
00132
00133 OGR_SRSNode *poRoot;
00134
00135 int nRefCount;
00136 int bNormInfoSet;
00137
00138 OGRErr ValidateProjection();
00139 int IsAliasFor( const char *, const char * );
00140 void GetNormInfo() const;
00141
00142 public:
00143 OGRSpatialReference(const OGRSpatialReference&);
00144 OGRSpatialReference(const char * = NULL);
00145
00146 virtual ~OGRSpatialReference();
00147
00148 OGRSpatialReference &operator=(const OGRSpatialReference&);
00149
00150 int Reference();
00151 int Dereference();
00152 int GetReferenceCount() const { return nRefCount; }
00153 void Release();
00154
00155 OGRSpatialReference *Clone() const;
00156 OGRSpatialReference *CloneGeogCS() const;
00157
00158 OGRErr exportToWkt( char ** ) const;
00159 OGRErr exportToPrettyWkt( char **, int = FALSE) const;
00160 OGRErr exportToProj4( char ** ) const;
00161 OGRErr exportToPCI( char **, char **, double ** ) const;
00162 OGRErr exportToUSGS( long *, long *, double **, long * ) const;
00163 OGRErr exportToXML( char **, const char * = NULL ) const;
00164 OGRErr exportToPanorama( long *, long *, long *, long *,
00165 double * ) const;
00166 OGRErr exportToERM( char *pszProj, char *pszDatum, char *pszUnits );
00167
00168 OGRErr importFromWkt( char ** );
00169 OGRErr importFromProj4( const char * );
00170 OGRErr importFromEPSG( int );
00171 OGRErr importFromESRI( char ** );
00172 OGRErr importFromPCI( const char *, const char * = NULL,
00173 double * = NULL );
00174 OGRErr importFromUSGS( long, long, double *, long );
00175 OGRErr importFromPanorama( long, long, long, double* );
00176 OGRErr importFromWMSAUTO( const char *pszAutoDef );
00177 OGRErr importFromXML( const char * );
00178 OGRErr importFromDict( const char *pszDict, const char *pszCode );
00179 OGRErr importFromURN( const char * );
00180 OGRErr importFromERM( const char *pszProj, const char *pszDatum,
00181 const char *pszUnits );
00182 OGRErr importFromUrl( const char * );
00183
00184 OGRErr morphToESRI();
00185 OGRErr morphFromESRI();
00186
00187 OGRErr Validate();
00188 OGRErr StripCTParms( OGR_SRSNode * = NULL );
00189 OGRErr FixupOrdering();
00190 OGRErr Fixup();
00191
00192
00193 OGR_SRSNode *GetRoot() { return poRoot; }
00194 const OGR_SRSNode *GetRoot() const { return poRoot; }
00195 void SetRoot( OGR_SRSNode * );
00196
00197 OGR_SRSNode *GetAttrNode(const char *);
00198 const OGR_SRSNode *GetAttrNode(const char *) const;
00199 const char *GetAttrValue(const char *, int = 0) const;
00200
00201 OGRErr SetNode( const char *, const char * );
00202 OGRErr SetNode( const char *, double );
00203
00204 OGRErr SetLinearUnitsAndUpdateParameters( const char *pszName,
00205 double dfInMeters );
00206 OGRErr SetLinearUnits( const char *pszName, double dfInMeters );
00207 double GetLinearUnits( char ** = NULL ) const;
00208
00209 OGRErr SetAngularUnits( const char *pszName, double dfInRadians );
00210 double GetAngularUnits( char ** = NULL ) const;
00211
00212 double GetPrimeMeridian( char ** = NULL ) const;
00213
00214 int IsGeographic() const;
00215 int IsProjected() const;
00216 int IsLocal() const;
00217 int IsSameGeogCS( const OGRSpatialReference * ) const;
00218 int IsSame( const OGRSpatialReference * ) const;
00219
00220 void Clear();
00221 OGRErr SetLocalCS( const char * );
00222 OGRErr SetProjCS( const char * );
00223 OGRErr SetProjection( const char * );
00224 OGRErr SetGeogCS( const char * pszGeogName,
00225 const char * pszDatumName,
00226 const char * pszEllipsoidName,
00227 double dfSemiMajor, double dfInvFlattening,
00228 const char * pszPMName = NULL,
00229 double dfPMOffset = 0.0,
00230 const char * pszUnits = NULL,
00231 double dfConvertToRadians = 0.0 );
00232 OGRErr SetWellKnownGeogCS( const char * );
00233 OGRErr CopyGeogCSFrom( const OGRSpatialReference * poSrcSRS );
00234
00235 OGRErr SetFromUserInput( const char * );
00236
00237 OGRErr SetTOWGS84( double, double, double,
00238 double = 0.0, double = 0.0, double = 0.0,
00239 double = 0.0 );
00240 OGRErr GetTOWGS84( double *padfCoef, int nCoeff = 7 ) const;
00241
00242 double GetSemiMajor( OGRErr * = NULL ) const;
00243 double GetSemiMinor( OGRErr * = NULL ) const;
00244 double GetInvFlattening( OGRErr * = NULL ) const;
00245
00246 OGRErr SetAuthority( const char * pszTargetKey,
00247 const char * pszAuthority,
00248 int nCode );
00249
00250 OGRErr AutoIdentifyEPSG();
00251 int GetEPSGGeogCS();
00252
00253 const char *GetAuthorityCode( const char * pszTargetKey ) const;
00254 const char *GetAuthorityName( const char * pszTargetKey ) const;
00255
00256 const char *GetExtension( const char *pszTargetKey,
00257 const char *pszName,
00258 const char *pszDefault = NULL ) const;
00259 OGRErr SetExtension( const char *pszTargetKey,
00260 const char *pszName,
00261 const char *pszValue );
00262
00263 int FindProjParm( const char *pszParameter,
00264 const OGR_SRSNode *poPROJCS=NULL ) const;
00265 OGRErr SetProjParm( const char *, double );
00266 double GetProjParm( const char *, double =0.0, OGRErr* = NULL ) const;
00267
00268 OGRErr SetNormProjParm( const char *, double );
00269 double GetNormProjParm( const char *, double=0.0, OGRErr* =NULL)const;
00270
00271 static int IsAngularParameter( const char * );
00272 static int IsLongitudeParameter( const char * );
00273 static int IsLinearParameter( const char * );
00274
00276 OGRErr SetACEA( double dfStdP1, double dfStdP2,
00277 double dfCenterLat, double dfCenterLong,
00278 double dfFalseEasting, double dfFalseNorthing );
00279
00281 OGRErr SetAE( double dfCenterLat, double dfCenterLong,
00282 double dfFalseEasting, double dfFalseNorthing );
00283
00285 OGRErr SetBonne( double dfStdP1, double dfCentralMeridian,
00286 double dfFalseEasting, double dfFalseNorthing );
00287
00289 OGRErr SetCEA( double dfStdP1, double dfCentralMeridian,
00290 double dfFalseEasting, double dfFalseNorthing );
00291
00293 OGRErr SetCS( double dfCenterLat, double dfCenterLong,
00294 double dfFalseEasting, double dfFalseNorthing );
00295
00297 OGRErr SetEC( double dfStdP1, double dfStdP2,
00298 double dfCenterLat, double dfCenterLong,
00299 double dfFalseEasting, double dfFalseNorthing );
00300
00302 OGRErr SetEckert( int nVariation, double dfCentralMeridian,
00303 double dfFalseEasting, double dfFalseNorthing );
00304
00305 OGRErr SetEckertIV( double dfCentralMeridian,
00306 double dfFalseEasting, double dfFalseNorthing );
00307
00308 OGRErr SetEckertVI( double dfCentralMeridian,
00309 double dfFalseEasting, double dfFalseNorthing );
00310
00312 OGRErr SetEquirectangular(double dfCenterLat, double dfCenterLong,
00313 double dfFalseEasting, double dfFalseNorthing );
00314
00316 OGRErr SetGEOS( double dfCentralMeridian, double dfSatelliteHeight,
00317 double dfFalseEasting, double dfFalseNorthing );
00318
00320 OGRErr SetGH( double dfCentralMeridian,
00321 double dfFalseEasting, double dfFalseNorthing );
00322
00324 OGRErr SetGS( double dfCentralMeridian,
00325 double dfFalseEasting, double dfFalseNorthing );
00326
00328 OGRErr SetGnomonic(double dfCenterLat, double dfCenterLong,
00329 double dfFalseEasting, double dfFalseNorthing );
00330
00331 OGRErr SetHOM( double dfCenterLat, double dfCenterLong,
00332 double dfAzimuth, double dfRectToSkew,
00333 double dfScale,
00334 double dfFalseEasting, double dfFalseNorthing );
00335
00336 OGRErr SetHOM2PNO( double dfCenterLat,
00337 double dfLat1, double dfLong1,
00338 double dfLat2, double dfLong2,
00339 double dfScale,
00340 double dfFalseEasting, double dfFalseNorthing );
00341
00343 OGRErr SetKrovak( double dfCenterLat, double dfCenterLong,
00344 double dfAzimuth, double dfPseudoStdParallelLat,
00345 double dfScale,
00346 double dfFalseEasting, double dfFalseNorthing );
00347
00349 OGRErr SetLAEA( double dfCenterLat, double dfCenterLong,
00350 double dfFalseEasting, double dfFalseNorthing );
00351
00353 OGRErr SetLCC( double dfStdP1, double dfStdP2,
00354 double dfCenterLat, double dfCenterLong,
00355 double dfFalseEasting, double dfFalseNorthing );
00356
00358 OGRErr SetLCC1SP( double dfCenterLat, double dfCenterLong,
00359 double dfScale,
00360 double dfFalseEasting, double dfFalseNorthing );
00361
00363 OGRErr SetLCCB( double dfStdP1, double dfStdP2,
00364 double dfCenterLat, double dfCenterLong,
00365 double dfFalseEasting, double dfFalseNorthing );
00366
00368 OGRErr SetMC( double dfCenterLat, double dfCenterLong,
00369 double dfFalseEasting, double dfFalseNorthing );
00370
00372 OGRErr SetMercator( double dfCenterLat, double dfCenterLong,
00373 double dfScale,
00374 double dfFalseEasting, double dfFalseNorthing );
00375
00376 OGRErr SetMercator2SP( double dfStdP1,
00377 double dfCenterLat, double dfCenterLong,
00378 double dfFalseEasting, double dfFalseNorthing );
00379
00381 OGRErr SetMollweide( double dfCentralMeridian,
00382 double dfFalseEasting, double dfFalseNorthing );
00383
00385 OGRErr SetNZMG( double dfCenterLat, double dfCenterLong,
00386 double dfFalseEasting, double dfFalseNorthing );
00387
00389 OGRErr SetOS( double dfOriginLat, double dfCMeridian,
00390 double dfScale,
00391 double dfFalseEasting,double dfFalseNorthing);
00392
00394 OGRErr SetOrthographic( double dfCenterLat, double dfCenterLong,
00395 double dfFalseEasting,double dfFalseNorthing);
00396
00398 OGRErr SetPolyconic( double dfCenterLat, double dfCenterLong,
00399 double dfFalseEasting, double dfFalseNorthing );
00400
00402 OGRErr SetPS( double dfCenterLat, double dfCenterLong,
00403 double dfScale,
00404 double dfFalseEasting, double dfFalseNorthing);
00405
00407 OGRErr SetRobinson( double dfCenterLong,
00408 double dfFalseEasting, double dfFalseNorthing );
00409
00411 OGRErr SetSinusoidal( double dfCenterLong,
00412 double dfFalseEasting, double dfFalseNorthing );
00413
00415 OGRErr SetStereographic( double dfCenterLat, double dfCenterLong,
00416 double dfScale,
00417 double dfFalseEasting,double dfFalseNorthing);
00418
00420 OGRErr SetSOC( double dfLatitudeOfOrigin, double dfCentralMeridian,
00421 double dfFalseEasting, double dfFalseNorthing );
00422
00424 OGRErr SetTM( double dfCenterLat, double dfCenterLong,
00425 double dfScale,
00426 double dfFalseEasting, double dfFalseNorthing );
00427
00429 OGRErr SetTMVariant( const char *pszVariantName,
00430 double dfCenterLat, double dfCenterLong,
00431 double dfScale,
00432 double dfFalseEasting, double dfFalseNorthing );
00433
00435 OGRErr SetTMG( double dfCenterLat, double dfCenterLong,
00436 double dfFalseEasting, double dfFalseNorthing );
00437
00439 OGRErr SetTMSO( double dfCenterLat, double dfCenterLong,
00440 double dfScale,
00441 double dfFalseEasting, double dfFalseNorthing );
00442
00444 OGRErr SetTPED( double dfLat1, double dfLong1,
00445 double dfLat2, double dfLong2,
00446 double dfFalseEasting, double dfFalseNorthing );
00447
00449 OGRErr SetVDG( double dfCenterLong,
00450 double dfFalseEasting, double dfFalseNorthing );
00451
00453 OGRErr SetUTM( int nZone, int bNorth = TRUE );
00454 int GetUTMZone( int *pbNorth = NULL ) const;
00455
00457 OGRErr SetStatePlane( int nZone, int bNAD83 = TRUE,
00458 const char *pszOverrideUnitName = NULL,
00459 double dfOverrideUnit = 0.0 );
00460 };
00461
00462
00463
00464
00465
00466
00467
00468
00475 class CPL_DLL OGRCoordinateTransformation
00476 {
00477 public:
00478 virtual ~OGRCoordinateTransformation() {}
00479
00480
00481
00483 virtual OGRSpatialReference *GetSourceCS() = 0;
00484
00486 virtual OGRSpatialReference *GetTargetCS() = 0;
00487
00488
00489
00505 virtual int Transform( int nCount,
00506 double *x, double *y, double *z = NULL ) = 0;
00507
00523 virtual int TransformEx( int nCount,
00524 double *x, double *y, double *z = NULL,
00525 int *pabSuccess = NULL ) = 0;
00526
00527 };
00528
00529 OGRCoordinateTransformation CPL_DLL *
00530 OGRCreateCoordinateTransformation( OGRSpatialReference *poSource,
00531 OGRSpatialReference *poTarget );
00532
00533 #endif