@@ -524,11 +524,12 @@ bool QgsGeometry::moveVertexAt(double x, double y,
524
524
geos::CoordinateSequence* sequence = mGeos ->getCoordinates ();
525
525
sequence->setAt (geos::Coordinate (x, y), atVertex.back ());
526
526
setGeos ( static_cast <geos::Geometry*>( geosGeometryFactory->createLineString (sequence) ) );
527
- break ;
527
+ mDirtyWkb = true ;
528
+ return true ;
528
529
}
529
530
case geos::GEOS_POLYGON:
530
531
{
531
- if (moveVertexFromPolygon (atVertex.back (), x, y))
532
+ if (movePolygonVertex (atVertex.back (), x, y))
532
533
{
533
534
mDirtyWkb = true ;
534
535
return true ;
@@ -538,49 +539,12 @@ bool QgsGeometry::moveVertexAt(double x, double y,
538
539
return false ;
539
540
}
540
541
}
541
- mDirtyWkb = true ;
542
- return true ;
543
542
}
544
543
}
545
544
546
545
return false ;
547
546
}
548
547
549
-
550
- bool QgsGeometry::deleteVertexAt (int atVertex,
551
- const geos::CoordinateSequence* old_sequence,
552
- geos::CoordinateSequence** new_sequence)
553
- {
554
- int numPoints = old_sequence->getSize ();
555
-
556
- // Bounds checking
557
- if (
558
- (atVertex < 0 ) ||
559
- (atVertex >= numPoints) ||
560
- (numPoints <= 2 ) // guard against collapsing to a point
561
- )
562
- {
563
- (*new_sequence) = 0 ;
564
- return FALSE ;
565
- }
566
-
567
- // Copy to the new sequence, excepting the deleted vertex
568
- (*new_sequence) = new geos::DefaultCoordinateSequence ();
569
-
570
- for (int i = 0 ; i < numPoints; i++)
571
- {
572
- // Do we delete (omit) the vertex here?
573
- if (atVertex != i)
574
- {
575
- (*new_sequence)->add ( old_sequence->getAt (i) );
576
- }
577
- }
578
-
579
- // TODO: Check that the sequence is still simple, e.g. with geos::Geometry->isSimple()
580
- return true ;
581
- }
582
-
583
-
584
548
bool QgsGeometry::deleteVertexAt (QgsGeometryVertexIndex atVertex)
585
549
{
586
550
@@ -608,21 +572,19 @@ bool QgsGeometry::deleteVertexAt(QgsGeometryVertexIndex atVertex)
608
572
{
609
573
// Get the embedded GEOS Coordinate Sequence
610
574
geos::LineString* geosls = static_cast <geos::LineString*>(mGeos );
611
- const geos::CoordinateSequence* old_sequence = geosls->getCoordinatesRO ();
612
- geos::CoordinateSequence* new_sequence;
613
-
614
- if ( deleteVertexAt (atVertex.back (), old_sequence, (&new_sequence) ) )
615
- {
616
- // Put in the new GEOS geometry
617
- setGeos ( static_cast <geos::Geometry*>( geosGeometryFactory->createLineString (new_sequence) ) );
618
- mDirtyWkb = true ;
619
- return TRUE ;
620
- }
575
+ geos::CoordinateSequence* sequence = geosls->getCoordinates ();
576
+ sequence->deleteAt (atVertex.back ());
577
+ geos::LineString* newLineString = geosGeometryFactory->createLineString (sequence);
578
+ if (newLineString)
579
+ {
580
+ setGeos (newLineString);
581
+ mDirtyWkb = true ;
582
+ return TRUE ;
583
+ }
621
584
else
622
- {
623
- return FALSE ;
624
- }
625
-
585
+ {
586
+ return FALSE ;
587
+ }
626
588
} // case geos::GEOS_LINESTRING
627
589
628
590
case geos::GEOS_LINEARRING: // a linear ring (linestring with 1st point == last point)
@@ -2087,7 +2049,7 @@ double QgsGeometry::distanceSquaredPointToSegment(QgsPoint& point,
2087
2049
2088
2050
}
2089
2051
2090
- bool QgsGeometry::moveVertexFromPolygon (int atVertex, double x, double y)
2052
+ bool QgsGeometry::movePolygonVertex (int atVertex, double x, double y)
2091
2053
{
2092
2054
if (!mGeos )
2093
2055
{
0 commit comments