Skip to content

Commit 309cd27

Browse files
author
mhugent
committed
Changed std::list to QList in addRing functions
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@6946 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent fbdbddb commit 309cd27

6 files changed

+19
-15
lines changed

src/app/qgsmaptooladdfeature.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ void QgsMapToolAddFeature::canvasReleaseEvent(QMouseEvent * e)
225225
memcpy(&wkb[1+sizeof(int)],&length, sizeof(int));
226226
int position=1+2*sizeof(int);
227227
double x,y;
228-
for(std::list<QgsPoint>::iterator it=mCaptureList.begin();it!=mCaptureList.end();++it)
228+
for(QList<QgsPoint>::iterator it=mCaptureList.begin();it!=mCaptureList.end();++it)
229229
{
230230
QgsPoint savePoint = *it;
231231
x = savePoint.x();
@@ -260,7 +260,7 @@ void QgsMapToolAddFeature::canvasReleaseEvent(QMouseEvent * e)
260260
memcpy(&wkb[position], &length, sizeof(int));
261261
position += sizeof(int);
262262
double x,y;
263-
for(std::list<QgsPoint>::iterator it=mCaptureList.begin();it!=mCaptureList.end();++it)
263+
for(QList<QgsPoint>::iterator it=mCaptureList.begin();it!=mCaptureList.end();++it)
264264
{
265265
QgsPoint savePoint = *it;
266266
x = savePoint.x();
@@ -289,7 +289,7 @@ void QgsMapToolAddFeature::canvasReleaseEvent(QMouseEvent * e)
289289
memcpy(&wkb[1+2*sizeof(int)],&length, sizeof(int));
290290
int position=1+3*sizeof(int);
291291
double x,y;
292-
std::list<QgsPoint>::iterator it;
292+
QList<QgsPoint>::iterator it;
293293
for(it=mCaptureList.begin();it!=mCaptureList.end();++it)
294294
{
295295
QgsPoint savePoint = *it;
@@ -338,7 +338,7 @@ void QgsMapToolAddFeature::canvasReleaseEvent(QMouseEvent * e)
338338
memcpy(&wkb[position], &length, sizeof(int));
339339
position += sizeof(int);
340340
double x,y;
341-
std::list<QgsPoint>::iterator it;
341+
QList<QgsPoint>::iterator it;
342342
for(it=mCaptureList.begin();it!=mCaptureList.end();++it)//add the captured points to the polygon
343343
{
344344
QgsPoint savePoint = *it;

src/app/qgsmaptoolcapture.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
class QgsRubberBand;
2525

2626
#include <QPoint>
27-
#include <list>
27+
#include <QList>
2828

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

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

8282
/**Adds a point to the rubber band (in map coordinates) and to the capture list (in layer coordinates)
8383
@return 0 in case of success, 1 if current layer is not a vector layer, 2 if coordinate transformation failed*/

src/core/qgsgeometry.cpp

+9-5
Original file line numberDiff line numberDiff line change
@@ -2249,18 +2249,22 @@ double QgsGeometry::closestSegmentWithContext(const QgsPoint& point,
22492249
return sqrDist;
22502250
}
22512251

2252-
int QgsGeometry::addRing(const std::list<QgsPoint>& ring)
2252+
int QgsGeometry::addRing(const QList<QgsPoint>& ring)
22532253
{
22542254
//bail out if this geometry is not polygon/multipolygon
22552255
if(vectorType() != QGis::Polygon)
22562256
{
22572257
return 1;
22582258
}
22592259

2260+
//test for invalid geometries
2261+
if(ring.size() < 4)
2262+
{
2263+
return 3;
2264+
}
2265+
22602266
//ring must be closed
2261-
std::list<QgsPoint>::const_iterator it1 = ring.begin();
2262-
std::list<QgsPoint>::const_reverse_iterator it2 = ring.rbegin();
2263-
if(*it1 != *it2)
2267+
if(ring.first() != ring.last())
22642268
{
22652269
return 2;
22662270
}
@@ -2302,7 +2306,7 @@ int QgsGeometry::addRing(const std::list<QgsPoint>& ring)
23022306

23032307
//create new ring
23042308
GEOS_GEOM::DefaultCoordinateSequence* newSequence=new GEOS_GEOM::DefaultCoordinateSequence();
2305-
for(std::list<QgsPoint>::const_iterator it = ring.begin(); it != ring.end(); ++it)
2309+
for(QList<QgsPoint>::const_iterator it = ring.begin(); it != ring.end(); ++it)
23062310
{
23072311
newSequence->add(GEOS_GEOM::Coordinate(it->x(),it->y()));
23082312
}

src/core/qgsgeometry.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ class CORE_EXPORT QgsGeometry {
237237
/**Adds a new ring to this geometry. This makes only sense for polygon and multipolygons.
238238
@return 0 success (ring added), 1 problem with geometry type, 2 ring not closed, 3 ring is not valid geometry, \
239239
4 ring not disjoint with existing rings, 5 no polygon found which contained the ring*/
240-
int addRing(const std::list<QgsPoint>& ring);
240+
int addRing(const QList<QgsPoint>& ring);
241241

242242
/**Returns the bounding box of this feature*/
243243
QgsRect boundingBox();

src/core/qgsvectorlayer.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1371,7 +1371,7 @@ bool QgsVectorLayer::deleteSelectedFeatures()
13711371
return true;
13721372
}
13731373

1374-
int QgsVectorLayer::addRing(const std::list<QgsPoint>& ring)
1374+
int QgsVectorLayer::addRing(const QList<QgsPoint>& ring)
13751375
{
13761376
int addRingReturnCode = 0;
13771377

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

1384-
for(std::list<QgsPoint>::const_iterator it = ring.begin(); it != ring.end(); ++it)
1384+
for(QList<QgsPoint>::const_iterator it = ring.constBegin(); it != ring.constEnd(); ++it)
13851385
{
13861386
if(it->x() < xMin)
13871387
{

src/core/qgsvectorlayer.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
234234
/**Adds a ring to polygon/multipolygon features
235235
@return 0 in case of success, 1 problem with feature type, 2 ring not closed, 3 ring not valid, 4 ring crosses \
236236
existing rings, 5 no feature found where ring can be inserted*/
237-
int addRing(const std::list<QgsPoint>& ring);
237+
int addRing(const QList<QgsPoint>& ring);
238238

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

0 commit comments

Comments
 (0)