OGR
ogr_spatialref.h
Go to the documentation of this file.
1 /******************************************************************************
2  * $Id: ogr_spatialref.h 22952 2011-08-19 21:08:31Z rouault $
3  *
4  * Project: OpenGIS Simple Features Reference Implementation
5  * Purpose: Classes for manipulating spatial reference systems in a
6  * platform non-specific manner.
7  * Author: Frank Warmerdam, warmerdam@pobox.com
8  *
9  ******************************************************************************
10  * Copyright (c) 1999, Les Technologies SoftMap Inc.
11  *
12  * Permission is hereby granted, free of charge, to any person obtaining a
13  * copy of this software and associated documentation files (the "Software"),
14  * to deal in the Software without restriction, including without limitation
15  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
16  * and/or sell copies of the Software, and to permit persons to whom the
17  * Software is furnished to do so, subject to the following conditions:
18  *
19  * The above copyright notice and this permission notice shall be included
20  * in all copies or substantial portions of the Software.
21  *
22  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
25  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
28  * DEALINGS IN THE SOFTWARE.
29  ****************************************************************************/
30 
31 #ifndef _OGR_SPATIALREF_H_INCLUDED
32 #define _OGR_SPATIALREF_H_INCLUDED
33 
34 #include "ogr_srs_api.h"
35 
42 /************************************************************************/
43 /* OGR_SRSNode */
44 /************************************************************************/
45 
59 class CPL_DLL OGR_SRSNode
60 {
61  char *pszValue;
62 
63  OGR_SRSNode **papoChildNodes;
64  OGR_SRSNode *poParent;
65 
66  int nChildren;
67 
68  int NeedsQuoting() const;
69 
70  public:
71  OGR_SRSNode(const char * = NULL);
72  ~OGR_SRSNode();
73 
74  int IsLeafNode() const { return nChildren == 0; }
75 
76  int GetChildCount() const { return nChildren; }
77  OGR_SRSNode *GetChild( int );
78  const OGR_SRSNode *GetChild( int ) const;
79 
80  OGR_SRSNode *GetNode( const char * );
81  const OGR_SRSNode *GetNode( const char * ) const;
82 
83  void InsertChild( OGR_SRSNode *, int );
84  void AddChild( OGR_SRSNode * );
85  int FindChild( const char * ) const;
86  void DestroyChild( int );
87  void ClearChildren();
88  void StripNodes( const char * );
89 
90  const char *GetValue() const { return pszValue; }
91  void SetValue( const char * );
92 
93  void MakeValueSafe();
94  OGRErr FixupOrdering();
95 
96  OGR_SRSNode *Clone() const;
97 
98  OGRErr importFromWkt( char ** );
99  OGRErr exportToWkt( char ** ) const;
100  OGRErr exportToPrettyWkt( char **, int = 1) const;
101 
102  OGRErr applyRemapper( const char *pszNode,
103  char **papszSrcValues,
104  char **papszDstValues,
105  int nStepSize = 1,
106  int bChildOfHit = FALSE );
107 };
108 
109 /************************************************************************/
110 /* OGRSpatialReference */
111 /************************************************************************/
112 
127 class CPL_DLL OGRSpatialReference
128 {
129  double dfFromGreenwich;
130  double dfToMeter;
131  double dfToDegrees;
132 
133  OGR_SRSNode *poRoot;
134 
135  int nRefCount;
136  int bNormInfoSet;
137 
138  static OGRErr Validate(OGR_SRSNode *poRoot);
139  static OGRErr ValidateAuthority(OGR_SRSNode *poRoot);
140  static OGRErr ValidateAxis(OGR_SRSNode *poRoot);
141  static OGRErr ValidateUnit(OGR_SRSNode *poRoot);
142  static OGRErr ValidateVertDatum(OGR_SRSNode *poRoot);
143  static OGRErr ValidateProjection( OGR_SRSNode* poRoot );
144  static int IsAliasFor( const char *, const char * );
145  void GetNormInfo() const;
146 
147  OGRErr importFromURNPart(const char* pszAuthority,
148  const char* pszCode,
149  const char* pszURN);
150  public:
152  OGRSpatialReference(const char * = NULL);
153 
154  virtual ~OGRSpatialReference();
155 
156  static void DestroySpatialReference(OGRSpatialReference* poSRS);
157 
158  OGRSpatialReference &operator=(const OGRSpatialReference&);
159 
160  int Reference();
161  int Dereference();
162  int GetReferenceCount() const { return nRefCount; }
163  void Release();
164 
165  OGRSpatialReference *Clone() const;
166  OGRSpatialReference *CloneGeogCS() const;
167 
168  OGRErr exportToWkt( char ** ) const;
169  OGRErr exportToPrettyWkt( char **, int = FALSE) const;
170  OGRErr exportToProj4( char ** ) const;
171  OGRErr exportToPCI( char **, char **, double ** ) const;
172  OGRErr exportToUSGS( long *, long *, double **, long * ) const;
173  OGRErr exportToXML( char **, const char * = NULL ) const;
174  OGRErr exportToPanorama( long *, long *, long *, long *,
175  double * ) const;
176  OGRErr exportToERM( char *pszProj, char *pszDatum, char *pszUnits );
177  OGRErr exportToMICoordSys( char ** ) const;
178 
179  OGRErr importFromWkt( char ** );
180  OGRErr importFromProj4( const char * );
181  OGRErr importFromEPSG( int );
182  OGRErr importFromEPSGA( int );
183  OGRErr importFromESRI( char ** );
184  OGRErr importFromPCI( const char *, const char * = NULL,
185  double * = NULL );
186  OGRErr importFromUSGS( long iProjSys, long iZone,
187  double *padfPrjParams,
188  long iDatum, int bAnglesInPackedDMSFormat = TRUE );
189  OGRErr importFromPanorama( long, long, long, double* );
190  OGRErr importFromOzi( const char *, const char *, const char * );
191  OGRErr importFromWMSAUTO( const char *pszAutoDef );
192  OGRErr importFromXML( const char * );
193  OGRErr importFromDict( const char *pszDict, const char *pszCode );
194  OGRErr importFromURN( const char * );
195  OGRErr importFromERM( const char *pszProj, const char *pszDatum,
196  const char *pszUnits );
197  OGRErr importFromUrl( const char * );
198  OGRErr importFromMICoordSys( const char * );
199 
200  OGRErr morphToESRI();
201  OGRErr morphFromESRI();
202 
203  OGRErr Validate();
204  OGRErr StripCTParms( OGR_SRSNode * = NULL );
205  OGRErr StripVertical();
206  OGRErr FixupOrdering();
207  OGRErr Fixup();
208 
209  int EPSGTreatsAsLatLong();
210  const char *GetAxis( const char *pszTargetKey, int iAxis,
211  OGRAxisOrientation *peOrientation ) const;
212  OGRErr SetAxes( const char *pszTargetKey,
213  const char *pszXAxisName,
214  OGRAxisOrientation eXAxisOrientation,
215  const char *pszYAxisName,
216  OGRAxisOrientation eYAxisOrientation );
217 
218  // Machinary for accessing parse nodes
219  OGR_SRSNode *GetRoot() { return poRoot; }
220  const OGR_SRSNode *GetRoot() const { return poRoot; }
221  void SetRoot( OGR_SRSNode * );
222 
223  OGR_SRSNode *GetAttrNode(const char *);
224  const OGR_SRSNode *GetAttrNode(const char *) const;
225  const char *GetAttrValue(const char *, int = 0) const;
226 
227  OGRErr SetNode( const char *, const char * );
228  OGRErr SetNode( const char *, double );
229 
230  OGRErr SetLinearUnitsAndUpdateParameters( const char *pszName,
231  double dfInMeters );
232  OGRErr SetLinearUnits( const char *pszName, double dfInMeters );
233  OGRErr SetTargetLinearUnits( const char *pszTargetKey,
234  const char *pszName, double dfInMeters );
235  double GetLinearUnits( char ** = NULL ) const;
236  double GetTargetLinearUnits( const char *pszTargetKey,
237  char ** ppszRetName = NULL ) const;
238 
239  OGRErr SetAngularUnits( const char *pszName, double dfInRadians );
240  double GetAngularUnits( char ** = NULL ) const;
241 
242  double GetPrimeMeridian( char ** = NULL ) const;
243 
244  int IsGeographic() const;
245  int IsProjected() const;
246  int IsGeocentric() const;
247  int IsLocal() const;
248  int IsVertical() const;
249  int IsCompound() const;
250  int IsSameGeogCS( const OGRSpatialReference * ) const;
251  int IsSameVertCS( const OGRSpatialReference * ) const;
252  int IsSame( const OGRSpatialReference * ) const;
253 
254  void Clear();
255  OGRErr SetLocalCS( const char * );
256  OGRErr SetProjCS( const char * );
257  OGRErr SetProjection( const char * );
258  OGRErr SetGeocCS( const char * pszGeocName );
259  OGRErr SetGeogCS( const char * pszGeogName,
260  const char * pszDatumName,
261  const char * pszEllipsoidName,
262  double dfSemiMajor, double dfInvFlattening,
263  const char * pszPMName = NULL,
264  double dfPMOffset = 0.0,
265  const char * pszUnits = NULL,
266  double dfConvertToRadians = 0.0 );
267  OGRErr SetWellKnownGeogCS( const char * );
268  OGRErr CopyGeogCSFrom( const OGRSpatialReference * poSrcSRS );
269  OGRErr SetVertCS( const char *pszVertCSName,
270  const char *pszVertDatumName,
271  int nVertDatumClass = 2005 );
272  OGRErr SetCompoundCS( const char *pszName,
273  const OGRSpatialReference *poHorizSRS,
274  const OGRSpatialReference *poVertSRS );
275 
276  OGRErr SetFromUserInput( const char * );
277 
278  OGRErr SetTOWGS84( double, double, double,
279  double = 0.0, double = 0.0, double = 0.0,
280  double = 0.0 );
281  OGRErr GetTOWGS84( double *padfCoef, int nCoeff = 7 ) const;
282 
283  double GetSemiMajor( OGRErr * = NULL ) const;
284  double GetSemiMinor( OGRErr * = NULL ) const;
285  double GetInvFlattening( OGRErr * = NULL ) const;
286 
287  OGRErr SetAuthority( const char * pszTargetKey,
288  const char * pszAuthority,
289  int nCode );
290 
291  OGRErr AutoIdentifyEPSG();
292  int GetEPSGGeogCS();
293 
294  const char *GetAuthorityCode( const char * pszTargetKey ) const;
295  const char *GetAuthorityName( const char * pszTargetKey ) const;
296 
297  const char *GetExtension( const char *pszTargetKey,
298  const char *pszName,
299  const char *pszDefault = NULL ) const;
300  OGRErr SetExtension( const char *pszTargetKey,
301  const char *pszName,
302  const char *pszValue );
303 
304  int FindProjParm( const char *pszParameter,
305  const OGR_SRSNode *poPROJCS=NULL ) const;
306  OGRErr SetProjParm( const char *, double );
307  double GetProjParm( const char *, double =0.0, OGRErr* = NULL ) const;
308 
309  OGRErr SetNormProjParm( const char *, double );
310  double GetNormProjParm( const char *, double=0.0, OGRErr* =NULL)const;
311 
312  static int IsAngularParameter( const char * );
313  static int IsLongitudeParameter( const char * );
314  static int IsLinearParameter( const char * );
315 
317  OGRErr SetACEA( double dfStdP1, double dfStdP2,
318  double dfCenterLat, double dfCenterLong,
319  double dfFalseEasting, double dfFalseNorthing );
320 
322  OGRErr SetAE( double dfCenterLat, double dfCenterLong,
323  double dfFalseEasting, double dfFalseNorthing );
324 
326  OGRErr SetBonne( double dfStdP1, double dfCentralMeridian,
327  double dfFalseEasting, double dfFalseNorthing );
328 
330  OGRErr SetCEA( double dfStdP1, double dfCentralMeridian,
331  double dfFalseEasting, double dfFalseNorthing );
332 
334  OGRErr SetCS( double dfCenterLat, double dfCenterLong,
335  double dfFalseEasting, double dfFalseNorthing );
336 
338  OGRErr SetEC( double dfStdP1, double dfStdP2,
339  double dfCenterLat, double dfCenterLong,
340  double dfFalseEasting, double dfFalseNorthing );
341 
343  OGRErr SetEckert( int nVariation, double dfCentralMeridian,
344  double dfFalseEasting, double dfFalseNorthing );
345 
346  OGRErr SetEckertIV( double dfCentralMeridian,
347  double dfFalseEasting, double dfFalseNorthing );
348 
349  OGRErr SetEckertVI( double dfCentralMeridian,
350  double dfFalseEasting, double dfFalseNorthing );
351 
353  OGRErr SetEquirectangular(double dfCenterLat, double dfCenterLong,
354  double dfFalseEasting, double dfFalseNorthing );
356  OGRErr SetEquirectangular2( double dfCenterLat, double dfCenterLong,
357  double dfPseudoStdParallel1,
358  double dfFalseEasting, double dfFalseNorthing );
359 
361  OGRErr SetGEOS( double dfCentralMeridian, double dfSatelliteHeight,
362  double dfFalseEasting, double dfFalseNorthing );
363 
365  OGRErr SetGH( double dfCentralMeridian,
366  double dfFalseEasting, double dfFalseNorthing );
367 
369  OGRErr SetIGH();
370 
372  OGRErr SetGS( double dfCentralMeridian,
373  double dfFalseEasting, double dfFalseNorthing );
374 
376  OGRErr SetGaussSchreiberTMercator(double dfCenterLat, double dfCenterLong,
377  double dfScale,
378  double dfFalseEasting, double dfFalseNorthing );
379 
381  OGRErr SetGnomonic(double dfCenterLat, double dfCenterLong,
382  double dfFalseEasting, double dfFalseNorthing );
383 
385  OGRErr SetHOM( double dfCenterLat, double dfCenterLong,
386  double dfAzimuth, double dfRectToSkew,
387  double dfScale,
388  double dfFalseEasting, double dfFalseNorthing );
389 
390  OGRErr SetHOM2PNO( double dfCenterLat,
391  double dfLat1, double dfLong1,
392  double dfLat2, double dfLong2,
393  double dfScale,
394  double dfFalseEasting, double dfFalseNorthing );
395 
397  OGRErr SetIWMPolyconic( double dfLat1, double dfLat2,
398  double dfCenterLong,
399  double dfFalseEasting,
400  double dfFalseNorthing );
401 
403  OGRErr SetKrovak( double dfCenterLat, double dfCenterLong,
404  double dfAzimuth, double dfPseudoStdParallelLat,
405  double dfScale,
406  double dfFalseEasting, double dfFalseNorthing );
407 
409  OGRErr SetLAEA( double dfCenterLat, double dfCenterLong,
410  double dfFalseEasting, double dfFalseNorthing );
411 
413  OGRErr SetLCC( double dfStdP1, double dfStdP2,
414  double dfCenterLat, double dfCenterLong,
415  double dfFalseEasting, double dfFalseNorthing );
416 
418  OGRErr SetLCC1SP( double dfCenterLat, double dfCenterLong,
419  double dfScale,
420  double dfFalseEasting, double dfFalseNorthing );
421 
423  OGRErr SetLCCB( double dfStdP1, double dfStdP2,
424  double dfCenterLat, double dfCenterLong,
425  double dfFalseEasting, double dfFalseNorthing );
426 
428  OGRErr SetMC( double dfCenterLat, double dfCenterLong,
429  double dfFalseEasting, double dfFalseNorthing );
430 
432  OGRErr SetMercator( double dfCenterLat, double dfCenterLong,
433  double dfScale,
434  double dfFalseEasting, double dfFalseNorthing );
435 
436  OGRErr SetMercator2SP( double dfStdP1,
437  double dfCenterLat, double dfCenterLong,
438  double dfFalseEasting, double dfFalseNorthing );
439 
441  OGRErr SetMollweide( double dfCentralMeridian,
442  double dfFalseEasting, double dfFalseNorthing );
443 
445  OGRErr SetNZMG( double dfCenterLat, double dfCenterLong,
446  double dfFalseEasting, double dfFalseNorthing );
447 
449  OGRErr SetOS( double dfOriginLat, double dfCMeridian,
450  double dfScale,
451  double dfFalseEasting,double dfFalseNorthing);
452 
454  OGRErr SetOrthographic( double dfCenterLat, double dfCenterLong,
455  double dfFalseEasting,double dfFalseNorthing);
456 
458  OGRErr SetPolyconic( double dfCenterLat, double dfCenterLong,
459  double dfFalseEasting, double dfFalseNorthing );
460 
462  OGRErr SetPS( double dfCenterLat, double dfCenterLong,
463  double dfScale,
464  double dfFalseEasting, double dfFalseNorthing);
465 
467  OGRErr SetRobinson( double dfCenterLong,
468  double dfFalseEasting, double dfFalseNorthing );
469 
471  OGRErr SetSinusoidal( double dfCenterLong,
472  double dfFalseEasting, double dfFalseNorthing );
473 
475  OGRErr SetStereographic( double dfCenterLat, double dfCenterLong,
476  double dfScale,
477  double dfFalseEasting,double dfFalseNorthing);
478 
480  OGRErr SetSOC( double dfLatitudeOfOrigin, double dfCentralMeridian,
481  double dfFalseEasting, double dfFalseNorthing );
482 
484  OGRErr SetTM( double dfCenterLat, double dfCenterLong,
485  double dfScale,
486  double dfFalseEasting, double dfFalseNorthing );
487 
489  OGRErr SetTMVariant( const char *pszVariantName,
490  double dfCenterLat, double dfCenterLong,
491  double dfScale,
492  double dfFalseEasting, double dfFalseNorthing );
493 
495  OGRErr SetTMG( double dfCenterLat, double dfCenterLong,
496  double dfFalseEasting, double dfFalseNorthing );
497 
499  OGRErr SetTMSO( double dfCenterLat, double dfCenterLong,
500  double dfScale,
501  double dfFalseEasting, double dfFalseNorthing );
502 
504  OGRErr SetTPED( double dfLat1, double dfLong1,
505  double dfLat2, double dfLong2,
506  double dfFalseEasting, double dfFalseNorthing );
507 
509  OGRErr SetVDG( double dfCenterLong,
510  double dfFalseEasting, double dfFalseNorthing );
511 
513  OGRErr SetUTM( int nZone, int bNorth = TRUE );
514  int GetUTMZone( int *pbNorth = NULL ) const;
515 
517  OGRErr SetWagner( int nVariation, double dfCenterLat,
518  double dfFalseEasting, double dfFalseNorthing );
519 
521  OGRErr SetStatePlane( int nZone, int bNAD83 = TRUE,
522  const char *pszOverrideUnitName = NULL,
523  double dfOverrideUnit = 0.0 );
524 
525  OGRErr ImportFromESRIStatePlaneWKT(
526  int nCode, const char* pszDatumName, const char* pszUnitsName,
527  int nPCSCode, const char* pszCSName = 0 );
528  OGRErr ImportFromESRIWisconsinWKT(
529  const char* pszPrjName, double dfCentralMeridian, double dfLatOfOrigin,
530  const char* pszUnitsName, const char* pszCSName = 0 );
531 };
532 
533 /************************************************************************/
534 /* OGRCoordinateTransformation */
535 /* */
536 /* This is really just used as a base class for a private */
537 /* implementation. */
538 /************************************************************************/
539 
550 {
551 public:
552  virtual ~OGRCoordinateTransformation() {}
553 
554  static void DestroyCT(OGRCoordinateTransformation* poCT);
555 
556  // From CT_CoordinateTransformation
557 
559  virtual OGRSpatialReference *GetSourceCS() = 0;
560 
562  virtual OGRSpatialReference *GetTargetCS() = 0;
563 
564  // From CT_MathTransform
565 
581  virtual int Transform( int nCount,
582  double *x, double *y, double *z = NULL ) = 0;
583 
599  virtual int TransformEx( int nCount,
600  double *x, double *y, double *z = NULL,
601  int *pabSuccess = NULL ) = 0;
602 
603 };
604 
607  OGRSpatialReference *poTarget );
608 
609 #endif /* ndef _OGR_SPATIALREF_H_INCLUDED */

Generated for GDAL by doxygen 1.8.3.1.