@@ -2878,18 +2878,10 @@ int QgsGeometry::splitGeometry( const QList<QgsPoint>& splitLine, QList<QgsGeome
2878
2878
return 7 ;
2879
2879
2880
2880
// make sure splitLine is valid
2881
- if ( splitLine.size () < 1 )
2881
+ if (( type () == QGis::Line && splitLine.size () < 1 ) ||
2882
+ ( type () == QGis::Polygon && splitLine.size () < 2 ) )
2882
2883
return 1 ;
2883
2884
2884
- // Treat the special case of a single point to split a line without geos
2885
- if ( splitLine.size () == 1 )
2886
- {
2887
- // A point cannot split a polygon
2888
- if ( type () == QGis::Polygon )
2889
- return 1 ;
2890
- // return splitLinearGeometryAtPoint( splitLine[0], newGeometries );
2891
- }
2892
-
2893
2885
newGeometries.clear ();
2894
2886
2895
2887
try
@@ -4584,8 +4576,6 @@ GEOSGeometry* QgsGeometry::linePointDifference( GEOSGeometry* GEOSsplitPoint )
4584
4576
4585
4577
QgsPoint splitPoint = fromGeosGeom ( GEOSsplitPoint )->asPoint ();
4586
4578
4587
- QgsPoint p1, p2;
4588
- QgsGeometry* g;
4589
4579
QgsMultiPolyline lines;
4590
4580
QgsPolyline line;
4591
4581
QgsPolyline newline;
@@ -4594,10 +4584,10 @@ GEOSGeometry* QgsGeometry::linePointDifference( GEOSGeometry* GEOSsplitPoint )
4594
4584
for ( int i = 0 ; i < multiLine.size () ; ++i )
4595
4585
{
4596
4586
line = multiLine[i];
4597
- // For each segment
4598
4587
newline = QgsPolyline ();
4599
- newline.append (line[0 ]);
4600
- for ( int j = 1 ; j < line.size ()-1 ; ++j )
4588
+ newline.append ( line[0 ] );
4589
+ // For each segment
4590
+ for ( int j = 1 ; j < line.size () - 1 ; ++j )
4601
4591
{
4602
4592
newline.append ( line[j] );
4603
4593
if ( line[j] == splitPoint )
@@ -4628,24 +4618,25 @@ int QgsGeometry::splitLinearGeometry( GEOSGeometry *splitLine, QList<QgsGeometry
4628
4618
if ( !mGeos )
4629
4619
return 5 ;
4630
4620
4621
+ // first test if linestring intersects geometry. If not, return straight away
4622
+ if ( !GEOSIntersects ( splitLine, mGeos ) )
4623
+ return 1 ;
4631
4624
4632
4625
// check that split line has no linear intersection
4633
4626
int linearIntersect = GEOSRelatePattern ( mGeos , splitLine, " 1********" );
4634
4627
if ( linearIntersect > 0 )
4635
4628
return 3 ;
4636
4629
4637
4630
int splitGeomType = GEOSGeomTypeId ( splitLine );
4638
- // first test if linestring intersects geometry. If not, return straight away
4639
- if ( splitGeomType == GEOS_LINESTRING && !GEOSIntersects ( splitLine, mGeos ) )
4640
- return 1 ;
4631
+
4641
4632
GEOSGeometry* splitGeom;
4642
- if ( splitGeomType == GEOS_LINESTRING )
4633
+ if ( splitGeomType == GEOS_POINT )
4643
4634
{
4644
- splitGeom = GEOSDifference ( mGeos , splitLine );
4635
+ splitGeom = linePointDifference ( splitLine );
4645
4636
}
4646
4637
else
4647
4638
{
4648
- splitGeom = linePointDifference ( splitLine );
4639
+ splitGeom = GEOSDifference ( mGeos , splitLine );
4649
4640
}
4650
4641
QVector<GEOSGeometry*> lineGeoms;
4651
4642
0 commit comments