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
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099 #ifndef _OGR_SPATIALREF_H_INCLUDED
00100 #define _OGR_SPATIALREF_H_INCLUDED
00101
00102 #include "ogr_srs_api.h"
00103
00110
00111
00112
00113
00127 class CPL_DLL OGR_SRSNode
00128 {
00129 char *pszValue;
00130
00131 int nChildren;
00132 OGR_SRSNode **papoChildNodes;
00133
00134 OGR_SRSNode *poParent;
00135
00136 void ClearChildren();
00137 int NeedsQuoting() const;
00138
00139 public:
00140 OGR_SRSNode(const char * = NULL);
00141 ~OGR_SRSNode();
00142
00143 int IsLeafNode() const { return nChildren == 0; }
00144
00145 int GetChildCount() const { return nChildren; }
00146 OGR_SRSNode *GetChild( int );
00147 const OGR_SRSNode *GetChild( int ) const;
00148
00149 OGR_SRSNode *GetNode( const char * );
00150 const OGR_SRSNode *GetNode( const char * ) const;
00151
00152 void InsertChild( OGR_SRSNode *, int );
00153 void AddChild( OGR_SRSNode * );
00154 int FindChild( const char * ) const;
00155 void DestroyChild( int );
00156 void StripNodes( const char * );
00157
00158 const char *GetValue() const { return pszValue; }
00159 void SetValue( const char * );
00160
00161 void MakeValueSafe();
00162 OGRErr FixupOrdering();
00163
00164 OGR_SRSNode *Clone() const;
00165
00166 OGRErr importFromWkt( char ** );
00167 OGRErr exportToWkt( char ** ) const;
00168 OGRErr exportToPrettyWkt( char **, int = 1) const;
00169
00170 OGRErr applyRemapper( const char *pszNode,
00171 char **papszSrcValues,
00172 char **papszDstValues,
00173 int nStepSize = 1,
00174 int bChildOfHit = FALSE );
00175 };
00176
00177
00178
00179
00180
00195 class CPL_DLL OGRSpatialReference
00196 {
00197 int nRefCount;
00198
00199 OGR_SRSNode *poRoot;
00200
00201 int bNormInfoSet;
00202 double dfFromGreenwich;
00203 double dfToMeter;
00204 double dfToDegrees;
00205
00206 OGRErr ValidateProjection();
00207 int IsAliasFor( const char *, const char * );
00208 void GetNormInfo() const;
00209
00210 public:
00211 OGRSpatialReference(const OGRSpatialReference&);
00212 OGRSpatialReference(const char * = NULL);
00213
00214 virtual ~OGRSpatialReference();
00215
00216 OGRSpatialReference &operator=(const OGRSpatialReference&);
00217
00218 int Reference();
00219 int Dereference();
00220 int GetReferenceCount() const { return nRefCount; }
00221 void Release();
00222
00223 OGRSpatialReference *Clone() const;
00224 OGRSpatialReference *CloneGeogCS() const;
00225
00226 OGRErr exportToWkt( char ** ) const;
00227 OGRErr exportToPrettyWkt( char **, int = FALSE) const;
00228 OGRErr exportToProj4( char ** ) const;
00229 OGRErr exportToPCI( char **, char **, double ** ) const;
00230 OGRErr exportToUSGS( long *, long *, double **, long * ) const;
00231 OGRErr exportToXML( char **, const char * = NULL ) const;
00232 OGRErr importFromWkt( char ** );
00233 OGRErr importFromProj4( const char * );
00234 OGRErr importFromEPSG( int );
00235 OGRErr importFromESRI( char ** );
00236 OGRErr importFromPCI( const char *pszProj,
00237 const char *pszUnits = NULL,
00238 double *padfPrjParams = NULL );
00239 OGRErr importFromUSGS( long iProjsys, long iZone,
00240 double *padfPrjParams, long iDatum );
00241 OGRErr importFromWMSAUTO( const char *pszAutoDef );
00242 OGRErr importFromXML( const char * );
00243 OGRErr importFromDict( const char *pszDict, const char *pszCode );
00244
00245 OGRErr morphToESRI();
00246 OGRErr morphFromESRI();
00247
00248 OGRErr Validate();
00249 OGRErr StripCTParms( OGR_SRSNode * = NULL );
00250 OGRErr FixupOrdering();
00251 OGRErr Fixup();
00252
00253
00254 OGR_SRSNode *GetRoot() { return poRoot; }
00255 const OGR_SRSNode *GetRoot() const { return poRoot; }
00256 void SetRoot( OGR_SRSNode * );
00257
00258 OGR_SRSNode *GetAttrNode(const char *);
00259 const OGR_SRSNode *GetAttrNode(const char *) const;
00260 const char *GetAttrValue(const char *, int = 0) const;
00261
00262 OGRErr SetNode( const char *, const char * );
00263 OGRErr SetNode( const char *, double );
00264
00265 OGRErr SetLinearUnitsAndUpdateParameters( const char *pszName,
00266 double dfInMeters );
00267 OGRErr SetLinearUnits( const char *pszName, double dfInMeters );
00268 double GetLinearUnits( char ** = NULL ) const;
00269
00270 OGRErr SetAngularUnits( const char *pszName, double dfInRadians );
00271 double GetAngularUnits( char ** = NULL ) const;
00272
00273 double GetPrimeMeridian( char ** = NULL ) const;
00274
00275 int IsGeographic() const;
00276 int IsProjected() const;
00277 int IsLocal() const;
00278 int IsSameGeogCS( const OGRSpatialReference * ) const;
00279 int IsSame( const OGRSpatialReference * ) const;
00280
00281 void Clear();
00282 OGRErr SetLocalCS( const char * );
00283 OGRErr SetProjCS( const char * );
00284 OGRErr SetProjection( const char * );
00285 OGRErr SetGeogCS( const char * pszGeogName,
00286 const char * pszDatumName,
00287 const char * pszEllipsoidName,
00288 double dfSemiMajor, double dfInvFlattening,
00289 const char * pszPMName = NULL,
00290 double dfPMOffset = 0.0,
00291 const char * pszUnits = NULL,
00292 double dfConvertToRadians = 0.0 );
00293 OGRErr SetWellKnownGeogCS( const char * );
00294 OGRErr CopyGeogCSFrom( const OGRSpatialReference * poSrcSRS );
00295
00296 OGRErr SetFromUserInput( const char * );
00297
00298 OGRErr SetTOWGS84( double, double, double,
00299 double = 0.0, double = 0.0, double = 0.0,
00300 double = 0.0 );
00301 OGRErr GetTOWGS84( double *padfCoef, int nCoeff = 7 ) const;
00302
00303 double GetSemiMajor( OGRErr * = NULL ) const;
00304 double GetSemiMinor( OGRErr * = NULL ) const;
00305 double GetInvFlattening( OGRErr * = NULL ) const;
00306
00307 OGRErr SetAuthority( const char * pszTargetKey,
00308 const char * pszAuthority,
00309 int nCode );
00310
00311 OGRErr AutoIdentifyEPSG();
00312
00313 const char *GetAuthorityCode( const char * pszTargetKey ) const;
00314 const char *GetAuthorityName( const char * pszTargetKey ) const;
00315
00316 OGRErr SetProjParm( const char *, double );
00317 double GetProjParm( const char *, double =0.0, OGRErr* = NULL ) const;
00318
00319 OGRErr SetNormProjParm( const char *, double );
00320 double GetNormProjParm( const char *, double=0.0, OGRErr* =NULL)const;
00321
00322 static int IsAngularParameter( const char * );
00323 static int IsLongitudeParameter( const char * );
00324 static int IsLinearParameter( const char * );
00325
00327 OGRErr SetACEA( double dfStdP1, double dfStdP2,
00328 double dfCenterLat, double dfCenterLong,
00329 double dfFalseEasting, double dfFalseNorthing );
00330
00332 OGRErr SetAE( double dfCenterLat, double dfCenterLong,
00333 double dfFalseEasting, double dfFalseNorthing );
00334
00336 OGRErr SetBonne( double dfStdP1, double dfCentralMeridian,
00337 double dfFalseEasting, double dfFalseNorthing );
00338
00340 OGRErr SetCEA( double dfStdP1, double dfCentralMeridian,
00341 double dfFalseEasting, double dfFalseNorthing );
00342
00344 OGRErr SetCS( double dfCenterLat, double dfCenterLong,
00345 double dfFalseEasting, double dfFalseNorthing );
00346
00348 OGRErr SetEC( double dfStdP1, double dfStdP2,
00349 double dfCenterLat, double dfCenterLong,
00350 double dfFalseEasting, double dfFalseNorthing );
00351
00353 OGRErr SetEckertIV( double dfCentralMeridian,
00354 double dfFalseEasting, double dfFalseNorthing );
00355
00357 OGRErr SetEckertVI( double dfCentralMeridian,
00358 double dfFalseEasting, double dfFalseNorthing );
00359
00361 OGRErr SetEquirectangular(double dfCenterLat, double dfCenterLong,
00362 double dfFalseEasting, double dfFalseNorthing );
00363
00365 OGRErr SetGEOS( double dfCentralMeridian, double dfSatelliteHeight,
00366 double dfFalseEasting, double dfFalseNorthing );
00367
00369 OGRErr SetGH( double dfCentralMeridian,
00370 double dfFalseEasting, double dfFalseNorthing );
00371
00373 OGRErr SetGS( double dfCentralMeridian,
00374 double dfFalseEasting, double dfFalseNorthing );
00375
00377 OGRErr SetGnomonic(double dfCenterLat, double dfCenterLong,
00378 double dfFalseEasting, double dfFalseNorthing );
00379
00380 OGRErr SetHOM( double dfCenterLat, double dfCenterLong,
00381 double dfAzimuth, double dfRectToSkew,
00382 double dfScale,
00383 double dfFalseEasting, double dfFalseNorthing );
00384
00385 OGRErr SetHOM2PNO( double dfCenterLat,
00386 double dfLat1, double dfLong1,
00387 double dfLat2, double dfLong2,
00388 double dfScale,
00389 double dfFalseEasting, double dfFalseNorthing );
00390
00392 OGRErr SetKrovak( double dfCenterLat, double dfCenterLong,
00393 double dfAzimuth, double dfPseudoStdParallelLat,
00394 double dfScale,
00395 double dfFalseEasting, double dfFalseNorthing );
00396
00398 OGRErr SetLAEA( double dfCenterLat, double dfCenterLong,
00399 double dfFalseEasting, double dfFalseNorthing );
00400
00402 OGRErr SetLCC( double dfStdP1, double dfStdP2,
00403 double dfCenterLat, double dfCenterLong,
00404 double dfFalseEasting, double dfFalseNorthing );
00405
00407 OGRErr SetLCC1SP( double dfCenterLat, double dfCenterLong,
00408 double dfScale,
00409 double dfFalseEasting, double dfFalseNorthing );
00410
00412 OGRErr SetLCCB( double dfStdP1, double dfStdP2,
00413 double dfCenterLat, double dfCenterLong,
00414 double dfFalseEasting, double dfFalseNorthing );
00415
00417 OGRErr SetMC( double dfCenterLat, double dfCenterLong,
00418 double dfFalseEasting, double dfFalseNorthing );
00419
00421 OGRErr SetMercator( double dfCenterLat, double dfCenterLong,
00422 double dfScale,
00423 double dfFalseEasting, double dfFalseNorthing );
00424
00426 OGRErr SetMollweide( double dfCentralMeridian,
00427 double dfFalseEasting, double dfFalseNorthing );
00428
00430 OGRErr SetNZMG( double dfCenterLat, double dfCenterLong,
00431 double dfFalseEasting, double dfFalseNorthing );
00432
00434 OGRErr SetOS( double dfOriginLat, double dfCMeridian,
00435 double dfScale,
00436 double dfFalseEasting,double dfFalseNorthing);
00437
00439 OGRErr SetOrthographic( double dfCenterLat, double dfCenterLong,
00440 double dfFalseEasting,double dfFalseNorthing);
00441
00443 OGRErr SetPolyconic( double dfCenterLat, double dfCenterLong,
00444 double dfFalseEasting, double dfFalseNorthing );
00445
00447 OGRErr SetPS( double dfCenterLat, double dfCenterLong,
00448 double dfScale,
00449 double dfFalseEasting, double dfFalseNorthing);
00450
00452 OGRErr SetRobinson( double dfCenterLong,
00453 double dfFalseEasting, double dfFalseNorthing );
00454
00456 OGRErr SetSinusoidal( double dfCenterLong,
00457 double dfFalseEasting, double dfFalseNorthing );
00458
00460 OGRErr SetStereographic( double dfCenterLat, double dfCenterLong,
00461 double dfScale,
00462 double dfFalseEasting,double dfFalseNorthing);
00463
00465 OGRErr SetSOC( double dfLatitudeOfOrigin, double dfCentralMeridian,
00466 double dfFalseEasting, double dfFalseNorthing );
00467
00469 OGRErr SetTM( double dfCenterLat, double dfCenterLong,
00470 double dfScale,
00471 double dfFalseEasting, double dfFalseNorthing );
00472
00474 OGRErr SetTMVariant( const char *pszVariantName,
00475 double dfCenterLat, double dfCenterLong,
00476 double dfScale,
00477 double dfFalseEasting, double dfFalseNorthing );
00478
00480 OGRErr SetTMG( double dfCenterLat, double dfCenterLong,
00481 double dfFalseEasting, double dfFalseNorthing );
00482
00484 OGRErr SetTMSO( double dfCenterLat, double dfCenterLong,
00485 double dfScale,
00486 double dfFalseEasting, double dfFalseNorthing );
00487
00489 OGRErr SetVDG( double dfCenterLong,
00490 double dfFalseEasting, double dfFalseNorthing );
00491
00493 OGRErr SetUTM( int nZone, int bNorth = TRUE );
00494 int GetUTMZone( int *pbNorth = NULL ) const;
00495
00497 OGRErr SetStatePlane( int nZone, int bNAD83 = TRUE,
00498 const char *pszOverrideUnitName = NULL,
00499 double dfOverrideUnit = 0.0 );
00500 };
00501
00502
00503
00504
00505
00506
00507
00508
00515 class CPL_DLL OGRCoordinateTransformation
00516 {
00517 public:
00518 virtual ~OGRCoordinateTransformation() {}
00519
00520
00521
00523 virtual OGRSpatialReference *GetSourceCS() = 0;
00524
00526 virtual OGRSpatialReference *GetTargetCS() = 0;
00527
00528
00529
00545 virtual int Transform( int nCount,
00546 double *x, double *y, double *z = NULL ) = 0;
00547
00563 virtual int TransformEx( int nCount,
00564 double *x, double *y, double *z = NULL,
00565 int *pabSuccess = NULL ) = 0;
00566
00567 };
00568
00569 OGRCoordinateTransformation CPL_DLL *
00570 OGRCreateCoordinateTransformation( OGRSpatialReference *poSource,
00571 OGRSpatialReference *poTarget );
00572
00573 #endif