Statistics
| Revision:

svn-gvsig-desktop / tags / v1_2_Build_1202 / libraries / libjni-gdal / include / ogr_spatialref.h @ 33918

History | View | Annotate | Download (21.3 KB)

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

    
99
#ifndef _OGR_SPATIALREF_H_INCLUDED
100
#define _OGR_SPATIALREF_H_INCLUDED
101

    
102
#include "ogr_srs_api.h"
103

    
104
/**
105
 * \file ogr_spatialref.h
106
 *
107
 * Coordinate systems services.
108
 */
109

    
110
/************************************************************************/
111
/*                             OGR_SRSNode                              */
112
/************************************************************************/
113

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

    
127
class CPL_DLL OGR_SRSNode
128
{
129
    char        *pszValue;
130

    
131
    int         nChildren;
132
    OGR_SRSNode **papoChildNodes;
133

    
134
    OGR_SRSNode *poParent;
135

    
136
    void        ClearChildren();
137
    int         NeedsQuoting() const;
138
    
139
  public:
140
                OGR_SRSNode(const char * = NULL);
141
                ~OGR_SRSNode();
142

    
143
    int         IsLeafNode() const { return nChildren == 0; }
144
    
145
    int         GetChildCount() const { return nChildren; }
146
    OGR_SRSNode *GetChild( int );
147
    const OGR_SRSNode *GetChild( int ) const;
148

    
149
    OGR_SRSNode *GetNode( const char * );
150
    const OGR_SRSNode *GetNode( const char * ) const;
151

    
152
    void        InsertChild( OGR_SRSNode *, int );
153
    void        AddChild( OGR_SRSNode * );
154
    int         FindChild( const char * ) const;
155
    void        DestroyChild( int );
156
    void        StripNodes( const char * );
157

    
158
    const char  *GetValue() const { return pszValue; }
159
    void        SetValue( const char * );
160

    
161
    void        MakeValueSafe();
162
    OGRErr      FixupOrdering();
163

    
164
    OGR_SRSNode *Clone() const;
165

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

    
177
/************************************************************************/
178
/*                         OGRSpatialReference                          */
179
/************************************************************************/
180

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

    
195
class CPL_DLL OGRSpatialReference
196
{
197
    int         nRefCount;
198

    
199
    OGR_SRSNode *poRoot;
200

    
201
    int         bNormInfoSet;
202
    double      dfFromGreenwich;
203
    double      dfToMeter;
204
    double      dfToDegrees;
205

    
206
    OGRErr      ValidateProjection();
207
    int         IsAliasFor( const char *, const char * );
208
    void        GetNormInfo() const;
209

    
210
  public:
211
                OGRSpatialReference(const OGRSpatialReference&);
212
                OGRSpatialReference(const char * = NULL);
213
                
214
    virtual    ~OGRSpatialReference();
215
                
216
    OGRSpatialReference &operator=(const OGRSpatialReference&);
217

    
218
    int         Reference();
219
    int         Dereference();
220
    int         GetReferenceCount() const { return nRefCount; }
221

    
222
    OGRSpatialReference *Clone() const;
223
    OGRSpatialReference *CloneGeogCS() const;
224

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

    
244
    OGRErr      morphToESRI();
245
    OGRErr      morphFromESRI();
246

    
247
    OGRErr      Validate();
248
    OGRErr      StripCTParms( OGR_SRSNode * = NULL );
249
    OGRErr      FixupOrdering();
250
    OGRErr      Fixup();
251

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

    
261
    OGRErr      SetNode( const char *, const char * );
262
    OGRErr      SetNode( const char *, double );
263

    
264
    OGRErr      SetLinearUnits( const char *pszName, double dfInMeters );
265
    double      GetLinearUnits( char ** = NULL ) const;
266

    
267
    OGRErr      SetAngularUnits( const char *pszName, double dfInRadians );
268
    double      GetAngularUnits( char ** = NULL ) const;
269

    
270
    double      GetPrimeMeridian( char ** = NULL ) const;
271

    
272
    int         IsGeographic() const;
273
    int         IsProjected() const;
274
    int         IsLocal() const;
275
    int         IsSameGeogCS( const OGRSpatialReference * ) const;
276
    int         IsSame( const OGRSpatialReference * ) const;
277

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

    
293
    OGRErr      SetFromUserInput( const char * );
294

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

    
304
    OGRErr      SetAuthority( const char * pszTargetKey, 
305
                              const char * pszAuthority, 
306
                              int nCode );
307

    
308
    OGRErr      AutoIdentifyEPSG();
309

    
310
    const char *GetAuthorityCode( const char * pszTargetKey ) const;
311
    const char *GetAuthorityName( const char * pszTargetKey ) const;
312
                           
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
    /** Cylindrical Equal Area */
333
    OGRErr      SetCEA( double dfStdP1, double dfCentralMeridian,
334
                        double dfFalseEasting, double dfFalseNorthing );
335

    
336
    /** Cassini-Soldner */
337
    OGRErr      SetCS( double dfCenterLat, double dfCenterLong,
338
                       double dfFalseEasting, double dfFalseNorthing );
339

    
340
    /** Equidistant Conic */
341
    OGRErr      SetEC( double dfStdP1, double dfStdP2,
342
                       double dfCenterLat, double dfCenterLong,
343
                       double dfFalseEasting, double dfFalseNorthing );
344

    
345
    /** Eckert IV */
346
    OGRErr      SetEckertIV( double dfCentralMeridian,
347
                             double dfFalseEasting, double dfFalseNorthing );
348

    
349
    /** Eckert VI */
350
    OGRErr      SetEckertVI( double dfCentralMeridian,
351
                             double dfFalseEasting, double dfFalseNorthing );
352

    
353
    /** Equirectangular */
354
    OGRErr      SetEquirectangular(double dfCenterLat, double dfCenterLong,
355
                            double dfFalseEasting, double dfFalseNorthing );
356

    
357
    /** Gall Stereograpic */
358
    OGRErr      SetGS( double dfCentralMeridian,
359
                       double dfFalseEasting, double dfFalseNorthing );
360
    
361
    /** Gnomonic */
362
    OGRErr      SetGnomonic(double dfCenterLat, double dfCenterLong,
363
                            double dfFalseEasting, double dfFalseNorthing );
364

    
365
    OGRErr      SetHOM( double dfCenterLat, double dfCenterLong,
366
                        double dfAzimuth, double dfRectToSkew,
367
                        double dfScale,
368
                        double dfFalseEasting, double dfFalseNorthing );
369

    
370
    OGRErr      SetHOM2PNO( double dfCenterLat,
371
                            double dfLat1, double dfLong1,
372
                            double dfLat2, double dfLong2,
373
                            double dfScale,
374
                            double dfFalseEasting, double dfFalseNorthing );
375

    
376
    /** Krovak Oblique Conic Conformal */
377
    OGRErr      SetKrovak( double dfCenterLat, double dfCenterLong,
378
                           double dfAzimuth, double dfPseudoStdParallelLat,
379
                           double dfScale, 
380
                           double dfFalseEasting, double dfFalseNorthing );
381

    
382
    /** Lambert Azimuthal Equal-Area */
383
    OGRErr      SetLAEA( double dfCenterLat, double dfCenterLong,
384
                         double dfFalseEasting, double dfFalseNorthing );
385

    
386
    /** Lambert Conformal Conic */
387
    OGRErr      SetLCC( double dfStdP1, double dfStdP2,
388
                        double dfCenterLat, double dfCenterLong,
389
                        double dfFalseEasting, double dfFalseNorthing );
390

    
391
    /** Lambert Conformal Conic 1SP */
392
    OGRErr      SetLCC1SP( double dfCenterLat, double dfCenterLong,
393
                           double dfScale,
394
                           double dfFalseEasting, double dfFalseNorthing );
395

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

    
405
    /** Mercator */
406
    OGRErr      SetMercator( double dfCenterLat, double dfCenterLong,
407
                             double dfScale, 
408
                             double dfFalseEasting, double dfFalseNorthing );
409

    
410
    /** Mollweide */
411
    OGRErr      SetMollweide( double dfCentralMeridian,
412
                              double dfFalseEasting, double dfFalseNorthing );
413

    
414
    /** New Zealand Map Grid */
415
    OGRErr      SetNZMG( double dfCenterLat, double dfCenterLong,
416
                         double dfFalseEasting, double dfFalseNorthing );
417

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

    
427
    /** Polyconic */
428
    OGRErr      SetPolyconic( double dfCenterLat, double dfCenterLong,
429
                              double dfFalseEasting, double dfFalseNorthing );
430

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

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

    
464
    /** Tunesia Mining Grid  */
465
    OGRErr      SetTMG( double dfCenterLat, double dfCenterLong, 
466
                        double dfFalseEasting, double dfFalseNorthing );
467

    
468
    /** Transverse Mercator (South Oriented) */
469
    OGRErr      SetTMSO( double dfCenterLat, double dfCenterLong,
470
                         double dfScale,
471
                         double dfFalseEasting, double dfFalseNorthing );
472

    
473
    /** VanDerGrinten */
474
    OGRErr      SetVDG( double dfCenterLong,
475
                        double dfFalseEasting, double dfFalseNorthing );
476

    
477
    /** Universal Transverse Mercator */
478
    OGRErr      SetUTM( int nZone, int bNorth = TRUE );
479
    int         GetUTMZone( int *pbNorth = NULL ) const;
480

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

    
487
/************************************************************************/
488
/*                     OGRCoordinateTransformation                      */
489
/*                                                                      */
490
/*      This is really just used as a base class for a private          */
491
/*      implementation.                                                 */
492
/************************************************************************/
493

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

    
505
    // From CT_CoordinateTransformation
506

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

    
510
    /** Fetch internal target coordinate system. */
511
    virtual OGRSpatialReference *GetTargetCS() = 0;
512

    
513
    // From CT_MathTransform
514

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

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

    
552
};
553

    
554
OGRCoordinateTransformation CPL_DLL *
555
OGRCreateCoordinateTransformation( OGRSpatialReference *poSource, 
556
                                   OGRSpatialReference *poTarget );
557

    
558
#endif /* ndef _OGR_SPATIALREF_H_INCLUDED */