diff --git a/__test__/Polyline/__snapshots__/offset.test.ts.snap b/__test__/Polyline/__snapshots__/offset.test.ts.snap index 0f505651d..63d1e6c6f 100644 --- a/__test__/Polyline/__snapshots__/offset.test.ts.snap +++ b/__test__/Polyline/__snapshots__/offset.test.ts.snap @@ -64,6 +64,10 @@ exports[`复杂圆盘选点 9`] = `1`; exports[`复杂圆盘选点 10`] = `206.82332282556683`; +exports[`多段线因为合并问题造成的错误 1`] = `1`; + +exports[`多段线因为合并问题造成的错误 2`] = `2210.3833040297095`; + exports[`多段线存在0长度线段导致偏移错误 1`] = `1`; exports[`多段线存在0长度线段导致偏移错误 2`] = `81933.70549460054`; diff --git a/__test__/Polyline/offset.test.ts b/__test__/Polyline/offset.test.ts index 7760390e7..0a344c1aa 100644 --- a/__test__/Polyline/offset.test.ts +++ b/__test__/Polyline/offset.test.ts @@ -900,3 +900,12 @@ test('纯圆生成的多段线偏移', () => testOffset(pl, 100); testOffset(pl, -100); }); + +test('多段线因为合并问题造成的错误', () => +{ + let pl = loadFile( + [1, ["Polyline", 1, 1, 38, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 10, [560.4622946261899, 280.3468208092485], 0, [273.1213872832369, 280.3468208092485], 0, [273.1213872832369, 70.80924855491334], 0, [273.1213872832369, 70.80924855491334], 0, [520.5860801571987, 70.80924855491334], 0.45552774411272906, [773.2934581245079, 9.947706891888771], 1.0105662598284268, [843.111615774608, 120.72879526430421], 0.42745194242823337, [695.3090834219281, 321.1478937918483], 3.4733857741050023, [602.1148370593586, 307.0986147536708], 0.07222028753966563, [560.4622946261899, 280.3468208092485], 0, false]] + )[0]; + + testOffset(pl, 37.8831); +}); diff --git a/src/GraphicsSystem/OffsetPolyline.ts b/src/GraphicsSystem/OffsetPolyline.ts index 27a54f0c3..a3637d143 100644 --- a/src/GraphicsSystem/OffsetPolyline.ts +++ b/src/GraphicsSystem/OffsetPolyline.ts @@ -128,7 +128,9 @@ export class PolyOffsetUtil //有共线部分才允许合并. if (c2.PtOnCurve2(c1.StartPoint) || c2.PtOnCurve2(c1.EndPoint) - || c1.PtOnCurve2(c2.StartPoint) || c1.PtOnCurve2(c2.EndPoint)) + || c1.PtOnCurve2(c2.StartPoint) || c1.PtOnCurve2(c2.EndPoint) + || (c1.PtOnCurve(c2.StartPoint) && c1.PtOnCurve(c2.EndPoint)) + ) if (c1.Join(c2) === Status.True) { this.m_RetCurves.splice(j, 1);