Skip to content

Commit

Permalink
Changed std::list to QList in addRing functions
Browse files Browse the repository at this point in the history
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 309cd27
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 15 deletions.
8 changes: 4 additions & 4 deletions src/app/qgsmaptooladdfeature.cpp
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/app/qgsmaptoolcapture.h
Expand Up @@ -24,7 +24,7 @@
class QgsRubberBand;

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

class QgsMapToolCapture : public QgsMapTool
{
Expand Down Expand Up @@ -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*/
Expand Down
14 changes: 9 additions & 5 deletions src/core/qgsgeometry.cpp
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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()));
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsgeometry.h
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions src/core/qgsvectorlayer.cpp
Expand Up @@ -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;

Expand All @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsvectorlayer.h
Expand Up @@ -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 );
Expand Down

0 comments on commit 309cd27

Please sign in to comment.