GDAL

- Main Page
- Related Pages
- Classes
- Files

- File List
- File Members

ogr_spatialref.h
Go to the documentation of this file.
1 /******************************************************************************
2 * $Id: ogr_spatialref.h 33631 2016-03-04 06:28:09Z goatbar $
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:
153 OGRSpatialReference(const OGRSpatialReference&);
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* papszLines );
197 OGRErr importFromWMSAUTO( const char *pszAutoDef );
198 OGRErr importFromXML( const char * );
199 OGRErr importFromDict( const char *pszDict, const char *pszCode );
200 OGRErr importFromURN( const char * );
201 OGRErr importFromCRSURL( const char * );
202 OGRErr importFromERM( const char *pszProj, const char *pszDatum,
203 const char *pszUnits );
204 OGRErr importFromUrl( const char * );
205 OGRErr importFromMICoordSys( const char * );
206
207 OGRErr morphToESRI();
208 OGRErr morphFromESRI();
209
210 OGRErr Validate();
211 OGRErr StripCTParms( OGR_SRSNode * = NULL );
212 OGRErr StripVertical();
213 OGRErr FixupOrdering();
214 OGRErr Fixup();
215
216 int EPSGTreatsAsLatLong();
217 int EPSGTreatsAsNorthingEasting();
218 const char *GetAxis( const char *pszTargetKey, int iAxis,
219 OGRAxisOrientation *peOrientation ) const;
220 OGRErr SetAxes( const char *pszTargetKey,
221 const char *pszXAxisName,
222 OGRAxisOrientation eXAxisOrientation,
223 const char *pszYAxisName,
224 OGRAxisOrientation eYAxisOrientation );
225
226 // Machinery for accessing parse nodes
227 OGR_SRSNode *GetRoot() { return poRoot; }
228 const OGR_SRSNode *GetRoot() const { return poRoot; }
229 void SetRoot( OGR_SRSNode * );
230
231 OGR_SRSNode *GetAttrNode(const char *);
232 const OGR_SRSNode *GetAttrNode(const char *) const;
233 const char *GetAttrValue(const char *, int = 0) const;
234
235 OGRErr SetNode( const char *, const char * );
236 OGRErr SetNode( const char *, double );
237
238 OGRErr SetLinearUnitsAndUpdateParameters( const char *pszName,
239 double dfInMeters );
240 OGRErr SetLinearUnits( const char *pszName, double dfInMeters );
241 OGRErr SetTargetLinearUnits( const char *pszTargetKey,
242 const char *pszName, double dfInMeters );
243 double GetLinearUnits( char ** = NULL ) const;
244 double GetTargetLinearUnits( const char *pszTargetKey,
245 char ** ppszRetName = NULL ) const;
246
247 OGRErr SetAngularUnits( const char *pszName, double dfInRadians );
248 double GetAngularUnits( char ** = NULL ) const;
249
250 double GetPrimeMeridian( char ** = NULL ) const;
251
252 int IsGeographic() const;
253 int IsProjected() const;
254 int IsGeocentric() const;
255 int IsLocal() const;
256 int IsVertical() const;
257 int IsCompound() const;
258 int IsSameGeogCS( const OGRSpatialReference * ) const;
259 int IsSameVertCS( const OGRSpatialReference * ) const;
260 int IsSame( const OGRSpatialReference * ) const;
261
262 void Clear();
263 OGRErr SetLocalCS( const char * );
264 OGRErr SetProjCS( const char * );
265 OGRErr SetProjection( const char * );
266 OGRErr SetGeocCS( const char * pszGeocName );
267 OGRErr SetGeogCS( const char * pszGeogName,
268 const char * pszDatumName,
269 const char * pszEllipsoidName,
270 double dfSemiMajor, double dfInvFlattening,
271 const char * pszPMName = NULL,
272 double dfPMOffset = 0.0,
273 const char * pszUnits = NULL,
274 double dfConvertToRadians = 0.0 );
275 OGRErr SetWellKnownGeogCS( const char * );
276 OGRErr CopyGeogCSFrom( const OGRSpatialReference * poSrcSRS );
277 OGRErr SetVertCS( const char *pszVertCSName,
278 const char *pszVertDatumName,
279 int nVertDatumClass = 2005 );
280 OGRErr SetCompoundCS( const char *pszName,
281 const OGRSpatialReference *poHorizSRS,
282 const OGRSpatialReference *poVertSRS );
283
284 OGRErr SetFromUserInput( const char * );
285
286 OGRErr SetTOWGS84( double, double, double,
287 double = 0.0, double = 0.0, double = 0.0,
288 double = 0.0 );
289 OGRErr GetTOWGS84( double *padfCoef, int nCoeff = 7 ) const;
290
291 double GetSemiMajor( OGRErr * = NULL ) const;
292 double GetSemiMinor( OGRErr * = NULL ) const;
293 double GetInvFlattening( OGRErr * = NULL ) const;
294
295 OGRErr SetAuthority( const char * pszTargetKey,
296 const char * pszAuthority,
297 int nCode );
298
299 OGRErr AutoIdentifyEPSG();
300 int GetEPSGGeogCS();
301
302 const char *GetAuthorityCode( const char * pszTargetKey ) const;
303 const char *GetAuthorityName( const char * pszTargetKey ) const;
304
305 const char *GetExtension( const char *pszTargetKey,
306 const char *pszName,
307 const char *pszDefault = NULL ) const;
308 OGRErr SetExtension( const char *pszTargetKey,
309 const char *pszName,
310 const char *pszValue );
311
312 int FindProjParm( const char *pszParameter,
313 const OGR_SRSNode *poPROJCS=NULL ) const;
314 OGRErr SetProjParm( const char *, double );
315 double GetProjParm( const char *, double =0.0, OGRErr* = NULL ) const;
316
317 OGRErr SetNormProjParm( const char *, double );
318 double GetNormProjParm( const char *, double=0.0, OGRErr* =NULL)const;
319
320 static int IsAngularParameter( const char * );
321 static int IsLongitudeParameter( const char * );
322 static int IsLinearParameter( const char * );
323
325 OGRErr SetACEA( double dfStdP1, double dfStdP2,
326 double dfCenterLat, double dfCenterLong,
327 double dfFalseEasting, double dfFalseNorthing );
328
330 OGRErr SetAE( double dfCenterLat, double dfCenterLong,
331 double dfFalseEasting, double dfFalseNorthing );
332
334 OGRErr SetBonne( double dfStdP1, double dfCentralMeridian,
335 double dfFalseEasting, double dfFalseNorthing );
336
338 OGRErr SetCEA( double dfStdP1, double dfCentralMeridian,
339 double dfFalseEasting, double dfFalseNorthing );
340
342 OGRErr SetCS( double dfCenterLat, double dfCenterLong,
343 double dfFalseEasting, double dfFalseNorthing );
344
346 OGRErr SetEC( double dfStdP1, double dfStdP2,
347 double dfCenterLat, double dfCenterLong,
348 double dfFalseEasting, double dfFalseNorthing );
349
351 OGRErr SetEckert( int nVariation, double dfCentralMeridian,
352 double dfFalseEasting, double dfFalseNorthing );
353
354 OGRErr SetEckertIV( double dfCentralMeridian,
355 double dfFalseEasting, double dfFalseNorthing );
356
357 OGRErr SetEckertVI( double dfCentralMeridian,
358 double dfFalseEasting, double dfFalseNorthing );
359
361 OGRErr SetEquirectangular(double dfCenterLat, double dfCenterLong,
362 double dfFalseEasting, double dfFalseNorthing );
364 OGRErr SetEquirectangular2( double dfCenterLat, double dfCenterLong,
365 double dfPseudoStdParallel1,
366 double dfFalseEasting, double dfFalseNorthing );
367
369 OGRErr SetGEOS( double dfCentralMeridian, double dfSatelliteHeight,
370 double dfFalseEasting, double dfFalseNorthing );
371
373 OGRErr SetGH( double dfCentralMeridian,
374 double dfFalseEasting, double dfFalseNorthing );
375
377 OGRErr SetIGH();
378
380 OGRErr SetGS( double dfCentralMeridian,
381 double dfFalseEasting, double dfFalseNorthing );
382
384 OGRErr SetGaussSchreiberTMercator(double dfCenterLat, double dfCenterLong,
385 double dfScale,
386 double dfFalseEasting, double dfFalseNorthing );
387
389 OGRErr SetGnomonic(double dfCenterLat, double dfCenterLong,
390 double dfFalseEasting, double dfFalseNorthing );
391
393 OGRErr SetHOM( double dfCenterLat, double dfCenterLong,
394 double dfAzimuth, double dfRectToSkew,
395 double dfScale,
396 double dfFalseEasting, double dfFalseNorthing );
397
398 OGRErr SetHOM2PNO( double dfCenterLat,
399 double dfLat1, double dfLong1,
400 double dfLat2, double dfLong2,
401 double dfScale,
402 double dfFalseEasting, double dfFalseNorthing );
403
404 OGRErr SetOM( double dfCenterLat, double dfCenterLong,
405 double dfAzimuth, double dfRectToSkew,
406 double dfScale,
407 double dfFalseEasting, double dfFalseNorthing );
408
410 OGRErr SetHOMAC( double dfCenterLat, double dfCenterLong,
411 double dfAzimuth, double dfRectToSkew,
412 double dfScale,
413 double dfFalseEasting, double dfFalseNorthing );
414
416 OGRErr SetIWMPolyconic( double dfLat1, double dfLat2,
417 double dfCenterLong,
418 double dfFalseEasting,
419 double dfFalseNorthing );
420
422 OGRErr SetKrovak( double dfCenterLat, double dfCenterLong,
423 double dfAzimuth, double dfPseudoStdParallelLat,
424 double dfScale,
425 double dfFalseEasting, double dfFalseNorthing );
426
428 OGRErr SetLAEA( double dfCenterLat, double dfCenterLong,
429 double dfFalseEasting, double dfFalseNorthing );
430
432 OGRErr SetLCC( double dfStdP1, double dfStdP2,
433 double dfCenterLat, double dfCenterLong,
434 double dfFalseEasting, double dfFalseNorthing );
435
437 OGRErr SetLCC1SP( double dfCenterLat, double dfCenterLong,
438 double dfScale,
439 double dfFalseEasting, double dfFalseNorthing );
440
442 OGRErr SetLCCB( double dfStdP1, double dfStdP2,
443 double dfCenterLat, double dfCenterLong,
444 double dfFalseEasting, double dfFalseNorthing );
445
447 OGRErr SetMC( double dfCenterLat, double dfCenterLong,
448 double dfFalseEasting, double dfFalseNorthing );
449
451 OGRErr SetMercator( double dfCenterLat, double dfCenterLong,
452 double dfScale,
453 double dfFalseEasting, double dfFalseNorthing );
454
455 OGRErr SetMercator2SP( double dfStdP1,
456 double dfCenterLat, double dfCenterLong,
457 double dfFalseEasting, double dfFalseNorthing );
458
460 OGRErr SetMollweide( double dfCentralMeridian,
461 double dfFalseEasting, double dfFalseNorthing );
462
464 OGRErr SetNZMG( double dfCenterLat, double dfCenterLong,
465 double dfFalseEasting, double dfFalseNorthing );
466
468 OGRErr SetOS( double dfOriginLat, double dfCMeridian,
469 double dfScale,
470 double dfFalseEasting,double dfFalseNorthing);
471
473 OGRErr SetOrthographic( double dfCenterLat, double dfCenterLong,
474 double dfFalseEasting,double dfFalseNorthing);
475
477 OGRErr SetPolyconic( double dfCenterLat, double dfCenterLong,
478 double dfFalseEasting, double dfFalseNorthing );
479
481 OGRErr SetPS( double dfCenterLat, double dfCenterLong,
482 double dfScale,
483 double dfFalseEasting, double dfFalseNorthing);
484
486 OGRErr SetRobinson( double dfCenterLong,
487 double dfFalseEasting, double dfFalseNorthing );
488
490 OGRErr SetSinusoidal( double dfCenterLong,
491 double dfFalseEasting, double dfFalseNorthing );
492
494 OGRErr SetStereographic( double dfCenterLat, double dfCenterLong,
495 double dfScale,
496 double dfFalseEasting,double dfFalseNorthing);
497
499 OGRErr SetSOC( double dfLatitudeOfOrigin, double dfCentralMeridian,
500 double dfFalseEasting, double dfFalseNorthing );
501
503 OGRErr SetTM( double dfCenterLat, double dfCenterLong,
504 double dfScale,
505 double dfFalseEasting, double dfFalseNorthing );
506
508 OGRErr SetTMVariant( const char *pszVariantName,
509 double dfCenterLat, double dfCenterLong,
510 double dfScale,
511 double dfFalseEasting, double dfFalseNorthing );
512
514 OGRErr SetTMG( double dfCenterLat, double dfCenterLong,
515 double dfFalseEasting, double dfFalseNorthing );
516
518 OGRErr SetTMSO( double dfCenterLat, double dfCenterLong,
519 double dfScale,
520 double dfFalseEasting, double dfFalseNorthing );
521
523 OGRErr SetTPED( double dfLat1, double dfLong1,
524 double dfLat2, double dfLong2,
525 double dfFalseEasting, double dfFalseNorthing );
526
528 OGRErr SetVDG( double dfCenterLong,
529 double dfFalseEasting, double dfFalseNorthing );
530
532 OGRErr SetUTM( int nZone, int bNorth = TRUE );
533 int GetUTMZone( int *pbNorth = NULL ) const;
534
536 OGRErr SetWagner( int nVariation, double dfCenterLat,
537 double dfFalseEasting, double dfFalseNorthing );
538
540 OGRErr SetQSC(double dfCenterLat, double dfCenterLong);
541
543 OGRErr SetSCH( double dfPegLat, double dfPegLong,
544 double dfPegHeading, double dfPegHgt);
546 OGRErr SetStatePlane( int nZone, int bNAD83 = TRUE,
547 const char *pszOverrideUnitName = NULL,
548 double dfOverrideUnit = 0.0 );
549
550 OGRErr ImportFromESRIStatePlaneWKT(
551 int nCode, const char* pszDatumName, const char* pszUnitsName,
552 int nPCSCode, const char* pszCSName = NULL );
553 OGRErr ImportFromESRIWisconsinWKT(
554 const char* pszPrjName, double dfCentralMeridian, double dfLatOfOrigin,
555 const char* pszUnitsName, const char* pszCSName = NULL );
556
557 static OGRSpatialReference* GetWGS84SRS();
558 };
559
560 /************************************************************************/
561 /* OGRCoordinateTransformation */
562 /* */
563 /* This is really just used as a base class for a private */
564 /* implementation. */
565 /************************************************************************/
566
576 class CPL_DLL OGRCoordinateTransformation
577 {
578 public:
579 virtual ~OGRCoordinateTransformation() {}
580
581 static void DestroyCT(OGRCoordinateTransformation* poCT);
582
583 // From CT_CoordinateTransformation
584
586 virtual OGRSpatialReference *GetSourceCS() = 0;
587
589 virtual OGRSpatialReference *GetTargetCS() = 0;
590
591 // From CT_MathTransform
592
608 virtual int Transform( int nCount,
609 double *x, double *y, double *z = NULL ) = 0;
610
626 virtual int TransformEx( int nCount,
627 double *x, double *y, double *z = NULL,
628 int *pabSuccess = NULL ) = 0;
629
630 };
631
632 OGRCoordinateTransformation CPL_DLL *
633 OGRCreateCoordinateTransformation( OGRSpatialReference *poSource,
634 OGRSpatialReference *poTarget );
635
636 #endif /* ndef OGR_SPATIALREF_H_INCLUDED */
OGRCreateCoordinateTransformation
OGRCoordinateTransformation * OGRCreateCoordinateTransformation(OGRSpatialReference *poSource, OGRSpatialReference *poTarget)
Create transformation object.
Definition: ogrct.cpp:423
OGR_SRSNode
Objects of this class are used to represent value nodes in the parsed representation of the WKT SRS f...
Definition: ogr_spatialref.h:60
OGR_SRSNode::GetValue
const char * GetValue() const
Fetch value string for this node.
Definition: ogr_spatialref.h:92
ogr_srs_api.h
C spatial reference system services and defines.
OGRSpatialReference
This class represents an OpenGIS Spatial Reference System, and contains methods for converting betwee...
Definition: ogr_spatialref.h:129
OGRSpatialReference::GetReferenceCount
int GetReferenceCount() const
Fetch current reference count.
Definition: ogr_spatialref.h:164
OGRCoordinateTransformation
Interface for transforming between coordinate systems.
Definition: ogr_spatialref.h:576
OGR_SRSNode::GetChildCount
int GetChildCount() const
Get number of children nodes.
Definition: ogr_spatialref.h:78

Generated for GDAL by 1.8.8.