Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 7e82b0f

Browse files
committedMar 9, 2019
Fix 3D polygon symbol to work with geometry collection
Some data sources report their geometry type as multi-surface (a collection of polygons and curve-polygons) and so we should handle them as well.
1 parent 7d83263 commit 7e82b0f

File tree

1 file changed

+24
-10
lines changed

1 file changed

+24
-10
lines changed
 

‎src/3d/symbols/qgspolygon3dsymbol_p.cpp‎

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class QgsPolygon3DSymbolHandler : public QgsFeature3DHandler
5454
QList<float> extrusionHeightPerPolygon; // will stay empty if not needed per polygon
5555
};
5656

57+
void processPolygon( QgsPolygon *polyClone, QgsFeatureId fid, float height, bool hasDDExtrusion, float extrusionHeight, const Qgs3DRenderContext &context, PolygonData &out );
5758
void makeEntity( Qt3DCore::QEntity *parent, const Qgs3DRenderContext &context, PolygonData &out, bool selected );
5859
Qt3DExtras::QPhongMaterial *material( const QgsPolygon3DSymbol &symbol ) const;
5960

@@ -75,6 +76,15 @@ bool QgsPolygon3DSymbolHandler::prepare( const Qgs3DRenderContext &context, QSet
7576
return true;
7677
}
7778

79+
void QgsPolygon3DSymbolHandler::processPolygon( QgsPolygon *polyClone, QgsFeatureId fid, float height, bool hasDDExtrusion, float extrusionHeight, const Qgs3DRenderContext &context, PolygonData &out )
80+
{
81+
Qgs3DUtils::clampAltitudes( polyClone, mSymbol.altitudeClamping(), mSymbol.altitudeBinding(), height, context.map() );
82+
out.polygons.append( polyClone );
83+
out.fids.append( fid );
84+
if ( hasDDExtrusion )
85+
out.extrusionHeightPerPolygon.append( extrusionHeight );
86+
}
87+
7888
void QgsPolygon3DSymbolHandler::processFeature( QgsFeature &f, const Qgs3DRenderContext &context )
7989
{
8090
if ( f.geometry().isNull() )
@@ -104,11 +114,7 @@ void QgsPolygon3DSymbolHandler::processFeature( QgsFeature &f, const Qgs3DRender
104114
if ( const QgsPolygon *poly = qgsgeometry_cast< const QgsPolygon *>( g ) )
105115
{
106116
QgsPolygon *polyClone = poly->clone();
107-
Qgs3DUtils::clampAltitudes( polyClone, mSymbol.altitudeClamping(), mSymbol.altitudeBinding(), height, context.map() );
108-
out.polygons.append( polyClone );
109-
out.fids.append( f.id() );
110-
if ( hasDDExtrusion )
111-
out.extrusionHeightPerPolygon.append( extrusionHeight );
117+
processPolygon( polyClone, f.id(), height, hasDDExtrusion, extrusionHeight, context, out );
112118
}
113119
else if ( const QgsMultiPolygon *mpoly = qgsgeometry_cast< const QgsMultiPolygon *>( g ) )
114120
{
@@ -117,11 +123,19 @@ void QgsPolygon3DSymbolHandler::processFeature( QgsFeature &f, const Qgs3DRender
117123
const QgsAbstractGeometry *g2 = mpoly->geometryN( i );
118124
Q_ASSERT( QgsWkbTypes::flatType( g2->wkbType() ) == QgsWkbTypes::Polygon );
119125
QgsPolygon *polyClone = static_cast< const QgsPolygon *>( g2 )->clone();
120-
Qgs3DUtils::clampAltitudes( polyClone, mSymbol.altitudeClamping(), mSymbol.altitudeBinding(), height, context.map() );
121-
out.polygons.append( polyClone );
122-
out.fids.append( f.id() );
123-
if ( hasDDExtrusion )
124-
out.extrusionHeightPerPolygon.append( extrusionHeight );
126+
processPolygon( polyClone, f.id(), height, hasDDExtrusion, extrusionHeight, context, out );
127+
}
128+
}
129+
else if ( const QgsGeometryCollection *gc = qgsgeometry_cast< const QgsGeometryCollection *>( g ) )
130+
{
131+
for ( int i = 0; i < gc->numGeometries(); ++i )
132+
{
133+
const QgsAbstractGeometry *g2 = gc->geometryN( i );
134+
if ( QgsWkbTypes::flatType( g2->wkbType() ) == QgsWkbTypes::Polygon )
135+
{
136+
QgsPolygon *polyClone = static_cast< const QgsPolygon *>( g2 )->clone();
137+
processPolygon( polyClone, f.id(), height, hasDDExtrusion, extrusionHeight, context, out );
138+
}
125139
}
126140
}
127141
else

0 commit comments

Comments
 (0)
Please sign in to comment.