Skip to content
Permalink
Browse files
[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
  • Loading branch information
3nids committed Feb 17, 2018
1 parent cad45c0 commit 45bfa50
Showing 1 changed file with 10 additions and 3 deletions.
@@ -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 )

0 comments on commit 45bfa50

Please sign in to comment.