Statistics
| Revision:

root / trunk / libraries / libjni-gdal / include / ogr_geometry.h @ 879

History | View | Annotate | Download (24.5 KB)

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

    
191
#ifndef _OGR_GEOMETRY_H_INCLUDED
192
#define _OGR_GEOMETRY_H_INCLUDED
193

    
194
#include "ogr_core.h"
195
#include "ogr_spatialref.h"
196

    
197
/**
198
 * \file ogr_geometry.h
199
 *
200
 * Simple feature geometry classes.
201
 */
202

    
203
/**
204
 * Simple container for a position.
205
 */
206
class OGRRawPoint
207
{
208
  public:
209
          OGRRawPoint()
210
          {
211
                  x = y = 0.0;
212
          }
213
    double      x;
214
    double      y;
215
};
216

    
217
namespace geos { 
218
    class Geometry;
219
    class GeometryFactory;
220
};
221

    
222
/************************************************************************/
223
/*                             OGRGeometry                              */
224
/************************************************************************/
225

    
226
/**
227
 * Abstract base class for all geometry classes.
228
 *
229
 * Note that the family of spatial analysis methods (Equal(), Disjoint(), ...,
230
 * ConvexHull(), Buffer(), ...) are not implemented at ths time.  Some other
231
 * required and optional geometry methods have also been omitted at this
232
 * time.
233
 */
234
 
235
class CPL_DLL OGRGeometry
236
{
237
  private:
238
    OGRSpatialReference * poSRS;                // may be NULL
239
    
240
  public:
241
                OGRGeometry();
242
    virtual     ~OGRGeometry();
243
                        
244
    // standard IGeometry
245
    virtual int getDimension() const = 0;
246
    virtual int getCoordinateDimension() const = 0;
247
    virtual OGRBoolean  IsEmpty() const { return 0; } 
248
    virtual OGRBoolean  IsSimple() const { return 1; }
249
    virtual void        empty() = 0;
250
    virtual OGRGeometry *clone() const = 0;
251
    virtual void getEnvelope( OGREnvelope * psEnvelope ) const = 0;
252

    
253
    // IWks Interface
254
    virtual int WkbSize() const = 0;
255
    virtual OGRErr importFromWkb( unsigned char *, int=-1 )=0;
256
    virtual OGRErr exportToWkb( OGRwkbByteOrder, unsigned char * ) const = 0;
257
    virtual OGRErr importFromWkt( char ** ppszInput ) = 0;
258
    virtual OGRErr exportToWkt( char ** ppszDstText ) const = 0;
259
    
260
    // non-standard
261
    virtual OGRwkbGeometryType getGeometryType() const = 0;
262
    virtual const char *getGeometryName() const = 0;
263
    virtual void   dumpReadable( FILE *, const char * = NULL );
264
    virtual void   flattenTo2D() = 0;
265
    virtual char * exportToGML() const;
266
    virtual geos::Geometry *exportToGEOS() const;
267
    virtual void closeRings();
268

    
269
    void    assignSpatialReference( OGRSpatialReference * poSR );
270
    OGRSpatialReference *getSpatialReference( void ) const { return poSRS; }
271

    
272
    virtual OGRErr  transform( OGRCoordinateTransformation *poCT ) = 0;
273
    OGRErr  transformTo( OGRSpatialReference *poSR );
274

    
275
    // ISpatialRelation
276
    virtual OGRBoolean  Intersect( OGRGeometry * ) const;
277
    virtual OGRBoolean  Equal( OGRGeometry * ) const = 0;
278
    virtual OGRBoolean  Disjoint( const OGRGeometry * ) const;
279
    virtual OGRBoolean  Touches( const OGRGeometry * ) const;
280
    virtual OGRBoolean  Crosses( const OGRGeometry * ) const;
281
    virtual OGRBoolean  Within( const OGRGeometry * ) const;
282
    virtual OGRBoolean  Contains( const OGRGeometry * ) const;
283
    virtual OGRBoolean  Overlaps( const OGRGeometry * ) const;
284
//    virtual OGRBoolean  Relate( const OGRGeometry *, const char * ) const;
285

    
286
    virtual OGRGeometry *getBoundary() const;
287
    virtual double  Distance( const OGRGeometry * ) const;
288
    virtual OGRGeometry *ConvexHull() const;
289
    virtual OGRGeometry *Buffer( double dfDist, int nQuadSegs = 30 ) const;
290
    virtual OGRGeometry *Intersection( const OGRGeometry *) const;
291
    virtual OGRGeometry *Union( const OGRGeometry * ) const;
292
    virtual OGRGeometry *Difference( const OGRGeometry * ) const;
293
    virtual OGRGeometry *SymmetricDifference( const OGRGeometry * ) const;
294

    
295
    // Special HACK for DB2 7.2 support
296
    static int bGenerate_DB2_V72_BYTE_ORDER;
297
};
298

    
299
/************************************************************************/
300
/*                               OGRPoint                               */
301
/************************************************************************/
302

    
303
/**
304
 * Point class.
305
 *
306
 * Implements SFCOM IPoint methods.
307
 */
308

    
309
class CPL_DLL OGRPoint : public OGRGeometry
310
{
311
    double      x;
312
    double      y;
313
    double      z;
314

    
315
  public:
316
                OGRPoint();
317
                OGRPoint( double x, double y, double z = 0.0 );
318
    virtual     ~OGRPoint();
319

    
320
    // IWks Interface
321
    virtual int WkbSize() const;
322
    virtual OGRErr importFromWkb( unsigned char *, int=-1 );
323
    virtual OGRErr exportToWkb( OGRwkbByteOrder, unsigned char * ) const;
324
    virtual OGRErr importFromWkt( char ** );
325
    virtual OGRErr exportToWkt( char ** ppszDstText ) const;
326
    
327
    // IGeometry
328
    virtual int getDimension() const;
329
    virtual int getCoordinateDimension() const;
330
    virtual OGRGeometry *clone() const;
331
    virtual void empty();
332
    virtual void getEnvelope( OGREnvelope * psEnvelope ) const;
333

    
334
    // IPoint
335
    double      getX() const { return x; } 
336
    double      getY() const { return y; }
337
    double      getZ() const { return z; }
338

    
339
    // Non standard
340
    void        setX( double xIn ) { x = xIn; }
341
    void        setY( double yIn ) { y = yIn; }
342
    void        setZ( double zIn ) { z = zIn; }
343

    
344
    // ISpatialRelation
345
    virtual OGRBoolean  Equal( OGRGeometry * ) const;
346
    
347
    // Non standard from OGRGeometry
348
    virtual const char *getGeometryName() const;
349
    virtual OGRwkbGeometryType getGeometryType() const;
350
    virtual OGRErr  transform( OGRCoordinateTransformation *poCT );
351
    virtual void flattenTo2D();
352

    
353
};
354

    
355
/************************************************************************/
356
/*                               OGRCurve                               */
357
/************************************************************************/
358

    
359
/**
360
 * Abstract curve base class.
361
 */
362

    
363
class CPL_DLL OGRCurve : public OGRGeometry
364
{
365
  public:
366
            OGRCurve();
367
    virtual ~OGRCurve();
368
    // ICurve methods
369
    virtual double get_Length() const = 0;
370
    virtual void StartPoint(OGRPoint *) const = 0;
371
    virtual void EndPoint(OGRPoint *) const = 0;
372
    virtual int  get_IsClosed() const;
373
    virtual void Value( double, OGRPoint * ) const = 0;
374

    
375
};
376

    
377
/************************************************************************/
378
/*                            OGRLineString                             */
379
/************************************************************************/
380

    
381
/**
382
 * Concrete representation of a multi-vertex line.
383
 */
384

    
385
class CPL_DLL OGRLineString : public OGRCurve
386
{
387
  protected:
388
    int         nPointCount;
389
    OGRRawPoint *paoPoints;
390
    double      *padfZ;
391

    
392
    void        Make3D();
393
    void        Make2D();
394

    
395
  public:
396
                OGRLineString();
397
    virtual     ~OGRLineString();
398

    
399
    // IWks Interface
400
    virtual int WkbSize() const;
401
    virtual OGRErr importFromWkb( unsigned char *, int = -1 );
402
    virtual OGRErr exportToWkb( OGRwkbByteOrder, unsigned char * ) const;
403
    virtual OGRErr importFromWkt( char ** );
404
    virtual OGRErr exportToWkt( char ** ppszDstText ) const;
405

    
406
    // IGeometry interface
407
    virtual int getDimension() const;
408
    virtual int getCoordinateDimension() const;
409
    virtual OGRGeometry *clone() const;
410
    virtual void empty();
411
    virtual void getEnvelope( OGREnvelope * psEnvelope ) const;
412

    
413
    // ICurve methods
414
    virtual double get_Length() const;
415
    virtual void StartPoint(OGRPoint *) const;
416
    virtual void EndPoint(OGRPoint *) const;
417
    virtual void Value( double, OGRPoint * ) const;
418
    
419
    // ILineString methods
420
    int         getNumPoints() const { return nPointCount; }
421
    void        getPoint( int, OGRPoint * ) const;
422
    double      getX( int i ) const { return paoPoints[i].x; }
423
    double      getY( int i ) const { return paoPoints[i].y; }
424
    double      getZ( int i ) const;
425

    
426
    // ISpatialRelation
427
    virtual OGRBoolean  Equal( OGRGeometry * ) const;
428
    
429
    // non standard.
430
    void        setNumPoints( int );
431
    void        setPoint( int, OGRPoint * );
432
    void        setPoint( int, double, double, double = 0.0 );
433
    void        setPoints( int, OGRRawPoint *, double * = NULL );
434
    void        setPoints( int, double * padfX, double * padfY,
435
                           double *padfZ = NULL );
436
    void        addPoint( OGRPoint * );
437
    void        addPoint( double, double, double = 0.0 );
438

    
439
    // non-standard from OGRGeometry
440
    virtual OGRwkbGeometryType getGeometryType() const;
441
    virtual const char *getGeometryName() const;
442
    virtual OGRErr  transform( OGRCoordinateTransformation *poCT );
443
    virtual void flattenTo2D();
444

    
445
};
446

    
447
/************************************************************************/
448
/*                            OGRLinearRing                             */
449
/*                                                                      */
450
/*      This is an alias for OGRLineString for now.                     */
451
/************************************************************************/
452

    
453
/**
454
 * Concrete representation of a closed ring.
455
 *
456
 * This class is functionally equivelent to an OGRLineString, but has a
457
 * separate identity to maintain alignment with the OpenGIS simple feature
458
 * data model.  It exists to serve as a component of an OGRPolygon.
459
 */
460

    
461
class CPL_DLL OGRLinearRing : public OGRLineString
462
{
463
  private:
464
    friend class OGRPolygon; 
465
    
466
    // These are not IWks compatible ... just a convenience for OGRPolygon.
467
    virtual int _WkbSize( int b3D ) const;
468
    virtual OGRErr _importFromWkb( OGRwkbByteOrder, int b3D,
469
                                   unsigned char *, int=-1 );
470
    virtual OGRErr _exportToWkb( OGRwkbByteOrder, int b3D, 
471
                                 unsigned char * ) const;
472
    
473
  public:
474
                        OGRLinearRing();
475
                        OGRLinearRing( OGRLinearRing * );
476
                        ~OGRLinearRing();
477

    
478
    // Non standard.
479
    virtual const char *getGeometryName() const;
480
    virtual OGRGeometry *clone() const;
481
    virtual int isClockwise() const;
482
    virtual void closeRings();
483
    virtual double get_Area() const;
484
    
485
    // IWks Interface - Note this isnt really a first class object
486
    // for the purposes of WKB form.  These methods always fail since this
487
    // object cant be serialized on its own. 
488
    virtual int WkbSize() const;
489
    virtual OGRErr importFromWkb( unsigned char *, int=-1 );
490
    virtual OGRErr exportToWkb( OGRwkbByteOrder, unsigned char * ) const;
491
};
492

    
493
/************************************************************************/
494
/*                              OGRSurface                              */
495
/************************************************************************/
496

    
497
/**
498
 * Abstract base class for 2 dimensional objects like polygons.
499
 */
500

    
501
class CPL_DLL OGRSurface : public OGRGeometry
502
{
503
  public:
504
    virtual double      get_Area() const = 0;
505
    virtual OGRErr      Centroid( OGRPoint * poPoint ) const = 0;
506
    virtual OGRErr      PointOnSurface( OGRPoint * poPoint ) const = 0;
507
};
508

    
509
/************************************************************************/
510
/*                              OGRPolygon                              */
511
/************************************************************************/
512

    
513
/**
514
 * Concrete class representing polygons.
515
 *
516
 * Note that the OpenGIS simple features polygons consist of one outer
517
 * ring, and zero or more inner rings.  A polygon cannot represent disconnected
518
 * regions (such as multiple islands in a political body).  The
519
 * OGRMultiPolygon must be used for this.
520
 */
521

    
522
class CPL_DLL OGRPolygon : public OGRSurface
523
{
524
    int         nRingCount;
525
    OGRLinearRing **papoRings;
526
    
527
  public:
528
                OGRPolygon();
529
    virtual     ~OGRPolygon();
530

    
531
    // Non standard (OGRGeometry).
532
    virtual const char *getGeometryName() const;
533
    virtual OGRwkbGeometryType getGeometryType() const;
534
    virtual OGRGeometry *clone() const;
535
    virtual void empty();
536
    virtual OGRErr  transform( OGRCoordinateTransformation *poCT );
537
    virtual void flattenTo2D();
538
    
539
    // ISurface Interface
540
    virtual double      get_Area() const;
541
    virtual int         Centroid( OGRPoint * poPoint ) const;
542
    virtual int         PointOnSurface( OGRPoint * poPoint ) const;
543
    
544
    // IWks Interface
545
    virtual int WkbSize() const;
546
    virtual OGRErr importFromWkb( unsigned char *, int = -1 );
547
    virtual OGRErr exportToWkb( OGRwkbByteOrder, unsigned char * ) const;
548
    virtual OGRErr importFromWkt( char ** );
549
    virtual OGRErr exportToWkt( char ** ppszDstText ) const;
550

    
551
    // IGeometry
552
    virtual int getDimension() const;
553
    virtual int getCoordinateDimension() const;
554
    virtual void getEnvelope( OGREnvelope * psEnvelope ) const;
555

    
556
    // ISpatialRelation
557
    virtual OGRBoolean  Equal( OGRGeometry * ) const;
558
    
559
    // Non standard
560
    void        addRing( OGRLinearRing * );
561
    void        addRingDirectly( OGRLinearRing * );
562

    
563
    OGRLinearRing *getExteriorRing();
564
    const OGRLinearRing *getExteriorRing() const;
565
    int         getNumInteriorRings() const;
566
    OGRLinearRing *getInteriorRing( int );
567
    const OGRLinearRing *getInteriorRing( int ) const;
568

    
569
    virtual void closeRings();
570
};
571

    
572
/************************************************************************/
573
/*                        OGRGeometryCollection                         */
574
/************************************************************************/
575

    
576
/**
577
 * A collection of 1 or more geometry objects.
578
 *
579
 * All geometries must share a common spatial reference system, and
580
 * Subclasses may impose additional restrictions on the contents.
581
 */
582

    
583
class CPL_DLL OGRGeometryCollection : public OGRGeometry
584
{
585
    int         nGeomCount;
586
    OGRGeometry **papoGeoms;
587

    
588
    int         nCoordinateDimension;
589
    
590
  public:
591
                OGRGeometryCollection();
592
    virtual     ~OGRGeometryCollection();
593

    
594
    // Non standard (OGRGeometry).
595
    virtual const char *getGeometryName() const;
596
    virtual OGRwkbGeometryType getGeometryType() const;
597
    virtual OGRGeometry *clone() const;
598
    virtual void empty();
599
    virtual OGRErr  transform( OGRCoordinateTransformation *poCT );
600
    virtual void flattenTo2D();
601
    
602
    // IWks Interface
603
    virtual int WkbSize() const;
604
    virtual OGRErr importFromWkb( unsigned char *, int = -1 );
605
    virtual OGRErr exportToWkb( OGRwkbByteOrder, unsigned char * ) const;
606
    virtual OGRErr importFromWkt( char ** );
607
    virtual OGRErr exportToWkt( char ** ppszDstText ) const;
608

    
609
    // IGeometry methods
610
    virtual int getDimension() const;
611
    virtual int getCoordinateDimension() const;
612
    virtual void getEnvelope( OGREnvelope * psEnvelope ) const;
613

    
614
    // IGeometryCollection
615
    int         getNumGeometries() const;
616
    OGRGeometry *getGeometryRef( int );
617
    const OGRGeometry *getGeometryRef( int ) const;
618

    
619
    // ISpatialRelation
620
    virtual OGRBoolean  Equal( OGRGeometry * ) const;
621
    
622
    // Non standard
623
    virtual OGRErr addGeometry( const OGRGeometry * );
624
    virtual OGRErr addGeometryDirectly( OGRGeometry * );
625
    virtual OGRErr removeGeometry( int iIndex, int bDelete = TRUE );
626

    
627
    void closeRings();
628
};
629

    
630
/************************************************************************/
631
/*                           OGRMultiPolygon                            */
632
/************************************************************************/
633

    
634
/**
635
 * A collection of non-overlapping OGRPolygons.
636
 *
637
 * Note that the IMultiSurface class hasn't been modelled, nor have any
638
 * of it's methods. 
639
 */
640

    
641
class CPL_DLL OGRMultiPolygon : public OGRGeometryCollection
642
{
643
  public:
644
            OGRMultiPolygon();
645
    // Non standard (OGRGeometry).
646
    virtual const char *getGeometryName() const;
647
    virtual OGRwkbGeometryType getGeometryType() const;
648
    virtual OGRGeometry *clone() const;
649
    virtual OGRErr importFromWkt( char ** );
650
    virtual OGRErr exportToWkt( char ** ) const;
651
    
652
    // Non standard
653
    virtual OGRErr addGeometryDirectly( OGRGeometry * );
654

    
655
    double  get_Area() const;
656
};
657

    
658
/************************************************************************/
659
/*                            OGRMultiPoint                             */
660
/************************************************************************/
661

    
662
/**
663
 * A collection of OGRPoints.
664
 */
665

    
666
class CPL_DLL OGRMultiPoint : public OGRGeometryCollection
667
{
668
  private:
669
    OGRErr  importFromWkt_Bracketed( char ** );
670

    
671
  public:
672
            OGRMultiPoint();
673
    // Non standard (OGRGeometry).
674
    virtual const char *getGeometryName() const;
675
    virtual OGRwkbGeometryType getGeometryType() const;
676
    virtual OGRGeometry *clone() const;
677
    virtual OGRErr importFromWkt( char ** );
678
    virtual OGRErr exportToWkt( char ** ) const;
679
    
680
    // Non standard
681
    virtual OGRErr addGeometryDirectly( OGRGeometry * );
682
};
683

    
684
/************************************************************************/
685
/*                          OGRMultiLineString                          */
686
/************************************************************************/
687

    
688
/**
689
 * A collection of OGRLineStrings.
690
 */
691

    
692
class CPL_DLL OGRMultiLineString : public OGRGeometryCollection
693
{
694
  public:
695
            OGRMultiLineString();
696
            ~OGRMultiLineString();
697
    // Non standard (OGRGeometry).
698
    virtual const char *getGeometryName() const;
699
    virtual OGRwkbGeometryType getGeometryType() const;
700
    virtual OGRGeometry *clone() const;
701
    virtual OGRErr importFromWkt( char ** );
702
    virtual OGRErr exportToWkt( char ** ) const;
703
    
704
    // Non standard
705
    virtual OGRErr addGeometryDirectly( OGRGeometry * );
706
};
707

    
708

    
709
/************************************************************************/
710
/*                          OGRGeometryFactory                          */
711
/************************************************************************/
712

    
713
/**
714
 * Create geometry objects from well known text/binary.
715
 */
716

    
717
class CPL_DLL OGRGeometryFactory
718
{
719
  public:
720
    static OGRErr createFromWkb( unsigned char *, OGRSpatialReference *,
721
                                 OGRGeometry **, int = -1 );
722
    static OGRErr createFromWkt( char **, OGRSpatialReference *,
723
                                 OGRGeometry ** );
724
    static OGRGeometry *createFromGML( const char * );
725
    static OGRGeometry *createFromGEOS( const geos::Geometry * );
726

    
727
    static void   destroyGeometry( OGRGeometry * );
728
    static OGRGeometry *createGeometry( OGRwkbGeometryType );
729

    
730
    static OGRGeometry * forceToPolygon( OGRGeometry * );
731
    static OGRGeometry * forceToMultiPolygon( OGRGeometry * );
732
    static OGRGeometry * forceToMultiPoint( OGRGeometry * );
733
    static OGRGeometry * forceToMultiLineString( OGRGeometry * );
734

    
735
    static geos::GeometryFactory *getGEOSGeometryFactory();
736

    
737
};
738

    
739
#endif /* ndef _OGR_GEOMETRY_H_INCLUDED */