Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Don't trust WKB type specified for multipart features.
Check whether the part has Z value because it might differ from the feature's WKB.
(feature's WKB is MultiLineString - but parts are of type LineString25D)
Fixes ticket #248.


git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@6072 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder committed Nov 10, 2006
1 parent dccc1c3 commit fdcff92
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
17 changes: 9 additions & 8 deletions src/gui/qgsvectorlayer.cpp
Expand Up @@ -423,20 +423,22 @@ QgsRect QgsVectorLayer::inverseProjectRect(const QgsRect& r) const
}

unsigned char* QgsVectorLayer::drawLineString(unsigned char* feature,
bool hasZValue,
QPainter* p,
QgsMapToPixel* mtp,
bool projectionsEnabledFlag,
bool drawingToEditingCanvas)
{
unsigned char *ptr = feature + 5;
unsigned int wkbType = *((int*)(feature+1));
unsigned int nPoints = *((int*)ptr);
ptr = feature + 9;

bool hasZValue = (wkbType == QGis::WKBLineString25D);

std::vector<double> x(nPoints);
std::vector<double> y(nPoints);
std::vector<double> z(nPoints, 0.0);

// Extract the points from the WKB format into the x and y vectors.
for (register unsigned int i = 0; i < nPoints; ++i)
{
Expand Down Expand Up @@ -523,7 +525,6 @@ unsigned char* QgsVectorLayer::drawLineString(unsigned char* feature,
}

unsigned char* QgsVectorLayer::drawPolygon(unsigned char* feature,
bool hasZValue,
QPainter* p,
QgsMapToPixel* mtp,
bool projectionsEnabledFlag,
Expand All @@ -539,6 +540,10 @@ unsigned char* QgsVectorLayer::drawPolygon(unsigned char* feature,
if ( numRings == 0 ) // sanity check for zero rings in polygon
return feature + 9;

unsigned int wkbType = *((int*)(feature+1));

bool hasZValue = (wkbType == QGis::WKBPolygon25D);

int total_points = 0;

// A vector containing a pointer to a pair of double vectors.The
Expand Down Expand Up @@ -3413,7 +3418,6 @@ void QgsVectorLayer::drawFeature(QPainter* p,
case QGis::WKBLineString25D:
{
drawLineString(feature,
(wkbType == QGis::WKBLineString25D),
p,
theMapToPixelTransform,
projectionsEnabledFlag,
Expand All @@ -3426,11 +3430,10 @@ void QgsVectorLayer::drawFeature(QPainter* p,
unsigned char* ptr = feature + 5;
unsigned int numLineStrings = *((int*)ptr);
ptr = feature + 9;

for (register unsigned int jdx = 0; jdx < numLineStrings; jdx++)
{
ptr = drawLineString(ptr,
(wkbType == QGis::WKBMultiLineString25D),
p,
theMapToPixelTransform,
projectionsEnabledFlag,
Expand All @@ -3442,7 +3445,6 @@ void QgsVectorLayer::drawFeature(QPainter* p,
case QGis::WKBPolygon25D:
{
drawPolygon(feature,
(wkbType == QGis::WKBPolygon25D),
p,
theMapToPixelTransform,
projectionsEnabledFlag,
Expand All @@ -3457,7 +3459,6 @@ void QgsVectorLayer::drawFeature(QPainter* p,
ptr = feature + 9;
for (register unsigned int kdx = 0; kdx < numPolygons; kdx++)
ptr = drawPolygon(ptr,
(wkbType == QGis::WKBMultiPolygon25D),
p,
theMapToPixelTransform,
projectionsEnabledFlag,
Expand Down
2 changes: 0 additions & 2 deletions src/gui/qgsvectorlayer.h
Expand Up @@ -579,7 +579,6 @@ protected slots:
// to the byte after the end of the line string binary data stream
// (WKB).
unsigned char* drawLineString(unsigned char* WKBlinestring,
bool hasZValue,
QPainter* p,
QgsMapToPixel* mtp,
bool projectionsEnabledFlag,
Expand All @@ -588,7 +587,6 @@ protected slots:
// Draw the polygon as given in the WKB format. Returns a pointer to
// the byte after the end of the polygon binary data stream (WKB).
unsigned char* drawPolygon(unsigned char* WKBpolygon,
bool hasZValue,
QPainter* p,
QgsMapToPixel* mtp,
bool projectionsEnabledFlag,
Expand Down

0 comments on commit fdcff92

Please sign in to comment.