Skip to content

Commit

Permalink
[bugfix] Fixes #17118 Reshape tool with z support
Browse files Browse the repository at this point in the history
  • Loading branch information
pblottiere committed Oct 16, 2017
1 parent 364847f commit cfec125
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/app/qgsmaptoolreshape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ void QgsMapToolReshape::cadCanvasReleaseEvent( QgsMapMouseEvent * e )
QgsGeometry* geom = f.geometry();
if ( geom )
{
reshapeReturn = geom->reshapeGeometry( points() );
reshapeReturn = geom->reshapeGeometry( pointsV2() );
if ( reshapeReturn == 0 )
{
//avoid intersections on polygon layers
Expand Down
16 changes: 11 additions & 5 deletions src/core/geometry/qgsgeometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -800,28 +800,34 @@ int QgsGeometry::splitGeometry( const QList<QgsPoint>& splitLine, QList<QgsGeome

/** Replaces a part of this geometry with another line*/
int QgsGeometry::reshapeGeometry( const QList<QgsPoint>& reshapeWithLine )
{
QgsPointSequenceV2 reshapeLine;
convertPointList( reshapeWithLine, reshapeLine );
return reshapeGeometry( reshapeLine );
}

int QgsGeometry::reshapeGeometry( const QList<QgsPointV2>& reshapeLine )
{
if ( !d->geometry )
{
return 0;
}

QgsPointSequenceV2 reshapeLine;
convertPointList( reshapeWithLine, reshapeLine );
QgsLineStringV2 reshapeLineString;
reshapeLineString.setPoints( reshapeLine );

QgsGeos geos( d->geometry );
int errorCode = 0;
QgsAbstractGeometryV2* geom = geos.reshapeGeometry( reshapeLineString, &errorCode );

if ( errorCode == 0 && geom )
{
detach( false );
detach( true );
delete d->geometry;
d->geometry = geom;
removeWkbGeos();
d->geometry = geom;
return 0;
}

return errorCode;
}

Expand Down
9 changes: 9 additions & 0 deletions src/core/geometry/qgsgeometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,15 @@ class CORE_EXPORT QgsGeometry
*/
int reshapeGeometry( const QList<QgsPoint>& reshapeWithLine );

/**
* Replaces a part of this geometry with another line with Z support
*
* @return 0 in case of success
*
* @note added in 2.18
*/
int reshapeGeometry( const QList<QgsPointV2>& reshapeLine );

/** Changes this geometry such that it does not intersect the other geometry
* @param other geometry that should not be intersect
* @return 0 in case of success
Expand Down
7 changes: 7 additions & 0 deletions src/gui/qgsmaptoolcapture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,13 @@ QList<QgsPoint> QgsMapToolCapture::points()
return points;
}

QgsPointSequenceV2 QgsMapToolCapture::pointsV2()
{
QgsPointSequenceV2 pts;
mCaptureCurve.points( pts );
return pts;
}

void QgsMapToolCapture::setPoints( const QList<QgsPoint>& pointList )
{
QgsPointSequenceV2 pts;
Expand Down
9 changes: 9 additions & 0 deletions src/gui/qgsmaptoolcapture.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,15 @@ class GUI_EXPORT QgsMapToolCapture : public QgsMapToolAdvancedDigitizing
*/
QList<QgsPoint> points();

/**
* List of digitized points with z support
*
* @return List of points
*
* @node added in 2.18
*/
QgsPointSequenceV2 pointsV2();

/**
* Set the points on which to work
*
Expand Down

0 comments on commit cfec125

Please sign in to comment.