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 int NeedsQuoting() const;
00069 OGRErr importFromWkt( char **, int nRecLevel, int* pnNodes );
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 ClearChildren();
00089 void StripNodes( const char * );
00090
00091 const char *GetValue() const { return pszValue; }
00092 void SetValue( const char * );
00093
00094 void MakeValueSafe();
00095 OGRErr FixupOrdering();
00096
00097 OGR_SRSNode *Clone() const;
00098
00099 OGRErr importFromWkt( char ** );
00100 OGRErr exportToWkt( char ** ) const;
00101 OGRErr exportToPrettyWkt( char **, int = 1) const;
00102
00103 OGRErr applyRemapper( const char *pszNode,
00104 char **papszSrcValues,
00105 char **papszDstValues,
00106 int nStepSize = 1,
00107 int bChildOfHit = FALSE );
00108 };
00109
00110
00111
00112
00113
00128 class CPL_DLL OGRSpatialReference
00129 {
00130 double dfFromGreenwich;
00131 double dfToMeter;
00132 double dfToDegrees;
00133
00134 OGR_SRSNode *poRoot;
00135
00136 int nRefCount;
00137 int bNormInfoSet;
00138
00139 static OGRErr Validate(OGR_SRSNode *poRoot);
00140 static OGRErr ValidateAuthority(OGR_SRSNode *poRoot);
00141 static OGRErr ValidateAxis(OGR_SRSNode *poRoot);
00142 static OGRErr ValidateUnit(OGR_SRSNode *poRoot);
00143 static OGRErr ValidateVertDatum(OGR_SRSNode *poRoot);
00144 static OGRErr ValidateProjection( OGR_SRSNode* poRoot );
00145 static int IsAliasFor( const char *, const char * );
00146 void GetNormInfo() const;
00147
00148 OGRErr importFromURNPart(const char* pszAuthority,
00149 const char* pszCode,
00150 const char* pszURN);
00151 public:
00152 OGRSpatialReference(const OGRSpatialReference&);
00153 OGRSpatialReference(const char * = NULL);
00154
00155 virtual ~OGRSpatialReference();
00156
00157 static void DestroySpatialReference(OGRSpatialReference* poSRS);
00158
00159 OGRSpatialReference &operator=(const OGRSpatialReference&);
00160
00161 int Reference();
00162 int Dereference();
00163 int GetReferenceCount() const { return nRefCount; }
00164 void Release();
00165
00166 OGRSpatialReference *Clone() const;
00167 OGRSpatialReference *CloneGeogCS() const;
00168
00169 void dumpReadable();
00170 OGRErr exportToWkt( char ** ) const;
00171 OGRErr exportToPrettyWkt( char **, int = FALSE) const;
00172 OGRErr exportToProj4( char ** ) const;
00173 OGRErr exportToPCI( char **, char **, double ** ) const;
00174 OGRErr exportToUSGS( long *, long *, double **, long * ) const;
00175 OGRErr exportToXML( char **, const char * = NULL ) const;
00176 OGRErr exportToPanorama( long *, long *, long *, long *,
00177 double * ) const;
00178 OGRErr exportToERM( char *pszProj, char *pszDatum, char *pszUnits );
00179 OGRErr exportToMICoordSys( char ** ) const;
00180
00181 OGRErr importFromWkt( char ** );
00182 OGRErr importFromProj4( const char * );
00183 OGRErr importFromEPSG( int );
00184 OGRErr importFromEPSGA( int );
00185 OGRErr importFromESRI( char ** );
00186 OGRErr importFromPCI( const char *, const char * = NULL,
00187 double * = NULL );
00188 #define USGS_ANGLE_DECIMALDEGREES 0
00189 #define USGS_ANGLE_PACKEDDMS TRUE
00190 #define USGS_ANGLE_RADIANS 2
00191 OGRErr importFromUSGS( long iProjSys, long iZone,
00192 double *padfPrjParams, long iDatum,
00193 int nUSGSAngleFormat = USGS_ANGLE_PACKEDDMS );
00194 OGRErr importFromPanorama( long, long, long, double* );
00195 OGRErr importFromOzi( const char *, const char *, const char * );
00196 OGRErr importFromOzi( const char * const* papszLines );
00197 OGRErr importFromWMSAUTO( const char *pszAutoDef );
00198 OGRErr importFromXML( const char * );
00199 OGRErr importFromDict( const char *pszDict, const char *pszCode );
00200 OGRErr importFromURN( const char * );
00201 OGRErr importFromCRSURL( const char * );
00202 OGRErr importFromERM( const char *pszProj, const char *pszDatum,
00203 const char *pszUnits );
00204 OGRErr importFromUrl( const char * );
00205 OGRErr importFromMICoordSys( const char * );
00206
00207 OGRErr morphToESRI();
00208 OGRErr morphFromESRI();
00209
00210 OGRErr Validate();
00211 OGRErr StripCTParms( OGR_SRSNode * = NULL );
00212 OGRErr StripVertical();
00213 OGRErr FixupOrdering();
00214 OGRErr Fixup();
00215
00216 int EPSGTreatsAsLatLong();
00217 int EPSGTreatsAsNorthingEasting();
00218 const char *GetAxis( const char *pszTargetKey, int iAxis,
00219 OGRAxisOrientation *peOrientation ) const;
00220 OGRErr SetAxes( const char *pszTargetKey,
00221 const char *pszXAxisName,
00222 OGRAxisOrientation eXAxisOrientation,
00223 const char *pszYAxisName,
00224 OGRAxisOrientation eYAxisOrientation );
00225
00226
00227 OGR_SRSNode *GetRoot() { return poRoot; }
00228 const OGR_SRSNode *GetRoot() const { return poRoot; }
00229 void SetRoot( OGR_SRSNode * );
00230
00231 OGR_SRSNode *GetAttrNode(const char *);
00232 const OGR_SRSNode *GetAttrNode(const char *) const;
00233 const char *GetAttrValue(const char *, int = 0) const;
00234
00235 OGRErr SetNode( const char *, const char * );
00236 OGRErr SetNode( const char *, double );
00237
00238 OGRErr SetLinearUnitsAndUpdateParameters( const char *pszName,
00239 double dfInMeters );
00240 OGRErr SetLinearUnits( const char *pszName, double dfInMeters );
00241 OGRErr SetTargetLinearUnits( const char *pszTargetKey,
00242 const char *pszName, double dfInMeters );
00243 double GetLinearUnits( char ** = NULL ) const;
00244 double GetTargetLinearUnits( const char *pszTargetKey,
00245 char ** ppszRetName = NULL ) const;
00246
00247 OGRErr SetAngularUnits( const char *pszName, double dfInRadians );
00248 double GetAngularUnits( char ** = NULL ) const;
00249
00250 double GetPrimeMeridian( char ** = NULL ) const;
00251
00252 int IsGeographic() const;
00253 int IsProjected() const;
00254 int IsGeocentric() const;
00255 int IsLocal() const;
00256 int IsVertical() const;
00257 int IsCompound() const;
00258 int IsSameGeogCS( const OGRSpatialReference * ) const;
00259 int IsSameVertCS( const OGRSpatialReference * ) const;
00260 int IsSame( const OGRSpatialReference * ) const;
00261
00262 void Clear();
00263 OGRErr SetLocalCS( const char * );
00264 OGRErr SetProjCS( const char * );
00265 OGRErr SetProjection( const char * );
00266 OGRErr SetGeocCS( const char * pszGeocName );
00267 OGRErr SetGeogCS( const char * pszGeogName,
00268 const char * pszDatumName,
00269 const char * pszEllipsoidName,
00270 double dfSemiMajor, double dfInvFlattening,
00271 const char * pszPMName = NULL,
00272 double dfPMOffset = 0.0,
00273 const char * pszUnits = NULL,
00274 double dfConvertToRadians = 0.0 );
00275 OGRErr SetWellKnownGeogCS( const char * );
00276 OGRErr CopyGeogCSFrom( const OGRSpatialReference * poSrcSRS );
00277 OGRErr SetVertCS( const char *pszVertCSName,
00278 const char *pszVertDatumName,
00279 int nVertDatumClass = 2005 );
00280 OGRErr SetCompoundCS( const char *pszName,
00281 const OGRSpatialReference *poHorizSRS,
00282 const OGRSpatialReference *poVertSRS );
00283
00284 OGRErr SetFromUserInput( const char * );
00285
00286 OGRErr SetTOWGS84( double, double, double,
00287 double = 0.0, double = 0.0, double = 0.0,
00288 double = 0.0 );
00289 OGRErr GetTOWGS84( double *padfCoef, int nCoeff = 7 ) const;
00290
00291 double GetSemiMajor( OGRErr * = NULL ) const;
00292 double GetSemiMinor( OGRErr * = NULL ) const;
00293 double GetInvFlattening( OGRErr * = NULL ) const;
00294
00295 OGRErr SetAuthority( const char * pszTargetKey,
00296 const char * pszAuthority,
00297 int nCode );
00298
00299 OGRErr AutoIdentifyEPSG();
00300 int GetEPSGGeogCS();
00301
00302 const char *GetAuthorityCode( const char * pszTargetKey ) const;
00303 const char *GetAuthorityName( const char * pszTargetKey ) const;
00304
00305 const char *GetExtension( const char *pszTargetKey,
00306 const char *pszName,
00307 const char *pszDefault = NULL ) const;
00308 OGRErr SetExtension( const char *pszTargetKey,
00309 const char *pszName,
00310 const char *pszValue );
00311
00312 int FindProjParm( const char *pszParameter,
00313 const OGR_SRSNode *poPROJCS=NULL ) const;
00314 OGRErr SetProjParm( const char *, double );
00315 double GetProjParm( const char *, double =0.0, OGRErr* = NULL ) const;
00316
00317 OGRErr SetNormProjParm( const char *, double );
00318 double GetNormProjParm( const char *, double=0.0, OGRErr* =NULL)const;
00319
00320 static int IsAngularParameter( const char * );
00321 static int IsLongitudeParameter( const char * );
00322 static int IsLinearParameter( const char * );
00323
00325 OGRErr SetACEA( double dfStdP1, double dfStdP2,
00326 double dfCenterLat, double dfCenterLong,
00327 double dfFalseEasting, double dfFalseNorthing );
00328
00330 OGRErr SetAE( double dfCenterLat, double dfCenterLong,
00331 double dfFalseEasting, double dfFalseNorthing );
00332
00334 OGRErr SetBonne( double dfStdP1, double dfCentralMeridian,
00335 double dfFalseEasting, double dfFalseNorthing );
00336
00338 OGRErr SetCEA( double dfStdP1, double dfCentralMeridian,
00339 double dfFalseEasting, double dfFalseNorthing );
00340
00342 OGRErr SetCS( double dfCenterLat, double dfCenterLong,
00343 double dfFalseEasting, double dfFalseNorthing );
00344
00346 OGRErr SetEC( double dfStdP1, double dfStdP2,
00347 double dfCenterLat, double dfCenterLong,
00348 double dfFalseEasting, double dfFalseNorthing );
00349
00351 OGRErr SetEckert( int nVariation, double dfCentralMeridian,
00352 double dfFalseEasting, double dfFalseNorthing );
00353
00354 OGRErr SetEckertIV( double dfCentralMeridian,
00355 double dfFalseEasting, double dfFalseNorthing );
00356
00357 OGRErr SetEckertVI( double dfCentralMeridian,
00358 double dfFalseEasting, double dfFalseNorthing );
00359
00361 OGRErr SetEquirectangular(double dfCenterLat, double dfCenterLong,
00362 double dfFalseEasting, double dfFalseNorthing );
00364 OGRErr SetEquirectangular2( double dfCenterLat, double dfCenterLong,
00365 double dfPseudoStdParallel1,
00366 double dfFalseEasting, double dfFalseNorthing );
00367
00369 OGRErr SetGEOS( double dfCentralMeridian, double dfSatelliteHeight,
00370 double dfFalseEasting, double dfFalseNorthing );
00371
00373 OGRErr SetGH( double dfCentralMeridian,
00374 double dfFalseEasting, double dfFalseNorthing );
00375
00377 OGRErr SetIGH();
00378
00380 OGRErr SetGS( double dfCentralMeridian,
00381 double dfFalseEasting, double dfFalseNorthing );
00382
00384 OGRErr SetGaussSchreiberTMercator(double dfCenterLat, double dfCenterLong,
00385 double dfScale,
00386 double dfFalseEasting, double dfFalseNorthing );
00387
00389 OGRErr SetGnomonic(double dfCenterLat, double dfCenterLong,
00390 double dfFalseEasting, double dfFalseNorthing );
00391
00393 OGRErr SetHOM( double dfCenterLat, double dfCenterLong,
00394 double dfAzimuth, double dfRectToSkew,
00395 double dfScale,
00396 double dfFalseEasting, double dfFalseNorthing );
00397
00398 OGRErr SetHOM2PNO( double dfCenterLat,
00399 double dfLat1, double dfLong1,
00400 double dfLat2, double dfLong2,
00401 double dfScale,
00402 double dfFalseEasting, double dfFalseNorthing );
00403
00404 OGRErr SetOM( double dfCenterLat, double dfCenterLong,
00405 double dfAzimuth, double dfRectToSkew,
00406 double dfScale,
00407 double dfFalseEasting, double dfFalseNorthing );
00408
00410 OGRErr SetHOMAC( double dfCenterLat, double dfCenterLong,
00411 double dfAzimuth, double dfRectToSkew,
00412 double dfScale,
00413 double dfFalseEasting, double dfFalseNorthing );
00414
00416 OGRErr SetIWMPolyconic( double dfLat1, double dfLat2,
00417 double dfCenterLong,
00418 double dfFalseEasting,
00419 double dfFalseNorthing );
00420
00422 OGRErr SetKrovak( double dfCenterLat, double dfCenterLong,
00423 double dfAzimuth, double dfPseudoStdParallelLat,
00424 double dfScale,
00425 double dfFalseEasting, double dfFalseNorthing );
00426
00428 OGRErr SetLAEA( double dfCenterLat, double dfCenterLong,
00429 double dfFalseEasting, double dfFalseNorthing );
00430
00432 OGRErr SetLCC( double dfStdP1, double dfStdP2,
00433 double dfCenterLat, double dfCenterLong,
00434 double dfFalseEasting, double dfFalseNorthing );
00435
00437 OGRErr SetLCC1SP( double dfCenterLat, double dfCenterLong,
00438 double dfScale,
00439 double dfFalseEasting, double dfFalseNorthing );
00440
00442 OGRErr SetLCCB( double dfStdP1, double dfStdP2,
00443 double dfCenterLat, double dfCenterLong,
00444 double dfFalseEasting, double dfFalseNorthing );
00445
00447 OGRErr SetMC( double dfCenterLat, double dfCenterLong,
00448 double dfFalseEasting, double dfFalseNorthing );
00449
00451 OGRErr SetMercator( double dfCenterLat, double dfCenterLong,
00452 double dfScale,
00453 double dfFalseEasting, double dfFalseNorthing );
00454
00455 OGRErr SetMercator2SP( double dfStdP1,
00456 double dfCenterLat, double dfCenterLong,
00457 double dfFalseEasting, double dfFalseNorthing );
00458
00460 OGRErr SetMollweide( double dfCentralMeridian,
00461 double dfFalseEasting, double dfFalseNorthing );
00462
00464 OGRErr SetNZMG( double dfCenterLat, double dfCenterLong,
00465 double dfFalseEasting, double dfFalseNorthing );
00466
00468 OGRErr SetOS( double dfOriginLat, double dfCMeridian,
00469 double dfScale,
00470 double dfFalseEasting,double dfFalseNorthing);
00471
00473 OGRErr SetOrthographic( double dfCenterLat, double dfCenterLong,
00474 double dfFalseEasting,double dfFalseNorthing);
00475
00477 OGRErr SetPolyconic( double dfCenterLat, double dfCenterLong,
00478 double dfFalseEasting, double dfFalseNorthing );
00479
00481 OGRErr SetPS( double dfCenterLat, double dfCenterLong,
00482 double dfScale,
00483 double dfFalseEasting, double dfFalseNorthing);
00484
00486 OGRErr SetRobinson( double dfCenterLong,
00487 double dfFalseEasting, double dfFalseNorthing );
00488
00490 OGRErr SetSinusoidal( double dfCenterLong,
00491 double dfFalseEasting, double dfFalseNorthing );
00492
00494 OGRErr SetStereographic( double dfCenterLat, double dfCenterLong,
00495 double dfScale,
00496 double dfFalseEasting,double dfFalseNorthing);
00497
00499 OGRErr SetSOC( double dfLatitudeOfOrigin, double dfCentralMeridian,
00500 double dfFalseEasting, double dfFalseNorthing );
00501
00503 OGRErr SetTM( double dfCenterLat, double dfCenterLong,
00504 double dfScale,
00505 double dfFalseEasting, double dfFalseNorthing );
00506
00508 OGRErr SetTMVariant( const char *pszVariantName,
00509 double dfCenterLat, double dfCenterLong,
00510 double dfScale,
00511 double dfFalseEasting, double dfFalseNorthing );
00512
00514 OGRErr SetTMG( double dfCenterLat, double dfCenterLong,
00515 double dfFalseEasting, double dfFalseNorthing );
00516
00518 OGRErr SetTMSO( double dfCenterLat, double dfCenterLong,
00519 double dfScale,
00520 double dfFalseEasting, double dfFalseNorthing );
00521
00523 OGRErr SetTPED( double dfLat1, double dfLong1,
00524 double dfLat2, double dfLong2,
00525 double dfFalseEasting, double dfFalseNorthing );
00526
00528 OGRErr SetVDG( double dfCenterLong,
00529 double dfFalseEasting, double dfFalseNorthing );
00530
00532 OGRErr SetUTM( int nZone, int bNorth = TRUE );
00533 int GetUTMZone( int *pbNorth = NULL ) const;
00534
00536 OGRErr SetWagner( int nVariation, double dfCenterLat,
00537 double dfFalseEasting, double dfFalseNorthing );
00538
00540 OGRErr SetStatePlane( int nZone, int bNAD83 = TRUE,
00541 const char *pszOverrideUnitName = NULL,
00542 double dfOverrideUnit = 0.0 );
00543
00544 OGRErr ImportFromESRIStatePlaneWKT(
00545 int nCode, const char* pszDatumName, const char* pszUnitsName,
00546 int nPCSCode, const char* pszCSName = 0 );
00547 OGRErr ImportFromESRIWisconsinWKT(
00548 const char* pszPrjName, double dfCentralMeridian, double dfLatOfOrigin,
00549 const char* pszUnitsName, const char* pszCSName = 0 );
00550 };
00551
00552
00553
00554
00555
00556
00557
00558
00568 class CPL_DLL OGRCoordinateTransformation
00569 {
00570 public:
00571 virtual ~OGRCoordinateTransformation() {}
00572
00573 static void DestroyCT(OGRCoordinateTransformation* poCT);
00574
00575
00576
00578 virtual OGRSpatialReference *GetSourceCS() = 0;
00579
00581 virtual OGRSpatialReference *GetTargetCS() = 0;
00582
00583
00584
00600 virtual int Transform( int nCount,
00601 double *x, double *y, double *z = NULL ) = 0;
00602
00618 virtual int TransformEx( int nCount,
00619 double *x, double *y, double *z = NULL,
00620 int *pabSuccess = NULL ) = 0;
00621
00622 };
00623
00624 OGRCoordinateTransformation CPL_DLL *
00625 OGRCreateCoordinateTransformation( OGRSpatialReference *poSource,
00626 OGRSpatialReference *poTarget );
00627
00628 #endif