Skip to content

Commit

Permalink
some bugfixes for editing multiline geometries
Browse files Browse the repository at this point in the history
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 0314c97
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions src/core/qgsgeometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
{
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 0314c97

Please sign in to comment.