/usr/include/gdal/ogr_geometry.h is in libgdal1-dev 1.7.3-6ubuntu3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 | /******************************************************************************
* $Id: ogr_geometry.h 18155 2009-12-02 15:27:29Z warmerdam $
*
* Project: OpenGIS Simple Features Reference Implementation
* Purpose: Classes for manipulating simple features that is not specific
* to a particular interface technology.
* Author: Frank Warmerdam, warmerdam@pobox.com
*
******************************************************************************
* Copyright (c) 1999, Frank Warmerdam
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
****************************************************************************/
#ifndef _OGR_GEOMETRY_H_INCLUDED
#define _OGR_GEOMETRY_H_INCLUDED
#include "ogr_core.h"
#include "ogr_spatialref.h"
/**
* \file ogr_geometry.h
*
* Simple feature geometry classes.
*/
/**
* Simple container for a position.
*/
class OGRRawPoint
{
public:
OGRRawPoint()
{
x = y = 0.0;
}
double x;
double y;
};
typedef struct GEOSGeom_t *GEOSGeom;
/************************************************************************/
/* OGRGeometry */
/************************************************************************/
/**
* Abstract base class for all geometry classes.
*
* Note that the family of spatial analysis methods (Equal(), Disjoint(), ...,
* ConvexHull(), Buffer(), ...) are not implemented at ths time. Some other
* required and optional geometry methods have also been omitted at this
* time.
*
* Some spatial analysis methods require that OGR is built on the GEOS library
* to work properly. The precise meaning of methods that describe spatial relationships
* between geometries is described in the SFCOM, or other simple features interface
* specifications, like "OpenGISĀ® Implementation Specification for
* Geographic information - Simple feature access - Part 1: Common architecture"
* (<a href="http://www.opengeospatial.org/standards/sfa">OGC 06-103r3</a>)
*
*/
class CPL_DLL OGRGeometry
{
private:
OGRSpatialReference * poSRS; // may be NULL
protected:
int nCoordDimension;
public:
OGRGeometry();
virtual ~OGRGeometry();
// standard IGeometry
virtual int getDimension() const = 0;
virtual int getCoordinateDimension() const;
virtual OGRBoolean IsEmpty() const = 0;
virtual OGRBoolean IsValid() const;
virtual OGRBoolean IsSimple() const;
virtual OGRBoolean IsRing() const;
virtual void empty() = 0;
virtual OGRGeometry *clone() const = 0;
virtual void getEnvelope( OGREnvelope * psEnvelope ) const = 0;
// IWks Interface
virtual int WkbSize() const = 0;
virtual OGRErr importFromWkb( unsigned char *, int=-1 )=0;
virtual OGRErr exportToWkb( OGRwkbByteOrder, unsigned char * ) const = 0;
virtual OGRErr importFromWkt( char ** ppszInput ) = 0;
virtual OGRErr exportToWkt( char ** ppszDstText ) const = 0;
// non-standard
virtual OGRwkbGeometryType getGeometryType() const = 0;
virtual const char *getGeometryName() const = 0;
virtual void dumpReadable( FILE *, const char * = NULL, char** papszOptions = NULL ) const;
virtual void flattenTo2D() = 0;
virtual char * exportToGML() const;
virtual char * exportToKML() const;
virtual char * exportToJson() const;
virtual GEOSGeom exportToGEOS() const;
virtual void closeRings();
virtual void setCoordinateDimension( int nDimension );
void assignSpatialReference( OGRSpatialReference * poSR );
OGRSpatialReference *getSpatialReference( void ) const { return poSRS; }
virtual OGRErr transform( OGRCoordinateTransformation *poCT ) = 0;
OGRErr transformTo( OGRSpatialReference *poSR );
virtual void segmentize(double dfMaxLength);
// ISpatialRelation
virtual OGRBoolean Intersects( OGRGeometry * ) const;
virtual OGRBoolean Equals( OGRGeometry * ) const = 0;
virtual OGRBoolean Disjoint( const OGRGeometry * ) const;
virtual OGRBoolean Touches( const OGRGeometry * ) const;
virtual OGRBoolean Crosses( const OGRGeometry * ) const;
virtual OGRBoolean Within( const OGRGeometry * ) const;
virtual OGRBoolean Contains( const OGRGeometry * ) const;
virtual OGRBoolean Overlaps( const OGRGeometry * ) const;
// virtual OGRBoolean Relate( const OGRGeometry *, const char * ) const;
virtual OGRGeometry *getBoundary() const;
virtual double Distance( const OGRGeometry * ) const;
virtual OGRGeometry *ConvexHull() const;
virtual OGRGeometry *Buffer( double dfDist, int nQuadSegs = 30 ) const;
virtual OGRGeometry *Intersection( const OGRGeometry *) const;
virtual OGRGeometry *Union( const OGRGeometry * ) const;
virtual OGRGeometry *Difference( const OGRGeometry * ) const;
virtual OGRGeometry *SymmetricDifference( const OGRGeometry * ) const;
// backward compatibility methods.
OGRBoolean Intersect( OGRGeometry * ) const;
OGRBoolean Equal( OGRGeometry * ) const;
// Special HACK for DB2 7.2 support
static int bGenerate_DB2_V72_BYTE_ORDER;
};
/************************************************************************/
/* OGRPoint */
/************************************************************************/
/**
* Point class.
*
* Implements SFCOM IPoint methods.
*/
class CPL_DLL OGRPoint : public OGRGeometry
{
double x;
double y;
double z;
public:
OGRPoint();
OGRPoint( double x, double y );
OGRPoint( double x, double y, double z );
virtual ~OGRPoint();
// IWks Interface
virtual int WkbSize() const;
virtual OGRErr importFromWkb( unsigned char *, int=-1 );
virtual OGRErr exportToWkb( OGRwkbByteOrder, unsigned char * ) const;
virtual OGRErr importFromWkt( char ** );
virtual OGRErr exportToWkt( char ** ppszDstText ) const;
// IGeometry
virtual int getDimension() const;
virtual OGRGeometry *clone() const;
virtual void empty();
virtual void getEnvelope( OGREnvelope * psEnvelope ) const;
virtual OGRBoolean IsEmpty() const;
// IPoint
double getX() const { return x; }
double getY() const { return y; }
double getZ() const { return z; }
// Non standard
virtual void setCoordinateDimension( int nDimension );
void setX( double xIn ) { x = xIn; if (nCoordDimension == 0) nCoordDimension = 2; }
void setY( double yIn ) { y = yIn; if (nCoordDimension == 0) nCoordDimension = 2; }
void setZ( double zIn ) { z = zIn; nCoordDimension=3; }
// ISpatialRelation
virtual OGRBoolean Equals( OGRGeometry * ) const;
// Non standard from OGRGeometry
virtual const char *getGeometryName() const;
virtual OGRwkbGeometryType getGeometryType() const;
virtual OGRErr transform( OGRCoordinateTransformation *poCT );
virtual void flattenTo2D();
};
/************************************************************************/
/* OGRCurve */
/************************************************************************/
/**
* Abstract curve base class.
*/
class CPL_DLL OGRCurve : public OGRGeometry
{
public:
OGRCurve();
virtual ~OGRCurve();
// ICurve methods
virtual double get_Length() const = 0;
virtual void StartPoint(OGRPoint *) const = 0;
virtual void EndPoint(OGRPoint *) const = 0;
virtual int get_IsClosed() const;
virtual void Value( double, OGRPoint * ) const = 0;
};
/************************************************************************/
/* OGRLineString */
/************************************************************************/
/**
* Concrete representation of a multi-vertex line.
*/
class CPL_DLL OGRLineString : public OGRCurve
{
protected:
int nPointCount;
OGRRawPoint *paoPoints;
double *padfZ;
void Make3D();
void Make2D();
public:
OGRLineString();
virtual ~OGRLineString();
// IWks Interface
virtual int WkbSize() const;
virtual OGRErr importFromWkb( unsigned char *, int = -1 );
virtual OGRErr exportToWkb( OGRwkbByteOrder, unsigned char * ) const;
virtual OGRErr importFromWkt( char ** );
virtual OGRErr exportToWkt( char ** ppszDstText ) const;
// IGeometry interface
virtual int getDimension() const;
virtual OGRGeometry *clone() const;
virtual void empty();
virtual void getEnvelope( OGREnvelope * psEnvelope ) const;
virtual OGRBoolean IsEmpty() const;
// ICurve methods
virtual double get_Length() const;
virtual void StartPoint(OGRPoint *) const;
virtual void EndPoint(OGRPoint *) const;
virtual void Value( double, OGRPoint * ) const;
// ILineString methods
int getNumPoints() const { return nPointCount; }
void getPoint( int, OGRPoint * ) const;
double getX( int i ) const { return paoPoints[i].x; }
double getY( int i ) const { return paoPoints[i].y; }
double getZ( int i ) const;
// ISpatialRelation
virtual OGRBoolean Equals( OGRGeometry * ) const;
// non standard.
virtual void setCoordinateDimension( int nDimension );
void setNumPoints( int );
void setPoint( int, OGRPoint * );
void setPoint( int, double, double );
void setPoint( int, double, double, double );
void setPoints( int, OGRRawPoint *, double * = NULL );
void setPoints( int, double * padfX, double * padfY,
double *padfZ = NULL );
void addPoint( OGRPoint * );
void addPoint( double, double );
void addPoint( double, double, double );
void getPoints( OGRRawPoint *, double * = NULL ) const;
void addSubLineString( const OGRLineString *,
int nStartVertex = 0, int nEndVertex = -1 );
// non-standard from OGRGeometry
virtual OGRwkbGeometryType getGeometryType() const;
virtual const char *getGeometryName() const;
virtual OGRErr transform( OGRCoordinateTransformation *poCT );
virtual void flattenTo2D();
virtual void segmentize(double dfMaxLength);
};
/************************************************************************/
/* OGRLinearRing */
/************************************************************************/
/**
* Concrete representation of a closed ring.
*
* This class is functionally equivelent to an OGRLineString, but has a
* separate identity to maintain alignment with the OpenGIS simple feature
* data model. It exists to serve as a component of an OGRPolygon.
*
* The OGRLinearRing has no corresponding free standing well known binary
* representation, so importFromWkb() and exportToWkb() will not actually
* work. There is a non-standard GDAL WKT representation though.
*
* Because OGRLinearRing is not a "proper" free standing simple features
* object, it cannot be directly used on a feature via SetGeometry(), and
* cannot genearally be used with GEOS for operations like Intersects().
* Instead the polygon should be used, or the OGRLinearRing should be
* converted to an OGRLineString for such operations.
*/
class CPL_DLL OGRLinearRing : public OGRLineString
{
private:
friend class OGRPolygon;
// These are not IWks compatible ... just a convenience for OGRPolygon.
virtual int _WkbSize( int b3D ) const;
virtual OGRErr _importFromWkb( OGRwkbByteOrder, int b3D,
unsigned char *, int=-1 );
virtual OGRErr _exportToWkb( OGRwkbByteOrder, int b3D,
unsigned char * ) const;
public:
OGRLinearRing();
OGRLinearRing( OGRLinearRing * );
~OGRLinearRing();
// Non standard.
virtual const char *getGeometryName() const;
virtual OGRGeometry *clone() const;
virtual int isClockwise() const;
virtual void reverseWindingOrder();
virtual void closeRings();
virtual double get_Area() const;
OGRBoolean isPointInRing(const OGRPoint* pt, int bTestEnvelope = TRUE) const;
OGRBoolean isPointOnRingBoundary(const OGRPoint* pt, int bTestEnvelope = TRUE) const;
// IWks Interface - Note this isnt really a first class object
// for the purposes of WKB form. These methods always fail since this
// object cant be serialized on its own.
virtual int WkbSize() const;
virtual OGRErr importFromWkb( unsigned char *, int=-1 );
virtual OGRErr exportToWkb( OGRwkbByteOrder, unsigned char * ) const;
};
/************************************************************************/
/* OGRSurface */
/************************************************************************/
/**
* Abstract base class for 2 dimensional objects like polygons.
*/
class CPL_DLL OGRSurface : public OGRGeometry
{
public:
virtual double get_Area() const = 0;
virtual OGRErr Centroid( OGRPoint * poPoint ) const = 0;
virtual OGRErr PointOnSurface( OGRPoint * poPoint ) const = 0;
};
/************************************************************************/
/* OGRPolygon */
/************************************************************************/
/**
* Concrete class representing polygons.
*
* Note that the OpenGIS simple features polygons consist of one outer
* ring, and zero or more inner rings. A polygon cannot represent disconnected
* regions (such as multiple islands in a political body). The
* OGRMultiPolygon must be used for this.
*/
class CPL_DLL OGRPolygon : public OGRSurface
{
int nRingCount;
OGRLinearRing **papoRings;
public:
OGRPolygon();
virtual ~OGRPolygon();
// Non standard (OGRGeometry).
virtual const char *getGeometryName() const;
virtual OGRwkbGeometryType getGeometryType() const;
virtual OGRGeometry *clone() const;
virtual void empty();
virtual OGRErr transform( OGRCoordinateTransformation *poCT );
virtual void flattenTo2D();
virtual OGRBoolean IsEmpty() const;
virtual void segmentize(double dfMaxLength);
// ISurface Interface
virtual double get_Area() const;
virtual int Centroid( OGRPoint * poPoint ) const;
virtual int PointOnSurface( OGRPoint * poPoint ) const;
// IWks Interface
virtual int WkbSize() const;
virtual OGRErr importFromWkb( unsigned char *, int = -1 );
virtual OGRErr exportToWkb( OGRwkbByteOrder, unsigned char * ) const;
virtual OGRErr importFromWkt( char ** );
virtual OGRErr exportToWkt( char ** ppszDstText ) const;
// IGeometry
virtual int getDimension() const;
virtual void getEnvelope( OGREnvelope * psEnvelope ) const;
// ISpatialRelation
virtual OGRBoolean Equals( OGRGeometry * ) const;
// Non standard
virtual void setCoordinateDimension( int nDimension );
void addRing( OGRLinearRing * );
void addRingDirectly( OGRLinearRing * );
OGRLinearRing *getExteriorRing();
const OGRLinearRing *getExteriorRing() const;
int getNumInteriorRings() const;
OGRLinearRing *getInteriorRing( int );
const OGRLinearRing *getInteriorRing( int ) const;
OGRBoolean IsPointOnSurface( const OGRPoint * ) const;
virtual void closeRings();
};
/************************************************************************/
/* OGRGeometryCollection */
/************************************************************************/
/**
* A collection of 1 or more geometry objects.
*
* All geometries must share a common spatial reference system, and
* Subclasses may impose additional restrictions on the contents.
*/
class CPL_DLL OGRGeometryCollection : public OGRGeometry
{
int nGeomCount;
OGRGeometry **papoGeoms;
public:
OGRGeometryCollection();
virtual ~OGRGeometryCollection();
// Non standard (OGRGeometry).
virtual const char *getGeometryName() const;
virtual OGRwkbGeometryType getGeometryType() const;
virtual OGRGeometry *clone() const;
virtual void empty();
virtual OGRErr transform( OGRCoordinateTransformation *poCT );
virtual void flattenTo2D();
virtual OGRBoolean IsEmpty() const;
virtual void segmentize(double dfMaxLength);
// IWks Interface
virtual int WkbSize() const;
virtual OGRErr importFromWkb( unsigned char *, int = -1 );
virtual OGRErr exportToWkb( OGRwkbByteOrder, unsigned char * ) const;
virtual OGRErr importFromWkt( char ** );
virtual OGRErr exportToWkt( char ** ppszDstText ) const;
virtual double get_Area() const;
// IGeometry methods
virtual int getDimension() const;
virtual void getEnvelope( OGREnvelope * psEnvelope ) const;
// IGeometryCollection
int getNumGeometries() const;
OGRGeometry *getGeometryRef( int );
const OGRGeometry *getGeometryRef( int ) const;
// ISpatialRelation
virtual OGRBoolean Equals( OGRGeometry * ) const;
// Non standard
virtual void setCoordinateDimension( int nDimension );
virtual OGRErr addGeometry( const OGRGeometry * );
virtual OGRErr addGeometryDirectly( OGRGeometry * );
virtual OGRErr removeGeometry( int iIndex, int bDelete = TRUE );
void closeRings();
};
/************************************************************************/
/* OGRMultiPolygon */
/************************************************************************/
/**
* A collection of non-overlapping OGRPolygons.
*
* Note that the IMultiSurface class hasn't been modelled, nor have any
* of it's methods.
*/
class CPL_DLL OGRMultiPolygon : public OGRGeometryCollection
{
public:
OGRMultiPolygon();
// Non standard (OGRGeometry).
virtual const char *getGeometryName() const;
virtual OGRwkbGeometryType getGeometryType() const;
virtual OGRGeometry *clone() const;
virtual OGRErr importFromWkt( char ** );
virtual OGRErr exportToWkt( char ** ) const;
// Non standard
virtual OGRErr addGeometryDirectly( OGRGeometry * );
virtual double get_Area() const;
};
/************************************************************************/
/* OGRMultiPoint */
/************************************************************************/
/**
* A collection of OGRPoints.
*/
class CPL_DLL OGRMultiPoint : public OGRGeometryCollection
{
private:
OGRErr importFromWkt_Bracketed( char ** );
public:
OGRMultiPoint();
// Non standard (OGRGeometry).
virtual const char *getGeometryName() const;
virtual OGRwkbGeometryType getGeometryType() const;
virtual OGRGeometry *clone() const;
virtual OGRErr importFromWkt( char ** );
virtual OGRErr exportToWkt( char ** ) const;
// Non standard
virtual OGRErr addGeometryDirectly( OGRGeometry * );
};
/************************************************************************/
/* OGRMultiLineString */
/************************************************************************/
/**
* A collection of OGRLineStrings.
*/
class CPL_DLL OGRMultiLineString : public OGRGeometryCollection
{
public:
OGRMultiLineString();
~OGRMultiLineString();
// Non standard (OGRGeometry).
virtual const char *getGeometryName() const;
virtual OGRwkbGeometryType getGeometryType() const;
virtual OGRGeometry *clone() const;
virtual OGRErr importFromWkt( char ** );
virtual OGRErr exportToWkt( char ** ) const;
// Non standard
virtual OGRErr addGeometryDirectly( OGRGeometry * );
};
/************************************************************************/
/* OGRGeometryFactory */
/************************************************************************/
/**
* Create geometry objects from well known text/binary.
*/
class CPL_DLL OGRGeometryFactory
{
public:
static OGRErr createFromWkb( unsigned char *, OGRSpatialReference *,
OGRGeometry **, int = -1 );
static OGRErr createFromWkt( char **, OGRSpatialReference *,
OGRGeometry ** );
static OGRErr createFromFgf( unsigned char *, OGRSpatialReference *,
OGRGeometry **, int = -1, int * = NULL );
static OGRGeometry *createFromGML( const char * );
static OGRGeometry *createFromGEOS( GEOSGeom );
static void destroyGeometry( OGRGeometry * );
static OGRGeometry *createGeometry( OGRwkbGeometryType );
static OGRGeometry * forceToPolygon( OGRGeometry * );
static OGRGeometry * forceToMultiPolygon( OGRGeometry * );
static OGRGeometry * forceToMultiPoint( OGRGeometry * );
static OGRGeometry * forceToMultiLineString( OGRGeometry * );
static OGRGeometry * organizePolygons( OGRGeometry **papoPolygons,
int nPolygonCount,
int *pbResultValidGeometry,
const char **papszOptions = NULL);
static void *getGEOSGeometryFactory();
static int haveGEOS();
static OGRGeometry* transformWithOptions( const OGRGeometry* poSrcGeom,
OGRCoordinateTransformation *poCT,
char** papszOptions );
static OGRGeometry*
approximateArcAngles( double dfX, double dfY, double dfZ,
double dfPrimaryRadius, double dfSecondaryAxis,
double dfRotation,
double dfStartAngle, double dfEndAngle,
double dfMaxAngleStepSizeDegrees );
};
#endif /* ndef _OGR_GEOMETRY_H_INCLUDED */
|