ol 10.7.1-dev.1767564255094 → 10.7.1-dev.1768058236017
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/coordinate.d.ts +8 -0
- package/coordinate.d.ts.map +1 -1
- package/coordinate.js +31 -1
- package/dist/ol.d.ts +4 -0
- package/dist/ol.d.ts.map +1 -1
- package/dist/ol.js +1 -1
- package/dist/ol.js.map +1 -1
- package/geom/flat/lineoffset.d.ts +45 -0
- package/geom/flat/lineoffset.d.ts.map +1 -0
- package/geom/flat/lineoffset.js +173 -0
- package/package.json +1 -1
- package/render/canvas/Builder.d.ts.map +1 -1
- package/render/canvas/Builder.js +8 -1
- package/render/canvas/Executor.d.ts.map +1 -1
- package/render/canvas/Executor.js +49 -2
- package/render/canvas/Immediate.d.ts +2 -0
- package/render/canvas/Immediate.d.ts.map +1 -1
- package/render/canvas/Immediate.js +28 -4
- package/render/canvas/LineStringBuilder.d.ts +1 -0
- package/render/canvas/LineStringBuilder.d.ts.map +1 -1
- package/render/canvas/LineStringBuilder.js +13 -5
- package/render/canvas/PolygonBuilder.d.ts +2 -0
- package/render/canvas/PolygonBuilder.d.ts.map +1 -1
- package/render/canvas/PolygonBuilder.js +72 -6
- package/render/canvas/style.d.ts.map +1 -1
- package/render/canvas/style.js +10 -0
- package/render/canvas.d.ts +20 -0
- package/render/canvas.d.ts.map +1 -1
- package/render/canvas.js +9 -0
- package/render/webgl/bufferUtil.d.ts.map +1 -1
- package/render/webgl/bufferUtil.js +1 -31
- package/style/Stroke.d.ts +25 -0
- package/style/Stroke.d.ts.map +1 -1
- package/style/Stroke.js +28 -0
- package/style/flat.d.ts +2 -2
- package/style/flat.js +1 -1
- package/util.js +1 -1
- package/worker/webgl.js +1 -1
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Offsets a line string to the left / right along its segments direction.
|
|
3
|
+
* Offset is applied to each segment of the line in the direciton of the segment normal (positive offset goes "right" relative to the line direction).
|
|
4
|
+
* For very sharp angles between segments, the function falls back to offsetting along the segment normal direction to avoid excessively long miters.
|
|
5
|
+
*
|
|
6
|
+
* Coordinates and the offset should be in the same units — either pixels or the same spatial reference system as the input line coordinates.
|
|
7
|
+
*
|
|
8
|
+
* @param {Array<number>} flatCoordinates Flat coordinates.
|
|
9
|
+
* @param {number} stride Stride.
|
|
10
|
+
* @param {number} offset Offset distance along the segment normal direction.
|
|
11
|
+
* Positive values offset to the right relative to the direction of the line.
|
|
12
|
+
* Negative values offset to the left.
|
|
13
|
+
* @param {boolean} isClosedRing If coordinates build a closed circle (in this the first and the last coordinate offsets will consider previous / next ring coordinate)
|
|
14
|
+
* @param {Array<number>} [dest] Destination coordinate array. If not provided a new one will be created
|
|
15
|
+
* @param {number} [destinationStride] Stride of destination coordinates. If unspecified, assumed to be same as the source coordinates stride.
|
|
16
|
+
* @return {Array<number>} Result flat coordinates of the offset line.
|
|
17
|
+
*/
|
|
18
|
+
export function offsetLineString(flatCoordinates: Array<number>, stride: number, offset: number, isClosedRing: boolean, dest?: Array<number>, destinationStride?: number): Array<number>;
|
|
19
|
+
/**
|
|
20
|
+
* Computes the offset of a single vertex of a line string.
|
|
21
|
+
*
|
|
22
|
+
* The function calculates a new vertex coordinate offset along the normal/miter direction of the line at this vertex.
|
|
23
|
+
* Offset is applied along the segment normal (positive offset goes "right" relative to the line direction).
|
|
24
|
+
* It handles first and last vertices (caps) as well as joins between two segments (mitering).
|
|
25
|
+
* For very sharp angles, the function falls back to offsetting along the segment normal direction to avoid excessively long miters.
|
|
26
|
+
*
|
|
27
|
+
* Coordinates and the offset should be in the same units — either pixels or the same spatial reference system as the input line coordinates.
|
|
28
|
+
*
|
|
29
|
+
* @param {number} x Vertex x-coordinate.
|
|
30
|
+
* @param {number} y Vertex y-coordinate.
|
|
31
|
+
* @param {number|undefined} prevX Previous vertex x-coordinate.
|
|
32
|
+
* Pass undefined if computing the offset for the first vertex (no previous vertex).
|
|
33
|
+
* @param {number|undefined} prevY Previous vertex y-coordinate.
|
|
34
|
+
* Pass undefined if computing the offset for the first vertex (no previous vertex).
|
|
35
|
+
* @param {number|undefined} nextX Next vertex x-coordinate.
|
|
36
|
+
* Pass undefined if computing the offset for the last vertex (no next vertex).
|
|
37
|
+
* @param {number|undefined} nextY Next vertex y-coordinate.
|
|
38
|
+
* Pass undefined if computing the offset for the last vertex (no next vertex).
|
|
39
|
+
* @param {number} offset Offset distance along the segment normal direction.
|
|
40
|
+
* Positive values offset to the right relative to the direction from previous to next vertex.
|
|
41
|
+
* Negative values offset to the left.
|
|
42
|
+
* @return {import("../../coordinate.js").Coordinate} Offset vertex coordinate as `[x, y]`.
|
|
43
|
+
*/
|
|
44
|
+
export function offsetLineVertex(x: number, y: number, prevX: number | undefined, prevY: number | undefined, nextX: number | undefined, nextY: number | undefined, offset: number): import("../../coordinate.js").Coordinate;
|
|
45
|
+
//# sourceMappingURL=lineoffset.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lineoffset.d.ts","sourceRoot":"","sources":["lineoffset.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;GAgBG;AACH,kDAVW,KAAK,CAAC,MAAM,CAAC,UACb,MAAM,UACN,MAAM,gBAGN,OAAO,SACP,KAAK,CAAC,MAAM,CAAC,sBACb,MAAM,GACL,KAAK,CAAC,MAAM,CAAC,CAqExB;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,oCAfW,MAAM,KACN,MAAM,SACN,MAAM,GAAC,SAAS,SAEhB,MAAM,GAAC,SAAS,SAEhB,MAAM,GAAC,SAAS,SAEhB,MAAM,GAAC,SAAS,UAEhB,MAAM,GAGL,OAAO,qBAAqB,EAAE,UAAU,CA6DnD"}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import {angleBetween} from '../../coordinate.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Offsets a line string to the left / right along its segments direction.
|
|
5
|
+
* Offset is applied to each segment of the line in the direciton of the segment normal (positive offset goes "right" relative to the line direction).
|
|
6
|
+
* For very sharp angles between segments, the function falls back to offsetting along the segment normal direction to avoid excessively long miters.
|
|
7
|
+
*
|
|
8
|
+
* Coordinates and the offset should be in the same units — either pixels or the same spatial reference system as the input line coordinates.
|
|
9
|
+
*
|
|
10
|
+
* @param {Array<number>} flatCoordinates Flat coordinates.
|
|
11
|
+
* @param {number} stride Stride.
|
|
12
|
+
* @param {number} offset Offset distance along the segment normal direction.
|
|
13
|
+
* Positive values offset to the right relative to the direction of the line.
|
|
14
|
+
* Negative values offset to the left.
|
|
15
|
+
* @param {boolean} isClosedRing If coordinates build a closed circle (in this the first and the last coordinate offsets will consider previous / next ring coordinate)
|
|
16
|
+
* @param {Array<number>} [dest] Destination coordinate array. If not provided a new one will be created
|
|
17
|
+
* @param {number} [destinationStride] Stride of destination coordinates. If unspecified, assumed to be same as the source coordinates stride.
|
|
18
|
+
* @return {Array<number>} Result flat coordinates of the offset line.
|
|
19
|
+
*/
|
|
20
|
+
export function offsetLineString(
|
|
21
|
+
flatCoordinates,
|
|
22
|
+
stride,
|
|
23
|
+
offset,
|
|
24
|
+
isClosedRing,
|
|
25
|
+
dest,
|
|
26
|
+
destinationStride,
|
|
27
|
+
) {
|
|
28
|
+
dest = dest ?? [];
|
|
29
|
+
destinationStride = destinationStride ?? stride;
|
|
30
|
+
|
|
31
|
+
const firstPointX = flatCoordinates[0];
|
|
32
|
+
const firstPointY = flatCoordinates[1];
|
|
33
|
+
const secondToLastPointX = flatCoordinates[flatCoordinates.length - 4];
|
|
34
|
+
const secondToLastPointY = flatCoordinates[flatCoordinates.length - 3];
|
|
35
|
+
let x, y, prevX, prevY, nextX, nextY, offsetX, offsetY;
|
|
36
|
+
|
|
37
|
+
let i = 0;
|
|
38
|
+
for (let j = 0; j < flatCoordinates.length; j += stride) {
|
|
39
|
+
// 1. Detect previous and next coordinates of a current vertex
|
|
40
|
+
prevX = x;
|
|
41
|
+
prevY = y;
|
|
42
|
+
nextX = undefined;
|
|
43
|
+
nextY = undefined;
|
|
44
|
+
if (j + stride < flatCoordinates.length) {
|
|
45
|
+
nextX = flatCoordinates[j + stride];
|
|
46
|
+
nextY = flatCoordinates[j + stride + 1];
|
|
47
|
+
}
|
|
48
|
+
// First coordinate of a closed ring -> previous coordinate is the second to last one
|
|
49
|
+
if (isClosedRing && j === 0) {
|
|
50
|
+
prevX = secondToLastPointX;
|
|
51
|
+
prevY = secondToLastPointY;
|
|
52
|
+
}
|
|
53
|
+
// Last coordinate of a closed ring -> next coordinate is the first vertex of a line string
|
|
54
|
+
if (isClosedRing && j === flatCoordinates.length - 2) {
|
|
55
|
+
// last coordinate
|
|
56
|
+
nextX = firstPointX;
|
|
57
|
+
nextY = firstPointY;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// 2. Current vertex to offset
|
|
61
|
+
x = flatCoordinates[j];
|
|
62
|
+
y = flatCoordinates[j + 1];
|
|
63
|
+
|
|
64
|
+
// 3. Offset the vertex
|
|
65
|
+
[offsetX, offsetY] = offsetLineVertex(
|
|
66
|
+
x,
|
|
67
|
+
y,
|
|
68
|
+
prevX,
|
|
69
|
+
prevY,
|
|
70
|
+
nextX,
|
|
71
|
+
nextY,
|
|
72
|
+
offset,
|
|
73
|
+
);
|
|
74
|
+
dest[i++] = offsetX;
|
|
75
|
+
dest[i++] = offsetY;
|
|
76
|
+
|
|
77
|
+
// 4. Copy over other dimension values if any
|
|
78
|
+
for (let k = 2; k < destinationStride; k++) {
|
|
79
|
+
dest[i++] = flatCoordinates[j + k];
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (dest.length != i) {
|
|
84
|
+
dest.length = i;
|
|
85
|
+
}
|
|
86
|
+
return dest;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Computes the offset of a single vertex of a line string.
|
|
91
|
+
*
|
|
92
|
+
* The function calculates a new vertex coordinate offset along the normal/miter direction of the line at this vertex.
|
|
93
|
+
* Offset is applied along the segment normal (positive offset goes "right" relative to the line direction).
|
|
94
|
+
* It handles first and last vertices (caps) as well as joins between two segments (mitering).
|
|
95
|
+
* For very sharp angles, the function falls back to offsetting along the segment normal direction to avoid excessively long miters.
|
|
96
|
+
*
|
|
97
|
+
* Coordinates and the offset should be in the same units — either pixels or the same spatial reference system as the input line coordinates.
|
|
98
|
+
*
|
|
99
|
+
* @param {number} x Vertex x-coordinate.
|
|
100
|
+
* @param {number} y Vertex y-coordinate.
|
|
101
|
+
* @param {number|undefined} prevX Previous vertex x-coordinate.
|
|
102
|
+
* Pass undefined if computing the offset for the first vertex (no previous vertex).
|
|
103
|
+
* @param {number|undefined} prevY Previous vertex y-coordinate.
|
|
104
|
+
* Pass undefined if computing the offset for the first vertex (no previous vertex).
|
|
105
|
+
* @param {number|undefined} nextX Next vertex x-coordinate.
|
|
106
|
+
* Pass undefined if computing the offset for the last vertex (no next vertex).
|
|
107
|
+
* @param {number|undefined} nextY Next vertex y-coordinate.
|
|
108
|
+
* Pass undefined if computing the offset for the last vertex (no next vertex).
|
|
109
|
+
* @param {number} offset Offset distance along the segment normal direction.
|
|
110
|
+
* Positive values offset to the right relative to the direction from previous to next vertex.
|
|
111
|
+
* Negative values offset to the left.
|
|
112
|
+
* @return {import("../../coordinate.js").Coordinate} Offset vertex coordinate as `[x, y]`.
|
|
113
|
+
*/
|
|
114
|
+
export function offsetLineVertex(x, y, prevX, prevY, nextX, nextY, offset) {
|
|
115
|
+
// Compute segment direction
|
|
116
|
+
let nx, ny;
|
|
117
|
+
if (prevX !== undefined && prevY !== undefined) {
|
|
118
|
+
nx = x - prevX;
|
|
119
|
+
ny = y - prevY;
|
|
120
|
+
} else if (nextX !== undefined && nextY !== undefined) {
|
|
121
|
+
nx = nextX - x;
|
|
122
|
+
ny = nextY - y;
|
|
123
|
+
} else {
|
|
124
|
+
// no next, no previous point given -> just assume some default (horizontal) direction
|
|
125
|
+
nx = 1;
|
|
126
|
+
ny = 0;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Normalize -> tangent
|
|
130
|
+
const len = Math.hypot(nx, ny);
|
|
131
|
+
const tx = nx / len;
|
|
132
|
+
const ty = ny / len;
|
|
133
|
+
|
|
134
|
+
// Rotate tangent 90° -> normal
|
|
135
|
+
nx = -ty;
|
|
136
|
+
ny = tx;
|
|
137
|
+
|
|
138
|
+
// First / last vertex -> offset the point in the direction of the normal vector
|
|
139
|
+
if (prevX === undefined || prevY === undefined) {
|
|
140
|
+
return [x + nx * offset, y + ny * offset];
|
|
141
|
+
}
|
|
142
|
+
if (nextX === undefined || nextY === undefined) {
|
|
143
|
+
return [x + nx * offset, y + ny * offset];
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// Compute join angle - angle between 2 segments of the vertex.
|
|
147
|
+
const joinAngle = angleBetween([x, y], [prevX, prevY], [nextX, nextY]);
|
|
148
|
+
|
|
149
|
+
// Avoid huge or infinite miter joins for very sharp angles, offset in the segment direction in this case.
|
|
150
|
+
if (Math.cos(joinAngle) > 0.998) {
|
|
151
|
+
return [x + tx * offset, y + ty * offset];
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// Compute join offset direction.
|
|
155
|
+
// We rotate the normal vector by half of the join angle.
|
|
156
|
+
// This gives the direction of the miter at the vertex.
|
|
157
|
+
const cos = Math.cos(joinAngle / 2);
|
|
158
|
+
const sin = Math.sin(joinAngle / 2);
|
|
159
|
+
|
|
160
|
+
// Rotate the normal vector (nx, ny) by half of the join angle.
|
|
161
|
+
// bx/by = bisector direction before normalization
|
|
162
|
+
const bx = sin * nx + cos * ny;
|
|
163
|
+
const by = -cos * nx + sin * ny;
|
|
164
|
+
|
|
165
|
+
// Scale the bisector so that moving along it preserves the correct offset distance.
|
|
166
|
+
// Dividing by sin(half of angle) converts the bisector into the true miter vector.
|
|
167
|
+
// (This expands the miter for sharp angles and shortens it for wide ones.)
|
|
168
|
+
const dx = bx * (1 / sin);
|
|
169
|
+
const dy = by * (1 / sin);
|
|
170
|
+
|
|
171
|
+
// Offset final vertex along miter direction
|
|
172
|
+
return [x + dx * offset, y + dy * offset];
|
|
173
|
+
}
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Builder.d.ts","sourceRoot":"","sources":["Builder.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"Builder.d.ts","sourceRoot":"","sources":["Builder.js"],"names":[],"mappings":";AA+BA;IACE;;;;;OAKG;IACH,uBALW,MAAM,aACN,OAAO,iBAAiB,EAAE,MAAM,cAChC,MAAM,cACN,MAAM,EAoFhB;IA/EC;;;OAGG;IACH,qBAFU,MAAM,CAEU;IAE1B;;;;OAIG;IACH,qBAFU,OAAO,iBAAiB,EAAE,MAAM,CAEhB;IAE1B;;;OAGG;IACH,sBAFU,MAAM,CAEY;IAE5B;;;OAGG;IACH,wBAFU,MAAM,CAEK;IAErB;;;;OAIG;IACH,sBAFU,MAAM,CAEY;IAE5B;;;OAGG;IACH,mCAAsC;IAEtC;;;OAGG;IACH,mCAAsC;IAEtC;;;OAGG;IACH,2BAA8B;IAE9B;;;OAGG;IACH,wBAFU,KAAK,CAAC,GAAC,CAAC,CAEI;IAEtB;;;OAGG;IACH,uBAFU,KAAK,CAAC,MAAM,CAAC,CAEF;IAErB;;;OAGG;IACH,uBAAwB;IAExB;;;OAGG;IACH,oCAFU,KAAK,CAAC,GAAC,CAAC,CAEgB;IAElC;;;OAGG;IACH,iBAFU,OAAO,cAAc,EAAE,eAAe,CAEuB;IAGzE;;;;OAIG;IACH,qCAHW,KAAK,CAAC,MAAM,CAAC,GACZ,KAAK,CAAC,MAAM,CAAC,CASxB;IAED;;;;;OAKG;IACH,sDALW,KAAK,CAAC,MAAM,CAAC,UACb,MAAM,GAEL,MAAM,CAgBjB;IAED;;;;;;;;;OASG;IACH,qDATW,KAAK,CAAC,MAAM,CAAC,UACb,MAAM,OACN,MAAM,UACN,MAAM,UACN,OAAO,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WAAW,QAUhD;IAED;;;;;;OAMG;IACH,kCAHY,OAAO,iBAAiB,EAAE,MAAM,CAY3C;CACF;0BA5qByB,qBAAqB"}
|
package/render/canvas/Builder.js
CHANGED
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
defaultLineJoin,
|
|
25
25
|
defaultLineWidth,
|
|
26
26
|
defaultMiterLimit,
|
|
27
|
+
defaultStrokeOffset,
|
|
27
28
|
defaultStrokeStyle,
|
|
28
29
|
} from '../canvas.js';
|
|
29
30
|
import CanvasInstruction from './Instruction.js';
|
|
@@ -549,6 +550,8 @@ class CanvasBuilder extends VectorContext {
|
|
|
549
550
|
strokeStyleMiterLimit !== undefined
|
|
550
551
|
? strokeStyleMiterLimit
|
|
551
552
|
: defaultMiterLimit;
|
|
553
|
+
const strokeStyleOffset = strokeStyle.getOffset();
|
|
554
|
+
state.strokeOffset = strokeStyleOffset ?? defaultStrokeOffset;
|
|
552
555
|
|
|
553
556
|
if (state.lineWidth > this.maxLineWidth) {
|
|
554
557
|
this.maxLineWidth = state.lineWidth;
|
|
@@ -563,6 +566,7 @@ class CanvasBuilder extends VectorContext {
|
|
|
563
566
|
state.lineJoin = undefined;
|
|
564
567
|
state.lineWidth = undefined;
|
|
565
568
|
state.miterLimit = undefined;
|
|
569
|
+
state.strokeOffset = undefined;
|
|
566
570
|
}
|
|
567
571
|
return state;
|
|
568
572
|
}
|
|
@@ -641,6 +645,7 @@ class CanvasBuilder extends VectorContext {
|
|
|
641
645
|
const lineJoin = state.lineJoin;
|
|
642
646
|
const lineWidth = state.lineWidth;
|
|
643
647
|
const miterLimit = state.miterLimit;
|
|
648
|
+
const strokeOffset = state.strokeOffset;
|
|
644
649
|
if (
|
|
645
650
|
state.currentStrokeStyle != strokeStyle ||
|
|
646
651
|
state.currentLineCap != lineCap ||
|
|
@@ -649,7 +654,8 @@ class CanvasBuilder extends VectorContext {
|
|
|
649
654
|
state.currentLineDashOffset != lineDashOffset ||
|
|
650
655
|
state.currentLineJoin != lineJoin ||
|
|
651
656
|
state.currentLineWidth != lineWidth ||
|
|
652
|
-
state.currentMiterLimit != miterLimit
|
|
657
|
+
state.currentMiterLimit != miterLimit ||
|
|
658
|
+
state.currentStrokeOffset != strokeOffset
|
|
653
659
|
) {
|
|
654
660
|
applyStroke.call(this, state);
|
|
655
661
|
state.currentStrokeStyle = strokeStyle;
|
|
@@ -659,6 +665,7 @@ class CanvasBuilder extends VectorContext {
|
|
|
659
665
|
state.currentLineJoin = lineJoin;
|
|
660
666
|
state.currentLineWidth = lineWidth;
|
|
661
667
|
state.currentMiterLimit = miterLimit;
|
|
668
|
+
state.currentStrokeOffset = strokeOffset;
|
|
662
669
|
}
|
|
663
670
|
}
|
|
664
671
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Executor.d.ts","sourceRoot":"","sources":["Executor.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"Executor.d.ts","sourceRoot":"","sources":["Executor.js"],"names":[],"mappings":";6BA4Ba,OAAO,wBAAwB,EAAE,KAAK,CAAC,OAAO,kBAAkB,EAAE,WAAW,CAAC;;;;;gBAK7E,MAAM;;;;gBACN,MAAM;;;;gBACN,MAAM;;;;gBACN,MAAM;;;;aACN,MAAM;;;;aACN,MAAM;;;;WACN,KAAK,CAAC,MAAM,CAAC;;;;kBACb,cAAc;;;;qBACd,OAAO,oBAAoB,EAAE,SAAS;;qCAIvC;IAAC,CAAC,EAAE,wBAAwB,GAAC,iCAAiC,CAAC;IAAC,CAAC,EAAE,OAAO,eAAe,EAAE,IAAI,CAAC;IAAC,CAAC,EAAE,OAAO,cAAc,EAAE,KAAK,GAAC,gBAAgB,GAAC,iBAAiB,GAAC,gBAAgB,CAAC;IAAC,CAAC,EAAE,sBAAsB,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,KAAK,CAAC,GAAC,CAAC,CAAC;IAAC,CAAC,EAAE,KAAK,CAAC,GAAC,CAAC,CAAA;CAAC;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vC;IAED;;;;;;;;OAQG;IACH,+BARW,wBAAwB,MACxB,OAAO,qBAAqB,EAAE,UAAU,MACxC,OAAO,qBAAqB,EAAE,UAAU,MACxC,OAAO,qBAAqB,EAAE,UAAU,MACxC,OAAO,qBAAqB,EAAE,UAAU,mBACxC,KAAK,CAAC,GAAC,CAAC,qBACR,KAAK,CAAC,GAAC,CAAC,QA6BlB;IAED;;;;;;;;;;;;;;;;;;;OAmBG;IACH,yCA+FC;IAED;;;;;;;;;;OAUG;IACH,4BAgDC;IAED;;;OAGG;IACH,cAeC;IAED;;;;OAIG;IACH,wBAYC;IAED;;;;;;;OAOG;IACH,qCA2BC;IAED;;;;;;;;;;;;;OAaG;IACH,iBAonBC;IAED;;;;;;;OAOG;IACH,iBAPW,wBAAwB,GAAC,iCAAiC,oBAC1D,OAAO,eAAe,EAAE,IAAI,aAC5B,OAAO,oBAAoB,EAAE,SAAS,gBACtC,MAAM,eACN,OAAO,kBACP,OAAO,OAAO,EAAE,OAAO,CAAC,cAAc,CAAC,QAqBjD;IAED;;;;;;;;;OASG;IACH,oBAFa,CAAC,WAPH,wBAAwB,GAAC,iCAAiC,aAC1D,OAAO,oBAAoB,EAAE,SAAS,gBACtC,MAAM,oBACN,eAAe,CAAC,CAAC,CAAC,cAClB,OAAO,iBAAiB,EAAE,MAAM,GAE/B,CAAC,GAAC,SAAS,CAoBtB;CACF;0BAn0CyB,4BAA4B"}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import {equals} from '../../array.js';
|
|
5
5
|
import {createEmpty, createOrUpdate, intersects} from '../../extent.js';
|
|
6
6
|
import {lineStringLength} from '../../geom/flat/length.js';
|
|
7
|
+
import {offsetLineVertex} from '../../geom/flat/lineoffset.js';
|
|
7
8
|
import {drawTextOnPath} from '../../geom/flat/textpath.js';
|
|
8
9
|
import {transform2D} from '../../geom/flat/transform.js';
|
|
9
10
|
import {
|
|
@@ -707,6 +708,9 @@ class Executor {
|
|
|
707
708
|
let dd; // end of per-instruction data
|
|
708
709
|
let anchorX,
|
|
709
710
|
anchorY,
|
|
711
|
+
lineOffsetPx,
|
|
712
|
+
/** @type {boolean} */ isClosedRing,
|
|
713
|
+
/** @type {number} */ dStart,
|
|
710
714
|
/** @type {import('../../style/Style.js').DeclutterMode} */
|
|
711
715
|
declutterMode,
|
|
712
716
|
prevX,
|
|
@@ -781,10 +785,11 @@ class Executor {
|
|
|
781
785
|
break;
|
|
782
786
|
case CanvasInstruction.CIRCLE:
|
|
783
787
|
d = /** @type {number} */ (instruction[1]);
|
|
788
|
+
lineOffsetPx = /** @type {number} */ instruction[2] ?? 0;
|
|
784
789
|
const x1 = pixelCoordinates[d];
|
|
785
790
|
const y1 = pixelCoordinates[d + 1];
|
|
786
|
-
const x2 = pixelCoordinates[d + 2];
|
|
787
|
-
const y2 = pixelCoordinates[d + 3];
|
|
791
|
+
const x2 = pixelCoordinates[d + 2] - lineOffsetPx;
|
|
792
|
+
const y2 = pixelCoordinates[d + 3] - lineOffsetPx;
|
|
788
793
|
const dx = x2 - x1;
|
|
789
794
|
const dy = y2 - y1;
|
|
790
795
|
const r = Math.sqrt(dx * dx + dy * dy);
|
|
@@ -1192,8 +1197,25 @@ class Executor {
|
|
|
1192
1197
|
case CanvasInstruction.MOVE_TO_LINE_TO:
|
|
1193
1198
|
d = /** @type {number} */ (instruction[1]);
|
|
1194
1199
|
dd = /** @type {number} */ (instruction[2]);
|
|
1200
|
+
lineOffsetPx = /** @type {number|undefined} */ (instruction[3]);
|
|
1201
|
+
isClosedRing =
|
|
1202
|
+
/** @type {boolean|undefined} */ (instruction[4]) ?? false;
|
|
1195
1203
|
x = pixelCoordinates[d];
|
|
1196
1204
|
y = pixelCoordinates[d + 1];
|
|
1205
|
+
|
|
1206
|
+
if (lineOffsetPx) {
|
|
1207
|
+
dStart = d;
|
|
1208
|
+
[x, y] = offsetLineVertex(
|
|
1209
|
+
x,
|
|
1210
|
+
y,
|
|
1211
|
+
isClosedRing ? pixelCoordinates[dd - 4] : undefined,
|
|
1212
|
+
isClosedRing ? pixelCoordinates[dd - 3] : undefined,
|
|
1213
|
+
pixelCoordinates[d + 2],
|
|
1214
|
+
pixelCoordinates[d + 3],
|
|
1215
|
+
lineOffsetPx,
|
|
1216
|
+
);
|
|
1217
|
+
}
|
|
1218
|
+
|
|
1197
1219
|
context.moveTo(x, y);
|
|
1198
1220
|
prevX = (x + 0.5) | 0;
|
|
1199
1221
|
prevY = (y + 0.5) | 0;
|
|
@@ -1203,6 +1225,31 @@ class Executor {
|
|
|
1203
1225
|
roundX = (x + 0.5) | 0;
|
|
1204
1226
|
roundY = (y + 0.5) | 0;
|
|
1205
1227
|
if (d == dd - 2 || roundX !== prevX || roundY !== prevY) {
|
|
1228
|
+
if (lineOffsetPx) {
|
|
1229
|
+
if (d == dd - 2) {
|
|
1230
|
+
// last coordinate
|
|
1231
|
+
[x, y] = offsetLineVertex(
|
|
1232
|
+
x,
|
|
1233
|
+
y,
|
|
1234
|
+
pixelCoordinates[d - 2],
|
|
1235
|
+
pixelCoordinates[d - 1],
|
|
1236
|
+
isClosedRing ? pixelCoordinates[dStart + 2] : undefined,
|
|
1237
|
+
isClosedRing ? pixelCoordinates[dStart + 3] : undefined,
|
|
1238
|
+
lineOffsetPx,
|
|
1239
|
+
);
|
|
1240
|
+
} else {
|
|
1241
|
+
[x, y] = offsetLineVertex(
|
|
1242
|
+
x,
|
|
1243
|
+
y,
|
|
1244
|
+
pixelCoordinates[d - 2],
|
|
1245
|
+
pixelCoordinates[d - 1],
|
|
1246
|
+
pixelCoordinates[d + 2],
|
|
1247
|
+
pixelCoordinates[d + 3],
|
|
1248
|
+
lineOffsetPx,
|
|
1249
|
+
);
|
|
1250
|
+
}
|
|
1251
|
+
}
|
|
1252
|
+
|
|
1206
1253
|
context.lineTo(x, y);
|
|
1207
1254
|
prevX = roundX;
|
|
1208
1255
|
prevY = roundY;
|
|
@@ -216,6 +216,7 @@ declare class CanvasImmediateRenderer extends VectorContext {
|
|
|
216
216
|
* @param {number} end End.
|
|
217
217
|
* @param {number} stride Stride.
|
|
218
218
|
* @param {boolean} close Close.
|
|
219
|
+
* @param {number} [strokeOffset] Stroke Offset.
|
|
219
220
|
* @private
|
|
220
221
|
* @return {number} end End.
|
|
221
222
|
*/
|
|
@@ -225,6 +226,7 @@ declare class CanvasImmediateRenderer extends VectorContext {
|
|
|
225
226
|
* @param {number} offset Offset.
|
|
226
227
|
* @param {Array<number>} ends Ends.
|
|
227
228
|
* @param {number} stride Stride.
|
|
229
|
+
* @param {number} [strokeOffset] Stroke Offset.
|
|
228
230
|
* @private
|
|
229
231
|
* @return {number} End.
|
|
230
232
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Immediate.d.ts","sourceRoot":"","sources":["Immediate.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"Immediate.d.ts","sourceRoot":"","sources":["Immediate.js"],"names":[],"mappings":";AAiCA;;;;;;;;GAQG;AACH;IACE;;;;;;;;OAQG;IACH,qBARW,wBAAwB,GAAC,iCAAiC,cAC1D,MAAM,UACN,OAAO,iBAAiB,EAAE,MAAM,aAChC,OAAO,oBAAoB,EAAE,SAAS,gBACtC,MAAM,qBACN,MAAM,kBACN,OAAO,eAAe,EAAE,iBAAiB,EAgOnD;IAnNC;;;OAGG;IACH,iBAAuB;IAEvB;;;OAGG;IACH,oBAA6B;IAE7B;;;OAGG;IACH,gBAAqB;IAErB;;;OAGG;IACH,mBAA2B;IAE3B;;;OAGG;IACH,2BAEK;IAEL;;;OAGG;IACH,sBAAiC;IAEjC;;;OAGG;IACH,0BAAyC;IAEzC;;;OAGG;IACH,uBAAmC;IAEnC;;;OAGG;IACH,0BAA6B;IAE7B;;;OAGG;IACH,4BAA+B;IAE/B;;;OAGG;IACH,0BAA6B;IAE7B;;;OAGG;IACH,mBAAsB;IAEtB;;;OAGG;IACH,qBAAwB;IAExB;;;OAGG;IACH,eAAkB;IAElB;;;OAGG;IACH,sBAAsB;IAEtB;;;O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e,EAAE,OAAO,QAoBpF;IAED;;;;;;OAMG;IACH,kCAHW,OAAO,0BAA0B,EAAE,OAAO,GAAC,OAAO,eAAe,EAAE,OAAO,QAkCpF;IAED;;;;;;OAMG;IACH,uCAHW,OAAO,+BAA+B,EAAE,OAAO,GAAC,OAAO,eAAe,EAAE,OAAO,QAyCzF;IAED;;;;;;OAMG;IACH,+BAHW,OAAO,uBAAuB,EAAE,OAAO,GAAC,OAAO,eAAe,EAAE,OAAO,QA0CjF;IAED;;;;;OAKG;IACH,oCAHW,OAAO,4BAA4B,EAAE,OAAO,QAiDtD;IAED;;;OAGG;IACH,6BAcC;IAED;;;OAGG;IACH,+BAmDC;IAED;;;OAGG;IACH,6BA6BC;IAoED;;;;;;OAMG;IACH,mCAHW,OAAO,sBAAsB,EAAE,OAAO,QA2BhD;IAED;;;;;;OAMG;IACH,iCAHW,OAAO,qBAAqB,EAAE,OAAO,QA8F/C;CACF;0BA/qCyB,qBAAqB"}
|
|
@@ -9,6 +9,7 @@ import {equals} from '../../array.js';
|
|
|
9
9
|
import {asColorLike} from '../../colorlike.js';
|
|
10
10
|
import {intersects} from '../../extent.js';
|
|
11
11
|
import {transformGeom2D} from '../../geom/SimpleGeometry.js';
|
|
12
|
+
import {offsetLineString} from '../../geom/flat/lineoffset.js';
|
|
12
13
|
import {transform2D} from '../../geom/flat/transform.js';
|
|
13
14
|
import {toFixed} from '../../math.js';
|
|
14
15
|
import {
|
|
@@ -431,12 +432,13 @@ class CanvasImmediateRenderer extends VectorContext {
|
|
|
431
432
|
* @param {number} end End.
|
|
432
433
|
* @param {number} stride Stride.
|
|
433
434
|
* @param {boolean} close Close.
|
|
435
|
+
* @param {number} [strokeOffset] Stroke Offset.
|
|
434
436
|
* @private
|
|
435
437
|
* @return {number} end End.
|
|
436
438
|
*/
|
|
437
|
-
moveToLineTo_(flatCoordinates, offset, end, stride, close) {
|
|
439
|
+
moveToLineTo_(flatCoordinates, offset, end, stride, close, strokeOffset) {
|
|
438
440
|
const context = this.context_;
|
|
439
|
-
|
|
441
|
+
let pixelCoordinates = transform2D(
|
|
440
442
|
flatCoordinates,
|
|
441
443
|
offset,
|
|
442
444
|
end,
|
|
@@ -444,6 +446,15 @@ class CanvasImmediateRenderer extends VectorContext {
|
|
|
444
446
|
this.transform_,
|
|
445
447
|
this.pixelCoordinates_,
|
|
446
448
|
);
|
|
449
|
+
if (Math.abs(strokeOffset) > 0) {
|
|
450
|
+
pixelCoordinates = offsetLineString(
|
|
451
|
+
pixelCoordinates,
|
|
452
|
+
stride,
|
|
453
|
+
strokeOffset,
|
|
454
|
+
close,
|
|
455
|
+
pixelCoordinates,
|
|
456
|
+
);
|
|
457
|
+
}
|
|
447
458
|
context.moveTo(pixelCoordinates[0], pixelCoordinates[1]);
|
|
448
459
|
let length = pixelCoordinates.length;
|
|
449
460
|
if (close) {
|
|
@@ -463,10 +474,11 @@ class CanvasImmediateRenderer extends VectorContext {
|
|
|
463
474
|
* @param {number} offset Offset.
|
|
464
475
|
* @param {Array<number>} ends Ends.
|
|
465
476
|
* @param {number} stride Stride.
|
|
477
|
+
* @param {number} [strokeOffset] Stroke Offset.
|
|
466
478
|
* @private
|
|
467
479
|
* @return {number} End.
|
|
468
480
|
*/
|
|
469
|
-
drawRings_(flatCoordinates, offset, ends, stride) {
|
|
481
|
+
drawRings_(flatCoordinates, offset, ends, stride, strokeOffset) {
|
|
470
482
|
for (let i = 0, ii = ends.length; i < ii; ++i) {
|
|
471
483
|
offset = this.moveToLineTo_(
|
|
472
484
|
flatCoordinates,
|
|
@@ -474,6 +486,7 @@ class CanvasImmediateRenderer extends VectorContext {
|
|
|
474
486
|
ends[i],
|
|
475
487
|
stride,
|
|
476
488
|
true,
|
|
489
|
+
strokeOffset,
|
|
477
490
|
);
|
|
478
491
|
}
|
|
479
492
|
return offset;
|
|
@@ -733,6 +746,7 @@ class CanvasImmediateRenderer extends VectorContext {
|
|
|
733
746
|
flatCoordinates.length,
|
|
734
747
|
geometry.getStride(),
|
|
735
748
|
false,
|
|
749
|
+
this.strokeState_.strokeOffset,
|
|
736
750
|
);
|
|
737
751
|
context.stroke();
|
|
738
752
|
}
|
|
@@ -778,6 +792,7 @@ class CanvasImmediateRenderer extends VectorContext {
|
|
|
778
792
|
ends[i],
|
|
779
793
|
stride,
|
|
780
794
|
false,
|
|
795
|
+
this.strokeState_.strokeOffset,
|
|
781
796
|
);
|
|
782
797
|
}
|
|
783
798
|
context.stroke();
|
|
@@ -821,6 +836,7 @@ class CanvasImmediateRenderer extends VectorContext {
|
|
|
821
836
|
0,
|
|
822
837
|
/** @type {Array<number>} */ (geometry.getEnds()),
|
|
823
838
|
geometry.getStride(),
|
|
839
|
+
this.strokeState_?.strokeOffset,
|
|
824
840
|
);
|
|
825
841
|
if (this.fillState_) {
|
|
826
842
|
context.fill();
|
|
@@ -868,7 +884,13 @@ class CanvasImmediateRenderer extends VectorContext {
|
|
|
868
884
|
context.beginPath();
|
|
869
885
|
for (let i = 0, ii = endss.length; i < ii; ++i) {
|
|
870
886
|
const ends = endss[i];
|
|
871
|
-
offset = this.drawRings_(
|
|
887
|
+
offset = this.drawRings_(
|
|
888
|
+
flatCoordinates,
|
|
889
|
+
offset,
|
|
890
|
+
ends,
|
|
891
|
+
stride,
|
|
892
|
+
this.strokeState_?.strokeOffset,
|
|
893
|
+
);
|
|
872
894
|
}
|
|
873
895
|
if (this.fillState_) {
|
|
874
896
|
context.fill();
|
|
@@ -1027,6 +1049,7 @@ class CanvasImmediateRenderer extends VectorContext {
|
|
|
1027
1049
|
const lineDash = strokeStyleLineDash
|
|
1028
1050
|
? strokeStyleLineDash
|
|
1029
1051
|
: defaultLineDash;
|
|
1052
|
+
const strokeOffset = strokeStyle.getOffset();
|
|
1030
1053
|
this.strokeState_ = {
|
|
1031
1054
|
lineCap:
|
|
1032
1055
|
strokeStyleLineCap !== undefined
|
|
@@ -1055,6 +1078,7 @@ class CanvasImmediateRenderer extends VectorContext {
|
|
|
1055
1078
|
strokeStyle: asColorLike(
|
|
1056
1079
|
strokeStyleColor ? strokeStyleColor : defaultStrokeStyle,
|
|
1057
1080
|
),
|
|
1081
|
+
strokeOffset: (strokeOffset ?? 0) * this.pixelRatio_,
|
|
1058
1082
|
};
|
|
1059
1083
|
}
|
|
1060
1084
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LineStringBuilder.d.ts","sourceRoot":"","sources":["LineStringBuilder.js"],"names":[],"mappings":";AAUA;IAWE
|
|
1
|
+
{"version":3,"file":"LineStringBuilder.d.ts","sourceRoot":"","sources":["LineStringBuilder.js"],"names":[],"mappings":";AAUA;IAWE;;;;;;;;OAQG;IACH,6BAuBC;CAyHF;0BA1KyB,cAAc"}
|
|
@@ -24,10 +24,11 @@ class CanvasLineStringBuilder extends CanvasBuilder {
|
|
|
24
24
|
* @param {number} offset Offset.
|
|
25
25
|
* @param {number} end End.
|
|
26
26
|
* @param {number} stride Stride.
|
|
27
|
+
* @param {number} [strokeOffset] Stroke Offset in pixels.
|
|
27
28
|
* @private
|
|
28
29
|
* @return {number} end.
|
|
29
30
|
*/
|
|
30
|
-
drawFlatCoordinates_(flatCoordinates, offset, end, stride) {
|
|
31
|
+
drawFlatCoordinates_(flatCoordinates, offset, end, stride, strokeOffset) {
|
|
31
32
|
const myBegin = this.coordinates.length;
|
|
32
33
|
const myEnd = this.appendFlatLineCoordinates(
|
|
33
34
|
flatCoordinates,
|
|
@@ -37,13 +38,18 @@ class CanvasLineStringBuilder extends CanvasBuilder {
|
|
|
37
38
|
false,
|
|
38
39
|
false,
|
|
39
40
|
);
|
|
40
|
-
|
|
41
|
+
this.instructions.push([
|
|
41
42
|
CanvasInstruction.MOVE_TO_LINE_TO,
|
|
42
43
|
myBegin,
|
|
43
44
|
myEnd,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
this.hitDetectionInstructions.push(
|
|
45
|
+
strokeOffset * this.pixelRatio,
|
|
46
|
+
]);
|
|
47
|
+
this.hitDetectionInstructions.push([
|
|
48
|
+
CanvasInstruction.MOVE_TO_LINE_TO,
|
|
49
|
+
myBegin,
|
|
50
|
+
myEnd,
|
|
51
|
+
strokeOffset,
|
|
52
|
+
]);
|
|
47
53
|
return end;
|
|
48
54
|
}
|
|
49
55
|
|
|
@@ -57,6 +63,7 @@ class CanvasLineStringBuilder extends CanvasBuilder {
|
|
|
57
63
|
const state = this.state;
|
|
58
64
|
const strokeStyle = state.strokeStyle;
|
|
59
65
|
const lineWidth = state.lineWidth;
|
|
66
|
+
const strokeOffset = state.strokeOffset;
|
|
60
67
|
if (strokeStyle === undefined || lineWidth === undefined) {
|
|
61
68
|
return;
|
|
62
69
|
}
|
|
@@ -82,6 +89,7 @@ class CanvasLineStringBuilder extends CanvasBuilder {
|
|
|
82
89
|
0,
|
|
83
90
|
flatCoordinates.length,
|
|
84
91
|
stride,
|
|
92
|
+
strokeOffset,
|
|
85
93
|
);
|
|
86
94
|
this.hitDetectionInstructions.push(strokeInstruction);
|
|
87
95
|
this.endGeometry(feature);
|
|
@@ -5,6 +5,7 @@ declare class CanvasPolygonBuilder extends CanvasBuilder {
|
|
|
5
5
|
* @param {number} offset Offset.
|
|
6
6
|
* @param {Array<number>} ends Ends.
|
|
7
7
|
* @param {number} stride Stride.
|
|
8
|
+
* @param {number} [strokeOffset] Stroke Offset in pixels.
|
|
8
9
|
* @private
|
|
9
10
|
* @return {number} End.
|
|
10
11
|
*/
|
|
@@ -13,6 +14,7 @@ declare class CanvasPolygonBuilder extends CanvasBuilder {
|
|
|
13
14
|
* @private
|
|
14
15
|
*/
|
|
15
16
|
private setFillStrokeStyles_;
|
|
17
|
+
handleStrokeOffset_(drawGeometryCallback: any): boolean;
|
|
16
18
|
}
|
|
17
19
|
import CanvasBuilder from './Builder.js';
|
|
18
20
|
//# sourceMappingURL=PolygonBuilder.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PolygonBuilder.d.ts","sourceRoot":"","sources":["PolygonBuilder.js"],"names":[],"mappings":";AAiBA;IAWE
|
|
1
|
+
{"version":3,"file":"PolygonBuilder.d.ts","sourceRoot":"","sources":["PolygonBuilder.js"],"names":[],"mappings":";AAiBA;IAWE;;;;;;;;OAQG;IACH,8BAiDC;IA0MD;;OAEG;IACH,6BAIC;IAED,wDA4BC;CACF;0BA7TyB,cAAc"}
|