[offset tool] fix #18115 improved offset calculation

* use QgsGeometry::contains for polygons (contains => negative offset)
* use the geometry part and not the whole geometry to find closest segment
This commit is contained in:
Denis Rouzaud 2018-02-17 13:28:10 -04:00
parent cad45c0b80
commit 45bfa50cba

View File

@ -367,8 +367,15 @@ double QgsMapToolOffsetCurve::calculateOffset( QgsPointXY mapPoint )
int beforeVertex;
int leftOf = 0;
offset = std::sqrt( mOriginalGeometry.closestSegmentWithContext( layerCoords, minDistPoint, beforeVertex, &leftOf ) );
offset = leftOf < 0 ? offset : -offset;
offset = std::sqrt( mManipulatedGeometry.closestSegmentWithContext( layerCoords, minDistPoint, beforeVertex, &leftOf ) );
if ( QgsWkbTypes::geometryType( mManipulatedGeometry.wkbType() ) == QgsWkbTypes::LineGeometry )
{
offset = leftOf < 0 ? offset : -offset;
}
else
{
offset = mManipulatedGeometry.contains( &layerCoords ) ? -offset : offset;
}
}
return offset;
}
@ -573,7 +580,7 @@ void QgsMapToolOffsetCurve::updateGeometryAndRubberBand( double offset )
}
else
{
offsetGeom = mManipulatedGeometry.buffer( -offset, quadSegments, capStyle, joinStyle, miterLimit );
offsetGeom = mManipulatedGeometry.buffer( offset, quadSegments, capStyle, joinStyle, miterLimit );
}
if ( !offsetGeom )