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
00070 public:
00071 OGR_SRSNode(const char * = NULL);
00072 ~OGR_SRSNode();
00073
00074 int IsLeafNode() const { return nChildren == 0; }
00075
00076 int GetChildCount() const { return nChildren; }
00077 OGR_SRSNode *GetChild( int );
00078 const OGR_SRSNode *GetChild( int ) const;
00079
00080 OGR_SRSNode *GetNode( const char * );
00081 const OGR_SRSNode *GetNode( const char * ) const;
00082
00083 void InsertChild( OGR_SRSNode *, int );
00084 void AddChild( OGR_SRSNode * );
00085 int FindChild( const char * ) const;
00086 void DestroyChild( int );
00087 void ClearChildren();
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 static OGRErr Validate(OGR_SRSNode *poRoot);
00139 static OGRErr ValidateAuthority(OGR_SRSNode *poRoot);
00140 static OGRErr ValidateAxis(OGR_SRSNode *poRoot);
00141 static OGRErr ValidateUnit(OGR_SRSNode *poRoot);
00142 static OGRErr ValidateVertDatum(OGR_SRSNode *poRoot);
00143 static OGRErr ValidateProjection( OGR_SRSNode* poRoot );
00144 static int IsAliasFor( const char *, const char * );
00145 void GetNormInfo() const;
00146
00147 OGRErr importFromURNPart(const char* pszAuthority,
00148 const char* pszCode,
00149 const char* pszURN);
00150 public:
00151 OGRSpatialReference(const OGRSpatialReference&);
00152 OGRSpatialReference(const char * = NULL);
00153
00154 virtual ~OGRSpatialReference();
00155
00156 static void DestroySpatialReference(OGRSpatialReference* poSRS);
00157
00158 OGRSpatialReference &operator=(const OGRSpatialReference&);
00159
00160 int Reference();
00161 int Dereference();
00162 int GetReferenceCount() const { return nRefCount; }
00163 void Release();
00164
00165 OGRSpatialReference *Clone() const;
00166 OGRSpatialReference *CloneGeogCS() const;
00167
00168 void dumpReadable();
00169 OGRErr exportToWkt( char ** ) const;
00170 OGRErr exportToPrettyWkt( char **, int = FALSE) const;
00171 OGRErr exportToProj4( char ** ) const;
00172 OGRErr exportToPCI( char **, char **, double ** ) const;
00173 OGRErr exportToUSGS( long *, long *, double **, long * ) const;
00174 OGRErr exportToXML( char **, const char * = NULL ) const;
00175 OGRErr exportToPanorama( long *, long *, long *, long *,
00176 double * ) const;
00177 OGRErr exportToERM( char *pszProj, char *pszDatum, char *pszUnits );
00178 OGRErr exportToMICoordSys( char ** ) const;
00179
00180 OGRErr importFromWkt( char ** );
00181 OGRErr importFromProj4( const char * );
00182 OGRErr importFromEPSG( int );
00183 OGRErr importFromEPSGA( int );
00184 OGRErr importFromESRI( char ** );
00185 OGRErr importFromPCI( const char *, const char * = NULL,
00186 double * = NULL );
00187 #define USGS_ANGLE_DECIMALDEGREES 0
00188 #define USGS_ANGLE_PACKEDDMS TRUE
00189 #define USGS_ANGLE_RADIANS 2
00190 OGRErr importFromUSGS( long iProjSys, long iZone,
00191 double *padfPrjParams, long iDatum,
00192 int nUSGSAngleFormat = USGS_ANGLE_PACKEDDMS );
00193 OGRErr importFromPanorama( long, long, long, double* );
00194 OGRErr importFromOzi( const char *, const char *, const char * );
00195 OGRErr importFromWMSAUTO( const char *pszAutoDef );
00196 OGRErr importFromXML( const char * );
00197 OGRErr importFromDict( const char *pszDict, const char *pszCode );
00198 OGRErr importFromURN( const char * );
00199 OGRErr importFromERM( const char *pszProj, const char *pszDatum,
00200 const char *pszUnits );
00201 OGRErr importFromUrl( const char * );
00202 OGRErr importFromMICoordSys( const char * );
00203
00204 OGRErr morphToESRI();
00205 OGRErr morphFromESRI();
00206
00207 OGRErr Validate();
00208 OGRErr StripCTParms( OGR_SRSNode * = NULL );
00209 OGRErr StripVertical();
00210 OGRErr FixupOrdering();
00211 OGRErr Fixup();
00212
00213 int EPSGTreatsAsLatLong();
00214 const char *GetAxis( const char *pszTargetKey, int iAxis,
00215 OGRAxisOrientation *peOrientation ) const;
00216 OGRErr SetAxes( const char *pszTargetKey,
00217 const char *pszXAxisName,
00218 OGRAxisOrientation eXAxisOrientation,
00219 const char *pszYAxisName,
00220 OGRAxisOrientation eYAxisOrientation );
00221
00222
00223 OGR_SRSNode *GetRoot() { return poRoot; }
00224 const OGR_SRSNode *GetRoot() const { return poRoot; }
00225 void SetRoot( OGR_SRSNode * );
00226
00227 OGR_SRSNode *GetAttrNode(const char *);
00228 const OGR_SRSNode *GetAttrNode(const char *) const;
00229 const char *GetAttrValue(const char *, int = 0) const;
00230
00231 OGRErr SetNode( const char *, const char * );
00232 OGRErr SetNode( const char *, double );
00233
00234 OGRErr SetLinearUnitsAndUpdateParameters( const char *pszName,
00235 double dfInMeters );
00236 OGRErr SetLinearUnits( const char *pszName, double dfInMeters );
00237 OGRErr SetTargetLinearUnits( const char *pszTargetKey,
00238 const char *pszName, double dfInMeters );
00239 double GetLinearUnits( char ** = NULL ) const;
00240 double GetTargetLinearUnits( const char *pszTargetKey,
00241 char ** ppszRetName = NULL ) const;
00242
00243 OGRErr SetAngularUnits( const char *pszName, double dfInRadians );
00244 double GetAngularUnits( char ** = NULL ) const;
00245
00246 double GetPrimeMeridian( char ** = NULL ) const;
00247
00248 int IsGeographic() const;
00249 int IsProjected() const;
00250 int IsGeocentric() const;
00251 int IsLocal() const;
00252 int IsVertical() const;
00253 int IsCompound() const;
00254 int IsSameGeogCS( const OGRSpatialReference * ) const;
00255 int IsSameVertCS( const OGRSpatialReference * ) const;
00256 int IsSame( const OGRSpatialReference * ) const;
00257
00258 void Clear();
00259 OGRErr SetLocalCS( const char * );
00260 OGRErr SetProjCS( const char * );
00261 OGRErr SetProjection( const char * );
00262 OGRErr SetGeocCS( const char * pszGeocName );
00263 OGRErr SetGeogCS( const char * pszGeogName,
00264 const char * pszDatumName,
00265 const char * pszEllipsoidName,
00266 double dfSemiMajor, double dfInvFlattening,
00267 const char * pszPMName = NULL,
00268 double dfPMOffset = 0.0,
00269 const char * pszUnits = NULL,
00270 double dfConvertToRadians = 0.0 );
00271 OGRErr SetWellKnownGeogCS( const char * );
00272 OGRErr CopyGeogCSFrom( const OGRSpatialReference * poSrcSRS );
00273 OGRErr SetVertCS( const char *pszVertCSName,
00274 const char *pszVertDatumName,
00275 int nVertDatumClass = 2005 );
00276 OGRErr SetCompoundCS( const char *pszName,
00277 const OGRSpatialReference *poHorizSRS,
00278 const OGRSpatialReference *poVertSRS );
00279
00280 OGRErr SetFromUserInput( const char * );
00281
00282 OGRErr SetTOWGS84( double, double, double,
00283 double = 0.0, double = 0.0, double = 0.0,
00284 double = 0.0 );
00285 OGRErr GetTOWGS84( double *padfCoef, int nCoeff = 7 ) const;
00286
00287 double GetSemiMajor( OGRErr * = NULL ) const;
00288 double GetSemiMinor( OGRErr * = NULL ) const;
00289 double GetInvFlattening( OGRErr * = NULL ) const;
00290
00291 OGRErr SetAuthority( const char * pszTargetKey,
00292 const char * pszAuthority,
00293 int nCode );
00294
00295 OGRErr AutoIdentifyEPSG();
00296 int GetEPSGGeogCS();
00297
00298 const char *GetAuthorityCode( const char * pszTargetKey ) const;
00299 const char *GetAuthorityName( const char * pszTargetKey ) const;
00300
00301 const char *GetExtension( const char *pszTargetKey,
00302 const char *pszName,
00303 const char *pszDefault = NULL ) const;
00304 OGRErr SetExtension( const char *pszTargetKey,
00305 const char *pszName,
00306 const char *pszValue );
00307
00308 int FindProjParm( const char *pszParameter,
00309 const OGR_SRSNode *poPROJCS=NULL ) const;
00310 OGRErr SetProjParm( const char *, double );
00311 double GetProjParm( const char *, double =0.0, OGRErr* = NULL ) const;
00312
00313 OGRErr SetNormProjParm( const char *, double );
00314 double GetNormProjParm( const char *, double=0.0, OGRErr* =NULL)const;
00315
00316 static int IsAngularParameter( const char * );
00317 static int IsLongitudeParameter( const char * );
00318 static int IsLinearParameter( const char * );
00319
00321 OGRErr SetACEA( double dfStdP1, double dfStdP2,
00322 double dfCenterLat, double dfCenterLong,
00323 double dfFalseEasting, double dfFalseNorthing );
00324
00326 OGRErr SetAE( double dfCenterLat, double dfCenterLong,
00327 double dfFalseEasting, double dfFalseNorthing );
00328
00330 OGRErr SetBonne( double dfStdP1, double dfCentralMeridian,
00331 double dfFalseEasting, double dfFalseNorthing );
00332
00334 OGRErr SetCEA( double dfStdP1, double dfCentralMeridian,
00335 double dfFalseEasting, double dfFalseNorthing );
00336
00338 OGRErr SetCS( double dfCenterLat, double dfCenterLong,
00339 double dfFalseEasting, double dfFalseNorthing );
00340
00342 OGRErr SetEC( double dfStdP1, double dfStdP2,
00343 double dfCenterLat, double dfCenterLong,
00344 double dfFalseEasting, double dfFalseNorthing );
00345
00347 OGRErr SetEckert( int nVariation, double dfCentralMeridian,
00348 double dfFalseEasting, double dfFalseNorthing );
00349
00350 OGRErr SetEckertIV( double dfCentralMeridian,
00351 double dfFalseEasting, double dfFalseNorthing );
00352
00353 OGRErr SetEckertVI( double dfCentralMeridian,
00354 double dfFalseEasting, double dfFalseNorthing );
00355
00357 OGRErr SetEquirectangular(double dfCenterLat, double dfCenterLong,
00358 double dfFalseEasting, double dfFalseNorthing );
00360 OGRErr SetEquirectangular2( double dfCenterLat, double dfCenterLong,
00361 double dfPseudoStdParallel1,
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 SetIGH();
00374
00376 OGRErr SetGS( double dfCentralMeridian,
00377 double dfFalseEasting, double dfFalseNorthing );
00378
00380 OGRErr SetGaussSchreiberTMercator(double dfCenterLat, double dfCenterLong,
00381 double dfScale,
00382 double dfFalseEasting, double dfFalseNorthing );
00383
00385 OGRErr SetGnomonic(double dfCenterLat, double dfCenterLong,
00386 double dfFalseEasting, double dfFalseNorthing );
00387
00389 OGRErr SetHOM( double dfCenterLat, double dfCenterLong,
00390 double dfAzimuth, double dfRectToSkew,
00391 double dfScale,
00392 double dfFalseEasting, double dfFalseNorthing );
00393
00394 OGRErr SetHOM2PNO( double dfCenterLat,
00395 double dfLat1, double dfLong1,
00396 double dfLat2, double dfLong2,
00397 double dfScale,
00398 double dfFalseEasting, double dfFalseNorthing );
00399
00400 OGRErr SetOM( double dfCenterLat, double dfCenterLong,
00401 double dfAzimuth, double dfRectToSkew,
00402 double dfScale,
00403 double dfFalseEasting, double dfFalseNorthing );
00404
00406 OGRErr SetHOMAC( double dfCenterLat, double dfCenterLong,
00407 double dfAzimuth, double dfRectToSkew,
00408 double dfScale,
00409 double dfFalseEasting, double dfFalseNorthing );
00410
00412 OGRErr SetIWMPolyconic( double dfLat1, double dfLat2,
00413 double dfCenterLong,
00414 double dfFalseEasting,
00415 double dfFalseNorthing );
00416
00418 OGRErr SetKrovak( double dfCenterLat, double dfCenterLong,
00419 double dfAzimuth, double dfPseudoStdParallelLat,
00420 double dfScale,
00421 double dfFalseEasting, double dfFalseNorthing );
00422
00424 OGRErr SetLAEA( double dfCenterLat, double dfCenterLong,
00425 double dfFalseEasting, double dfFalseNorthing );
00426
00428 OGRErr SetLCC( double dfStdP1, double dfStdP2,
00429 double dfCenterLat, double dfCenterLong,
00430 double dfFalseEasting, double dfFalseNorthing );
00431
00433 OGRErr SetLCC1SP( double dfCenterLat, double dfCenterLong,
00434 double dfScale,
00435 double dfFalseEasting, double dfFalseNorthing );
00436
00438 OGRErr SetLCCB( double dfStdP1, double dfStdP2,
00439 double dfCenterLat, double dfCenterLong,
00440 double dfFalseEasting, double dfFalseNorthing );
00441
00443 OGRErr SetMC( double dfCenterLat, double dfCenterLong,
00444 double dfFalseEasting, double dfFalseNorthing );
00445
00447 OGRErr SetMercator( double dfCenterLat, double dfCenterLong,
00448 double dfScale,
00449 double dfFalseEasting, double dfFalseNorthing );
00450
00451 OGRErr SetMercator2SP( double dfStdP1,
00452 double dfCenterLat, double dfCenterLong,
00453 double dfFalseEasting, double dfFalseNorthing );
00454
00456 OGRErr SetMollweide( double dfCentralMeridian,
00457 double dfFalseEasting, double dfFalseNorthing );
00458
00460 OGRErr SetNZMG( double dfCenterLat, double dfCenterLong,
00461 double dfFalseEasting, double dfFalseNorthing );
00462
00464 OGRErr SetOS( double dfOriginLat, double dfCMeridian,
00465 double dfScale,
00466 double dfFalseEasting,double dfFalseNorthing);
00467
00469 OGRErr SetOrthographic( double dfCenterLat, double dfCenterLong,
00470 double dfFalseEasting,double dfFalseNorthing);
00471
00473 OGRErr SetPolyconic( double dfCenterLat, double dfCenterLong,
00474 double dfFalseEasting, double dfFalseNorthing );
00475
00477 OGRErr SetPS( double dfCenterLat, double dfCenterLong,
00478 double dfScale,
00479 double dfFalseEasting, double dfFalseNorthing);
00480
00482 OGRErr SetRobinson( double dfCenterLong,
00483 double dfFalseEasting, double dfFalseNorthing );
00484
00486 OGRErr SetSinusoidal( double dfCenterLong,
00487 double dfFalseEasting, double dfFalseNorthing );
00488
00490 OGRErr SetStereographic( double dfCenterLat, double dfCenterLong,
00491 double dfScale,
00492 double dfFalseEasting,double dfFalseNorthing);
00493
00495 OGRErr SetSOC( double dfLatitudeOfOrigin, double dfCentralMeridian,
00496 double dfFalseEasting, double dfFalseNorthing );
00497
00499 OGRErr SetTM( double dfCenterLat, double dfCenterLong,
00500 double dfScale,
00501 double dfFalseEasting, double dfFalseNorthing );
00502
00504 OGRErr SetTMVariant( const char *pszVariantName,
00505 double dfCenterLat, double dfCenterLong,
00506 double dfScale,
00507 double dfFalseEasting, double dfFalseNorthing );
00508
00510 OGRErr SetTMG( double dfCenterLat, double dfCenterLong,
00511 double dfFalseEasting, double dfFalseNorthing );
00512
00514 OGRErr SetTMSO( double dfCenterLat, double dfCenterLong,
00515 double dfScale,
00516 double dfFalseEasting, double dfFalseNorthing );
00517
00519 OGRErr SetTPED( double dfLat1, double dfLong1,
00520 double dfLat2, double dfLong2,
00521 double dfFalseEasting, double dfFalseNorthing );
00522
00524 OGRErr SetVDG( double dfCenterLong,
00525 double dfFalseEasting, double dfFalseNorthing );
00526
00528 OGRErr SetUTM( int nZone, int bNorth = TRUE );
00529 int GetUTMZone( int *pbNorth = NULL ) const;
00530
00532 OGRErr SetWagner( int nVariation, double dfCenterLat,
00533 double dfFalseEasting, double dfFalseNorthing );
00534
00536 OGRErr SetStatePlane( int nZone, int bNAD83 = TRUE,
00537 const char *pszOverrideUnitName = NULL,
00538 double dfOverrideUnit = 0.0 );
00539
00540 OGRErr ImportFromESRIStatePlaneWKT(
00541 int nCode, const char* pszDatumName, const char* pszUnitsName,
00542 int nPCSCode, const char* pszCSName = 0 );
00543 OGRErr ImportFromESRIWisconsinWKT(
00544 const char* pszPrjName, double dfCentralMeridian, double dfLatOfOrigin,
00545 const char* pszUnitsName, const char* pszCSName = 0 );
00546 };
00547
00548
00549
00550
00551
00552
00553
00554
00564 class CPL_DLL OGRCoordinateTransformation
00565 {
00566 public:
00567 virtual ~OGRCoordinateTransformation() {}
00568
00569 static void DestroyCT(OGRCoordinateTransformation* poCT);
00570
00571
00572
00574 virtual OGRSpatialReference *GetSourceCS() = 0;
00575
00577 virtual OGRSpatialReference *GetTargetCS() = 0;
00578
00579
00580
00596 virtual int Transform( int nCount,
00597 double *x, double *y, double *z = NULL ) = 0;
00598
00614 virtual int TransformEx( int nCount,
00615 double *x, double *y, double *z = NULL,
00616 int *pabSuccess = NULL ) = 0;
00617
00618 };
00619
00620 OGRCoordinateTransformation CPL_DLL *
00621 OGRCreateCoordinateTransformation( OGRSpatialReference *poSource,
00622 OGRSpatialReference *poTarget );
00623
00624 #endif