mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-01 00:46:20 -05:00
[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:
parent
cad45c0b80
commit
45bfa50cba
@ -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 )
|
||||
|
Loading…
x
Reference in New Issue
Block a user