mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
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/qgis@5879 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
69d47323e9
commit
b946395852
@ -59,7 +59,13 @@ public:
|
||||
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,17 +3409,20 @@ 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;
|
||||
@ -3402,6 +3430,7 @@ void QgsVectorLayer::drawFeature(QPainter* p,
|
||||
for (register unsigned int jdx = 0; jdx < numLineStrings; jdx++)
|
||||
{
|
||||
ptr = drawLineString(ptr,
|
||||
(wkbType == QGis::WKBMultiLineString25D),
|
||||
p,
|
||||
theMapToPixelTransform,
|
||||
projectionsEnabledFlag,
|
||||
@ -3409,22 +3438,26 @@ void QgsVectorLayer::drawFeature(QPainter* p,
|
||||
}
|
||||
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 @@ 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,
|
||||
@ -587,6 +588,7 @@ 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,
|
||||
@ -622,15 +624,6 @@ private: // Private attributes
|
||||
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 */
|
||||
|
Loading…
x
Reference in New Issue
Block a user