mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
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
This commit is contained in:
parent
60f7822a6e
commit
60b96fc9f7
@ -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)
|
||||
{
|
||||
@ -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,
|
||||
@ -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
|
||||
@ -3413,7 +3418,6 @@ void QgsVectorLayer::drawFeature(QPainter* p,
|
||||
case QGis::WKBLineString25D:
|
||||
{
|
||||
drawLineString(feature,
|
||||
(wkbType == QGis::WKBLineString25D),
|
||||
p,
|
||||
theMapToPixelTransform,
|
||||
projectionsEnabledFlag,
|
||||
@ -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,
|
||||
@ -3442,7 +3445,6 @@ void QgsVectorLayer::drawFeature(QPainter* p,
|
||||
case QGis::WKBPolygon25D:
|
||||
{
|
||||
drawPolygon(feature,
|
||||
(wkbType == QGis::WKBPolygon25D),
|
||||
p,
|
||||
theMapToPixelTransform,
|
||||
projectionsEnabledFlag,
|
||||
@ -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,
|
||||
|
@ -579,7 +579,6 @@ private: // Private attributes
|
||||
// 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,
|
||||
@ -588,7 +587,6 @@ private: // Private attributes
|
||||
// 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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user