Skip to content
Permalink
Browse files
Allow displaying layers with 2.5D geometries.
For now, Z value is ignored.
This addresses ticket #308.


git-svn-id: http://svn.osgeo.org/qgis/trunk@5879 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder committed Sep 27, 2006
1 parent 10f9dbc commit a1f37426f496ca6420977d8b7583ecc120320f23
Showing with 51 additions and 19 deletions.
  1. +7 −1 src/core/qgis.h
  2. +42 −9 src/gui/qgsvectorlayer.cpp
  3. +2 −9 src/gui/qgsvectorlayer.h
@@ -59,7 +59,13 @@ class QGis
WKBMultiPoint,
WKBMultiLineString,
WKBMultiPolygon,
WKBUnknown
WKBUnknown,
WKBPoint25D = 0x80000001,
WKBLineString25D,
WKBPolygon25D,
WKBMultiPoint25D,
WKBMultiLineString25D,
WKBMultiPolygon25D
};
enum VectorType
{
@@ -423,6 +423,7 @@ QgsRect QgsVectorLayer::inverseProjectRect(const QgsRect& r) const
}

unsigned char* QgsVectorLayer::drawLineString(unsigned char* feature,
bool hasZValue,
QPainter* p,
QgsMapToPixel* mtp,
bool projectionsEnabledFlag,
@@ -443,6 +444,9 @@ unsigned char* QgsVectorLayer::drawLineString(unsigned char* feature,
ptr += sizeof(double);
y[i] = *((double *) ptr);
ptr += sizeof(double);

if (hasZValue) // ignore Z value
ptr += sizeof(double);
}

// Transform the points into map coordinates (and reproject if
@@ -519,6 +523,7 @@ unsigned char* QgsVectorLayer::drawLineString(unsigned char* feature,
}

unsigned char* QgsVectorLayer::drawPolygon(unsigned char* feature,
bool hasZValue,
QPainter* p,
QgsMapToPixel* mtp,
bool projectionsEnabledFlag,
@@ -568,6 +573,10 @@ std::cerr << "Points for ring " << idx << " ("
ptr += sizeof(double);
ring->second[jdx] = *((double *) ptr);
ptr += sizeof(double);

if (hasZValue)
ptr += sizeof(double);

/*
#ifdef QGISDEBUG
std::cerr << jdx << ": "
@@ -1303,16 +1312,27 @@ QGis::VectorType QgsVectorLayer::vectorType() const
switch (type)
{
case QGis::WKBPoint:
case QGis::WKBPoint25D:
return QGis::Point;

case QGis::WKBLineString:
case QGis::WKBLineString25D:
return QGis::Line;

case QGis::WKBPolygon:
case QGis::WKBPolygon25D:
return QGis::Polygon;

case QGis::WKBMultiPoint:
case QGis::WKBMultiPoint25D:
return QGis::Point;

case QGis::WKBMultiLineString:
case QGis::WKBMultiLineString25D:
return QGis::Line;

case QGis::WKBMultiPolygon:
case QGis::WKBMultiPolygon25D:
return QGis::Polygon;
}
#ifdef QGISDEBUG
@@ -3326,7 +3346,8 @@ void QgsVectorLayer::drawFeature(QPainter* p,

switch (wkbType)
{
case WKBPoint:
case QGis::WKBPoint:
case QGis::WKBPoint25D:
{
double x = *((double *) (feature + 5));
double y = *((double *) (feature + 5 + sizeof(double)));
@@ -3346,7 +3367,8 @@ void QgsVectorLayer::drawFeature(QPainter* p,

break;
}
case WKBMultiPoint:
case QGis::WKBMultiPoint:
case QGis::WKBMultiPoint25D:
{
unsigned char *ptr = feature + 5;
unsigned int nPoints = *((int*)ptr);
@@ -3362,6 +3384,9 @@ void QgsVectorLayer::drawFeature(QPainter* p,
ptr += sizeof(double);
double y = *((double *) ptr);
ptr += sizeof(double);

if (wkbType == QGis::WKBMultiPoint25D) // ignore Z value
ptr += sizeof(double);

#ifdef QGISDEBUG
std::cout <<"...WKBMultiPoint (" << x << ", " << y << ")" <<std::endl;
@@ -3384,47 +3409,55 @@ void QgsVectorLayer::drawFeature(QPainter* p,

break;
}
case WKBLineString:
case QGis::WKBLineString:
case QGis::WKBLineString25D:
{
drawLineString(feature,
(wkbType == QGis::WKBLineString25D),
p,
theMapToPixelTransform,
projectionsEnabledFlag,
drawingToEditingCanvas);
break;
}
case WKBMultiLineString:
{
case QGis::WKBMultiLineString:
case QGis::WKBMultiLineString25D:
{
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,
drawingToEditingCanvas);
}
break;
}
case WKBPolygon:
{
case QGis::WKBPolygon:
case QGis::WKBPolygon25D:
{
drawPolygon(feature,
(wkbType == QGis::WKBPolygon25D),
p,
theMapToPixelTransform,
projectionsEnabledFlag,
drawingToEditingCanvas);
break;
}
case WKBMultiPolygon:
{
case QGis::WKBMultiPolygon:
case QGis::WKBMultiPolygon25D:
{
unsigned char *ptr = feature + 5;
unsigned int numPolygons = *((int*)ptr);
ptr = feature + 9;
for (register unsigned int kdx = 0; kdx < numPolygons; kdx++)
ptr = drawPolygon(ptr,
(wkbType == QGis::WKBMultiPolygon25D),
p,
theMapToPixelTransform,
projectionsEnabledFlag,
@@ -579,6 +579,7 @@ 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,
@@ -587,6 +588,7 @@ 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,
@@ -622,15 +624,6 @@ protected slots:
bool valid;
bool registered;

enum WKBTYPE
{
WKBPoint = 1,
WKBLineString,
WKBPolygon,
WKBMultiPoint,
WKBMultiLineString,
WKBMultiPolygon
};
private: // Private methods

/**Caches all the (commited) geometries to mCachedGeometries - somewhat out of date as mCachedGeometries should only contain geometries currently visible on the canvas */

0 comments on commit a1f3742

Please sign in to comment.