Skip to content
Permalink
Browse files

Adapt renderer to consider z/m in wkb parsing

  • Loading branch information
mhugent committed Jul 28, 2015
1 parent e03463c commit 00b8c1d27bb1e976938c16340e8bc57bb30d1220
@@ -116,77 +116,97 @@ QString QgsWKBTypes::displayString( Type type )
return it->mName;
}

bool QgsWKBTypes::hasZ( Type type )
{
QMap< Type, wkbEntry >::const_iterator it = entries()->find( type );
if ( it == entries()->constEnd() )
{
return false;
}
return it->mHasZ;
}

bool QgsWKBTypes::hasM( Type type )
{
QMap< Type, wkbEntry >::const_iterator it = entries()->find( type );
if ( it == entries()->constEnd() )
{
return false;
}
return it->mHasM;
}

QMap<QgsWKBTypes::Type, QgsWKBTypes::wkbEntry> QgsWKBTypes::registerTypes()
{
QMap<QgsWKBTypes::Type, QgsWKBTypes::wkbEntry> entries;
//register the known wkb types
entries.insert( Unknown, wkbEntry( "Unknown", false, Unknown, Unknown, Unknown, UnknownGeometry ) );
entries.insert( NoGeometry, wkbEntry( "NoGeometry", false, NoGeometry, NoGeometry, NoGeometry, NullGeometry ) );
entries.insert( Unknown, wkbEntry( "Unknown", false, Unknown, Unknown, Unknown, UnknownGeometry, false, false ) );
entries.insert( NoGeometry, wkbEntry( "NoGeometry", false, NoGeometry, NoGeometry, NoGeometry, NullGeometry, false, false ) );
//point
entries.insert( Point, wkbEntry( "Point", false, MultiPoint, Point, Point, PointGeometry ) );
entries.insert( PointZ, wkbEntry( "PointZ", false, MultiPointZ, PointZ, Point, PointGeometry ) );
entries.insert( PointM, wkbEntry( "PointM", false, MultiPointM, PointM, Point, PointGeometry ) );
entries.insert( PointZM, wkbEntry( "PointZM", false, MultiPointZM, PointZM, Point, PointGeometry ) );
entries.insert( Point25D, wkbEntry( "Point25D", false, MultiPoint25D, Point25D, Point, PointGeometry ) );
entries.insert( Point, wkbEntry( "Point", false, MultiPoint, Point, Point, PointGeometry, false, false ) );
entries.insert( PointZ, wkbEntry( "PointZ", false, MultiPointZ, PointZ, Point, PointGeometry, true, false ) );
entries.insert( PointM, wkbEntry( "PointM", false, MultiPointM, PointM, Point, PointGeometry, false, true ) );
entries.insert( PointZM, wkbEntry( "PointZM", false, MultiPointZM, PointZM, Point, PointGeometry, true, true ) );
entries.insert( Point25D, wkbEntry( "Point25D", false, MultiPoint25D, Point25D, Point, PointGeometry, true, false ) );
//linestring
entries.insert( LineString, wkbEntry( "LineString", false, MultiLineString, LineString, LineString, LineGeometry ) );
entries.insert( LineStringZ, wkbEntry( "LineStringZ", false, MultiLineStringZ, LineStringZ, LineString, LineGeometry ) );
entries.insert( LineStringM, wkbEntry( "LineStringM", false, MultiLineStringM, LineStringM, LineString, LineGeometry ) );
entries.insert( LineStringZM, wkbEntry( "LineStringZM", false, MultiLineStringZM, LineStringZM, LineString, LineGeometry ) );
entries.insert( LineString25D, wkbEntry( "LineString25D", false, MultiLineString25D, LineString25D, LineString, LineGeometry ) );
entries.insert( LineString, wkbEntry( "LineString", false, MultiLineString, LineString, LineString, LineGeometry, false, false ) );
entries.insert( LineStringZ, wkbEntry( "LineStringZ", false, MultiLineStringZ, LineStringZ, LineString, LineGeometry, true, false ) );
entries.insert( LineStringM, wkbEntry( "LineStringM", false, MultiLineStringM, LineStringM, LineString, LineGeometry, false, true ) );
entries.insert( LineStringZM, wkbEntry( "LineStringZM", false, MultiLineStringZM, LineStringZM, LineString, LineGeometry, true, true ) );
entries.insert( LineString25D, wkbEntry( "LineString25D", false, MultiLineString25D, LineString25D, LineString, LineGeometry, true, false ) );
//circularstring
entries.insert( CircularString, wkbEntry( "CircularString", false, MultiCurve, CircularString, CircularString, LineGeometry ) );
entries.insert( CircularStringZ, wkbEntry( "CircularStringZ", false, MultiCurveZ, CircularStringZ, CircularString, LineGeometry ) );
entries.insert( CircularStringM, wkbEntry( "CircularStringM", false, MultiCurveM, CircularStringM, CircularString, LineGeometry ) );
entries.insert( CircularStringZM, wkbEntry( "CircularStringZM", false, MultiCurveZM, CircularStringZM, CircularString, LineGeometry ) );
entries.insert( CircularString, wkbEntry( "CircularString", false, MultiCurve, CircularString, CircularString, LineGeometry, false, false ) );
entries.insert( CircularStringZ, wkbEntry( "CircularStringZ", false, MultiCurveZ, CircularStringZ, CircularString, LineGeometry, true, false ) );
entries.insert( CircularStringM, wkbEntry( "CircularStringM", false, MultiCurveM, CircularStringM, CircularString, LineGeometry, false, true ) );
entries.insert( CircularStringZM, wkbEntry( "CircularStringZM", false, MultiCurveZM, CircularStringZM, CircularString, LineGeometry, true, true ) );
//compoundcurve
entries.insert( CompoundCurve, wkbEntry( "CompoundCurve", false, MultiCurve, CompoundCurve, CompoundCurve, LineGeometry ) );
entries.insert( CompoundCurveZ, wkbEntry( "CompoundCurveZ", false, MultiCurveZ, CompoundCurveZ, CompoundCurve, LineGeometry ) );
entries.insert( CompoundCurveM, wkbEntry( "CompoundCurveM", false, MultiCurveM, CompoundCurveM, CompoundCurve, LineGeometry ) );
entries.insert( CompoundCurveZM, wkbEntry( "CompoundCurveZM", false, MultiCurveZM, CompoundCurveZM, CompoundCurve, LineGeometry ) );
entries.insert( CompoundCurve, wkbEntry( "CompoundCurve", false, MultiCurve, CompoundCurve, CompoundCurve, LineGeometry, false, false ) );
entries.insert( CompoundCurveZ, wkbEntry( "CompoundCurveZ", false, MultiCurveZ, CompoundCurveZ, CompoundCurve, LineGeometry, true, false ) );
entries.insert( CompoundCurveM, wkbEntry( "CompoundCurveM", false, MultiCurveM, CompoundCurveM, CompoundCurve, LineGeometry, false, true ) );
entries.insert( CompoundCurveZM, wkbEntry( "CompoundCurveZM", false, MultiCurveZM, CompoundCurveZM, CompoundCurve, LineGeometry, true, true ) );
//polygon
entries.insert( Polygon, wkbEntry( "Polygon", false, MultiPolygon, Polygon, Polygon, PolygonGeometry ) );
entries.insert( PolygonZ, wkbEntry( "PolygonZ", false, MultiPolygonZ, PolygonZ, Polygon, PolygonGeometry ) );
entries.insert( PolygonM, wkbEntry( "PolygonM", false, MultiPolygonM, PolygonM, Polygon, PolygonGeometry ) );
entries.insert( PolygonZM, wkbEntry( "PolygonZM", false, MultiPolygonZM, PolygonZM, Polygon, PolygonGeometry ) );
entries.insert( Polygon25D, wkbEntry( "Polygon25D", false, MultiPolygon25D, Polygon25D, Polygon, PolygonGeometry ) );
entries.insert( Polygon, wkbEntry( "Polygon", false, MultiPolygon, Polygon, Polygon, PolygonGeometry, false, false ) );
entries.insert( PolygonZ, wkbEntry( "PolygonZ", false, MultiPolygonZ, PolygonZ, Polygon, PolygonGeometry, true, false ) );
entries.insert( PolygonM, wkbEntry( "PolygonM", false, MultiPolygonM, PolygonM, Polygon, PolygonGeometry, false, true ) );
entries.insert( PolygonZM, wkbEntry( "PolygonZM", false, MultiPolygonZM, PolygonZM, Polygon, PolygonGeometry, true, true ) );
entries.insert( Polygon25D, wkbEntry( "Polygon25D", false, MultiPolygon25D, Polygon25D, Polygon, PolygonGeometry, true, false ) );
//curvepolygon
entries.insert( CurvePolygon, wkbEntry( "CurvePolygon", false, MultiSurface, CurvePolygon, CurvePolygon, PolygonGeometry ) );
entries.insert( CurvePolygonZ, wkbEntry( "CurvePolygonZ", false, MultiSurfaceZ, CurvePolygonZ, CurvePolygon, PolygonGeometry ) );
entries.insert( CurvePolygonM, wkbEntry( "CurvePolygonM", false, MultiSurfaceM, CurvePolygonM, CurvePolygon, PolygonGeometry ) );
entries.insert( CurvePolygonZM, wkbEntry( "CurvePolygonZM", false, MultiSurfaceZM, CurvePolygonZM, CurvePolygon, PolygonGeometry ) );
entries.insert( CurvePolygon, wkbEntry( "CurvePolygon", false, MultiSurface, CurvePolygon, CurvePolygon, PolygonGeometry, false, false ) );
entries.insert( CurvePolygonZ, wkbEntry( "CurvePolygonZ", false, MultiSurfaceZ, CurvePolygonZ, CurvePolygon, PolygonGeometry, true, false ) );
entries.insert( CurvePolygonM, wkbEntry( "CurvePolygonM", false, MultiSurfaceM, CurvePolygonM, CurvePolygon, PolygonGeometry, false, true ) );
entries.insert( CurvePolygonZM, wkbEntry( "CurvePolygonZM", false, MultiSurfaceZM, CurvePolygonZM, CurvePolygon, PolygonGeometry, true, true ) );
//multipoint
entries.insert( MultiPoint, wkbEntry( "MultiPoint", true, MultiPoint, Point, MultiPoint, PointGeometry ) );
entries.insert( MultiPointZ, wkbEntry( "MultiPointZ", true, MultiPointZ, PointZ, MultiPoint, PointGeometry ) );
entries.insert( MultiPointM, wkbEntry( "MultiPointM", true, MultiPointM, PointM, MultiPoint, PointGeometry ) );
entries.insert( MultiPointZM, wkbEntry( "MultiPointZM", true, MultiPointZM, PointZM, MultiPoint, PointGeometry ) );
entries.insert( MultiPoint25D, wkbEntry( "MultiPoint25D", true, MultiPoint25D, Point25D, MultiPoint, PointGeometry ) );
entries.insert( MultiPoint, wkbEntry( "MultiPoint", true, MultiPoint, Point, MultiPoint, PointGeometry, false, false ) );
entries.insert( MultiPointZ, wkbEntry( "MultiPointZ", true, MultiPointZ, PointZ, MultiPoint, PointGeometry, true, false ) );
entries.insert( MultiPointM, wkbEntry( "MultiPointM", true, MultiPointM, PointM, MultiPoint, PointGeometry, false, true ) );
entries.insert( MultiPointZM, wkbEntry( "MultiPointZM", true, MultiPointZM, PointZM, MultiPoint, PointGeometry, true, true ) );
entries.insert( MultiPoint25D, wkbEntry( "MultiPoint25D", true, MultiPoint25D, Point25D, MultiPoint, PointGeometry, true, false ) );
//multiline
entries.insert( MultiLineString, wkbEntry( "MultiLineString", true, MultiLineString, LineString, MultiLineString, LineGeometry ) );
entries.insert( MultiLineStringZ, wkbEntry( "MultiLineStringZ", true, MultiLineStringZ, LineStringZ, MultiLineString, LineGeometry ) );
entries.insert( MultiLineStringM, wkbEntry( "MultiLineStringM", true, MultiLineStringM, LineStringM, MultiLineString, LineGeometry ) );
entries.insert( MultiLineStringZM, wkbEntry( "MultiLineStringZM", true, MultiLineStringZM, LineStringZM, MultiLineString, LineGeometry ) );
entries.insert( MultiLineString25D, wkbEntry( "MultiLineString25D", true, MultiLineString25D, LineString25D, MultiLineString, LineGeometry ) );
entries.insert( MultiLineString, wkbEntry( "MultiLineString", true, MultiLineString, LineString, MultiLineString, LineGeometry, false, false ) );
entries.insert( MultiLineStringZ, wkbEntry( "MultiLineStringZ", true, MultiLineStringZ, LineStringZ, MultiLineString, LineGeometry, true, false ) );
entries.insert( MultiLineStringM, wkbEntry( "MultiLineStringM", true, MultiLineStringM, LineStringM, MultiLineString, LineGeometry, false, true ) );
entries.insert( MultiLineStringZM, wkbEntry( "MultiLineStringZM", true, MultiLineStringZM, LineStringZM, MultiLineString, LineGeometry, true, true ) );
entries.insert( MultiLineString25D, wkbEntry( "MultiLineString25D", true, MultiLineString25D, LineString25D, MultiLineString, LineGeometry, true, false ) );
//multicurve
entries.insert( MultiCurve, wkbEntry( "MultiCurve", true, MultiCurve, CompoundCurve, MultiCurve, LineGeometry ) );
entries.insert( MultiCurveZ, wkbEntry( "MultiCurveZ", true, MultiCurveZ, CompoundCurveZ, MultiCurve, LineGeometry ) );
entries.insert( MultiCurveM, wkbEntry( "MultiCurveM", true, MultiCurveM, CompoundCurveM, MultiCurve, LineGeometry ) );
entries.insert( MultiCurveZM, wkbEntry( "MultiCurveZM", true, MultiCurveZM, CompoundCurveZM, MultiCurve, LineGeometry ) );
entries.insert( MultiCurve, wkbEntry( "MultiCurve", true, MultiCurve, CompoundCurve, MultiCurve, LineGeometry, false, false ) );
entries.insert( MultiCurveZ, wkbEntry( "MultiCurveZ", true, MultiCurveZ, CompoundCurveZ, MultiCurve, LineGeometry, true, false ) );
entries.insert( MultiCurveM, wkbEntry( "MultiCurveM", true, MultiCurveM, CompoundCurveM, MultiCurve, LineGeometry, false, true ) );
entries.insert( MultiCurveZM, wkbEntry( "MultiCurveZM", true, MultiCurveZM, CompoundCurveZM, MultiCurve, LineGeometry, true, true ) );
//multipolygon
entries.insert( MultiPolygon, wkbEntry( "MultiPolygon", true, MultiPolygon, Polygon, MultiPolygon, PolygonGeometry ) );
entries.insert( MultiPolygonZ, wkbEntry( "MultiPolygonZ", true, MultiPolygonZ, PolygonZ, MultiPolygon, PolygonGeometry ) );
entries.insert( MultiPolygonM, wkbEntry( "MultiPolygonM", true, MultiPolygonM, PolygonM, MultiPolygon, PolygonGeometry ) );
entries.insert( MultiPolygonZM, wkbEntry( "MultiPolygonZM", true, MultiPolygonZM, PolygonZM, MultiPolygon, PolygonGeometry ) );
entries.insert( MultiPolygon25D, wkbEntry( "MultiPolygon25D", true, MultiPolygon25D, Polygon25D, MultiPolygon, PolygonGeometry ) );
entries.insert( MultiPolygon, wkbEntry( "MultiPolygon", true, MultiPolygon, Polygon, MultiPolygon, PolygonGeometry, false, false ) );
entries.insert( MultiPolygonZ, wkbEntry( "MultiPolygonZ", true, MultiPolygonZ, PolygonZ, MultiPolygon, PolygonGeometry, true, false ) );
entries.insert( MultiPolygonM, wkbEntry( "MultiPolygonM", true, MultiPolygonM, PolygonM, MultiPolygon, PolygonGeometry, false, true ) );
entries.insert( MultiPolygonZM, wkbEntry( "MultiPolygonZM", true, MultiPolygonZM, PolygonZM, MultiPolygon, PolygonGeometry, true, true ) );
entries.insert( MultiPolygon25D, wkbEntry( "MultiPolygon25D", true, MultiPolygon25D, Polygon25D, MultiPolygon, PolygonGeometry, true, false ) );
//multisurface
entries.insert( MultiSurface, wkbEntry( "MultiSurface", true, MultiSurface, CurvePolygon, MultiSurface, PolygonGeometry ) );
entries.insert( MultiSurfaceZ, wkbEntry( "MultiSurfaceZ", true, MultiSurfaceZ, CurvePolygonZ, MultiSurface, PolygonGeometry ) );
entries.insert( MultiSurfaceM, wkbEntry( "MultiSurfaceM", true, MultiSurfaceM, CurvePolygonM, MultiSurface, PolygonGeometry ) );
entries.insert( MultiSurfaceZM, wkbEntry( "MultiSurfaceZM", true, MultiSurfaceZM, CurvePolygonZM, MultiSurface, PolygonGeometry ) );
entries.insert( MultiSurface, wkbEntry( "MultiSurface", true, MultiSurface, CurvePolygon, MultiSurface, PolygonGeometry, false, false ) );
entries.insert( MultiSurfaceZ, wkbEntry( "MultiSurfaceZ", true, MultiSurfaceZ, CurvePolygonZ, MultiSurface, PolygonGeometry, true, false ) );
entries.insert( MultiSurfaceM, wkbEntry( "MultiSurfaceM", true, MultiSurfaceM, CurvePolygonM, MultiSurface, PolygonGeometry, false, true ) );
entries.insert( MultiSurfaceZM, wkbEntry( "MultiSurfaceZM", true, MultiSurfaceZM, CurvePolygonZM, MultiSurface, PolygonGeometry, true, true ) );
//geometrycollection
entries.insert( GeometryCollection, wkbEntry( "GeometryCollection", true, GeometryCollection, Unknown, GeometryCollection, UnknownGeometry ) );
entries.insert( GeometryCollectionZ, wkbEntry( "GeometryCollectionZ", true, GeometryCollectionZ, Unknown, GeometryCollection, UnknownGeometry ) );
entries.insert( GeometryCollectionM, wkbEntry( "GeometryCollectionM", true, GeometryCollectionM, Unknown, GeometryCollection, UnknownGeometry ) );
entries.insert( GeometryCollectionZM, wkbEntry( "GeometryCollectionZM", true, GeometryCollectionZM, Unknown, GeometryCollection, UnknownGeometry ) );
entries.insert( GeometryCollection, wkbEntry( "GeometryCollection", true, GeometryCollection, Unknown, GeometryCollection, UnknownGeometry, false, false ) );
entries.insert( GeometryCollectionZ, wkbEntry( "GeometryCollectionZ", true, GeometryCollectionZ, Unknown, GeometryCollection, UnknownGeometry, true, false ) );
entries.insert( GeometryCollectionM, wkbEntry( "GeometryCollectionM", true, GeometryCollectionM, Unknown, GeometryCollection, UnknownGeometry, false, true ) );
entries.insert( GeometryCollectionZM, wkbEntry( "GeometryCollectionZM", true, GeometryCollectionZM, Unknown, GeometryCollection, UnknownGeometry, true, true ) );
return entries;
}
@@ -21,7 +21,7 @@
#include <QMap>
#include <QString>

/**Class to store information about wkb types.*/
/** Class to store information about wkb types.*/
class CORE_EXPORT QgsWKBTypes
{
public:
@@ -97,14 +97,18 @@ class CORE_EXPORT QgsWKBTypes

struct wkbEntry
{
wkbEntry( QString name, bool isMultiType, Type multiType, Type singleType, Type flatType, GeometryType geometryType ):
mName( name ), mIsMultiType( isMultiType ), mMultiType( multiType ), mSingleType( singleType ), mFlatType( flatType ), mGeometryType( geometryType ) {}
wkbEntry( QString name, bool isMultiType, Type multiType, Type singleType, Type flatType, GeometryType geometryType,
bool hasZ, bool hasM ):
mName( name ), mIsMultiType( isMultiType ), mMultiType( multiType ), mSingleType( singleType ), mFlatType( flatType ), mGeometryType( geometryType ),
mHasZ( hasZ ), mHasM( hasM ) {}
QString mName;
bool mIsMultiType;
Type mMultiType;
Type mSingleType;
Type mFlatType;
GeometryType mGeometryType;
bool mHasZ;
bool mHasM;
};

static Type singleType( Type type );
@@ -116,6 +120,8 @@ class CORE_EXPORT QgsWKBTypes
static int wkbDimensions( Type type );
static GeometryType geometryType( Type type );
static QString displayString( Type type );
static bool hasZ( Type type );
static bool hasM( Type type );

private:
static QMap<Type, wkbEntry> registerTypes();
@@ -45,7 +45,9 @@ const unsigned char* QgsClipper::clippedLineWKB( const unsigned char* wkb, const

wkbPtr >> wkbType >> nPoints;

bool hasZValue = ( wkbType == QGis::WKBLineString25D );
bool hasZValue = QgsWKBTypes::hasZ(( QgsWKBTypes::Type )wkbType );
bool hasMValue = QgsWKBTypes::hasM(( QgsWKBTypes::Type )wkbType );


double p0x, p0y, p1x = 0.0, p1y = 0.0; //original coordinates
double p1x_c, p1y_c; //clipped end coordinates
@@ -61,6 +63,8 @@ const unsigned char* QgsClipper::clippedLineWKB( const unsigned char* wkb, const
wkbPtr >> p1x >> p1y;
if ( hasZValue )
wkbPtr += sizeof( double );
if ( hasMValue )
wkbPtr += sizeof( double );

continue;
}
@@ -72,6 +76,8 @@ const unsigned char* QgsClipper::clippedLineWKB( const unsigned char* wkb, const
wkbPtr >> p1x >> p1y;
if ( hasZValue )
wkbPtr += sizeof( double );
if ( hasMValue )
wkbPtr += sizeof( double );

p1x_c = p1x; p1y_c = p1y;
if ( clipLineSegment( clipExtent.xMinimum(), clipExtent.xMaximum(), clipExtent.yMinimum(), clipExtent.yMaximum(),

0 comments on commit 00b8c1d

Please sign in to comment.
You can’t perform that action at this time.