Skip to content
Permalink
Browse files
Changed std::list to QList in addRing functions
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@6946 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed May 16, 2007
1 parent fbdbddb commit 309cd27eafcd19a943bdc5d07a1a20fb5a2669b1
Showing with 19 additions and 15 deletions.
  1. +4 −4 src/app/qgsmaptooladdfeature.cpp
  2. +2 −2 src/app/qgsmaptoolcapture.h
  3. +9 −5 src/core/qgsgeometry.cpp
  4. +1 −1 src/core/qgsgeometry.h
  5. +2 −2 src/core/qgsvectorlayer.cpp
  6. +1 −1 src/core/qgsvectorlayer.h
@@ -225,7 +225,7 @@ void QgsMapToolAddFeature::canvasReleaseEvent(QMouseEvent * e)
memcpy(&wkb[1+sizeof(int)],&length, sizeof(int));
int position=1+2*sizeof(int);
double x,y;
for(std::list<QgsPoint>::iterator it=mCaptureList.begin();it!=mCaptureList.end();++it)
for(QList<QgsPoint>::iterator it=mCaptureList.begin();it!=mCaptureList.end();++it)
{
QgsPoint savePoint = *it;
x = savePoint.x();
@@ -260,7 +260,7 @@ void QgsMapToolAddFeature::canvasReleaseEvent(QMouseEvent * e)
memcpy(&wkb[position], &length, sizeof(int));
position += sizeof(int);
double x,y;
for(std::list<QgsPoint>::iterator it=mCaptureList.begin();it!=mCaptureList.end();++it)
for(QList<QgsPoint>::iterator it=mCaptureList.begin();it!=mCaptureList.end();++it)
{
QgsPoint savePoint = *it;
x = savePoint.x();
@@ -289,7 +289,7 @@ void QgsMapToolAddFeature::canvasReleaseEvent(QMouseEvent * e)
memcpy(&wkb[1+2*sizeof(int)],&length, sizeof(int));
int position=1+3*sizeof(int);
double x,y;
std::list<QgsPoint>::iterator it;
QList<QgsPoint>::iterator it;
for(it=mCaptureList.begin();it!=mCaptureList.end();++it)
{
QgsPoint savePoint = *it;
@@ -338,7 +338,7 @@ void QgsMapToolAddFeature::canvasReleaseEvent(QMouseEvent * e)
memcpy(&wkb[position], &length, sizeof(int));
position += sizeof(int);
double x,y;
std::list<QgsPoint>::iterator it;
QList<QgsPoint>::iterator it;
for(it=mCaptureList.begin();it!=mCaptureList.end();++it)//add the captured points to the polygon
{
QgsPoint savePoint = *it;
@@ -24,7 +24,7 @@
class QgsRubberBand;

#include <QPoint>
#include <list>
#include <QList>

class QgsMapToolCapture : public QgsMapTool
{
@@ -77,7 +77,7 @@ class QgsMapToolCapture : public QgsMapTool
QgsRubberBand* mRubberBand;

/** List to store the points of digitised lines and polygons */
std::list<QgsPoint> mCaptureList;
QList<QgsPoint> mCaptureList;

/**Adds a point to the rubber band (in map coordinates) and to the capture list (in layer coordinates)
@return 0 in case of success, 1 if current layer is not a vector layer, 2 if coordinate transformation failed*/
@@ -2249,18 +2249,22 @@ double QgsGeometry::closestSegmentWithContext(const QgsPoint& point,
return sqrDist;
}

int QgsGeometry::addRing(const std::list<QgsPoint>& ring)
int QgsGeometry::addRing(const QList<QgsPoint>& ring)
{
//bail out if this geometry is not polygon/multipolygon
if(vectorType() != QGis::Polygon)
{
return 1;
}

//test for invalid geometries
if(ring.size() < 4)
{
return 3;
}

//ring must be closed
std::list<QgsPoint>::const_iterator it1 = ring.begin();
std::list<QgsPoint>::const_reverse_iterator it2 = ring.rbegin();
if(*it1 != *it2)
if(ring.first() != ring.last())
{
return 2;
}
@@ -2302,7 +2306,7 @@ int QgsGeometry::addRing(const std::list<QgsPoint>& ring)

//create new ring
GEOS_GEOM::DefaultCoordinateSequence* newSequence=new GEOS_GEOM::DefaultCoordinateSequence();
for(std::list<QgsPoint>::const_iterator it = ring.begin(); it != ring.end(); ++it)
for(QList<QgsPoint>::const_iterator it = ring.begin(); it != ring.end(); ++it)
{
newSequence->add(GEOS_GEOM::Coordinate(it->x(),it->y()));
}
@@ -237,7 +237,7 @@ class CORE_EXPORT QgsGeometry {
/**Adds a new ring to this geometry. This makes only sense for polygon and multipolygons.
@return 0 success (ring added), 1 problem with geometry type, 2 ring not closed, 3 ring is not valid geometry, \
4 ring not disjoint with existing rings, 5 no polygon found which contained the ring*/
int addRing(const std::list<QgsPoint>& ring);
int addRing(const QList<QgsPoint>& ring);

/**Returns the bounding box of this feature*/
QgsRect boundingBox();
@@ -1371,7 +1371,7 @@ bool QgsVectorLayer::deleteSelectedFeatures()
return true;
}

int QgsVectorLayer::addRing(const std::list<QgsPoint>& ring)
int QgsVectorLayer::addRing(const QList<QgsPoint>& ring)
{
int addRingReturnCode = 0;

@@ -1381,7 +1381,7 @@ int QgsVectorLayer::addRing(const std::list<QgsPoint>& ring)
double yMin = std::numeric_limits<double>::max();
double yMax = -std::numeric_limits<double>::max();

for(std::list<QgsPoint>::const_iterator it = ring.begin(); it != ring.end(); ++it)
for(QList<QgsPoint>::const_iterator it = ring.constBegin(); it != ring.constEnd(); ++it)
{
if(it->x() < xMin)
{
@@ -234,7 +234,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
/**Adds a ring to polygon/multipolygon features
@return 0 in case of success, 1 problem with feature type, 2 ring not closed, 3 ring not valid, 4 ring crosses \
existing rings, 5 no feature found where ring can be inserted*/
int addRing(const std::list<QgsPoint>& ring);
int addRing(const QList<QgsPoint>& ring);

/** Set labels on */
void setLabelOn( bool on );

0 comments on commit 309cd27

Please sign in to comment.