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

Generated for GDAL by doxygen 1.8.11.