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 OGRErr SetProjParm( const char *, double );
00264 double GetProjParm( const char *, double =0.0, OGRErr* = NULL ) const;
00265
00266 OGRErr SetNormProjParm( const char *, double );
00267 double GetNormProjParm( const char *, double=0.0, OGRErr* =NULL)const;
00268
00269 static int IsAngularParameter( const char * );
00270 static int IsLongitudeParameter( const char * );
00271 static int IsLinearParameter( const char * );
00272
00274 OGRErr SetACEA( double dfStdP1, double dfStdP2,
00275 double dfCenterLat, double dfCenterLong,
00276 double dfFalseEasting, double dfFalseNorthing );
00277
00279 OGRErr SetAE( double dfCenterLat, double dfCenterLong,
00280 double dfFalseEasting, double dfFalseNorthing );
00281
00283 OGRErr SetBonne( double dfStdP1, double dfCentralMeridian,
00284 double dfFalseEasting, double dfFalseNorthing );
00285
00287 OGRErr SetCEA( double dfStdP1, double dfCentralMeridian,
00288 double dfFalseEasting, double dfFalseNorthing );
00289
00291 OGRErr SetCS( double dfCenterLat, double dfCenterLong,
00292 double dfFalseEasting, double dfFalseNorthing );
00293
00295 OGRErr SetEC( double dfStdP1, double dfStdP2,
00296 double dfCenterLat, double dfCenterLong,
00297 double dfFalseEasting, double dfFalseNorthing );
00298
00300 OGRErr SetEckert( int nVariation, double dfCentralMeridian,
00301 double dfFalseEasting, double dfFalseNorthing );
00302
00303 OGRErr SetEckertIV( double dfCentralMeridian,
00304 double dfFalseEasting, double dfFalseNorthing );
00305
00306 OGRErr SetEckertVI( double dfCentralMeridian,
00307 double dfFalseEasting, double dfFalseNorthing );
00308
00310 OGRErr SetEquirectangular(double dfCenterLat, double dfCenterLong,
00311 double dfFalseEasting, double dfFalseNorthing );
00312
00314 OGRErr SetGEOS( double dfCentralMeridian, double dfSatelliteHeight,
00315 double dfFalseEasting, double dfFalseNorthing );
00316
00318 OGRErr SetGH( double dfCentralMeridian,
00319 double dfFalseEasting, double dfFalseNorthing );
00320
00322 OGRErr SetGS( double dfCentralMeridian,
00323 double dfFalseEasting, double dfFalseNorthing );
00324
00326 OGRErr SetGnomonic(double dfCenterLat, double dfCenterLong,
00327 double dfFalseEasting, double dfFalseNorthing );
00328
00329 OGRErr SetHOM( double dfCenterLat, double dfCenterLong,
00330 double dfAzimuth, double dfRectToSkew,
00331 double dfScale,
00332 double dfFalseEasting, double dfFalseNorthing );
00333
00334 OGRErr SetHOM2PNO( double dfCenterLat,
00335 double dfLat1, double dfLong1,
00336 double dfLat2, double dfLong2,
00337 double dfScale,
00338 double dfFalseEasting, double dfFalseNorthing );
00339
00341 OGRErr SetKrovak( double dfCenterLat, double dfCenterLong,
00342 double dfAzimuth, double dfPseudoStdParallelLat,
00343 double dfScale,
00344 double dfFalseEasting, double dfFalseNorthing );
00345
00347 OGRErr SetLAEA( double dfCenterLat, double dfCenterLong,
00348 double dfFalseEasting, double dfFalseNorthing );
00349
00351 OGRErr SetLCC( double dfStdP1, double dfStdP2,
00352 double dfCenterLat, double dfCenterLong,
00353 double dfFalseEasting, double dfFalseNorthing );
00354
00356 OGRErr SetLCC1SP( double dfCenterLat, double dfCenterLong,
00357 double dfScale,
00358 double dfFalseEasting, double dfFalseNorthing );
00359
00361 OGRErr SetLCCB( double dfStdP1, double dfStdP2,
00362 double dfCenterLat, double dfCenterLong,
00363 double dfFalseEasting, double dfFalseNorthing );
00364
00366 OGRErr SetMC( double dfCenterLat, double dfCenterLong,
00367 double dfFalseEasting, double dfFalseNorthing );
00368
00370 OGRErr SetMercator( double dfCenterLat, double dfCenterLong,
00371 double dfScale,
00372 double dfFalseEasting, double dfFalseNorthing );
00373
00374 OGRErr SetMercator2SP( double dfStdP1,
00375 double dfCenterLat, double dfCenterLong,
00376 double dfFalseEasting, double dfFalseNorthing );
00377
00379 OGRErr SetMollweide( double dfCentralMeridian,
00380 double dfFalseEasting, double dfFalseNorthing );
00381
00383 OGRErr SetNZMG( double dfCenterLat, double dfCenterLong,
00384 double dfFalseEasting, double dfFalseNorthing );
00385
00387 OGRErr SetOS( double dfOriginLat, double dfCMeridian,
00388 double dfScale,
00389 double dfFalseEasting,double dfFalseNorthing);
00390
00392 OGRErr SetOrthographic( double dfCenterLat, double dfCenterLong,
00393 double dfFalseEasting,double dfFalseNorthing);
00394
00396 OGRErr SetPolyconic( double dfCenterLat, double dfCenterLong,
00397 double dfFalseEasting, double dfFalseNorthing );
00398
00400 OGRErr SetPS( double dfCenterLat, double dfCenterLong,
00401 double dfScale,
00402 double dfFalseEasting, double dfFalseNorthing);
00403
00405 OGRErr SetRobinson( double dfCenterLong,
00406 double dfFalseEasting, double dfFalseNorthing );
00407
00409 OGRErr SetSinusoidal( double dfCenterLong,
00410 double dfFalseEasting, double dfFalseNorthing );
00411
00413 OGRErr SetStereographic( double dfCenterLat, double dfCenterLong,
00414 double dfScale,
00415 double dfFalseEasting,double dfFalseNorthing);
00416
00418 OGRErr SetSOC( double dfLatitudeOfOrigin, double dfCentralMeridian,
00419 double dfFalseEasting, double dfFalseNorthing );
00420
00422 OGRErr SetTM( double dfCenterLat, double dfCenterLong,
00423 double dfScale,
00424 double dfFalseEasting, double dfFalseNorthing );
00425
00427 OGRErr SetTMVariant( const char *pszVariantName,
00428 double dfCenterLat, double dfCenterLong,
00429 double dfScale,
00430 double dfFalseEasting, double dfFalseNorthing );
00431
00433 OGRErr SetTMG( double dfCenterLat, double dfCenterLong,
00434 double dfFalseEasting, double dfFalseNorthing );
00435
00437 OGRErr SetTMSO( double dfCenterLat, double dfCenterLong,
00438 double dfScale,
00439 double dfFalseEasting, double dfFalseNorthing );
00440
00442 OGRErr SetTPED( double dfLat1, double dfLong1,
00443 double dfLat2, double dfLong2,
00444 double dfFalseEasting, double dfFalseNorthing );
00445
00447 OGRErr SetVDG( double dfCenterLong,
00448 double dfFalseEasting, double dfFalseNorthing );
00449
00451 OGRErr SetUTM( int nZone, int bNorth = TRUE );
00452 int GetUTMZone( int *pbNorth = NULL ) const;
00453
00455 OGRErr SetStatePlane( int nZone, int bNAD83 = TRUE,
00456 const char *pszOverrideUnitName = NULL,
00457 double dfOverrideUnit = 0.0 );
00458 };
00459
00460
00461
00462
00463
00464
00465
00466
00473 class CPL_DLL OGRCoordinateTransformation
00474 {
00475 public:
00476 virtual ~OGRCoordinateTransformation() {}
00477
00478
00479
00481 virtual OGRSpatialReference *GetSourceCS() = 0;
00482
00484 virtual OGRSpatialReference *GetTargetCS() = 0;
00485
00486
00487
00503 virtual int Transform( int nCount,
00504 double *x, double *y, double *z = NULL ) = 0;
00505
00521 virtual int TransformEx( int nCount,
00522 double *x, double *y, double *z = NULL,
00523 int *pabSuccess = NULL ) = 0;
00524
00525 };
00526
00527 OGRCoordinateTransformation CPL_DLL *
00528 OGRCreateCoordinateTransformation( OGRSpatialReference *poSource,
00529 OGRSpatialReference *poTarget );
00530
00531 #endif