Skip to content

Commit 60b96fc

Browse files
author
wonder
committed
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@6072 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 60f7822 commit 60b96fc

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

src/gui/qgsvectorlayer.cpp

+9-8
Original file line numberDiff line numberDiff line change
@@ -423,20 +423,22 @@ QgsRect QgsVectorLayer::inverseProjectRect(const QgsRect& r) const
423423
}
424424

425425
unsigned char* QgsVectorLayer::drawLineString(unsigned char* feature,
426-
bool hasZValue,
427426
QPainter* p,
428427
QgsMapToPixel* mtp,
429428
bool projectionsEnabledFlag,
430429
bool drawingToEditingCanvas)
431430
{
432431
unsigned char *ptr = feature + 5;
432+
unsigned int wkbType = *((int*)(feature+1));
433433
unsigned int nPoints = *((int*)ptr);
434434
ptr = feature + 9;
435+
436+
bool hasZValue = (wkbType == QGis::WKBLineString25D);
435437

436438
std::vector<double> x(nPoints);
437439
std::vector<double> y(nPoints);
438440
std::vector<double> z(nPoints, 0.0);
439-
441+
440442
// Extract the points from the WKB format into the x and y vectors.
441443
for (register unsigned int i = 0; i < nPoints; ++i)
442444
{
@@ -523,7 +525,6 @@ unsigned char* QgsVectorLayer::drawLineString(unsigned char* feature,
523525
}
524526

525527
unsigned char* QgsVectorLayer::drawPolygon(unsigned char* feature,
526-
bool hasZValue,
527528
QPainter* p,
528529
QgsMapToPixel* mtp,
529530
bool projectionsEnabledFlag,
@@ -539,6 +540,10 @@ unsigned char* QgsVectorLayer::drawPolygon(unsigned char* feature,
539540
if ( numRings == 0 ) // sanity check for zero rings in polygon
540541
return feature + 9;
541542

543+
unsigned int wkbType = *((int*)(feature+1));
544+
545+
bool hasZValue = (wkbType == QGis::WKBPolygon25D);
546+
542547
int total_points = 0;
543548

544549
// A vector containing a pointer to a pair of double vectors.The
@@ -3413,7 +3418,6 @@ void QgsVectorLayer::drawFeature(QPainter* p,
34133418
case QGis::WKBLineString25D:
34143419
{
34153420
drawLineString(feature,
3416-
(wkbType == QGis::WKBLineString25D),
34173421
p,
34183422
theMapToPixelTransform,
34193423
projectionsEnabledFlag,
@@ -3426,11 +3430,10 @@ void QgsVectorLayer::drawFeature(QPainter* p,
34263430
unsigned char* ptr = feature + 5;
34273431
unsigned int numLineStrings = *((int*)ptr);
34283432
ptr = feature + 9;
3429-
3433+
34303434
for (register unsigned int jdx = 0; jdx < numLineStrings; jdx++)
34313435
{
34323436
ptr = drawLineString(ptr,
3433-
(wkbType == QGis::WKBMultiLineString25D),
34343437
p,
34353438
theMapToPixelTransform,
34363439
projectionsEnabledFlag,
@@ -3442,7 +3445,6 @@ void QgsVectorLayer::drawFeature(QPainter* p,
34423445
case QGis::WKBPolygon25D:
34433446
{
34443447
drawPolygon(feature,
3445-
(wkbType == QGis::WKBPolygon25D),
34463448
p,
34473449
theMapToPixelTransform,
34483450
projectionsEnabledFlag,
@@ -3457,7 +3459,6 @@ void QgsVectorLayer::drawFeature(QPainter* p,
34573459
ptr = feature + 9;
34583460
for (register unsigned int kdx = 0; kdx < numPolygons; kdx++)
34593461
ptr = drawPolygon(ptr,
3460-
(wkbType == QGis::WKBMultiPolygon25D),
34613462
p,
34623463
theMapToPixelTransform,
34633464
projectionsEnabledFlag,

src/gui/qgsvectorlayer.h

-2
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,6 @@ protected slots:
579579
// to the byte after the end of the line string binary data stream
580580
// (WKB).
581581
unsigned char* drawLineString(unsigned char* WKBlinestring,
582-
bool hasZValue,
583582
QPainter* p,
584583
QgsMapToPixel* mtp,
585584
bool projectionsEnabledFlag,
@@ -588,7 +587,6 @@ protected slots:
588587
// Draw the polygon as given in the WKB format. Returns a pointer to
589588
// the byte after the end of the polygon binary data stream (WKB).
590589
unsigned char* drawPolygon(unsigned char* WKBpolygon,
591-
bool hasZValue,
592590
QPainter* p,
593591
QgsMapToPixel* mtp,
594592
bool projectionsEnabledFlag,

0 commit comments

Comments
 (0)