File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -109,17 +109,20 @@ QVariantMap QgsKMeansClusteringAlgorithm::processAlgorithm( const QVariantMap &p
109
109
if ( !feat.hasGeometry () )
110
110
continue ;
111
111
112
- n++;
113
-
114
112
QgsPointXY point;
115
113
if ( QgsWkbTypes::flatType ( feat.geometry ().wkbType () ) == QgsWkbTypes::Point )
116
114
point = QgsPointXY ( *qgsgeometry_cast< const QgsPoint * >( feat.geometry ().constGet () ) );
117
115
else
118
116
{
119
117
QgsGeometry centroid = feat.geometry ().centroid ();
118
+ if ( !centroid )
119
+ continue ; // centroid failed, e.g. empty linestring
120
+
120
121
point = QgsPointXY ( *qgsgeometry_cast< const QgsPoint * >( centroid.constGet () ) );
121
122
}
122
123
124
+ n++;
125
+
123
126
idToObj.insert ( feat.id (), clusterFeatures.size () );
124
127
clusterFeatures.emplace_back ( Feature ( point ) );
125
128
}
You can’t perform that action at this time.
0 commit comments