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