Statistics
| Revision:

svn-gvsig-desktop / tags / v2_0_Build_1220 / libraries / libjni-gdal-macosx / include / ogr_spatialref.h @ 33831

History | View | Annotate | Download (21.2 KB)

1
/******************************************************************************
2
 * $Id: ogr_spatialref.h 8219 2006-10-23 06:25:39Z nacho $
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
 * $Log$
32
 * Revision 1.1  2006-10-23 06:25:39  nacho
33
 * *** empty log message ***
34
 *
35
 * Revision 1.1  2006/06/29 16:23:27  nacho
36
 * *** empty log message ***
37
 *
38
 * Revision 1.2  2006/01/09 12:50:13  nacho
39
 * *** empty log message ***
40
 *
41
 * Revision 1.1  2005/07/27 08:22:55  igbrotru
42
 * *** empty log message ***
43
 *
44
 * Revision 1.1  2005/01/11 15:23:01  igbrotru
45
 * *** empty log message ***
46
 *
47
 * Revision 1.61  2004/05/10 17:05:14  warmerda
48
 * added AutoIdentifyEPSG()
49
 *
50
 * Revision 1.60  2004/03/04 18:04:45  warmerda
51
 * added importFromDict() support
52
 *
53
 * Revision 1.59  2004/02/07 17:31:21  dron
54
 * Added OSRExportToUSGS() method.
55
 *
56
 * Revision 1.58  2004/02/05 17:07:59  dron
57
 * Support for HOM projection, specified by two points on centerline.
58
 *
59
 * Revision 1.57  2004/02/01 14:24:09  dron
60
 * Added OGRSpatialReference::importFromUSGS().
61
 *
62
 * Revision 1.56  2004/01/24 09:34:59  warmerda
63
 * added TransformEx support to capture per point reprojection failure
64
 *
65
 * Revision 1.55  2003/10/07 04:20:50  warmerda
66
 * added WMS AUTO: support
67
 *
68
 * Revision 1.54  2003/09/09 07:49:19  dron
69
 * Added exportToPCI() method.
70
 *
71
 * Revision 1.53  2003/08/31 14:51:30  dron
72
 * Added importFromPCI() method.
73
 *
74
 * Revision 1.52  2003/08/18 13:26:01  warmerda
75
 * added SetTMVariant() and related definitions
76
 *
77
 * Revision 1.51  2003/05/30 15:39:53  warmerda
78
 * Added override units capability for SetStatePlane()
79
 *
80
 * Revision 1.50  2003/05/28 19:16:42  warmerda
81
 * fixed up argument names and stuff for docs
82
 *
83
 * Revision 1.49  2003/03/12 14:25:01  warmerda
84
 * added NeedsQuoting() method
85
 *
86
 * Revision 1.48  2003/02/25 04:53:51  warmerda
87
 * added CopyGeogCSFrom() method
88
 *
89
 * Revision 1.47  2003/02/06 04:53:12  warmerda
90
 * added Fixup() method
91
 *
92
 * Revision 1.46  2003/01/08 18:14:28  warmerda
93
 * added FixupOrdering()
94
 */
95

    
96
#ifndef _OGR_SPATIALREF_H_INCLUDED
97
#define _OGR_SPATIALREF_H_INCLUDED
98

    
99
#include "ogr_srs_api.h"
100

    
101
/**
102
 * \file ogr_spatialref.h
103
 *
104
 * Coordinate systems services.
105
 */
106

    
107
/************************************************************************/
108
/*                             OGR_SRSNode                              */
109
/************************************************************************/
110

    
111
/**
112
 * Objects of this class are used to represent value nodes in the parsed
113
 * representation of the WKT SRS format.  For instance UNIT["METER",1]
114
 * would be rendered into three OGR_SRSNodes.  The root node would have a
115
 * value of UNIT, and two children, the first with a value of METER, and the
116
 * second with a value of 1.
117
 *
118
 * Normally application code just interacts with the OGRSpatialReference
119
 * object, which uses the OGR_SRSNode to implement it's data structure;
120
 * however, this class is user accessable for detailed access to components
121
 * of an SRS definition.
122
 */
123

    
124
class CPL_DLL OGR_SRSNode
125
{
126
    char        *pszValue;
127

    
128
    int         nChildren;
129
    OGR_SRSNode **papoChildNodes;
130

    
131
    OGR_SRSNode *poParent;
132

    
133
    void        ClearChildren();
134
    int         NeedsQuoting() const;
135
    
136
  public:
137
                OGR_SRSNode(const char * = NULL);
138
                ~OGR_SRSNode();
139

    
140
    int         IsLeafNode() const { return nChildren == 0; }
141
    
142
    int         GetChildCount() const { return nChildren; }
143
    OGR_SRSNode *GetChild( int );
144
    const OGR_SRSNode *GetChild( int ) const;
145

    
146
    OGR_SRSNode *GetNode( const char * );
147
    const OGR_SRSNode *GetNode( const char * ) const;
148

    
149
    void        InsertChild( OGR_SRSNode *, int );
150
    void        AddChild( OGR_SRSNode * );
151
    int         FindChild( const char * ) const;
152
    void        DestroyChild( int );
153
    void        StripNodes( const char * );
154

    
155
    const char  *GetValue() const { return pszValue; }
156
    void        SetValue( const char * );
157

    
158
    void        MakeValueSafe();
159
    OGRErr      FixupOrdering();
160

    
161
    OGR_SRSNode *Clone() const;
162

    
163
    OGRErr      importFromWkt( char ** );
164
    OGRErr      exportToWkt( char ** ) const;
165
    OGRErr      exportToPrettyWkt( char **, int = 1) const;
166
    
167
    OGRErr      applyRemapper( const char *pszNode, 
168
                               char **papszSrcValues, 
169
                               char **papszDstValues, 
170
                               int nStepSize = 1,
171
                               int bChildOfHit = FALSE );
172
};
173

    
174
/************************************************************************/
175
/*                         OGRSpatialReference                          */
176
/************************************************************************/
177

    
178
/**
179
 * This class respresents a OpenGIS Spatial Reference System, and contains
180
 * methods for converting between this object organization and well known
181
 * text (WKT) format.  This object is reference counted as one instance of
182
 * the object is normally shared between many OGRGeometry objects.
183
 *
184
 * Normally application code can fetch needed parameter values for this
185
 * SRS using GetAttrValue(), but in special cases the underlying parse tree
186
 * (or OGR_SRSNode objects) can be accessed more directly.
187
 *
188
 * See <a href="osr_tutorial.html">the tutorial</a> for more information on
189
 * how to use this class.
190
 */
191

    
192
class CPL_DLL OGRSpatialReference
193
{
194
    int         nRefCount;
195

    
196
    OGR_SRSNode *poRoot;
197

    
198
    int         bNormInfoSet;
199
    double      dfFromGreenwich;
200
    double      dfToMeter;
201
    double      dfToDegrees;
202

    
203
    OGRErr      ValidateProjection();
204
    int         IsAliasFor( const char *, const char * );
205
    void        GetNormInfo() const;
206

    
207
  public:
208
                OGRSpatialReference(const OGRSpatialReference&);
209
                OGRSpatialReference(const char * = NULL);
210
                
211
    virtual    ~OGRSpatialReference();
212
                
213
    OGRSpatialReference &operator=(const OGRSpatialReference&);
214

    
215
    int         Reference();
216
    int         Dereference();
217
    int         GetReferenceCount() const { return nRefCount; }
218

    
219
    OGRSpatialReference *Clone() const;
220
    OGRSpatialReference *CloneGeogCS() const;
221

    
222
    OGRErr      exportToWkt( char ** );
223
    OGRErr      exportToPrettyWkt( char **, int = FALSE) const;
224
    OGRErr      exportToProj4( char ** ) const;
225
    OGRErr      exportToPCI( char **, char **, double ** ) const;
226
    OGRErr      exportToUSGS( long *, long *, double **, long * ) const;
227
    OGRErr      exportToXML( char **, const char * = NULL ) const;
228
    OGRErr      importFromWkt( char ** );
229
    OGRErr      importFromProj4( const char * );
230
    OGRErr      importFromEPSG( int );
231
    OGRErr      importFromESRI( char ** );
232
    OGRErr      importFromPCI( const char *pszProj,
233
                               const char *pszUnits = NULL,
234
                               double *padfPrjParams = NULL );
235
    OGRErr      importFromUSGS( long iProjsys, long iZone,
236
                                double *padfPrjParams, long iDatum );
237
    OGRErr      importFromWMSAUTO( const char *pszAutoDef );
238
    OGRErr      importFromXML( const char * );
239
    OGRErr      importFromDict( const char *pszDict, const char *pszCode );
240

    
241
    OGRErr      morphToESRI();
242
    OGRErr      morphFromESRI();
243

    
244
    OGRErr      Validate();
245
    OGRErr      StripCTParms( OGR_SRSNode * = NULL );
246
    OGRErr      FixupOrdering();
247
    OGRErr      Fixup();
248

    
249
    // Machinary for accessing parse nodes
250
    OGR_SRSNode *GetRoot() { return poRoot; }
251
    const OGR_SRSNode *GetRoot() const { return poRoot; }
252
    void        SetRoot( OGR_SRSNode * );
253
    
254
    OGR_SRSNode *GetAttrNode(const char *);
255
    const OGR_SRSNode *GetAttrNode(const char *) const;
256
    const char  *GetAttrValue(const char *, int = 0) const;
257

    
258
    OGRErr      SetNode( const char *, const char * );
259
    OGRErr      SetNode( const char *, double );
260

    
261
    OGRErr      SetLinearUnits( const char *pszName, double dfInMeters );
262
    double      GetLinearUnits( char ** = NULL ) const;
263

    
264
    OGRErr      SetAngularUnits( const char *pszName, double dfInRadians );
265
    double      GetAngularUnits( char ** = NULL ) const;
266

    
267
    double      GetPrimeMeridian( char ** = NULL ) const;
268

    
269
    int         IsGeographic() const;
270
    int         IsProjected() const;
271
    int         IsLocal() const;
272
    int         IsSameGeogCS( const OGRSpatialReference * ) const;
273
    int         IsSame( const OGRSpatialReference * ) const;
274

    
275
    void        Clear();
276
    OGRErr      SetLocalCS( const char * );
277
    OGRErr      SetProjCS( const char * );
278
    OGRErr      SetProjection( const char * );
279
    OGRErr      SetGeogCS( const char * pszGeogName,
280
                           const char * pszDatumName,
281
                           const char * pszEllipsoidName,
282
                           double dfSemiMajor, double dfInvFlattening,
283
                           const char * pszPMName = NULL,
284
                           double dfPMOffset = 0.0,
285
                           const char * pszUnits = NULL,
286
                           double dfConvertToRadians = 0.0 );
287
    OGRErr      SetWellKnownGeogCS( const char * );
288
    OGRErr      CopyGeogCSFrom( const OGRSpatialReference * poSrcSRS );
289

    
290
    OGRErr      SetFromUserInput( const char * );
291

    
292
    OGRErr      SetTOWGS84( double, double, double,
293
                            double = 0.0, double = 0.0, double = 0.0,
294
                            double = 0.0 );
295
    OGRErr      GetTOWGS84( double *padfCoef, int nCoeff = 7 ) const;
296
    
297
    double      GetSemiMajor( OGRErr * = NULL ) const;
298
    double      GetSemiMinor( OGRErr * = NULL ) const;
299
    double      GetInvFlattening( OGRErr * = NULL ) const;
300

    
301
    OGRErr      SetAuthority( const char * pszTargetKey, 
302
                              const char * pszAuthority, 
303
                              int nCode );
304

    
305
    OGRErr      AutoIdentifyEPSG();
306

    
307
    const char *GetAuthorityCode( const char * pszTargetKey ) const;
308
    const char *GetAuthorityName( const char * pszTargetKey ) const;
309
                           
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
    /** Cylindrical Equal Area */
330
    OGRErr      SetCEA( double dfStdP1, double dfCentralMeridian,
331
                        double dfFalseEasting, double dfFalseNorthing );
332

    
333
    /** Cassini-Soldner */
334
    OGRErr      SetCS( double dfCenterLat, double dfCenterLong,
335
                       double dfFalseEasting, double dfFalseNorthing );
336

    
337
    /** Equidistant Conic */
338
    OGRErr      SetEC( double dfStdP1, double dfStdP2,
339
                       double dfCenterLat, double dfCenterLong,
340
                       double dfFalseEasting, double dfFalseNorthing );
341

    
342
    /** Eckert IV */
343
    OGRErr      SetEckertIV( double dfCentralMeridian,
344
                             double dfFalseEasting, double dfFalseNorthing );
345

    
346
    /** Eckert VI */
347
    OGRErr      SetEckertVI( double dfCentralMeridian,
348
                             double dfFalseEasting, double dfFalseNorthing );
349

    
350
    /** Equirectangular */
351
    OGRErr      SetEquirectangular(double dfCenterLat, double dfCenterLong,
352
                            double dfFalseEasting, double dfFalseNorthing );
353

    
354
    /** Gall Stereograpic */
355
    OGRErr      SetGS( double dfCentralMeridian,
356
                       double dfFalseEasting, double dfFalseNorthing );
357
    
358
    /** Gnomonic */
359
    OGRErr      SetGnomonic(double dfCenterLat, double dfCenterLong,
360
                            double dfFalseEasting, double dfFalseNorthing );
361

    
362
    OGRErr      SetHOM( double dfCenterLat, double dfCenterLong,
363
                        double dfAzimuth, double dfRectToSkew,
364
                        double dfScale,
365
                        double dfFalseEasting, double dfFalseNorthing );
366

    
367
    OGRErr      SetHOM2PNO( double dfCenterLat,
368
                            double dfLat1, double dfLong1,
369
                            double dfLat2, double dfLong2,
370
                            double dfScale,
371
                            double dfFalseEasting, double dfFalseNorthing );
372

    
373
    /** Krovak Oblique Conic Conformal */
374
    OGRErr      SetKrovak( double dfCenterLat, double dfCenterLong,
375
                           double dfAzimuth, double dfPseudoStdParallelLat,
376
                           double dfScale, 
377
                           double dfFalseEasting, double dfFalseNorthing );
378

    
379
    /** Lambert Azimuthal Equal-Area */
380
    OGRErr      SetLAEA( double dfCenterLat, double dfCenterLong,
381
                         double dfFalseEasting, double dfFalseNorthing );
382

    
383
    /** Lambert Conformal Conic */
384
    OGRErr      SetLCC( double dfStdP1, double dfStdP2,
385
                        double dfCenterLat, double dfCenterLong,
386
                        double dfFalseEasting, double dfFalseNorthing );
387

    
388
    /** Lambert Conformal Conic 1SP */
389
    OGRErr      SetLCC1SP( double dfCenterLat, double dfCenterLong,
390
                           double dfScale,
391
                           double dfFalseEasting, double dfFalseNorthing );
392

    
393
    /** Lambert Conformal Conic (Belgium) */
394
    OGRErr      SetLCCB( double dfStdP1, double dfStdP2,
395
                         double dfCenterLat, double dfCenterLong,
396
                         double dfFalseEasting, double dfFalseNorthing );
397
    
398
    /** Miller Cylindrical */
399
    OGRErr      SetMC( double dfCenterLat, double dfCenterLong,
400
                       double dfFalseEasting, double dfFalseNorthing );
401

    
402
    /** Mercator */
403
    OGRErr      SetMercator( double dfCenterLat, double dfCenterLong,
404
                             double dfScale, 
405
                             double dfFalseEasting, double dfFalseNorthing );
406

    
407
    /** Mollweide */
408
    OGRErr      SetMollweide( double dfCentralMeridian,
409
                              double dfFalseEasting, double dfFalseNorthing );
410

    
411
    /** New Zealand Map Grid */
412
    OGRErr      SetNZMG( double dfCenterLat, double dfCenterLong,
413
                         double dfFalseEasting, double dfFalseNorthing );
414

    
415
    /** Oblique Stereographic */
416
    OGRErr      SetOS( double dfOriginLat, double dfCMeridian,
417
                       double dfScale,
418
                       double dfFalseEasting,double dfFalseNorthing);
419
    
420
    /** Orthographic */
421
    OGRErr      SetOrthographic( double dfCenterLat, double dfCenterLong,
422
                                 double dfFalseEasting,double dfFalseNorthing);
423

    
424
    /** Polyconic */
425
    OGRErr      SetPolyconic( double dfCenterLat, double dfCenterLong,
426
                              double dfFalseEasting, double dfFalseNorthing );
427

    
428
    /** Polar Stereographic */
429
    OGRErr      SetPS( double dfCenterLat, double dfCenterLong,
430
                       double dfScale,
431
                       double dfFalseEasting, double dfFalseNorthing);
432
    
433
    /** Robinson */
434
    OGRErr      SetRobinson( double dfCenterLong, 
435
                             double dfFalseEasting, double dfFalseNorthing );
436
    
437
    /** Sinusoidal */
438
    OGRErr      SetSinusoidal( double dfCenterLong, 
439
                               double dfFalseEasting, double dfFalseNorthing );
440
    
441
    /** Stereographic */
442
    OGRErr      SetStereographic( double dfCenterLat, double dfCenterLong,
443
                                  double dfScale,
444
                                 double dfFalseEasting,double dfFalseNorthing);
445
    
446
    /** Swiss Oblique Cylindrical */
447
    OGRErr      SetSOC( double dfLatitudeOfOrigin, double dfCentralMeridian,
448
                        double dfFalseEasting, double dfFalseNorthing );
449
    
450
    /** Transverse Mercator */
451
    OGRErr      SetTM( double dfCenterLat, double dfCenterLong,
452
                       double dfScale,
453
                       double dfFalseEasting, double dfFalseNorthing );
454

    
455
    /** Transverse Mercator variants. */
456
    OGRErr      SetTMVariant( const char *pszVariantName, 
457
                              double dfCenterLat, double dfCenterLong,
458
                              double dfScale,
459
                              double dfFalseEasting, double dfFalseNorthing );
460

    
461
    /** Tunesia Mining Grid  */
462
    OGRErr      SetTMG( double dfCenterLat, double dfCenterLong, 
463
                        double dfFalseEasting, double dfFalseNorthing );
464

    
465
    /** Transverse Mercator (South Oriented) */
466
    OGRErr      SetTMSO( double dfCenterLat, double dfCenterLong,
467
                         double dfScale,
468
                         double dfFalseEasting, double dfFalseNorthing );
469

    
470
    /** VanDerGrinten */
471
    OGRErr      SetVDG( double dfCenterLong,
472
                        double dfFalseEasting, double dfFalseNorthing );
473

    
474
    /** Universal Transverse Mercator */
475
    OGRErr      SetUTM( int nZone, int bNorth = TRUE );
476
    int         GetUTMZone( int *pbNorth = NULL ) const;
477

    
478
    /** State Plane */
479
    OGRErr      SetStatePlane( int nZone, int bNAD83 = TRUE,
480
                               const char *pszOverrideUnitName = NULL,
481
                               double dfOverrideUnit = 0.0 );
482
};
483

    
484
/************************************************************************/
485
/*                     OGRCoordinateTransformation                      */
486
/*                                                                      */
487
/*      This is really just used as a base class for a private          */
488
/*      implementation.                                                 */
489
/************************************************************************/
490

    
491
/**
492
 * Object for transforming between coordinate systems.
493
 *
494
 * Also, see OGRCreateSpatialReference() for creating transformations.
495
 */
496
 
497
class CPL_DLL OGRCoordinateTransformation
498
{
499
public:
500
    virtual ~OGRCoordinateTransformation() {}
501

    
502
    // From CT_CoordinateTransformation
503

    
504
    /** Fetch internal source coordinate system. */
505
    virtual OGRSpatialReference *GetSourceCS() = 0;
506

    
507
    /** Fetch internal target coordinate system. */
508
    virtual OGRSpatialReference *GetTargetCS() = 0;
509

    
510
    // From CT_MathTransform
511

    
512
    /**
513
     * Transform points from source to destination space.
514
     *
515
     * This method is the same as the C function OCTTransform().
516
     *
517
     * The method TransformEx() allows extended success information to 
518
     * be captured indicating which points failed to transform. 
519
     *
520
     * @param nCount number of points to transform.
521
     * @param x array of nCount X vertices, modified in place.
522
     * @param y array of nCount Y vertices, modified in place.
523
     * @param z array of nCount Z vertices, modified in place.
524
     * @return TRUE on success, or FALSE if some or all points fail to
525
     * transform.
526
     */
527
    virtual int Transform( int nCount, 
528
                           double *x, double *y, double *z = NULL ) = 0;
529

    
530
    /**
531
     * Transform points from source to destination space.
532
     *
533
     * This method is the same as the C function OCTTransformEx().
534
     *
535
     * @param nCount number of points to transform.
536
     * @param x array of nCount X vertices, modified in place.
537
     * @param y array of nCount Y vertices, modified in place.
538
     * @param z array of nCount Z vertices, modified in place.
539
     * @param pabSuccess array of per-point flags set to TRUE if that point 
540
     * transforms, or FALSE if it does not.
541
     *
542
     * @return TRUE if some or all points transform successfully, or FALSE if 
543
     * if none transform.
544
     */
545
    virtual int TransformEx( int nCount, 
546
                             double *x, double *y, double *z = NULL,
547
                             int *pabSuccess = NULL ) = 0;
548

    
549
};
550

    
551
OGRCoordinateTransformation CPL_DLL *
552
OGRCreateCoordinateTransformation( OGRSpatialReference *poSource, 
553
                                   OGRSpatialReference *poTarget );
554

    
555
#endif /* ndef _OGR_SPATIALREF_H_INCLUDED */