Skip to content

Commit

Permalink
Better fix for drawing the new geometry types
Browse files Browse the repository at this point in the history
  • Loading branch information
mhugent committed Jun 2, 2015
1 parent 710e7f7 commit 9fcbbc3
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 60 deletions.
36 changes: 0 additions & 36 deletions src/core/geometry/qgsgeometryimport.cpp
Expand Up @@ -43,42 +43,6 @@ QgsAbstractGeometryV2* QgsGeometryImport::geomFromWkb( const unsigned char* wkb

geom = geomFromWkbType( QgsWKBTypes::Type( type ) );

#if 0
type = QgsWKBTypes::flatType( QgsWKBTypes::Type( type ) );
switch ( type )
{
case QgsWKBTypes::Point:
geom = new QgsPointV2();
break;
case QgsWKBTypes::LineString:
geom = new QgsLineStringV2();
break;
case QgsWKBTypes::CircularString:
geom = new QgsCircularStringV2();
break;
case QgsWKBTypes::CompoundCurve:
geom = new QgsCompoundCurveV2();
break;
case QgsWKBTypes::Polygon:
geom = new QgsPolygonV2();
break;
case QgsWKBTypes::CurvePolygon:
geom = new QgsCurvePolygonV2();
break;
case QgsWKBTypes::MultiLineString:
geom = new QgsMultiLineStringV2();
break;
case QgsWKBTypes::MultiPolygon:
geom = new QgsMultiPolygonV2();
break;
case QgsWKBTypes::MultiPoint:
geom = new QgsMultiPointV2();
break;
default:
geom = 0;
}
#endif

if ( geom )
{
geom->fromWkb( wkb );
Expand Down
51 changes: 27 additions & 24 deletions src/core/symbology-ng/qgsrendererv2.cpp
Expand Up @@ -246,24 +246,35 @@ void QgsFeatureRendererV2::renderFeatureWithSymbol( QgsFeature& feature, QgsSymb
QgsSymbolV2::SymbolType symbolType = symbol->type();

const QgsGeometry* geom = feature.constGeometry();
if ( !geom )
if ( !geom || !geom->geometry() )
{
return;
}

if ( geom->requiresConversionToStraightSegments() )
//convert curve types to normal point/line/polygon ones
switch ( QgsWKBTypes::flatType( geom->geometry()->wkbType() ) )
{
//geometry requires conversion to straight segments
QgsGeometry* straightGeom = new QgsGeometry( *geom );
straightGeom->convertToStraightSegment();
feature.setGeometry( straightGeom );
geom = feature.constGeometry();
case QgsWKBTypes::CurvePolygon:
case QgsWKBTypes::CircularString:
case QgsWKBTypes::CompoundCurve:
case QgsWKBTypes::MultiSurface:
case QgsWKBTypes::MultiCurve:
{
QgsAbstractGeometryV2* g = geom->geometry()->segmentize();
if ( !g )
{
return;
}
feature.setGeometry( new QgsGeometry( g ) );
geom = feature.constGeometry();
}
default:
break;
}

switch ( geom->wkbType() )
switch ( QgsWKBTypes::flatType( geom->geometry()->wkbType() ) )
{
case QGis::WKBPoint:
case QGis::WKBPoint25D:
case QgsWKBTypes::Point:
{
if ( symbolType != QgsSymbolV2::Marker )
{
Expand All @@ -278,9 +289,7 @@ void QgsFeatureRendererV2::renderFeatureWithSymbol( QgsFeature& feature, QgsSymb
// renderVertexMarker( pt, context );
}
break;

case QGis::WKBLineString:
case QGis::WKBLineString25D:
case QgsWKBTypes::LineString:
{
if ( symbolType != QgsSymbolV2::Line )
{
Expand All @@ -295,9 +304,7 @@ void QgsFeatureRendererV2::renderFeatureWithSymbol( QgsFeature& feature, QgsSymb
renderVertexMarkerPolyline( pts, context );
}
break;

case QGis::WKBPolygon:
case QGis::WKBPolygon25D:
case QgsWKBTypes::Polygon:
{
if ( symbolType != QgsSymbolV2::Fill )
{
Expand All @@ -314,8 +321,7 @@ void QgsFeatureRendererV2::renderFeatureWithSymbol( QgsFeature& feature, QgsSymb
}
break;

case QGis::WKBMultiPoint:
case QGis::WKBMultiPoint25D:
case QgsWKBTypes::MultiPoint:
{
if ( symbolType != QgsSymbolV2::Marker )
{
Expand All @@ -340,8 +346,7 @@ void QgsFeatureRendererV2::renderFeatureWithSymbol( QgsFeature& feature, QgsSymb
}
break;

case QGis::WKBMultiLineString:
case QGis::WKBMultiLineString25D:
case QgsWKBTypes::MultiLineString:
{
if ( symbolType != QgsSymbolV2::Line )
{
Expand All @@ -366,8 +371,7 @@ void QgsFeatureRendererV2::renderFeatureWithSymbol( QgsFeature& feature, QgsSymb
}
break;

case QGis::WKBMultiPolygon:
case QGis::WKBMultiPolygon25D:
case QgsWKBTypes::MultiPolygon:
{
if ( symbolType != QgsSymbolV2::Fill )
{
Expand All @@ -390,9 +394,8 @@ void QgsFeatureRendererV2::renderFeatureWithSymbol( QgsFeature& feature, QgsSymb
if ( drawVertexMarker )
renderVertexMarkerPolygon( pts, ( holes.count() ? &holes : NULL ), context );
}
break;
}
break;

default:
QgsDebugMsg( QString( "feature %1: unsupported wkb type 0x%2 for rendering" ).arg( feature.id() ).arg( geom->wkbType(), 0, 16 ) );
}
Expand Down

0 comments on commit 9fcbbc3

Please sign in to comment.