Skip to content

Commit

Permalink
Take the changed geometry for rubberbanding instead of the original one
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@5103 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Mar 27, 2006
1 parent 62766b3 commit 14f574a
Showing 1 changed file with 64 additions and 53 deletions.
117 changes: 64 additions & 53 deletions src/core/qgsgeometry.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -771,106 +771,117 @@ bool QgsGeometry::vertexAt(double &x, double &y,
<< "." << std::endl; << "." << std::endl;
#endif #endif


if(mGeometry) if(mGeos)//try to find the vertex from the Geos geometry (it present)
{ {
int wkbType; geos::CoordinateSequence* cs = mGeos->getCoordinates();
if(cs)
{
const geos::Coordinate& coord = cs->getAt(atVertex.back());
x = coord.x;
y = coord.y;
delete cs;
return true;
}
}


memcpy(&wkbType, (mGeometry+1), sizeof(int)); else if(mGeometry)
switch (wkbType) {
{ int wkbType;

memcpy(&wkbType, (mGeometry+1), sizeof(int));
switch (wkbType)
{
case QGis::WKBPoint: case QGis::WKBPoint:
{ {
// TODO // TODO
return FALSE; return FALSE;
break; break;
} }
case QGis::WKBLineString: case QGis::WKBLineString:
{ {
unsigned char *ptr; unsigned char *ptr;
int *nPoints; int *nPoints;

// get number of points in the line // get number of points in the line
ptr = mGeometry + 5; // now at mGeometry.numPoints ptr = mGeometry + 5; // now at mGeometry.numPoints
nPoints = (int *) ptr; nPoints = (int *) ptr;

#ifdef QGISDEBUG #ifdef QGISDEBUG
std::cout << "QgsGeometry::vertexAt: Number of points in WKBLineString is " << *nPoints std::cout << "QgsGeometry::vertexAt: Number of points in WKBLineString is " << *nPoints
<< "." << std::endl; << "." << std::endl;
#endif #endif
// return error if underflow // return error if underflow
if (0 > atVertex.back()) if (0 > atVertex.back())
{ {
return FALSE; return FALSE;
} }
// return error if overflow // return error if overflow
if (*nPoints <= atVertex.back()) if (*nPoints <= atVertex.back())
{ {
return FALSE; return FALSE;
} }

// copy the vertex coordinates // copy the vertex coordinates
ptr = mGeometry + 9 + (atVertex.back() * 16); ptr = mGeometry + 9 + (atVertex.back() * 16);
memcpy(&x, ptr, 8); memcpy(&x, ptr, 8);
ptr += 8; ptr += 8;
memcpy(&y, ptr, 8); memcpy(&y, ptr, 8);

#ifdef QGISDEBUG #ifdef QGISDEBUG
std::cout << "QgsGeometry::vertexAt: Point is (" << x << ", " << y << ")" std::cout << "QgsGeometry::vertexAt: Point is (" << x << ", " << y << ")"
<< "." << std::endl; << "." << std::endl;
#endif #endif
break; break;
} }
case QGis::WKBPolygon: case QGis::WKBPolygon:
{ {
// TODO // TODO
return false; return false;
break; break;
} }
case QGis::WKBMultiPoint: case QGis::WKBMultiPoint:
{ {
// TODO // TODO
return false; return false;
break; break;
} }

case QGis::WKBMultiLineString: case QGis::WKBMultiLineString:
{ {
// TODO // TODO
return false; return false;
break; break;
} }

case QGis::WKBMultiPolygon: case QGis::WKBMultiPolygon:
{ {
// TODO // TODO
return false; return false;
break; break;
} }
default: default:
#ifdef QGISDEBUG #ifdef QGISDEBUG
qWarning("error: mGeometry type not recognized in QgsGeometry::vertexAt"); qWarning("error: mGeometry type not recognized in QgsGeometry::vertexAt");
#endif #endif
return false; return false;
break; break;
} }
#ifdef QGISDEBUG #ifdef QGISDEBUG
std::cout << "QgsGeometry::vertexAt: Exiting TRUE." << std::endl; std::cout << "QgsGeometry::vertexAt: Exiting TRUE." << std::endl;
#endif #endif
return true; return true;
} }
else else
{ {
#ifdef QGISDEBUG #ifdef QGISDEBUG
qWarning("error: no mGeometry pointer in QgsGeometry::vertexAt"); qWarning("error: no mGeometry pointer in QgsGeometry::vertexAt");
#endif #endif
return false; return false;
} }


} }




Expand Down

0 comments on commit 14f574a

Please sign in to comment.