Skip to content
Permalink
Browse files
some bugfixes for editing multiline geometries
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@5418 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed May 4, 2006
1 parent de5b6a3 commit 0314c97cc25a62a0d3a463c7edd46e6368c25320
Showing with 44 additions and 0 deletions.
  1. +44 −0 src/core/qgsgeometry.cpp
@@ -642,6 +642,8 @@ bool QgsGeometry::deleteVertexAt(QgsGeometryVertexIndex atVertex)
int pointindex = 0;
for(int linenr = 0; linenr < *nLines; ++linenr)
{
ptr += (sizeof(int) + 1);
newBufferPtr += (sizeof(int) + 1);
nPoints = (int*)ptr;
ptr += sizeof(int);
int newNPoint;
@@ -660,6 +662,7 @@ bool QgsGeometry::deleteVertexAt(QgsGeometryVertexIndex atVertex)
newNPoint = *nPoints;
}
memcpy(newBufferPtr, &newNPoint, sizeof(int));
newBufferPtr += sizeof(int);

for(int pointnr = 0; pointnr < *nPoints; ++pointnr)
{
@@ -873,6 +876,47 @@ bool QgsGeometry::insertVertexBefore(double x, double y, QgsGeometryVertexIndex
}
case QGis::WKBMultiLineString:
{
int* nLines = (int*)ptr;
int* nPoints = 0; //number of points in a line
ptr += sizeof(int);
memcpy(newBufferPtr, nLines, sizeof(int));
newBufferPtr += sizeof(int);
int pointindex = 0;

for(int linenr = 0; linenr < *nLines; ++linenr)
{
ptr += (sizeof(int) + 1);
newBufferPtr += (sizeof(int) + 1);
nPoints = (int*)ptr;
int newNPoints;
if(vertexnr >= pointindex && vertexnr < (pointindex + (*nPoints)))//point is in this ring
{
newNPoints = (*nPoints)+1;
}
else
{
newNPoints = *nPoints;
}
memcpy(newBufferPtr, &newNPoints, sizeof(double));
newBufferPtr += sizeof(int);
ptr += sizeof(int);

for(int pointnr = 0; pointnr < *nPoints; ++pointnr)
{
memcpy(newBufferPtr, ptr, sizeof(double));//x
memcpy(newBufferPtr+sizeof(double), ptr+sizeof(double), sizeof(double));//y
ptr += 2*sizeof(double);
newBufferPtr += 2*sizeof(double);
++pointindex;
if(pointindex == vertexnr)
{
memcpy(newBufferPtr, &x, sizeof(double));
memcpy(newBufferPtr+sizeof(double), &y, sizeof(double));
newBufferPtr += 2*sizeof(double);
success = true;
}
}
}
break;
}
case QGis::WKBPolygon:

0 comments on commit 0314c97

Please sign in to comment.