Skip to content

Commit 5f18537

Browse files
Fix line geometry: clamp fake-round join anchor on short
GitOrigin-RevId: b456fd5b872ccd24c857a06c21e658893910311f
1 parent 0603110 commit 5f18537

18 files changed

Lines changed: 153 additions & 3 deletions

File tree

src/data/bucket/line_bucket.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -877,9 +877,13 @@ class LineBucket implements Bucket {
877877
this.addCurrentVertex(currentVertex, endNormal ? endNormal : prevNormal, -capScale, -capScale, segment, lineProgressFeatures);
878878
}
879879

880-
const skipStraightEdges = dist <= 2 * sharpCornerOffset && currentJoin !== 'bevel';
880+
// On short segments also pull the fake-round fan anchor from the miter point back to
881+
// the unit circle: scaled by the line width, the miter point can land outside the
882+
// geometry and its fan paints border color across neighbouring segments.
883+
const skipStraightEdges = dist <= 1.0 * sharpCornerOffset && currentJoin !== 'bevel';
884+
const joinExtent = skipStraightEdges ? 1.0 : miterLength;
881885
const join = joinNormal.mult(lineTurnsLeft ? 1.0 : -1.0);
882-
join._mult(miterLength);
886+
join._mult(joinExtent);
883887
const next = nextNormal.mult(lineTurnsLeft ? -1.0 : 1.0);
884888
const prev = prevNormal.mult(lineTurnsLeft ? -1.0 : 1.0);
885889
const lpf = this.evaluateLineProgressFeatures(this.distance);
-316 Bytes
Loading
8.25 KB
Loading
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"network": [
3+
[
4+
"probeNetwork - default - end",
5+
0,
6+
0
7+
],
8+
[
9+
"probeNetwork - default - start",
10+
0,
11+
0
12+
]
13+
],
14+
"gfx": [
15+
[
16+
"probeGFX - default - end",
17+
12,
18+
2,
19+
2,
20+
1,
21+
[
22+
16388,
23+
16388
24+
],
25+
[
26+
1404,
27+
1404
28+
],
29+
[
30+
2816,
31+
2816
32+
]
33+
]
34+
]
35+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"network": [
3+
[
4+
"probeNetwork - default - end",
5+
0,
6+
0
7+
],
8+
[
9+
"probeNetwork - default - start",
10+
0,
11+
0
12+
]
13+
],
14+
"gfx": [
15+
[
16+
"probeGFX - default - end",
17+
12,
18+
0,
19+
0,
20+
0,
21+
[
22+
0,
23+
0
24+
],
25+
[
26+
0,
27+
0
28+
],
29+
[
30+
0,
31+
0
32+
]
33+
]
34+
]
35+
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
{
2+
"version": 8,
3+
"metadata": {
4+
"test": {
5+
"description": "Ensures that short segments in a wide line do not cause unclamped fake-round join anchors to extend beyond the geometry.",
6+
"width": 512,
7+
"height": 512,
8+
"image-threshold": [
9+
{
10+
"platform-tag-contains": "",
11+
"threshold": 1e-06
12+
}
13+
]
14+
}
15+
},
16+
"center": [0, 0],
17+
"zoom": 14,
18+
"bearing": 0,
19+
"pitch": 0,
20+
"sources": {
21+
"single-s": {
22+
"type": "geojson",
23+
"tolerance": 0,
24+
"data": {
25+
"type": "Feature",
26+
"properties": {},
27+
"geometry": {
28+
"type": "LineString",
29+
"coordinates": [
30+
[-0.005579, 0.000144],
31+
[-0.000461, 0.000144],
32+
[-0.000277, -0.000144],
33+
[-0.000092, 0.000144],
34+
[0.000092, -0.000144],
35+
[0.000277, 0.000144],
36+
[0.000461, -0.000144],
37+
[0.005579, -0.000144]
38+
]
39+
}
40+
}
41+
}
42+
},
43+
"layers": [
44+
{
45+
"id": "background",
46+
"type": "background",
47+
"paint": {
48+
"background-color": "white"
49+
}
50+
},
51+
{
52+
"id": "line",
53+
"type": "line",
54+
"source": "single-s",
55+
"layout": {
56+
"line-cap": "round",
57+
"line-join": "round"
58+
},
59+
"paint": {
60+
"line-color": "rgb(60,110,180)",
61+
"line-width": 44.0,
62+
"line-border-color": "rgb(220,70,40)",
63+
"line-border-width": 6.0
64+
}
65+
},
66+
{
67+
"id": "vertices",
68+
"type": "circle",
69+
"source": "single-s",
70+
"paint": {
71+
"circle-radius": 2.8,
72+
"circle-color": "black"
73+
}
74+
}
75+
]
76+
}
-704 Bytes
Loading
-1.35 KB
Loading
-15.6 KB
Loading
-561 Bytes
Loading

0 commit comments

Comments
 (0)