Skip to content
Permalink
Browse files
- renamed QgsGeometry::difference to QgsGeometry::makeDifference
- more geoprocessing in QgsGeometry: convexHull, intersection, Union, difference, symDifference


git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@7994 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder committed Jan 17, 2008
1 parent e048352 commit c5bb76ea1105d93388c0a2899aab3670a77d3e30
Showing with 100 additions and 5 deletions.
  1. +16 −1 python/core/qgsgeometry.sip
  2. +66 −1 src/core/qgsgeometry.cpp
  3. +16 −1 src/core/qgsgeometry.h
  4. +2 −2 src/core/qgsvectorlayer.cpp
@@ -195,7 +195,7 @@ not disjoint with existing polygons of the feature*/
/**Changes this geometry such that it does not intersect the other geometry
@param other geometry that should not be intersect
@return 0 in case of success*/
int difference(QgsGeometry* other);
int makeDifference(QgsGeometry* other);

/**Returns the bounding box of this feature*/
QgsRect boundingBox();
@@ -212,6 +212,21 @@ not disjoint with existing polygons of the feature*/
of segments used to approximate curves */
QgsGeometry* buffer(double distance, int segments) /Factory/;

/** Returns the smallest convex polygon that contains all the points in the geometry. */
QgsGeometry* convexHull() /Factory/;

/** Returns a geometry representing the points shared by this geometry and other. */
QgsGeometry* intersection(QgsGeometry* geometry) /Factory/;

/** Returns a geometry representing all the points in this geometry and other. */
QgsGeometry* Union(QgsGeometry* geometry) /Factory/;

/** Returns a geometry representing the points making up this geometry that do not make up other. */
QgsGeometry* difference(QgsGeometry* geometry) /Factory/;

/** Returns a Geometry representing the points making up this Geometry that do not make up other. */
QgsGeometry* symDifference(QgsGeometry* geometry) /Factory/;

/**Creates a geos geometry from this features geometry. Note, that the returned object needs to be deleted*/
// TODO: unsupported class... would be possible to use PyGEOS?
//geos::Geometry* geosGeometry() const;
@@ -2934,7 +2934,7 @@ int QgsGeometry::splitGeometry(const QList<QgsPoint>& splitLine, QList<QgsGeomet
return returnCode;
}

int QgsGeometry::difference(QgsGeometry* other)
int QgsGeometry::makeDifference(QgsGeometry* other)
{
//make sure geos geometry is up to date
if(!mGeos || mDirtyGeos)
@@ -5523,3 +5523,68 @@ QgsGeometry* QgsGeometry::buffer(double distance, int segments)
return g;
}

QgsGeometry* QgsGeometry::convexHull()
{
if (mGeos == NULL)
exportWkbToGeos();
GEOS_GEOM::Geometry* geos = mGeos->convexHull();
QgsGeometry* g = new QgsGeometry;
g->setGeos(geos);
return g;
}

QgsGeometry* QgsGeometry::intersection(QgsGeometry* geometry)
{
if (geometry == NULL)
return NULL;
if (mGeos == NULL)
exportWkbToGeos();
if (geometry->mGeos == NULL)
geometry->exportWkbToGeos();
GEOS_GEOM::Geometry* geos = mGeos->intersection(geometry->mGeos);
QgsGeometry* g = new QgsGeometry;
g->setGeos(geos);
return g;
}

QgsGeometry* QgsGeometry::Union(QgsGeometry* geometry)
{
if (geometry == NULL)
return NULL;
if (mGeos == NULL)
exportWkbToGeos();
if (geometry->mGeos == NULL)
geometry->exportWkbToGeos();
GEOS_GEOM::Geometry* geos = mGeos->Union(geometry->mGeos);
QgsGeometry* g = new QgsGeometry;
g->setGeos(geos);
return g;
}

QgsGeometry* QgsGeometry::difference(QgsGeometry* geometry)
{
if (geometry == NULL)
return NULL;
if (mGeos == NULL)
exportWkbToGeos();
if (geometry->mGeos == NULL)
geometry->exportWkbToGeos();
GEOS_GEOM::Geometry* geos = mGeos->difference(geometry->mGeos);
QgsGeometry* g = new QgsGeometry;
g->setGeos(geos);
return g;
}

QgsGeometry* QgsGeometry::symDifference(QgsGeometry* geometry)
{
if (geometry == NULL)
return NULL;
if (mGeos == NULL)
exportWkbToGeos();
if (geometry->mGeos == NULL)
geometry->exportWkbToGeos();
GEOS_GEOM::Geometry* geos = mGeos->symDifference(geometry->mGeos);
QgsGeometry* g = new QgsGeometry;
g->setGeos(geos);
return g;
}
@@ -265,7 +265,7 @@ not disjoint with existing polygons of the feature*/
/**Changes this geometry such that it does not intersect the other geometry
@param other geometry that should not be intersect
@return 0 in case of success*/
int difference(QgsGeometry* other);
int makeDifference(QgsGeometry* other);

/**Returns the bounding box of this feature*/
QgsRect boundingBox();
@@ -281,6 +281,21 @@ not disjoint with existing polygons of the feature*/
/** Returns a buffer region around this geometry having the given width and with a specified number
of segments used to approximate curves */
QgsGeometry* buffer(double distance, int segments);

/** Returns the smallest convex polygon that contains all the points in the geometry. */
QgsGeometry* convexHull();

/** Returns a geometry representing the points shared by this geometry and other. */
QgsGeometry* intersection(QgsGeometry* geometry);

/** Returns a geometry representing all the points in this geometry and other. */
QgsGeometry* Union(QgsGeometry* geometry);

/** Returns a geometry representing the points making up this geometry that do not make up other. */
QgsGeometry* difference(QgsGeometry* geometry);

/** Returns a Geometry representing the points making up this Geometry that do not make up other. */
QgsGeometry* symDifference(QgsGeometry* geometry);

/** Exports the geometry to mWkt
@return true in case of success and false else
@@ -1781,11 +1781,11 @@ int QgsVectorLayer::removePolygonIntersections(QgsGeometry* geom)

for(; it != featureList.end(); ++it)
{
//call geometry->difference for each feature
//call geometry->makeDifference for each feature
currentGeom = it->geometry();
if(currentGeom)
{
if(geom->difference(it->geometry()) != 0)
if(geom->makeDifference(it->geometry()) != 0)
{
returnValue = 2;
}

0 comments on commit c5bb76e

Please sign in to comment.