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 OGRErr exportToMICoordSys( char ** ) const;
00168
00169 OGRErr importFromWkt( char ** );
00170 OGRErr importFromProj4( const char * );
00171 OGRErr importFromEPSG( int );
00172 OGRErr importFromEPSGA( int );
00173 OGRErr importFromESRI( char ** );
00174 OGRErr importFromPCI( const char *, const char * = NULL,
00175 double * = NULL );
00176 OGRErr importFromUSGS( long iProjSys, long iZone,
00177 double *padfPrjParams,
00178 long iDatum, int bAnglesInPackedDMSFormat = TRUE );
00179 OGRErr importFromPanorama( long, long, long, double* );
00180 OGRErr importFromWMSAUTO( const char *pszAutoDef );
00181 OGRErr importFromXML( const char * );
00182 OGRErr importFromDict( const char *pszDict, const char *pszCode );
00183 OGRErr importFromURN( const char * );
00184 OGRErr importFromERM( const char *pszProj, const char *pszDatum,
00185 const char *pszUnits );
00186 OGRErr importFromUrl( const char * );
00187 OGRErr importFromMICoordSys( const char * );
00188
00189 OGRErr morphToESRI();
00190 OGRErr morphFromESRI();
00191
00192 OGRErr Validate();
00193 OGRErr StripCTParms( OGR_SRSNode * = NULL );
00194 OGRErr FixupOrdering();
00195 OGRErr Fixup();
00196
00197 int EPSGTreatsAsLatLong();
00198 const char *GetAxis( const char *pszTargetKey, int iAxis,
00199 OGRAxisOrientation *peOrientation );
00200 OGRErr SetAxes( const char *pszTargetKey,
00201 const char *pszXAxisName,
00202 OGRAxisOrientation eXAxisOrientation,
00203 const char *pszYAxisName,
00204 OGRAxisOrientation eYAxisOrientation );
00205
00206
00207 OGR_SRSNode *GetRoot() { return poRoot; }
00208 const OGR_SRSNode *GetRoot() const { return poRoot; }
00209 void SetRoot( OGR_SRSNode * );
00210
00211 OGR_SRSNode *GetAttrNode(const char *);
00212 const OGR_SRSNode *GetAttrNode(const char *) const;
00213 const char *GetAttrValue(const char *, int = 0) const;
00214
00215 OGRErr SetNode( const char *, const char * );
00216 OGRErr SetNode( const char *, double );
00217
00218 OGRErr SetLinearUnitsAndUpdateParameters( const char *pszName,
00219 double dfInMeters );
00220 OGRErr SetLinearUnits( const char *pszName, double dfInMeters );
00221 double GetLinearUnits( char ** = NULL ) const;
00222
00223 OGRErr SetAngularUnits( const char *pszName, double dfInRadians );
00224 double GetAngularUnits( char ** = NULL ) const;
00225
00226 double GetPrimeMeridian( char ** = NULL ) const;
00227
00228 int IsGeographic() const;
00229 int IsProjected() const;
00230 int IsLocal() const;
00231 int IsSameGeogCS( const OGRSpatialReference * ) const;
00232 int IsSame( const OGRSpatialReference * ) const;
00233
00234 void Clear();
00235 OGRErr SetLocalCS( const char * );
00236 OGRErr SetProjCS( const char * );
00237 OGRErr SetProjection( const char * );
00238 OGRErr SetGeogCS( const char * pszGeogName,
00239 const char * pszDatumName,
00240 const char * pszEllipsoidName,
00241 double dfSemiMajor, double dfInvFlattening,
00242 const char * pszPMName = NULL,
00243 double dfPMOffset = 0.0,
00244 const char * pszUnits = NULL,
00245 double dfConvertToRadians = 0.0 );
00246 OGRErr SetWellKnownGeogCS( const char * );
00247 OGRErr CopyGeogCSFrom( const OGRSpatialReference * poSrcSRS );
00248
00249 OGRErr SetFromUserInput( const char * );
00250
00251 OGRErr SetTOWGS84( double, double, double,
00252 double = 0.0, double = 0.0, double = 0.0,
00253 double = 0.0 );
00254 OGRErr GetTOWGS84( double *padfCoef, int nCoeff = 7 ) const;
00255
00256 double GetSemiMajor( OGRErr * = NULL ) const;
00257 double GetSemiMinor( OGRErr * = NULL ) const;
00258 double GetInvFlattening( OGRErr * = NULL ) const;
00259
00260 OGRErr SetAuthority( const char * pszTargetKey,
00261 const char * pszAuthority,
00262 int nCode );
00263
00264 OGRErr AutoIdentifyEPSG();
00265 int GetEPSGGeogCS();
00266
00267 const char *GetAuthorityCode( const char * pszTargetKey ) const;
00268 const char *GetAuthorityName( const char * pszTargetKey ) const;
00269
00270 const char *GetExtension( const char *pszTargetKey,
00271 const char *pszName,
00272 const char *pszDefault = NULL ) const;
00273 OGRErr SetExtension( const char *pszTargetKey,
00274 const char *pszName,
00275 const char *pszValue );
00276
00277 int FindProjParm( const char *pszParameter,
00278 const OGR_SRSNode *poPROJCS=NULL ) const;
00279 OGRErr SetProjParm( const char *, double );
00280 double GetProjParm( const char *, double =0.0, OGRErr* = NULL ) const;
00281
00282 OGRErr SetNormProjParm( const char *, double );
00283 double GetNormProjParm( const char *, double=0.0, OGRErr* =NULL)const;
00284
00285 static int IsAngularParameter( const char * );
00286 static int IsLongitudeParameter( const char * );
00287 static int IsLinearParameter( const char * );
00288
00290 OGRErr SetACEA( double dfStdP1, double dfStdP2,
00291 double dfCenterLat, double dfCenterLong,
00292 double dfFalseEasting, double dfFalseNorthing );
00293
00295 OGRErr SetAE( double dfCenterLat, double dfCenterLong,
00296 double dfFalseEasting, double dfFalseNorthing );
00297
00299 OGRErr SetBonne( double dfStdP1, double dfCentralMeridian,
00300 double dfFalseEasting, double dfFalseNorthing );
00301
00303 OGRErr SetCEA( double dfStdP1, double dfCentralMeridian,
00304 double dfFalseEasting, double dfFalseNorthing );
00305
00307 OGRErr SetCS( double dfCenterLat, double dfCenterLong,
00308 double dfFalseEasting, double dfFalseNorthing );
00309
00311 OGRErr SetEC( double dfStdP1, double dfStdP2,
00312 double dfCenterLat, double dfCenterLong,
00313 double dfFalseEasting, double dfFalseNorthing );
00314
00316 OGRErr SetEckert( int nVariation, double dfCentralMeridian,
00317 double dfFalseEasting, double dfFalseNorthing );
00318
00319 OGRErr SetEckertIV( double dfCentralMeridian,
00320 double dfFalseEasting, double dfFalseNorthing );
00321
00322 OGRErr SetEckertVI( double dfCentralMeridian,
00323 double dfFalseEasting, double dfFalseNorthing );
00324
00326 OGRErr SetEquirectangular(double dfCenterLat, double dfCenterLong,
00327 double dfFalseEasting, double dfFalseNorthing );
00329 OGRErr SetEquirectangular2( double dfCenterLat, double dfCenterLong,
00330 double dfPseudoStdParallel1,
00331 double dfFalseEasting, double dfFalseNorthing );
00332
00334 OGRErr SetGEOS( double dfCentralMeridian, double dfSatelliteHeight,
00335 double dfFalseEasting, double dfFalseNorthing );
00336
00338 OGRErr SetGH( double dfCentralMeridian,
00339 double dfFalseEasting, double dfFalseNorthing );
00340
00342 OGRErr SetGS( double dfCentralMeridian,
00343 double dfFalseEasting, double dfFalseNorthing );
00344
00346 OGRErr SetGaussSchreiberTMercator(double dfCenterLat, double dfCenterLong,
00347 double dfScale,
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 SetIWMPolyconic( double dfLat1, double dfLat2,
00367 double dfCenterLong,
00368 double dfFalseEasting,
00369 double dfFalseNorthing );
00370
00372 OGRErr SetKrovak( double dfCenterLat, double dfCenterLong,
00373 double dfAzimuth, double dfPseudoStdParallelLat,
00374 double dfScale,
00375 double dfFalseEasting, double dfFalseNorthing );
00376
00378 OGRErr SetLAEA( double dfCenterLat, double dfCenterLong,
00379 double dfFalseEasting, double dfFalseNorthing );
00380
00382 OGRErr SetLCC( double dfStdP1, double dfStdP2,
00383 double dfCenterLat, double dfCenterLong,
00384 double dfFalseEasting, double dfFalseNorthing );
00385
00387 OGRErr SetLCC1SP( double dfCenterLat, double dfCenterLong,
00388 double dfScale,
00389 double dfFalseEasting, double dfFalseNorthing );
00390
00392 OGRErr SetLCCB( double dfStdP1, double dfStdP2,
00393 double dfCenterLat, double dfCenterLong,
00394 double dfFalseEasting, double dfFalseNorthing );
00395
00397 OGRErr SetMC( double dfCenterLat, double dfCenterLong,
00398 double dfFalseEasting, double dfFalseNorthing );
00399
00401 OGRErr SetMercator( double dfCenterLat, double dfCenterLong,
00402 double dfScale,
00403 double dfFalseEasting, double dfFalseNorthing );
00404
00405 OGRErr SetMercator2SP( double dfStdP1,
00406 double dfCenterLat, double dfCenterLong,
00407 double dfFalseEasting, double dfFalseNorthing );
00408
00410 OGRErr SetMollweide( double dfCentralMeridian,
00411 double dfFalseEasting, double dfFalseNorthing );
00412
00414 OGRErr SetNZMG( double dfCenterLat, double dfCenterLong,
00415 double dfFalseEasting, double dfFalseNorthing );
00416
00418 OGRErr SetOS( double dfOriginLat, double dfCMeridian,
00419 double dfScale,
00420 double dfFalseEasting,double dfFalseNorthing);
00421
00423 OGRErr SetOrthographic( double dfCenterLat, double dfCenterLong,
00424 double dfFalseEasting,double dfFalseNorthing);
00425
00427 OGRErr SetPolyconic( double dfCenterLat, double dfCenterLong,
00428 double dfFalseEasting, double dfFalseNorthing );
00429
00431 OGRErr SetPS( double dfCenterLat, double dfCenterLong,
00432 double dfScale,
00433 double dfFalseEasting, double dfFalseNorthing);
00434
00436 OGRErr SetRobinson( double dfCenterLong,
00437 double dfFalseEasting, double dfFalseNorthing );
00438
00440 OGRErr SetSinusoidal( double dfCenterLong,
00441 double dfFalseEasting, double dfFalseNorthing );
00442
00444 OGRErr SetStereographic( double dfCenterLat, double dfCenterLong,
00445 double dfScale,
00446 double dfFalseEasting,double dfFalseNorthing);
00447
00449 OGRErr SetSOC( double dfLatitudeOfOrigin, double dfCentralMeridian,
00450 double dfFalseEasting, double dfFalseNorthing );
00451
00453 OGRErr SetTM( double dfCenterLat, double dfCenterLong,
00454 double dfScale,
00455 double dfFalseEasting, double dfFalseNorthing );
00456
00458 OGRErr SetTMVariant( const char *pszVariantName,
00459 double dfCenterLat, double dfCenterLong,
00460 double dfScale,
00461 double dfFalseEasting, double dfFalseNorthing );
00462
00464 OGRErr SetTMG( double dfCenterLat, double dfCenterLong,
00465 double dfFalseEasting, double dfFalseNorthing );
00466
00468 OGRErr SetTMSO( double dfCenterLat, double dfCenterLong,
00469 double dfScale,
00470 double dfFalseEasting, double dfFalseNorthing );
00471
00473 OGRErr SetTPED( double dfLat1, double dfLong1,
00474 double dfLat2, double dfLong2,
00475 double dfFalseEasting, double dfFalseNorthing );
00476
00478 OGRErr SetVDG( double dfCenterLong,
00479 double dfFalseEasting, double dfFalseNorthing );
00480
00482 OGRErr SetUTM( int nZone, int bNorth = TRUE );
00483 int GetUTMZone( int *pbNorth = NULL ) const;
00484
00486 OGRErr SetWagner( int nVariation, double dfCenterLat,
00487 double dfFalseEasting, double dfFalseNorthing );
00488
00490 OGRErr SetStatePlane( int nZone, int bNAD83 = TRUE,
00491 const char *pszOverrideUnitName = NULL,
00492 double dfOverrideUnit = 0.0 );
00493 };
00494
00495
00496
00497
00498
00499
00500
00501
00508 class CPL_DLL OGRCoordinateTransformation
00509 {
00510 public:
00511 virtual ~OGRCoordinateTransformation() {}
00512
00513
00514
00516 virtual OGRSpatialReference *GetSourceCS() = 0;
00517
00519 virtual OGRSpatialReference *GetTargetCS() = 0;
00520
00521
00522
00538 virtual int Transform( int nCount,
00539 double *x, double *y, double *z = NULL ) = 0;
00540
00556 virtual int TransformEx( int nCount,
00557 double *x, double *y, double *z = NULL,
00558 int *pabSuccess = NULL ) = 0;
00559
00560 };
00561
00562 OGRCoordinateTransformation CPL_DLL *
00563 OGRCreateCoordinateTransformation( OGRSpatialReference *poSource,
00564 OGRSpatialReference *poTarget );
00565
00566 #endif