Statistics
| Revision:

svn-gvsig-desktop / tags / v1_0_RELEASE / libraries / libjni-gdal / include / ogr_geometry.h @ 9167

History | View | Annotate | Download (25 KB)

1
/******************************************************************************
2
 * $Id: ogr_geometry.h 9167 2006-12-04 16:01:24Z  $
3
 *
4
 * Project:  OpenGIS Simple Features Reference Implementation
5
 * Purpose:  Classes for manipulating simple features that is not specific
6
 *           to a particular interface technology.
7
 * Author:   Frank Warmerdam, warmerda@home.com
8
 *
9
 ******************************************************************************
10
 * Copyright (c) 1999, Frank Warmerdam
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.2.10.2  2006-11-15 00:08:29  jjdelcerro
33
 * *** empty log message ***
34
 *
35
 * Revision 1.3  2006/10/03 07:05:18  nacho
36
 * *** empty log message ***
37
 *
38
 * Revision 1.1  2006/07/18 16:21:00  nacho
39
 * *** empty log message ***
40
 *
41
 * Revision 1.1  2006/06/29 16:23:27  nacho
42
 * *** empty log message ***
43
 *
44
 * Revision 1.2  2006/01/09 12:50:13  nacho
45
 * *** empty log message ***
46
 *
47
 * Revision 1.1  2005/07/27 08:22:55  igbrotru
48
 * *** empty log message ***
49
 *
50
 * Revision 1.1  2005/01/11 15:23:01  igbrotru
51
 * *** empty log message ***
52
 *
53
 * Revision 1.50  2004/09/17 15:05:36  fwarmerdam
54
 * added get_Area() support
55
 *
56
 * Revision 1.49  2004/08/20 21:21:28  warmerda
57
 * added support for managing a persistent geos::GeometryFactory
58
 *
59
 * Revision 1.48  2004/07/10 04:54:23  warmerda
60
 * added GEOS methods, and closeRings
61
 *
62
 * Revision 1.47  2004/02/21 15:36:14  warmerda
63
 * const correctness updates for geometry: bug 289
64
 *
65
 * Revision 1.46  2003/09/11 22:47:54  aamici
66
 * add class constructors and destructors where needed in order to
67
 * let the mingw/cygwin binutils produce sensible partially linked objet files
68
 * with 'ld -r'.
69
 *
70
 * Revision 1.45  2003/08/27 15:40:37  warmerda
71
 * added support for generating DB2 V7.2 compatible WKB
72
 *
73
 * Revision 1.44  2003/05/28 19:16:42  warmerda
74
 * fixed up argument names and stuff for docs
75
 *
76
 * Revision 1.43  2003/04/28 15:39:33  warmerda
77
 * ryan added forceToMultiPolyline and forceToMultiPoint
78
 *
79
 * Revision 1.42  2003/03/06 20:29:27  warmerda
80
 * added GML import/export entry points
81
 *
82
 * Revision 1.41  2003/01/14 22:13:35  warmerda
83
 * added isClockwise() method on OGRLinearRing
84
 *
85
 * Revision 1.40  2003/01/08 22:04:11  warmerda
86
 * added forceToPolygon and forceToMultiPolygon methods
87
 *
88
 * Revision 1.39  2003/01/07 16:44:27  warmerda
89
 * added removeGeometry
90
 *
91
 * Revision 1.38  2003/01/02 21:45:23  warmerda
92
 * move OGRBuildPolygonsFromEdges into C API
93
 *
94
 * Revision 1.37  2002/10/25 15:20:50  warmerda
95
 * fixed MULTIPOINT WKT format
96
 *
97
 * Revision 1.36  2002/10/24 20:53:02  warmerda
98
 * expand tabs
99
 *
100
 * Revision 1.35  2002/09/26 18:13:17  warmerda
101
 * moved some defs to ogr_core.h for sharing with ogr_api.h
102
 *
103
 * Revision 1.34  2002/09/11 13:47:17  warmerda
104
 * preliminary set of fixes for 3D WKB enum
105
 *
106
 * Revision 1.33  2002/08/12 15:02:18  warmerda
107
 * added OGRRawPoint and OGREnvelope initializes
108
 *
109
 * Revision 1.32  2002/05/02 19:45:36  warmerda
110
 * added flattenTo2D() method
111
 *
112
 * Revision 1.31  2002/02/22 22:23:38  warmerda
113
 * added tolerances when assembling polygons
114
 *
115
 * Revision 1.30  2002/02/18 21:12:23  warmerda
116
 * added OGRBuildPolygonFromEdges
117
 *
118
 * Revision 1.29  2001/11/01 16:56:08  warmerda
119
 * added createGeometry and destroyGeometry methods
120
 *
121
 * Revision 1.28  2001/09/21 16:24:20  warmerda
122
 * added transform() and transformTo() methods
123
 *
124
 * Revision 1.27  2001/09/04 14:48:34  warmerda
125
 * added some more 2.5D geometry types
126
 *
127
 * Revision 1.26  2001/05/24 18:05:18  warmerda
128
 * substantial fixes to WKT support for MULTIPOINT/LINE/POLYGON
129
 *
130
 * Revision 1.25  2001/02/06 17:10:28  warmerda
131
 * export entry points from DLL
132
 *
133
 * Revision 1.24  2001/01/19 21:10:47  warmerda
134
 * replaced tabs
135
 *
136
 * Revision 1.23  2000/10/17 17:55:26  warmerda
137
 * added comments for byte orders
138
 *
139
 * Revision 1.22  2000/04/26 18:25:55  warmerda
140
 * added missing CPL_DLL attributes
141
 *
142
 * Revision 1.21  2000/03/14 21:38:17  warmerda
143
 * added method to translate geometrytype to name
144
 *
145
 * Revision 1.20  1999/11/18 19:02:20  warmerda
146
 * expanded tabs
147
 *
148
 * Revision 1.19  1999/11/04 16:26:12  warmerda
149
 * Added the addGeometryDirectly() method for containers.
150
 *
151
 * Revision 1.18  1999/09/22 13:19:09  warmerda
152
 * Added the addRingDirectly() method on OGRPolygon.
153
 *
154
 * Revision 1.17  1999/09/13 14:34:07  warmerda
155
 * updated to use wkbZ of 0x8000 instead of 0x80000000
156
 *
157
 * Revision 1.16  1999/09/13 02:27:32  warmerda
158
 * incorporated limited 2.5d support
159
 *
160
 * Revision 1.15  1999/08/29 17:14:29  warmerda
161
 * Added wkbNone.
162
 *
163
 * Revision 1.14  1999/07/27 00:48:11  warmerda
164
 * Added Equal() support
165
 *
166
 * Revision 1.13  1999/07/08 20:26:03  warmerda
167
 * No longer override getGeometryType() on OGRLinearRing.
168
 *
169
 * Revision 1.12  1999/07/07 04:23:07  danmo
170
 * Fixed typo in  #define _OGR_..._H_INCLUDED  line
171
 *
172
 * Revision 1.11  1999/07/06 21:36:46  warmerda
173
 * tenatively added getEnvelope() and Intersect()
174
 *
175
 * Revision 1.10  1999/06/25 20:44:42  warmerda
176
 * implemented assignSpatialReference, carry properly
177
 *
178
 * Revision 1.9  1999/05/31 20:44:11  warmerda
179
 * ogr_geometry.h
180
 *
181
 * Revision 1.8  1999/05/31 15:01:59  warmerda
182
 * OGRCurve now an abstract base class with essentially no implementation.
183
 * Everything moved down to OGRLineString where it belongs.  Also documented
184
 * classes.
185
 *
186
 * Revision 1.7  1999/05/31 11:05:08  warmerda
187
 * added some documentation
188
 *
189
 * Revision 1.6  1999/05/23 05:34:40  warmerda
190
 * added support for clone(), multipolygons and geometry collections
191
 *
192
 * Revision 1.5  1999/05/20 14:35:44  warmerda
193
 * added support for well known text format
194
 *
195
 * Revision 1.4  1999/05/17 14:39:13  warmerda
196
 * Added ICurve, and some other IGeometry and related methods.
197
 *
198
 * Revision 1.3  1999/05/14 13:30:59  warmerda
199
 * added IsEmpty() and IsSimple()
200
 *
201
 * Revision 1.2  1999/03/30 21:21:43  warmerda
202
 * added linearring/polygon support
203
 *
204
 * Revision 1.1  1999/03/29 21:21:10  warmerda
205
 * New
206
 *
207
 */
208

    
209
#ifndef _OGR_GEOMETRY_H_INCLUDED
210
#define _OGR_GEOMETRY_H_INCLUDED
211

    
212
#include "ogr_core.h"
213
#include "ogr_spatialref.h"
214

    
215
/**
216
 * \file ogr_geometry.h
217
 *
218
 * Simple feature geometry classes.
219
 */
220

    
221
/**
222
 * Simple container for a position.
223
 */
224
class OGRRawPoint
225
{
226
  public:
227
          OGRRawPoint()
228
          {
229
                  x = y = 0.0;
230
          }
231
    double      x;
232
    double      y;
233
};
234

    
235
namespace geos { 
236
    class Geometry;
237
    class GeometryFactory;
238
};
239

    
240
/************************************************************************/
241
/*                             OGRGeometry                              */
242
/************************************************************************/
243

    
244
/**
245
 * Abstract base class for all geometry classes.
246
 *
247
 * Note that the family of spatial analysis methods (Equal(), Disjoint(), ...,
248
 * ConvexHull(), Buffer(), ...) are not implemented at ths time.  Some other
249
 * required and optional geometry methods have also been omitted at this
250
 * time.
251
 */
252
 
253
class CPL_DLL OGRGeometry
254
{
255
  private:
256
    OGRSpatialReference * poSRS;                // may be NULL
257
    
258
  public:
259
                OGRGeometry();
260
    virtual     ~OGRGeometry();
261
                        
262
    // standard IGeometry
263
    virtual int getDimension() const = 0;
264
    virtual int getCoordinateDimension() const = 0;
265
    virtual OGRBoolean  IsEmpty() const { return 0; } 
266
    virtual OGRBoolean  IsSimple() const { return 1; }
267
    virtual void        empty() = 0;
268
    virtual OGRGeometry *clone() const = 0;
269
    virtual void getEnvelope( OGREnvelope * psEnvelope ) const = 0;
270

    
271
    // IWks Interface
272
    virtual int WkbSize() const = 0;
273
    virtual OGRErr importFromWkb( unsigned char *, int=-1 )=0;
274
    virtual OGRErr exportToWkb( OGRwkbByteOrder, unsigned char * ) const = 0;
275
    virtual OGRErr importFromWkt( char ** ppszInput ) = 0;
276
    virtual OGRErr exportToWkt( char ** ppszDstText ) const = 0;
277
    
278
    // non-standard
279
    virtual OGRwkbGeometryType getGeometryType() const = 0;
280
    virtual const char *getGeometryName() const = 0;
281
    virtual void   dumpReadable( FILE *, const char * = NULL );
282
    virtual void   flattenTo2D() = 0;
283
    virtual char * exportToGML() const;
284
    virtual geos::Geometry *exportToGEOS() const;
285
    virtual void closeRings();
286

    
287
    void    assignSpatialReference( OGRSpatialReference * poSR );
288
    OGRSpatialReference *getSpatialReference( void ) const { return poSRS; }
289

    
290
    virtual OGRErr  transform( OGRCoordinateTransformation *poCT ) = 0;
291
    OGRErr  transformTo( OGRSpatialReference *poSR );
292

    
293
    // ISpatialRelation
294
    virtual OGRBoolean  Intersect( OGRGeometry * ) const;
295
    virtual OGRBoolean  Equal( OGRGeometry * ) const = 0;
296
    virtual OGRBoolean  Disjoint( const OGRGeometry * ) const;
297
    virtual OGRBoolean  Touches( const OGRGeometry * ) const;
298
    virtual OGRBoolean  Crosses( const OGRGeometry * ) const;
299
    virtual OGRBoolean  Within( const OGRGeometry * ) const;
300
    virtual OGRBoolean  Contains( const OGRGeometry * ) const;
301
    virtual OGRBoolean  Overlaps( const OGRGeometry * ) const;
302
//    virtual OGRBoolean  Relate( const OGRGeometry *, const char * ) const;
303

    
304
    virtual OGRGeometry *getBoundary() const;
305
    virtual double  Distance( const OGRGeometry * ) const;
306
    virtual OGRGeometry *ConvexHull() const;
307
    virtual OGRGeometry *Buffer( double dfDist, int nQuadSegs = 30 ) const;
308
    virtual OGRGeometry *Intersection( const OGRGeometry *) const;
309
    virtual OGRGeometry *Union( const OGRGeometry * ) const;
310
    virtual OGRGeometry *Difference( const OGRGeometry * ) const;
311
    virtual OGRGeometry *SymmetricDifference( const OGRGeometry * ) const;
312

    
313
    // Special HACK for DB2 7.2 support
314
    static int bGenerate_DB2_V72_BYTE_ORDER;
315
};
316

    
317
/************************************************************************/
318
/*                               OGRPoint                               */
319
/************************************************************************/
320

    
321
/**
322
 * Point class.
323
 *
324
 * Implements SFCOM IPoint methods.
325
 */
326

    
327
class CPL_DLL OGRPoint : public OGRGeometry
328
{
329
    double      x;
330
    double      y;
331
    double      z;
332

    
333
  public:
334
                OGRPoint();
335
                OGRPoint( double x, double y, double z = 0.0 );
336
    virtual     ~OGRPoint();
337

    
338
    // IWks Interface
339
    virtual int WkbSize() const;
340
    virtual OGRErr importFromWkb( unsigned char *, int=-1 );
341
    virtual OGRErr exportToWkb( OGRwkbByteOrder, unsigned char * ) const;
342
    virtual OGRErr importFromWkt( char ** );
343
    virtual OGRErr exportToWkt( char ** ppszDstText ) const;
344
    
345
    // IGeometry
346
    virtual int getDimension() const;
347
    virtual int getCoordinateDimension() const;
348
    virtual OGRGeometry *clone() const;
349
    virtual void empty();
350
    virtual void getEnvelope( OGREnvelope * psEnvelope ) const;
351

    
352
    // IPoint
353
    double      getX() const { return x; } 
354
    double      getY() const { return y; }
355
    double      getZ() const { return z; }
356

    
357
    // Non standard
358
    void        setX( double xIn ) { x = xIn; }
359
    void        setY( double yIn ) { y = yIn; }
360
    void        setZ( double zIn ) { z = zIn; }
361

    
362
    // ISpatialRelation
363
    virtual OGRBoolean  Equal( OGRGeometry * ) const;
364
    
365
    // Non standard from OGRGeometry
366
    virtual const char *getGeometryName() const;
367
    virtual OGRwkbGeometryType getGeometryType() const;
368
    virtual OGRErr  transform( OGRCoordinateTransformation *poCT );
369
    virtual void flattenTo2D();
370

    
371
};
372

    
373
/************************************************************************/
374
/*                               OGRCurve                               */
375
/************************************************************************/
376

    
377
/**
378
 * Abstract curve base class.
379
 */
380

    
381
class CPL_DLL OGRCurve : public OGRGeometry
382
{
383
  public:
384
            OGRCurve();
385
    virtual ~OGRCurve();
386
    // ICurve methods
387
    virtual double get_Length() const = 0;
388
    virtual void StartPoint(OGRPoint *) const = 0;
389
    virtual void EndPoint(OGRPoint *) const = 0;
390
    virtual int  get_IsClosed() const;
391
    virtual void Value( double, OGRPoint * ) const = 0;
392

    
393
};
394

    
395
/************************************************************************/
396
/*                            OGRLineString                             */
397
/************************************************************************/
398

    
399
/**
400
 * Concrete representation of a multi-vertex line.
401
 */
402

    
403
class CPL_DLL OGRLineString : public OGRCurve
404
{
405
  protected:
406
    int         nPointCount;
407
    OGRRawPoint *paoPoints;
408
    double      *padfZ;
409

    
410
    void        Make3D();
411
    void        Make2D();
412

    
413
  public:
414
                OGRLineString();
415
    virtual     ~OGRLineString();
416

    
417
    // IWks Interface
418
    virtual int WkbSize() const;
419
    virtual OGRErr importFromWkb( unsigned char *, int = -1 );
420
    virtual OGRErr exportToWkb( OGRwkbByteOrder, unsigned char * ) const;
421
    virtual OGRErr importFromWkt( char ** );
422
    virtual OGRErr exportToWkt( char ** ppszDstText ) const;
423

    
424
    // IGeometry interface
425
    virtual int getDimension() const;
426
    virtual int getCoordinateDimension() const;
427
    virtual OGRGeometry *clone() const;
428
    virtual void empty();
429
    virtual void getEnvelope( OGREnvelope * psEnvelope ) const;
430

    
431
    // ICurve methods
432
    virtual double get_Length() const;
433
    virtual void StartPoint(OGRPoint *) const;
434
    virtual void EndPoint(OGRPoint *) const;
435
    virtual void Value( double, OGRPoint * ) const;
436
    
437
    // ILineString methods
438
    int         getNumPoints() const { return nPointCount; }
439
    void        getPoint( int, OGRPoint * ) const;
440
    double      getX( int i ) const { return paoPoints[i].x; }
441
    double      getY( int i ) const { return paoPoints[i].y; }
442
    double      getZ( int i ) const;
443

    
444
    // ISpatialRelation
445
    virtual OGRBoolean  Equal( OGRGeometry * ) const;
446
    
447
    // non standard.
448
    void        setNumPoints( int );
449
    void        setPoint( int, OGRPoint * );
450
    void        setPoint( int, double, double, double = 0.0 );
451
    void        setPoints( int, OGRRawPoint *, double * = NULL );
452
    void        setPoints( int, double * padfX, double * padfY,
453
                           double *padfZ = NULL );
454
    void        addPoint( OGRPoint * );
455
    void        addPoint( double, double, double = 0.0 );
456

    
457
    // non-standard from OGRGeometry
458
    virtual OGRwkbGeometryType getGeometryType() const;
459
    virtual const char *getGeometryName() const;
460
    virtual OGRErr  transform( OGRCoordinateTransformation *poCT );
461
    virtual void flattenTo2D();
462

    
463
};
464

    
465
/************************************************************************/
466
/*                            OGRLinearRing                             */
467
/*                                                                      */
468
/*      This is an alias for OGRLineString for now.                     */
469
/************************************************************************/
470

    
471
/**
472
 * Concrete representation of a closed ring.
473
 *
474
 * This class is functionally equivelent to an OGRLineString, but has a
475
 * separate identity to maintain alignment with the OpenGIS simple feature
476
 * data model.  It exists to serve as a component of an OGRPolygon.
477
 */
478

    
479
class CPL_DLL OGRLinearRing : public OGRLineString
480
{
481
  private:
482
    friend class OGRPolygon; 
483
    
484
    // These are not IWks compatible ... just a convenience for OGRPolygon.
485
    virtual int _WkbSize( int b3D ) const;
486
    virtual OGRErr _importFromWkb( OGRwkbByteOrder, int b3D,
487
                                   unsigned char *, int=-1 );
488
    virtual OGRErr _exportToWkb( OGRwkbByteOrder, int b3D, 
489
                                 unsigned char * ) const;
490
    
491
  public:
492
                        OGRLinearRing();
493
                        OGRLinearRing( OGRLinearRing * );
494
                        ~OGRLinearRing();
495

    
496
    // Non standard.
497
    virtual const char *getGeometryName() const;
498
    virtual OGRGeometry *clone() const;
499
    virtual int isClockwise() const;
500
    virtual void closeRings();
501
    virtual double get_Area() const;
502
    
503
    // IWks Interface - Note this isnt really a first class object
504
    // for the purposes of WKB form.  These methods always fail since this
505
    // object cant be serialized on its own. 
506
    virtual int WkbSize() const;
507
    virtual OGRErr importFromWkb( unsigned char *, int=-1 );
508
    virtual OGRErr exportToWkb( OGRwkbByteOrder, unsigned char * ) const;
509
};
510

    
511
/************************************************************************/
512
/*                              OGRSurface                              */
513
/************************************************************************/
514

    
515
/**
516
 * Abstract base class for 2 dimensional objects like polygons.
517
 */
518

    
519
class CPL_DLL OGRSurface : public OGRGeometry
520
{
521
  public:
522
    virtual double      get_Area() const = 0;
523
    virtual OGRErr      Centroid( OGRPoint * poPoint ) const = 0;
524
    virtual OGRErr      PointOnSurface( OGRPoint * poPoint ) const = 0;
525
};
526

    
527
/************************************************************************/
528
/*                              OGRPolygon                              */
529
/************************************************************************/
530

    
531
/**
532
 * Concrete class representing polygons.
533
 *
534
 * Note that the OpenGIS simple features polygons consist of one outer
535
 * ring, and zero or more inner rings.  A polygon cannot represent disconnected
536
 * regions (such as multiple islands in a political body).  The
537
 * OGRMultiPolygon must be used for this.
538
 */
539

    
540
class CPL_DLL OGRPolygon : public OGRSurface
541
{
542
    int         nRingCount;
543
    OGRLinearRing **papoRings;
544
    
545
  public:
546
                OGRPolygon();
547
    virtual     ~OGRPolygon();
548

    
549
    // Non standard (OGRGeometry).
550
    virtual const char *getGeometryName() const;
551
    virtual OGRwkbGeometryType getGeometryType() const;
552
    virtual OGRGeometry *clone() const;
553
    virtual void empty();
554
    virtual OGRErr  transform( OGRCoordinateTransformation *poCT );
555
    virtual void flattenTo2D();
556
    
557
    // ISurface Interface
558
    virtual double      get_Area() const;
559
    virtual int         Centroid( OGRPoint * poPoint ) const;
560
    virtual int         PointOnSurface( OGRPoint * poPoint ) const;
561
    
562
    // IWks Interface
563
    virtual int WkbSize() const;
564
    virtual OGRErr importFromWkb( unsigned char *, int = -1 );
565
    virtual OGRErr exportToWkb( OGRwkbByteOrder, unsigned char * ) const;
566
    virtual OGRErr importFromWkt( char ** );
567
    virtual OGRErr exportToWkt( char ** ppszDstText ) const;
568

    
569
    // IGeometry
570
    virtual int getDimension() const;
571
    virtual int getCoordinateDimension() const;
572
    virtual void getEnvelope( OGREnvelope * psEnvelope ) const;
573

    
574
    // ISpatialRelation
575
    virtual OGRBoolean  Equal( OGRGeometry * ) const;
576
    
577
    // Non standard
578
    void        addRing( OGRLinearRing * );
579
    void        addRingDirectly( OGRLinearRing * );
580

    
581
    OGRLinearRing *getExteriorRing();
582
    const OGRLinearRing *getExteriorRing() const;
583
    int         getNumInteriorRings() const;
584
    OGRLinearRing *getInteriorRing( int );
585
    const OGRLinearRing *getInteriorRing( int ) const;
586

    
587
    virtual void closeRings();
588
};
589

    
590
/************************************************************************/
591
/*                        OGRGeometryCollection                         */
592
/************************************************************************/
593

    
594
/**
595
 * A collection of 1 or more geometry objects.
596
 *
597
 * All geometries must share a common spatial reference system, and
598
 * Subclasses may impose additional restrictions on the contents.
599
 */
600

    
601
class CPL_DLL OGRGeometryCollection : public OGRGeometry
602
{
603
    int         nGeomCount;
604
    OGRGeometry **papoGeoms;
605

    
606
    int         nCoordinateDimension;
607
    
608
  public:
609
                OGRGeometryCollection();
610
    virtual     ~OGRGeometryCollection();
611

    
612
    // Non standard (OGRGeometry).
613
    virtual const char *getGeometryName() const;
614
    virtual OGRwkbGeometryType getGeometryType() const;
615
    virtual OGRGeometry *clone() const;
616
    virtual void empty();
617
    virtual OGRErr  transform( OGRCoordinateTransformation *poCT );
618
    virtual void flattenTo2D();
619
    
620
    // IWks Interface
621
    virtual int WkbSize() const;
622
    virtual OGRErr importFromWkb( unsigned char *, int = -1 );
623
    virtual OGRErr exportToWkb( OGRwkbByteOrder, unsigned char * ) const;
624
    virtual OGRErr importFromWkt( char ** );
625
    virtual OGRErr exportToWkt( char ** ppszDstText ) const;
626

    
627
    // IGeometry methods
628
    virtual int getDimension() const;
629
    virtual int getCoordinateDimension() const;
630
    virtual void getEnvelope( OGREnvelope * psEnvelope ) const;
631

    
632
    // IGeometryCollection
633
    int         getNumGeometries() const;
634
    OGRGeometry *getGeometryRef( int );
635
    const OGRGeometry *getGeometryRef( int ) const;
636

    
637
    // ISpatialRelation
638
    virtual OGRBoolean  Equal( OGRGeometry * ) const;
639
    
640
    // Non standard
641
    virtual OGRErr addGeometry( const OGRGeometry * );
642
    virtual OGRErr addGeometryDirectly( OGRGeometry * );
643
    virtual OGRErr removeGeometry( int iIndex, int bDelete = TRUE );
644

    
645
    void closeRings();
646
};
647

    
648
/************************************************************************/
649
/*                           OGRMultiPolygon                            */
650
/************************************************************************/
651

    
652
/**
653
 * A collection of non-overlapping OGRPolygons.
654
 *
655
 * Note that the IMultiSurface class hasn't been modelled, nor have any
656
 * of it's methods. 
657
 */
658

    
659
class CPL_DLL OGRMultiPolygon : public OGRGeometryCollection
660
{
661
  public:
662
            OGRMultiPolygon();
663
    // Non standard (OGRGeometry).
664
    virtual const char *getGeometryName() const;
665
    virtual OGRwkbGeometryType getGeometryType() const;
666
    virtual OGRGeometry *clone() const;
667
    virtual OGRErr importFromWkt( char ** );
668
    virtual OGRErr exportToWkt( char ** ) const;
669
    
670
    // Non standard
671
    virtual OGRErr addGeometryDirectly( OGRGeometry * );
672

    
673
    double  get_Area() const;
674
};
675

    
676
/************************************************************************/
677
/*                            OGRMultiPoint                             */
678
/************************************************************************/
679

    
680
/**
681
 * A collection of OGRPoints.
682
 */
683

    
684
class CPL_DLL OGRMultiPoint : public OGRGeometryCollection
685
{
686
  private:
687
    OGRErr  importFromWkt_Bracketed( char ** );
688

    
689
  public:
690
            OGRMultiPoint();
691
    // Non standard (OGRGeometry).
692
    virtual const char *getGeometryName() const;
693
    virtual OGRwkbGeometryType getGeometryType() const;
694
    virtual OGRGeometry *clone() const;
695
    virtual OGRErr importFromWkt( char ** );
696
    virtual OGRErr exportToWkt( char ** ) const;
697
    
698
    // Non standard
699
    virtual OGRErr addGeometryDirectly( OGRGeometry * );
700
};
701

    
702
/************************************************************************/
703
/*                          OGRMultiLineString                          */
704
/************************************************************************/
705

    
706
/**
707
 * A collection of OGRLineStrings.
708
 */
709

    
710
class CPL_DLL OGRMultiLineString : public OGRGeometryCollection
711
{
712
  public:
713
            OGRMultiLineString();
714
            ~OGRMultiLineString();
715
    // Non standard (OGRGeometry).
716
    virtual const char *getGeometryName() const;
717
    virtual OGRwkbGeometryType getGeometryType() const;
718
    virtual OGRGeometry *clone() const;
719
    virtual OGRErr importFromWkt( char ** );
720
    virtual OGRErr exportToWkt( char ** ) const;
721
    
722
    // Non standard
723
    virtual OGRErr addGeometryDirectly( OGRGeometry * );
724
};
725

    
726

    
727
/************************************************************************/
728
/*                          OGRGeometryFactory                          */
729
/************************************************************************/
730

    
731
/**
732
 * Create geometry objects from well known text/binary.
733
 */
734

    
735
class CPL_DLL OGRGeometryFactory
736
{
737
  public:
738
    static OGRErr createFromWkb( unsigned char *, OGRSpatialReference *,
739
                                 OGRGeometry **, int = -1 );
740
    static OGRErr createFromWkt( char **, OGRSpatialReference *,
741
                                 OGRGeometry ** );
742
    static OGRGeometry *createFromGML( const char * );
743
    static OGRGeometry *createFromGEOS( const geos::Geometry * );
744

    
745
    static void   destroyGeometry( OGRGeometry * );
746
    static OGRGeometry *createGeometry( OGRwkbGeometryType );
747

    
748
    static OGRGeometry * forceToPolygon( OGRGeometry * );
749
    static OGRGeometry * forceToMultiPolygon( OGRGeometry * );
750
    static OGRGeometry * forceToMultiPoint( OGRGeometry * );
751
    static OGRGeometry * forceToMultiLineString( OGRGeometry * );
752

    
753
    static geos::GeometryFactory *getGEOSGeometryFactory();
754

    
755
};
756

    
757
#endif /* ndef _OGR_GEOMETRY_H_INCLUDED */