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 importFromEPSGA( int );
00172 OGRErr importFromESRI( char ** );
00173 OGRErr importFromPCI( const char *, const char * = NULL,
00174 double * = NULL );
00175 OGRErr importFromUSGS( long, long, double *, long );
00176 OGRErr importFromPanorama( long, long, long, double* );
00177 OGRErr importFromWMSAUTO( const char *pszAutoDef );
00178 OGRErr importFromXML( const char * );
00179 OGRErr importFromDict( const char *pszDict, const char *pszCode );
00180 OGRErr importFromURN( const char * );
00181 OGRErr importFromERM( const char *pszProj, const char *pszDatum,
00182 const char *pszUnits );
00183 OGRErr importFromUrl( const char * );
00184
00185 OGRErr morphToESRI();
00186 OGRErr morphFromESRI();
00187
00188 OGRErr Validate();
00189 OGRErr StripCTParms( OGR_SRSNode * = NULL );
00190 OGRErr FixupOrdering();
00191 OGRErr Fixup();
00192
00193 int EPSGTreatsAsLatLong();
00194 const char *GetAxis( const char *pszTargetKey, int iAxis,
00195 OGRAxisOrientation *peOrientation );
00196 OGRErr SetAxes( const char *pszTargetKey,
00197 const char *pszXAxisName,
00198 OGRAxisOrientation eXAxisOrientation,
00199 const char *pszYAxisName,
00200 OGRAxisOrientation eYAxisOrientation );
00201
00202
00203 OGR_SRSNode *GetRoot() { return poRoot; }
00204 const OGR_SRSNode *GetRoot() const { return poRoot; }
00205 void SetRoot( OGR_SRSNode * );
00206
00207 OGR_SRSNode *GetAttrNode(const char *);
00208 const OGR_SRSNode *GetAttrNode(const char *) const;
00209 const char *GetAttrValue(const char *, int = 0) const;
00210
00211 OGRErr SetNode( const char *, const char * );
00212 OGRErr SetNode( const char *, double );
00213
00214 OGRErr SetLinearUnitsAndUpdateParameters( const char *pszName,
00215 double dfInMeters );
00216 OGRErr SetLinearUnits( const char *pszName, double dfInMeters );
00217 double GetLinearUnits( char ** = NULL ) const;
00218
00219 OGRErr SetAngularUnits( const char *pszName, double dfInRadians );
00220 double GetAngularUnits( char ** = NULL ) const;
00221
00222 double GetPrimeMeridian( char ** = NULL ) const;
00223
00224 int IsGeographic() const;
00225 int IsProjected() const;
00226 int IsLocal() const;
00227 int IsSameGeogCS( const OGRSpatialReference * ) const;
00228 int IsSame( const OGRSpatialReference * ) const;
00229
00230 void Clear();
00231 OGRErr SetLocalCS( const char * );
00232 OGRErr SetProjCS( const char * );
00233 OGRErr SetProjection( const char * );
00234 OGRErr SetGeogCS( const char * pszGeogName,
00235 const char * pszDatumName,
00236 const char * pszEllipsoidName,
00237 double dfSemiMajor, double dfInvFlattening,
00238 const char * pszPMName = NULL,
00239 double dfPMOffset = 0.0,
00240 const char * pszUnits = NULL,
00241 double dfConvertToRadians = 0.0 );
00242 OGRErr SetWellKnownGeogCS( const char * );
00243 OGRErr CopyGeogCSFrom( const OGRSpatialReference * poSrcSRS );
00244
00245 OGRErr SetFromUserInput( const char * );
00246
00247 OGRErr SetTOWGS84( double, double, double,
00248 double = 0.0, double = 0.0, double = 0.0,
00249 double = 0.0 );
00250 OGRErr GetTOWGS84( double *padfCoef, int nCoeff = 7 ) const;
00251
00252 double GetSemiMajor( OGRErr * = NULL ) const;
00253 double GetSemiMinor( OGRErr * = NULL ) const;
00254 double GetInvFlattening( OGRErr * = NULL ) const;
00255
00256 OGRErr SetAuthority( const char * pszTargetKey,
00257 const char * pszAuthority,
00258 int nCode );
00259
00260 OGRErr AutoIdentifyEPSG();
00261 int GetEPSGGeogCS();
00262
00263 const char *GetAuthorityCode( const char * pszTargetKey ) const;
00264 const char *GetAuthorityName( const char * pszTargetKey ) const;
00265
00266 const char *GetExtension( const char *pszTargetKey,
00267 const char *pszName,
00268 const char *pszDefault = NULL ) const;
00269 OGRErr SetExtension( const char *pszTargetKey,
00270 const char *pszName,
00271 const char *pszValue );
00272
00273 OGRErr SetProjParm( const char *, double );
00274 double GetProjParm( const char *, double =0.0, OGRErr* = NULL ) const;
00275
00276 OGRErr SetNormProjParm( const char *, double );
00277 double GetNormProjParm( const char *, double=0.0, OGRErr* =NULL)const;
00278
00279 static int IsAngularParameter( const char * );
00280 static int IsLongitudeParameter( const char * );
00281 static int IsLinearParameter( const char * );
00282
00284 OGRErr SetACEA( double dfStdP1, double dfStdP2,
00285 double dfCenterLat, double dfCenterLong,
00286 double dfFalseEasting, double dfFalseNorthing );
00287
00289 OGRErr SetAE( double dfCenterLat, double dfCenterLong,
00290 double dfFalseEasting, double dfFalseNorthing );
00291
00293 OGRErr SetBonne( double dfStdP1, double dfCentralMeridian,
00294 double dfFalseEasting, double dfFalseNorthing );
00295
00297 OGRErr SetCEA( double dfStdP1, double dfCentralMeridian,
00298 double dfFalseEasting, double dfFalseNorthing );
00299
00301 OGRErr SetCS( double dfCenterLat, double dfCenterLong,
00302 double dfFalseEasting, double dfFalseNorthing );
00303
00305 OGRErr SetEC( double dfStdP1, double dfStdP2,
00306 double dfCenterLat, double dfCenterLong,
00307 double dfFalseEasting, double dfFalseNorthing );
00308
00310 OGRErr SetEckert( int nVariation, double dfCentralMeridian,
00311 double dfFalseEasting, double dfFalseNorthing );
00312
00313 OGRErr SetEckertIV( double dfCentralMeridian,
00314 double dfFalseEasting, double dfFalseNorthing );
00315
00316 OGRErr SetEckertVI( double dfCentralMeridian,
00317 double dfFalseEasting, double dfFalseNorthing );
00318
00320 OGRErr SetEquirectangular(double dfCenterLat, double dfCenterLong,
00321 double dfFalseEasting, double dfFalseNorthing );
00323 OGRErr SetEquirectangular2( double dfCenterLat, double dfCenterLong,
00324 double dfPseudoStdParallel1,
00325 double dfFalseEasting, double dfFalseNorthing );
00326
00328 OGRErr SetGEOS( double dfCentralMeridian, double dfSatelliteHeight,
00329 double dfFalseEasting, double dfFalseNorthing );
00330
00332 OGRErr SetGH( double dfCentralMeridian,
00333 double dfFalseEasting, double dfFalseNorthing );
00334
00336 OGRErr SetGS( double dfCentralMeridian,
00337 double dfFalseEasting, double dfFalseNorthing );
00338
00340 OGRErr SetGaussLabordeReunion(double dfCenterLat, double dfCenterLong,
00341 double dfScale,
00342 double dfFalseEasting, double dfFalseNorthing );
00343
00345 OGRErr SetGnomonic(double dfCenterLat, double dfCenterLong,
00346 double dfFalseEasting, double dfFalseNorthing );
00347
00348 OGRErr SetHOM( double dfCenterLat, double dfCenterLong,
00349 double dfAzimuth, double dfRectToSkew,
00350 double dfScale,
00351 double dfFalseEasting, double dfFalseNorthing );
00352
00353 OGRErr SetHOM2PNO( double dfCenterLat,
00354 double dfLat1, double dfLong1,
00355 double dfLat2, double dfLong2,
00356 double dfScale,
00357 double dfFalseEasting, double dfFalseNorthing );
00358
00360 OGRErr SetIWMPolyconic( double dfLat1, double dfLat2,
00361 double dfCenterLong,
00362 double dfFalseEasting,
00363 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
00399 OGRErr SetMercator2SP( double dfStdP1,
00400 double dfCenterLat, double dfCenterLong,
00401 double dfFalseEasting, double dfFalseNorthing );
00402
00404 OGRErr SetMollweide( double dfCentralMeridian,
00405 double dfFalseEasting, double dfFalseNorthing );
00406
00408 OGRErr SetNZMG( double dfCenterLat, double dfCenterLong,
00409 double dfFalseEasting, double dfFalseNorthing );
00410
00412 OGRErr SetOS( double dfOriginLat, double dfCMeridian,
00413 double dfScale,
00414 double dfFalseEasting,double dfFalseNorthing);
00415
00417 OGRErr SetOrthographic( double dfCenterLat, double dfCenterLong,
00418 double dfFalseEasting,double dfFalseNorthing);
00419
00421 OGRErr SetPolyconic( double dfCenterLat, double dfCenterLong,
00422 double dfFalseEasting, double dfFalseNorthing );
00423
00425 OGRErr SetPS( double dfCenterLat, double dfCenterLong,
00426 double dfScale,
00427 double dfFalseEasting, double dfFalseNorthing);
00428
00430 OGRErr SetRobinson( double dfCenterLong,
00431 double dfFalseEasting, double dfFalseNorthing );
00432
00434 OGRErr SetSinusoidal( double dfCenterLong,
00435 double dfFalseEasting, double dfFalseNorthing );
00436
00438 OGRErr SetStereographic( double dfCenterLat, double dfCenterLong,
00439 double dfScale,
00440 double dfFalseEasting,double dfFalseNorthing);
00441
00443 OGRErr SetSOC( double dfLatitudeOfOrigin, double dfCentralMeridian,
00444 double dfFalseEasting, double dfFalseNorthing );
00445
00447 OGRErr SetTM( double dfCenterLat, double dfCenterLong,
00448 double dfScale,
00449 double dfFalseEasting, double dfFalseNorthing );
00450
00452 OGRErr SetTMVariant( const char *pszVariantName,
00453 double dfCenterLat, double dfCenterLong,
00454 double dfScale,
00455 double dfFalseEasting, double dfFalseNorthing );
00456
00458 OGRErr SetTMG( double dfCenterLat, double dfCenterLong,
00459 double dfFalseEasting, double dfFalseNorthing );
00460
00462 OGRErr SetTMSO( double dfCenterLat, double dfCenterLong,
00463 double dfScale,
00464 double dfFalseEasting, double dfFalseNorthing );
00465
00467 OGRErr SetTPED( double dfLat1, double dfLong1,
00468 double dfLat2, double dfLong2,
00469 double dfFalseEasting, double dfFalseNorthing );
00470
00472 OGRErr SetVDG( double dfCenterLong,
00473 double dfFalseEasting, double dfFalseNorthing );
00474
00476 OGRErr SetUTM( int nZone, int bNorth = TRUE );
00477 int GetUTMZone( int *pbNorth = NULL ) const;
00478
00480 OGRErr SetWagner( int nVariation, double dfCenterLat,
00481 double dfFalseEasting, double dfFalseNorthing );
00482
00484 OGRErr SetStatePlane( int nZone, int bNAD83 = TRUE,
00485 const char *pszOverrideUnitName = NULL,
00486 double dfOverrideUnit = 0.0 );
00487 };
00488
00489
00490
00491
00492
00493
00494
00495
00502 class CPL_DLL OGRCoordinateTransformation
00503 {
00504 public:
00505 virtual ~OGRCoordinateTransformation() {}
00506
00507
00508
00510 virtual OGRSpatialReference *GetSourceCS() = 0;
00511
00513 virtual OGRSpatialReference *GetTargetCS() = 0;
00514
00515
00516
00532 virtual int Transform( int nCount,
00533 double *x, double *y, double *z = NULL ) = 0;
00534
00550 virtual int TransformEx( int nCount,
00551 double *x, double *y, double *z = NULL,
00552 int *pabSuccess = NULL ) = 0;
00553
00554 };
00555
00556 OGRCoordinateTransformation CPL_DLL *
00557 OGRCreateCoordinateTransformation( OGRSpatialReference *poSource,
00558 OGRSpatialReference *poTarget );
00559
00560 #endif