1 : /******************************************************************************
2 : * $Id: ogr_spatialref.h 25727 2013-03-10 14:56:33Z 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 :
36 : /**
37 : * \file ogr_spatialref.h
38 : *
39 : * Coordinate systems services.
40 : */
41 :
42 : /************************************************************************/
43 : /* OGR_SRSNode */
44 : /************************************************************************/
45 :
46 : /**
47 : * Objects of this class are used to represent value nodes in the parsed
48 : * representation of the WKT SRS format. For instance UNIT["METER",1]
49 : * would be rendered into three OGR_SRSNodes. The root node would have a
50 : * value of UNIT, and two children, the first with a value of METER, and the
51 : * second with a value of 1.
52 : *
53 : * Normally application code just interacts with the OGRSpatialReference
54 : * object, which uses the OGR_SRSNode to implement it's data structure;
55 : * however, this class is user accessable for detailed access to components
56 : * of an SRS definition.
57 : */
58 :
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 41149353 : 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 10291673 : 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 :
113 : /**
114 : * This class respresents a OpenGIS Spatial Reference System, and contains
115 : * methods for converting between this object organization and well known
116 : * text (WKT) format. This object is reference counted as one instance of
117 : * the object is normally shared between many OGRGeometry objects.
118 : *
119 : * Normally application code can fetch needed parameter values for this
120 : * SRS using GetAttrValue(), but in special cases the underlying parse tree
121 : * (or OGR_SRSNode objects) can be accessed more directly.
122 : *
123 : * See <a href="osr_tutorial.html">the tutorial</a> for more information on
124 : * how to use this class.
125 : */
126 :
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:
151 : OGRSpatialReference(const OGRSpatialReference&);
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 : void dumpReadable();
169 : OGRErr exportToWkt( char ** ) const;
170 : OGRErr exportToPrettyWkt( char **, int = FALSE) const;
171 : OGRErr exportToProj4( char ** ) const;
172 : OGRErr exportToPCI( char **, char **, double ** ) const;
173 : OGRErr exportToUSGS( long *, long *, double **, long * ) const;
174 : OGRErr exportToXML( char **, const char * = NULL ) const;
175 : OGRErr exportToPanorama( long *, long *, long *, long *,
176 : double * ) const;
177 : OGRErr exportToERM( char *pszProj, char *pszDatum, char *pszUnits );
178 : OGRErr exportToMICoordSys( char ** ) const;
179 :
180 : OGRErr importFromWkt( char ** );
181 : OGRErr importFromProj4( const char * );
182 : OGRErr importFromEPSG( int );
183 : OGRErr importFromEPSGA( int );
184 : OGRErr importFromESRI( char ** );
185 : OGRErr importFromPCI( const char *, const char * = NULL,
186 : double * = NULL );
187 : #define USGS_ANGLE_DECIMALDEGREES 0
188 : #define USGS_ANGLE_PACKEDDMS TRUE /* 1 */
189 : #define USGS_ANGLE_RADIANS 2
190 : OGRErr importFromUSGS( long iProjSys, long iZone,
191 : double *padfPrjParams, long iDatum,
192 : int nUSGSAngleFormat = USGS_ANGLE_PACKEDDMS );
193 : OGRErr importFromPanorama( long, long, long, double* );
194 : OGRErr importFromOzi( const char *, const char *, const char * );
195 : OGRErr importFromOzi( const char * const* papszLines );
196 : OGRErr importFromWMSAUTO( const char *pszAutoDef );
197 : OGRErr importFromXML( const char * );
198 : OGRErr importFromDict( const char *pszDict, const char *pszCode );
199 : OGRErr importFromURN( const char * );
200 : OGRErr importFromCRSURL( const char * );
201 : OGRErr importFromERM( const char *pszProj, const char *pszDatum,
202 : const char *pszUnits );
203 : OGRErr importFromUrl( const char * );
204 : OGRErr importFromMICoordSys( const char * );
205 :
206 : OGRErr morphToESRI();
207 : OGRErr morphFromESRI();
208 :
209 : OGRErr Validate();
210 : OGRErr StripCTParms( OGR_SRSNode * = NULL );
211 : OGRErr StripVertical();
212 : OGRErr FixupOrdering();
213 : OGRErr Fixup();
214 :
215 : int EPSGTreatsAsLatLong();
216 : int EPSGTreatsAsNorthingEasting();
217 : const char *GetAxis( const char *pszTargetKey, int iAxis,
218 : OGRAxisOrientation *peOrientation ) const;
219 : OGRErr SetAxes( const char *pszTargetKey,
220 : const char *pszXAxisName,
221 : OGRAxisOrientation eXAxisOrientation,
222 : const char *pszYAxisName,
223 : OGRAxisOrientation eYAxisOrientation );
224 :
225 : // Machinary for accessing parse nodes
226 2198898 : OGR_SRSNode *GetRoot() { return poRoot; }
227 148532 : const OGR_SRSNode *GetRoot() const { return poRoot; }
228 : void SetRoot( OGR_SRSNode * );
229 :
230 : OGR_SRSNode *GetAttrNode(const char *);
231 : const OGR_SRSNode *GetAttrNode(const char *) const;
232 : const char *GetAttrValue(const char *, int = 0) const;
233 :
234 : OGRErr SetNode( const char *, const char * );
235 : OGRErr SetNode( const char *, double );
236 :
237 : OGRErr SetLinearUnitsAndUpdateParameters( const char *pszName,
238 : double dfInMeters );
239 : OGRErr SetLinearUnits( const char *pszName, double dfInMeters );
240 : OGRErr SetTargetLinearUnits( const char *pszTargetKey,
241 : const char *pszName, double dfInMeters );
242 : double GetLinearUnits( char ** = NULL ) const;
243 : double GetTargetLinearUnits( const char *pszTargetKey,
244 : char ** ppszRetName = NULL ) const;
245 :
246 : OGRErr SetAngularUnits( const char *pszName, double dfInRadians );
247 : double GetAngularUnits( char ** = NULL ) const;
248 :
249 : double GetPrimeMeridian( char ** = NULL ) const;
250 :
251 : int IsGeographic() const;
252 : int IsProjected() const;
253 : int IsGeocentric() const;
254 : int IsLocal() const;
255 : int IsVertical() const;
256 : int IsCompound() const;
257 : int IsSameGeogCS( const OGRSpatialReference * ) const;
258 : int IsSameVertCS( const OGRSpatialReference * ) const;
259 : int IsSame( const OGRSpatialReference * ) const;
260 :
261 : void Clear();
262 : OGRErr SetLocalCS( const char * );
263 : OGRErr SetProjCS( const char * );
264 : OGRErr SetProjection( const char * );
265 : OGRErr SetGeocCS( const char * pszGeocName );
266 : OGRErr SetGeogCS( const char * pszGeogName,
267 : const char * pszDatumName,
268 : const char * pszEllipsoidName,
269 : double dfSemiMajor, double dfInvFlattening,
270 : const char * pszPMName = NULL,
271 : double dfPMOffset = 0.0,
272 : const char * pszUnits = NULL,
273 : double dfConvertToRadians = 0.0 );
274 : OGRErr SetWellKnownGeogCS( const char * );
275 : OGRErr CopyGeogCSFrom( const OGRSpatialReference * poSrcSRS );
276 : OGRErr SetVertCS( const char *pszVertCSName,
277 : const char *pszVertDatumName,
278 : int nVertDatumClass = 2005 );
279 : OGRErr SetCompoundCS( const char *pszName,
280 : const OGRSpatialReference *poHorizSRS,
281 : const OGRSpatialReference *poVertSRS );
282 :
283 : OGRErr SetFromUserInput( const char * );
284 :
285 : OGRErr SetTOWGS84( double, double, double,
286 : double = 0.0, double = 0.0, double = 0.0,
287 : double = 0.0 );
288 : OGRErr GetTOWGS84( double *padfCoef, int nCoeff = 7 ) const;
289 :
290 : double GetSemiMajor( OGRErr * = NULL ) const;
291 : double GetSemiMinor( OGRErr * = NULL ) const;
292 : double GetInvFlattening( OGRErr * = NULL ) const;
293 :
294 : OGRErr SetAuthority( const char * pszTargetKey,
295 : const char * pszAuthority,
296 : int nCode );
297 :
298 : OGRErr AutoIdentifyEPSG();
299 : int GetEPSGGeogCS();
300 :
301 : const char *GetAuthorityCode( const char * pszTargetKey ) const;
302 : const char *GetAuthorityName( const char * pszTargetKey ) const;
303 :
304 : const char *GetExtension( const char *pszTargetKey,
305 : const char *pszName,
306 : const char *pszDefault = NULL ) const;
307 : OGRErr SetExtension( const char *pszTargetKey,
308 : const char *pszName,
309 : const char *pszValue );
310 :
311 : int FindProjParm( const char *pszParameter,
312 : const OGR_SRSNode *poPROJCS=NULL ) const;
313 : OGRErr SetProjParm( const char *, double );
314 : double GetProjParm( const char *, double =0.0, OGRErr* = NULL ) const;
315 :
316 : OGRErr SetNormProjParm( const char *, double );
317 : double GetNormProjParm( const char *, double=0.0, OGRErr* =NULL)const;
318 :
319 : static int IsAngularParameter( const char * );
320 : static int IsLongitudeParameter( const char * );
321 : static int IsLinearParameter( const char * );
322 :
323 : /** Albers Conic Equal Area */
324 : OGRErr SetACEA( double dfStdP1, double dfStdP2,
325 : double dfCenterLat, double dfCenterLong,
326 : double dfFalseEasting, double dfFalseNorthing );
327 :
328 : /** Azimuthal Equidistant */
329 : OGRErr SetAE( double dfCenterLat, double dfCenterLong,
330 : double dfFalseEasting, double dfFalseNorthing );
331 :
332 : /** Bonne */
333 : OGRErr SetBonne( double dfStdP1, double dfCentralMeridian,
334 : double dfFalseEasting, double dfFalseNorthing );
335 :
336 : /** Cylindrical Equal Area */
337 : OGRErr SetCEA( double dfStdP1, double dfCentralMeridian,
338 : double dfFalseEasting, double dfFalseNorthing );
339 :
340 : /** Cassini-Soldner */
341 : OGRErr SetCS( double dfCenterLat, double dfCenterLong,
342 : double dfFalseEasting, double dfFalseNorthing );
343 :
344 : /** Equidistant Conic */
345 : OGRErr SetEC( double dfStdP1, double dfStdP2,
346 : double dfCenterLat, double dfCenterLong,
347 : double dfFalseEasting, double dfFalseNorthing );
348 :
349 : /** Eckert I-VI */
350 : OGRErr SetEckert( int nVariation, double dfCentralMeridian,
351 : double dfFalseEasting, double dfFalseNorthing );
352 :
353 : OGRErr SetEckertIV( double dfCentralMeridian,
354 : double dfFalseEasting, double dfFalseNorthing );
355 :
356 : OGRErr SetEckertVI( double dfCentralMeridian,
357 : double dfFalseEasting, double dfFalseNorthing );
358 :
359 : /** Equirectangular */
360 : OGRErr SetEquirectangular(double dfCenterLat, double dfCenterLong,
361 : double dfFalseEasting, double dfFalseNorthing );
362 : /** Equirectangular generalized form : */
363 : OGRErr SetEquirectangular2( double dfCenterLat, double dfCenterLong,
364 : double dfPseudoStdParallel1,
365 : double dfFalseEasting, double dfFalseNorthing );
366 :
367 : /** Geostationary Satellite */
368 : OGRErr SetGEOS( double dfCentralMeridian, double dfSatelliteHeight,
369 : double dfFalseEasting, double dfFalseNorthing );
370 :
371 : /** Goode Homolosine */
372 : OGRErr SetGH( double dfCentralMeridian,
373 : double dfFalseEasting, double dfFalseNorthing );
374 :
375 : /** Interrupted Goode Homolosine */
376 : OGRErr SetIGH();
377 :
378 : /** Gall Stereograpic */
379 : OGRErr SetGS( double dfCentralMeridian,
380 : double dfFalseEasting, double dfFalseNorthing );
381 :
382 : /** Gauss Schreiber Transverse Mercator */
383 : OGRErr SetGaussSchreiberTMercator(double dfCenterLat, double dfCenterLong,
384 : double dfScale,
385 : double dfFalseEasting, double dfFalseNorthing );
386 :
387 : /** Gnomonic */
388 : OGRErr SetGnomonic(double dfCenterLat, double dfCenterLong,
389 : double dfFalseEasting, double dfFalseNorthing );
390 :
391 : /** Hotine Oblique Mercator */
392 : OGRErr SetHOM( double dfCenterLat, double dfCenterLong,
393 : double dfAzimuth, double dfRectToSkew,
394 : double dfScale,
395 : double dfFalseEasting, double dfFalseNorthing );
396 :
397 : OGRErr SetHOM2PNO( double dfCenterLat,
398 : double dfLat1, double dfLong1,
399 : double dfLat2, double dfLong2,
400 : double dfScale,
401 : double dfFalseEasting, double dfFalseNorthing );
402 :
403 : OGRErr SetOM( double dfCenterLat, double dfCenterLong,
404 : double dfAzimuth, double dfRectToSkew,
405 : double dfScale,
406 : double dfFalseEasting, double dfFalseNorthing );
407 :
408 : /** Hotine Oblique Mercator Azimuth Center / Variant B */
409 : OGRErr SetHOMAC( double dfCenterLat, double dfCenterLong,
410 : double dfAzimuth, double dfRectToSkew,
411 : double dfScale,
412 : double dfFalseEasting, double dfFalseNorthing );
413 :
414 : /** International Map of the World Polyconic */
415 : OGRErr SetIWMPolyconic( double dfLat1, double dfLat2,
416 : double dfCenterLong,
417 : double dfFalseEasting,
418 : double dfFalseNorthing );
419 :
420 : /** Krovak Oblique Conic Conformal */
421 : OGRErr SetKrovak( double dfCenterLat, double dfCenterLong,
422 : double dfAzimuth, double dfPseudoStdParallelLat,
423 : double dfScale,
424 : double dfFalseEasting, double dfFalseNorthing );
425 :
426 : /** Lambert Azimuthal Equal-Area */
427 : OGRErr SetLAEA( double dfCenterLat, double dfCenterLong,
428 : double dfFalseEasting, double dfFalseNorthing );
429 :
430 : /** Lambert Conformal Conic */
431 : OGRErr SetLCC( double dfStdP1, double dfStdP2,
432 : double dfCenterLat, double dfCenterLong,
433 : double dfFalseEasting, double dfFalseNorthing );
434 :
435 : /** Lambert Conformal Conic 1SP */
436 : OGRErr SetLCC1SP( double dfCenterLat, double dfCenterLong,
437 : double dfScale,
438 : double dfFalseEasting, double dfFalseNorthing );
439 :
440 : /** Lambert Conformal Conic (Belgium) */
441 : OGRErr SetLCCB( double dfStdP1, double dfStdP2,
442 : double dfCenterLat, double dfCenterLong,
443 : double dfFalseEasting, double dfFalseNorthing );
444 :
445 : /** Miller Cylindrical */
446 : OGRErr SetMC( double dfCenterLat, double dfCenterLong,
447 : double dfFalseEasting, double dfFalseNorthing );
448 :
449 : /** Mercator */
450 : OGRErr SetMercator( double dfCenterLat, double dfCenterLong,
451 : double dfScale,
452 : double dfFalseEasting, double dfFalseNorthing );
453 :
454 : OGRErr SetMercator2SP( double dfStdP1,
455 : double dfCenterLat, double dfCenterLong,
456 : double dfFalseEasting, double dfFalseNorthing );
457 :
458 : /** Mollweide */
459 : OGRErr SetMollweide( double dfCentralMeridian,
460 : double dfFalseEasting, double dfFalseNorthing );
461 :
462 : /** New Zealand Map Grid */
463 : OGRErr SetNZMG( double dfCenterLat, double dfCenterLong,
464 : double dfFalseEasting, double dfFalseNorthing );
465 :
466 : /** Oblique Stereographic */
467 : OGRErr SetOS( double dfOriginLat, double dfCMeridian,
468 : double dfScale,
469 : double dfFalseEasting,double dfFalseNorthing);
470 :
471 : /** Orthographic */
472 : OGRErr SetOrthographic( double dfCenterLat, double dfCenterLong,
473 : double dfFalseEasting,double dfFalseNorthing);
474 :
475 : /** Polyconic */
476 : OGRErr SetPolyconic( double dfCenterLat, double dfCenterLong,
477 : double dfFalseEasting, double dfFalseNorthing );
478 :
479 : /** Polar Stereographic */
480 : OGRErr SetPS( double dfCenterLat, double dfCenterLong,
481 : double dfScale,
482 : double dfFalseEasting, double dfFalseNorthing);
483 :
484 : /** Robinson */
485 : OGRErr SetRobinson( double dfCenterLong,
486 : double dfFalseEasting, double dfFalseNorthing );
487 :
488 : /** Sinusoidal */
489 : OGRErr SetSinusoidal( double dfCenterLong,
490 : double dfFalseEasting, double dfFalseNorthing );
491 :
492 : /** Stereographic */
493 : OGRErr SetStereographic( double dfCenterLat, double dfCenterLong,
494 : double dfScale,
495 : double dfFalseEasting,double dfFalseNorthing);
496 :
497 : /** Swiss Oblique Cylindrical */
498 : OGRErr SetSOC( double dfLatitudeOfOrigin, double dfCentralMeridian,
499 : double dfFalseEasting, double dfFalseNorthing );
500 :
501 : /** Transverse Mercator */
502 : OGRErr SetTM( double dfCenterLat, double dfCenterLong,
503 : double dfScale,
504 : double dfFalseEasting, double dfFalseNorthing );
505 :
506 : /** Transverse Mercator variants. */
507 : OGRErr SetTMVariant( const char *pszVariantName,
508 : double dfCenterLat, double dfCenterLong,
509 : double dfScale,
510 : double dfFalseEasting, double dfFalseNorthing );
511 :
512 : /** Tunesia Mining Grid */
513 : OGRErr SetTMG( double dfCenterLat, double dfCenterLong,
514 : double dfFalseEasting, double dfFalseNorthing );
515 :
516 : /** Transverse Mercator (South Oriented) */
517 : OGRErr SetTMSO( double dfCenterLat, double dfCenterLong,
518 : double dfScale,
519 : double dfFalseEasting, double dfFalseNorthing );
520 :
521 : /** Two Point Equidistant */
522 : OGRErr SetTPED( double dfLat1, double dfLong1,
523 : double dfLat2, double dfLong2,
524 : double dfFalseEasting, double dfFalseNorthing );
525 :
526 : /** VanDerGrinten */
527 : OGRErr SetVDG( double dfCenterLong,
528 : double dfFalseEasting, double dfFalseNorthing );
529 :
530 : /** Universal Transverse Mercator */
531 : OGRErr SetUTM( int nZone, int bNorth = TRUE );
532 : int GetUTMZone( int *pbNorth = NULL ) const;
533 :
534 : /** Wagner I -- VII */
535 : OGRErr SetWagner( int nVariation, double dfCenterLat,
536 : double dfFalseEasting, double dfFalseNorthing );
537 :
538 : /** State Plane */
539 : OGRErr SetStatePlane( int nZone, int bNAD83 = TRUE,
540 : const char *pszOverrideUnitName = NULL,
541 : double dfOverrideUnit = 0.0 );
542 :
543 : OGRErr ImportFromESRIStatePlaneWKT(
544 : int nCode, const char* pszDatumName, const char* pszUnitsName,
545 : int nPCSCode, const char* pszCSName = 0 );
546 : OGRErr ImportFromESRIWisconsinWKT(
547 : const char* pszPrjName, double dfCentralMeridian, double dfLatOfOrigin,
548 : const char* pszUnitsName, const char* pszCSName = 0 );
549 : };
550 :
551 : /************************************************************************/
552 : /* OGRCoordinateTransformation */
553 : /* */
554 : /* This is really just used as a base class for a private */
555 : /* implementation. */
556 : /************************************************************************/
557 :
558 : /**
559 : * Interface for transforming between coordinate systems.
560 : *
561 : * Currently, the only implementation within OGR is OGRProj4CT, which
562 : * requires the PROJ.4 library to be available at run-time.
563 : *
564 : * Also, see OGRCreateCoordinateTransformation() for creating transformations.
565 : */
566 :
567 : class CPL_DLL OGRCoordinateTransformation
568 504 : {
569 : public:
570 504 : virtual ~OGRCoordinateTransformation() {}
571 :
572 : static void DestroyCT(OGRCoordinateTransformation* poCT);
573 :
574 : // From CT_CoordinateTransformation
575 :
576 : /** Fetch internal source coordinate system. */
577 : virtual OGRSpatialReference *GetSourceCS() = 0;
578 :
579 : /** Fetch internal target coordinate system. */
580 : virtual OGRSpatialReference *GetTargetCS() = 0;
581 :
582 : // From CT_MathTransform
583 :
584 : /**
585 : * Transform points from source to destination space.
586 : *
587 : * This method is the same as the C function OCTTransform().
588 : *
589 : * The method TransformEx() allows extended success information to
590 : * be captured indicating which points failed to transform.
591 : *
592 : * @param nCount number of points to transform.
593 : * @param x array of nCount X vertices, modified in place.
594 : * @param y array of nCount Y vertices, modified in place.
595 : * @param z array of nCount Z vertices, modified in place.
596 : * @return TRUE on success, or FALSE if some or all points fail to
597 : * transform.
598 : */
599 : virtual int Transform( int nCount,
600 : double *x, double *y, double *z = NULL ) = 0;
601 :
602 : /**
603 : * Transform points from source to destination space.
604 : *
605 : * This method is the same as the C function OCTTransformEx().
606 : *
607 : * @param nCount number of points to transform.
608 : * @param x array of nCount X vertices, modified in place.
609 : * @param y array of nCount Y vertices, modified in place.
610 : * @param z array of nCount Z vertices, modified in place.
611 : * @param pabSuccess array of per-point flags set to TRUE if that point
612 : * transforms, or FALSE if it does not.
613 : *
614 : * @return TRUE if some or all points transform successfully, or FALSE if
615 : * if none transform.
616 : */
617 : virtual int TransformEx( int nCount,
618 : double *x, double *y, double *z = NULL,
619 : int *pabSuccess = NULL ) = 0;
620 :
621 : };
622 :
623 : OGRCoordinateTransformation CPL_DLL *
624 : OGRCreateCoordinateTransformation( OGRSpatialReference *poSource,
625 : OGRSpatialReference *poTarget );
626 :
627 : #endif /* ndef _OGR_SPATIALREF_H_INCLUDED */
|