1 : /******************************************************************************
2 : * $Id: ogr_spatialref.h 24323 2012-04-27 05:45:18Z warmerdam $
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 75519357 : 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 18449338 : 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 importFromWMSAUTO( const char *pszAutoDef );
196 : OGRErr importFromXML( const char * );
197 : OGRErr importFromDict( const char *pszDict, const char *pszCode );
198 : OGRErr importFromURN( const char * );
199 : OGRErr importFromERM( const char *pszProj, const char *pszDatum,
200 : const char *pszUnits );
201 : OGRErr importFromUrl( const char * );
202 : OGRErr importFromMICoordSys( const char * );
203 :
204 : OGRErr morphToESRI();
205 : OGRErr morphFromESRI();
206 :
207 : OGRErr Validate();
208 : OGRErr StripCTParms( OGR_SRSNode * = NULL );
209 : OGRErr StripVertical();
210 : OGRErr FixupOrdering();
211 : OGRErr Fixup();
212 :
213 : int EPSGTreatsAsLatLong();
214 : const char *GetAxis( const char *pszTargetKey, int iAxis,
215 : OGRAxisOrientation *peOrientation ) const;
216 : OGRErr SetAxes( const char *pszTargetKey,
217 : const char *pszXAxisName,
218 : OGRAxisOrientation eXAxisOrientation,
219 : const char *pszYAxisName,
220 : OGRAxisOrientation eYAxisOrientation );
221 :
222 : // Machinary for accessing parse nodes
223 3870958 : OGR_SRSNode *GetRoot() { return poRoot; }
224 223260 : const OGR_SRSNode *GetRoot() const { return poRoot; }
225 : void SetRoot( OGR_SRSNode * );
226 :
227 : OGR_SRSNode *GetAttrNode(const char *);
228 : const OGR_SRSNode *GetAttrNode(const char *) const;
229 : const char *GetAttrValue(const char *, int = 0) const;
230 :
231 : OGRErr SetNode( const char *, const char * );
232 : OGRErr SetNode( const char *, double );
233 :
234 : OGRErr SetLinearUnitsAndUpdateParameters( const char *pszName,
235 : double dfInMeters );
236 : OGRErr SetLinearUnits( const char *pszName, double dfInMeters );
237 : OGRErr SetTargetLinearUnits( const char *pszTargetKey,
238 : const char *pszName, double dfInMeters );
239 : double GetLinearUnits( char ** = NULL ) const;
240 : double GetTargetLinearUnits( const char *pszTargetKey,
241 : char ** ppszRetName = NULL ) const;
242 :
243 : OGRErr SetAngularUnits( const char *pszName, double dfInRadians );
244 : double GetAngularUnits( char ** = NULL ) const;
245 :
246 : double GetPrimeMeridian( char ** = NULL ) const;
247 :
248 : int IsGeographic() const;
249 : int IsProjected() const;
250 : int IsGeocentric() const;
251 : int IsLocal() const;
252 : int IsVertical() const;
253 : int IsCompound() const;
254 : int IsSameGeogCS( const OGRSpatialReference * ) const;
255 : int IsSameVertCS( const OGRSpatialReference * ) const;
256 : int IsSame( const OGRSpatialReference * ) const;
257 :
258 : void Clear();
259 : OGRErr SetLocalCS( const char * );
260 : OGRErr SetProjCS( const char * );
261 : OGRErr SetProjection( const char * );
262 : OGRErr SetGeocCS( const char * pszGeocName );
263 : OGRErr SetGeogCS( const char * pszGeogName,
264 : const char * pszDatumName,
265 : const char * pszEllipsoidName,
266 : double dfSemiMajor, double dfInvFlattening,
267 : const char * pszPMName = NULL,
268 : double dfPMOffset = 0.0,
269 : const char * pszUnits = NULL,
270 : double dfConvertToRadians = 0.0 );
271 : OGRErr SetWellKnownGeogCS( const char * );
272 : OGRErr CopyGeogCSFrom( const OGRSpatialReference * poSrcSRS );
273 : OGRErr SetVertCS( const char *pszVertCSName,
274 : const char *pszVertDatumName,
275 : int nVertDatumClass = 2005 );
276 : OGRErr SetCompoundCS( const char *pszName,
277 : const OGRSpatialReference *poHorizSRS,
278 : const OGRSpatialReference *poVertSRS );
279 :
280 : OGRErr SetFromUserInput( const char * );
281 :
282 : OGRErr SetTOWGS84( double, double, double,
283 : double = 0.0, double = 0.0, double = 0.0,
284 : double = 0.0 );
285 : OGRErr GetTOWGS84( double *padfCoef, int nCoeff = 7 ) const;
286 :
287 : double GetSemiMajor( OGRErr * = NULL ) const;
288 : double GetSemiMinor( OGRErr * = NULL ) const;
289 : double GetInvFlattening( OGRErr * = NULL ) const;
290 :
291 : OGRErr SetAuthority( const char * pszTargetKey,
292 : const char * pszAuthority,
293 : int nCode );
294 :
295 : OGRErr AutoIdentifyEPSG();
296 : int GetEPSGGeogCS();
297 :
298 : const char *GetAuthorityCode( const char * pszTargetKey ) const;
299 : const char *GetAuthorityName( const char * pszTargetKey ) const;
300 :
301 : const char *GetExtension( const char *pszTargetKey,
302 : const char *pszName,
303 : const char *pszDefault = NULL ) const;
304 : OGRErr SetExtension( const char *pszTargetKey,
305 : const char *pszName,
306 : const char *pszValue );
307 :
308 : int FindProjParm( const char *pszParameter,
309 : const OGR_SRSNode *poPROJCS=NULL ) const;
310 : OGRErr SetProjParm( const char *, double );
311 : double GetProjParm( const char *, double =0.0, OGRErr* = NULL ) const;
312 :
313 : OGRErr SetNormProjParm( const char *, double );
314 : double GetNormProjParm( const char *, double=0.0, OGRErr* =NULL)const;
315 :
316 : static int IsAngularParameter( const char * );
317 : static int IsLongitudeParameter( const char * );
318 : static int IsLinearParameter( const char * );
319 :
320 : /** Albers Conic Equal Area */
321 : OGRErr SetACEA( double dfStdP1, double dfStdP2,
322 : double dfCenterLat, double dfCenterLong,
323 : double dfFalseEasting, double dfFalseNorthing );
324 :
325 : /** Azimuthal Equidistant */
326 : OGRErr SetAE( double dfCenterLat, double dfCenterLong,
327 : double dfFalseEasting, double dfFalseNorthing );
328 :
329 : /** Bonne */
330 : OGRErr SetBonne( double dfStdP1, double dfCentralMeridian,
331 : double dfFalseEasting, double dfFalseNorthing );
332 :
333 : /** Cylindrical Equal Area */
334 : OGRErr SetCEA( double dfStdP1, double dfCentralMeridian,
335 : double dfFalseEasting, double dfFalseNorthing );
336 :
337 : /** Cassini-Soldner */
338 : OGRErr SetCS( double dfCenterLat, double dfCenterLong,
339 : double dfFalseEasting, double dfFalseNorthing );
340 :
341 : /** Equidistant Conic */
342 : OGRErr SetEC( double dfStdP1, double dfStdP2,
343 : double dfCenterLat, double dfCenterLong,
344 : double dfFalseEasting, double dfFalseNorthing );
345 :
346 : /** Eckert I-VI */
347 : OGRErr SetEckert( int nVariation, double dfCentralMeridian,
348 : double dfFalseEasting, double dfFalseNorthing );
349 :
350 : OGRErr SetEckertIV( double dfCentralMeridian,
351 : double dfFalseEasting, double dfFalseNorthing );
352 :
353 : OGRErr SetEckertVI( double dfCentralMeridian,
354 : double dfFalseEasting, double dfFalseNorthing );
355 :
356 : /** Equirectangular */
357 : OGRErr SetEquirectangular(double dfCenterLat, double dfCenterLong,
358 : double dfFalseEasting, double dfFalseNorthing );
359 : /** Equirectangular generalized form : */
360 : OGRErr SetEquirectangular2( double dfCenterLat, double dfCenterLong,
361 : double dfPseudoStdParallel1,
362 : double dfFalseEasting, double dfFalseNorthing );
363 :
364 : /** Geostationary Satellite */
365 : OGRErr SetGEOS( double dfCentralMeridian, double dfSatelliteHeight,
366 : double dfFalseEasting, double dfFalseNorthing );
367 :
368 : /** Goode Homolosine */
369 : OGRErr SetGH( double dfCentralMeridian,
370 : double dfFalseEasting, double dfFalseNorthing );
371 :
372 : /** Interrupted Goode Homolosine */
373 : OGRErr SetIGH();
374 :
375 : /** Gall Stereograpic */
376 : OGRErr SetGS( double dfCentralMeridian,
377 : double dfFalseEasting, double dfFalseNorthing );
378 :
379 : /** Gauss Schreiber Transverse Mercator */
380 : OGRErr SetGaussSchreiberTMercator(double dfCenterLat, double dfCenterLong,
381 : double dfScale,
382 : double dfFalseEasting, double dfFalseNorthing );
383 :
384 : /** Gnomonic */
385 : OGRErr SetGnomonic(double dfCenterLat, double dfCenterLong,
386 : double dfFalseEasting, double dfFalseNorthing );
387 :
388 : /** Hotine Oblique Mercator */
389 : OGRErr SetHOM( double dfCenterLat, double dfCenterLong,
390 : double dfAzimuth, double dfRectToSkew,
391 : double dfScale,
392 : double dfFalseEasting, double dfFalseNorthing );
393 :
394 : OGRErr SetHOM2PNO( double dfCenterLat,
395 : double dfLat1, double dfLong1,
396 : double dfLat2, double dfLong2,
397 : double dfScale,
398 : double dfFalseEasting, double dfFalseNorthing );
399 :
400 : OGRErr SetOM( double dfCenterLat, double dfCenterLong,
401 : double dfAzimuth, double dfRectToSkew,
402 : double dfScale,
403 : double dfFalseEasting, double dfFalseNorthing );
404 :
405 : /** Hotine Oblique Mercator Azimuth Center / Variant B */
406 : OGRErr SetHOMAC( double dfCenterLat, double dfCenterLong,
407 : double dfAzimuth, double dfRectToSkew,
408 : double dfScale,
409 : double dfFalseEasting, double dfFalseNorthing );
410 :
411 : /** International Map of the World Polyconic */
412 : OGRErr SetIWMPolyconic( double dfLat1, double dfLat2,
413 : double dfCenterLong,
414 : double dfFalseEasting,
415 : double dfFalseNorthing );
416 :
417 : /** Krovak Oblique Conic Conformal */
418 : OGRErr SetKrovak( double dfCenterLat, double dfCenterLong,
419 : double dfAzimuth, double dfPseudoStdParallelLat,
420 : double dfScale,
421 : double dfFalseEasting, double dfFalseNorthing );
422 :
423 : /** Lambert Azimuthal Equal-Area */
424 : OGRErr SetLAEA( double dfCenterLat, double dfCenterLong,
425 : double dfFalseEasting, double dfFalseNorthing );
426 :
427 : /** Lambert Conformal Conic */
428 : OGRErr SetLCC( double dfStdP1, double dfStdP2,
429 : double dfCenterLat, double dfCenterLong,
430 : double dfFalseEasting, double dfFalseNorthing );
431 :
432 : /** Lambert Conformal Conic 1SP */
433 : OGRErr SetLCC1SP( double dfCenterLat, double dfCenterLong,
434 : double dfScale,
435 : double dfFalseEasting, double dfFalseNorthing );
436 :
437 : /** Lambert Conformal Conic (Belgium) */
438 : OGRErr SetLCCB( double dfStdP1, double dfStdP2,
439 : double dfCenterLat, double dfCenterLong,
440 : double dfFalseEasting, double dfFalseNorthing );
441 :
442 : /** Miller Cylindrical */
443 : OGRErr SetMC( double dfCenterLat, double dfCenterLong,
444 : double dfFalseEasting, double dfFalseNorthing );
445 :
446 : /** Mercator */
447 : OGRErr SetMercator( double dfCenterLat, double dfCenterLong,
448 : double dfScale,
449 : double dfFalseEasting, double dfFalseNorthing );
450 :
451 : OGRErr SetMercator2SP( double dfStdP1,
452 : double dfCenterLat, double dfCenterLong,
453 : double dfFalseEasting, double dfFalseNorthing );
454 :
455 : /** Mollweide */
456 : OGRErr SetMollweide( double dfCentralMeridian,
457 : double dfFalseEasting, double dfFalseNorthing );
458 :
459 : /** New Zealand Map Grid */
460 : OGRErr SetNZMG( double dfCenterLat, double dfCenterLong,
461 : double dfFalseEasting, double dfFalseNorthing );
462 :
463 : /** Oblique Stereographic */
464 : OGRErr SetOS( double dfOriginLat, double dfCMeridian,
465 : double dfScale,
466 : double dfFalseEasting,double dfFalseNorthing);
467 :
468 : /** Orthographic */
469 : OGRErr SetOrthographic( double dfCenterLat, double dfCenterLong,
470 : double dfFalseEasting,double dfFalseNorthing);
471 :
472 : /** Polyconic */
473 : OGRErr SetPolyconic( double dfCenterLat, double dfCenterLong,
474 : double dfFalseEasting, double dfFalseNorthing );
475 :
476 : /** Polar Stereographic */
477 : OGRErr SetPS( double dfCenterLat, double dfCenterLong,
478 : double dfScale,
479 : double dfFalseEasting, double dfFalseNorthing);
480 :
481 : /** Robinson */
482 : OGRErr SetRobinson( double dfCenterLong,
483 : double dfFalseEasting, double dfFalseNorthing );
484 :
485 : /** Sinusoidal */
486 : OGRErr SetSinusoidal( double dfCenterLong,
487 : double dfFalseEasting, double dfFalseNorthing );
488 :
489 : /** Stereographic */
490 : OGRErr SetStereographic( double dfCenterLat, double dfCenterLong,
491 : double dfScale,
492 : double dfFalseEasting,double dfFalseNorthing);
493 :
494 : /** Swiss Oblique Cylindrical */
495 : OGRErr SetSOC( double dfLatitudeOfOrigin, double dfCentralMeridian,
496 : double dfFalseEasting, double dfFalseNorthing );
497 :
498 : /** Transverse Mercator */
499 : OGRErr SetTM( double dfCenterLat, double dfCenterLong,
500 : double dfScale,
501 : double dfFalseEasting, double dfFalseNorthing );
502 :
503 : /** Transverse Mercator variants. */
504 : OGRErr SetTMVariant( const char *pszVariantName,
505 : double dfCenterLat, double dfCenterLong,
506 : double dfScale,
507 : double dfFalseEasting, double dfFalseNorthing );
508 :
509 : /** Tunesia Mining Grid */
510 : OGRErr SetTMG( double dfCenterLat, double dfCenterLong,
511 : double dfFalseEasting, double dfFalseNorthing );
512 :
513 : /** Transverse Mercator (South Oriented) */
514 : OGRErr SetTMSO( double dfCenterLat, double dfCenterLong,
515 : double dfScale,
516 : double dfFalseEasting, double dfFalseNorthing );
517 :
518 : /** Two Point Equidistant */
519 : OGRErr SetTPED( double dfLat1, double dfLong1,
520 : double dfLat2, double dfLong2,
521 : double dfFalseEasting, double dfFalseNorthing );
522 :
523 : /** VanDerGrinten */
524 : OGRErr SetVDG( double dfCenterLong,
525 : double dfFalseEasting, double dfFalseNorthing );
526 :
527 : /** Universal Transverse Mercator */
528 : OGRErr SetUTM( int nZone, int bNorth = TRUE );
529 : int GetUTMZone( int *pbNorth = NULL ) const;
530 :
531 : /** Wagner I -- VII */
532 : OGRErr SetWagner( int nVariation, double dfCenterLat,
533 : double dfFalseEasting, double dfFalseNorthing );
534 :
535 : /** State Plane */
536 : OGRErr SetStatePlane( int nZone, int bNAD83 = TRUE,
537 : const char *pszOverrideUnitName = NULL,
538 : double dfOverrideUnit = 0.0 );
539 :
540 : OGRErr ImportFromESRIStatePlaneWKT(
541 : int nCode, const char* pszDatumName, const char* pszUnitsName,
542 : int nPCSCode, const char* pszCSName = 0 );
543 : OGRErr ImportFromESRIWisconsinWKT(
544 : const char* pszPrjName, double dfCentralMeridian, double dfLatOfOrigin,
545 : const char* pszUnitsName, const char* pszCSName = 0 );
546 : };
547 :
548 : /************************************************************************/
549 : /* OGRCoordinateTransformation */
550 : /* */
551 : /* This is really just used as a base class for a private */
552 : /* implementation. */
553 : /************************************************************************/
554 :
555 : /**
556 : * Interface for transforming between coordinate systems.
557 : *
558 : * Currently, the only implementation within OGR is OGRProj4CT, which
559 : * requires the PROJ.4 library to be available at run-time.
560 : *
561 : * Also, see OGRCreateCoordinateTransformation() for creating transformations.
562 : */
563 :
564 : class CPL_DLL OGRCoordinateTransformation
565 822 : {
566 : public:
567 822 : virtual ~OGRCoordinateTransformation() {}
568 :
569 : static void DestroyCT(OGRCoordinateTransformation* poCT);
570 :
571 : // From CT_CoordinateTransformation
572 :
573 : /** Fetch internal source coordinate system. */
574 : virtual OGRSpatialReference *GetSourceCS() = 0;
575 :
576 : /** Fetch internal target coordinate system. */
577 : virtual OGRSpatialReference *GetTargetCS() = 0;
578 :
579 : // From CT_MathTransform
580 :
581 : /**
582 : * Transform points from source to destination space.
583 : *
584 : * This method is the same as the C function OCTTransform().
585 : *
586 : * The method TransformEx() allows extended success information to
587 : * be captured indicating which points failed to transform.
588 : *
589 : * @param nCount number of points to transform.
590 : * @param x array of nCount X vertices, modified in place.
591 : * @param y array of nCount Y vertices, modified in place.
592 : * @param z array of nCount Z vertices, modified in place.
593 : * @return TRUE on success, or FALSE if some or all points fail to
594 : * transform.
595 : */
596 : virtual int Transform( int nCount,
597 : double *x, double *y, double *z = NULL ) = 0;
598 :
599 : /**
600 : * Transform points from source to destination space.
601 : *
602 : * This method is the same as the C function OCTTransformEx().
603 : *
604 : * @param nCount number of points to transform.
605 : * @param x array of nCount X vertices, modified in place.
606 : * @param y array of nCount Y vertices, modified in place.
607 : * @param z array of nCount Z vertices, modified in place.
608 : * @param pabSuccess array of per-point flags set to TRUE if that point
609 : * transforms, or FALSE if it does not.
610 : *
611 : * @return TRUE if some or all points transform successfully, or FALSE if
612 : * if none transform.
613 : */
614 : virtual int TransformEx( int nCount,
615 : double *x, double *y, double *z = NULL,
616 : int *pabSuccess = NULL ) = 0;
617 :
618 : };
619 :
620 : OGRCoordinateTransformation CPL_DLL *
621 : OGRCreateCoordinateTransformation( OGRSpatialReference *poSource,
622 : OGRSpatialReference *poTarget );
623 :
624 : #endif /* ndef _OGR_SPATIALREF_H_INCLUDED */
|