@mapwhit/tilerenderer 1.1.0 → 1.2.0
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/build/min/package.json +1 -1
- package/package.json +5 -5
- package/src/data/bucket/circle_bucket.js +3 -8
- package/src/data/bucket/fill_bucket.js +4 -17
- package/src/data/bucket/fill_extrusion_bucket.js +4 -15
- package/src/data/bucket/line_bucket.js +4 -17
- package/src/data/bucket/pattern_bucket_features.js +4 -4
- package/src/data/bucket/symbol_bucket.js +4 -8
- package/src/data/feature_index.js +1 -1
- package/src/source/geojson_source.js +4 -3
- package/src/source/geojson_worker_source.js +26 -10
- package/src/source/load_tilejson.js +18 -6
- package/src/source/raster_tile_source.js +4 -5
- package/src/source/source_cache.js +9 -2
- package/src/source/tile.js +3 -0
- package/src/source/vector_tile_source.js +4 -6
- package/src/source/vector_tile_worker_source.js +6 -26
- package/src/source/worker_tile.js +67 -53
- package/src/style/create_style_layer.js +2 -2
- package/src/style/evaluation_parameters.js +0 -2
- package/src/style/properties.js +24 -15
- package/src/style/style.js +25 -10
- package/src/style/style_layer/background_style_layer.js +2 -2
- package/src/style/style_layer/circle_style_layer.js +3 -3
- package/src/style/style_layer/fill_extrusion_style_layer.js +3 -3
- package/src/style/style_layer/fill_style_layer.js +3 -3
- package/src/style/style_layer/heatmap_style_layer.js +3 -3
- package/src/style/style_layer/hillshade_style_layer.js +3 -3
- package/src/style/style_layer/line_style_layer.js +3 -3
- package/src/style/style_layer/raster_style_layer.js +2 -2
- package/src/style/style_layer/symbol_style_layer.js +2 -2
- package/src/style/style_layer.js +28 -7
- package/src/style-spec/feature_filter/index.js +7 -5
- package/src/style-spec/reference/v8.json +68 -9
- package/src/style-spec/visibility.js +37 -0
- package/src/symbol/collision_index.js +2 -2
- package/src/symbol/symbol_layout.js +1 -1
- package/src/ui/map.js +11 -4
- package/src/util/classify_rings.js +1 -1
- package/src/util/group_layers.js +1 -1
- package/src/util/object.js +0 -45
- package/src/util/util.js +0 -55
- package/src/util/async.js +0 -29
- package/src/util/find_pole_of_inaccessibility.js +0 -144
- package/src/util/intersection_tests.js +0 -245
|
@@ -1,245 +0,0 @@
|
|
|
1
|
-
import Point from '@mapbox/point-geometry';
|
|
2
|
-
import { isCounterClockwise } from './util.js';
|
|
3
|
-
|
|
4
|
-
export function polygonIntersectsPolygon(polygonA, polygonB) {
|
|
5
|
-
for (let i = 0; i < polygonA.length; i++) {
|
|
6
|
-
if (polygonContainsPoint(polygonB, polygonA[i])) {
|
|
7
|
-
return true;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
for (let i = 0; i < polygonB.length; i++) {
|
|
12
|
-
if (polygonContainsPoint(polygonA, polygonB[i])) {
|
|
13
|
-
return true;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
if (lineIntersectsLine(polygonA, polygonB)) {
|
|
18
|
-
return true;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function polygonIntersectsBufferedPoint(polygon, point, radius) {
|
|
25
|
-
if (polygonContainsPoint(polygon, point)) {
|
|
26
|
-
return true;
|
|
27
|
-
}
|
|
28
|
-
if (pointIntersectsBufferedLine(point, polygon, radius)) {
|
|
29
|
-
return true;
|
|
30
|
-
}
|
|
31
|
-
return false;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export function polygonIntersectsMultiPolygon(polygon, multiPolygon) {
|
|
35
|
-
if (polygon.length === 1) {
|
|
36
|
-
return multiPolygonContainsPoint(multiPolygon, polygon[0]);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
for (let m = 0; m < multiPolygon.length; m++) {
|
|
40
|
-
const ring = multiPolygon[m];
|
|
41
|
-
for (let n = 0; n < ring.length; n++) {
|
|
42
|
-
if (polygonContainsPoint(polygon, ring[n])) {
|
|
43
|
-
return true;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
for (let i = 0; i < polygon.length; i++) {
|
|
49
|
-
if (multiPolygonContainsPoint(multiPolygon, polygon[i])) {
|
|
50
|
-
return true;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
for (let k = 0; k < multiPolygon.length; k++) {
|
|
55
|
-
if (lineIntersectsLine(polygon, multiPolygon[k])) {
|
|
56
|
-
return true;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return false;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export function polygonIntersectsBufferedMultiLine(polygon, multiLine, radius) {
|
|
64
|
-
for (let i = 0; i < multiLine.length; i++) {
|
|
65
|
-
const line = multiLine[i];
|
|
66
|
-
|
|
67
|
-
if (polygon.length >= 3) {
|
|
68
|
-
for (let k = 0; k < line.length; k++) {
|
|
69
|
-
if (polygonContainsPoint(polygon, line[k])) {
|
|
70
|
-
return true;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
if (lineIntersectsBufferedLine(polygon, line, radius)) {
|
|
76
|
-
return true;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
return false;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
function lineIntersectsBufferedLine(lineA, lineB, radius) {
|
|
83
|
-
if (lineA.length > 1) {
|
|
84
|
-
if (lineIntersectsLine(lineA, lineB)) {
|
|
85
|
-
return true;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// Check whether any point in either line is within radius of the other line
|
|
89
|
-
for (let j = 0; j < lineB.length; j++) {
|
|
90
|
-
if (pointIntersectsBufferedLine(lineB[j], lineA, radius)) {
|
|
91
|
-
return true;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
for (let k = 0; k < lineA.length; k++) {
|
|
97
|
-
if (pointIntersectsBufferedLine(lineA[k], lineB, radius)) {
|
|
98
|
-
return true;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
return false;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
function lineIntersectsLine(lineA, lineB) {
|
|
106
|
-
if (lineA.length === 0 || lineB.length === 0) {
|
|
107
|
-
return false;
|
|
108
|
-
}
|
|
109
|
-
for (let i = 0; i < lineA.length - 1; i++) {
|
|
110
|
-
const a0 = lineA[i];
|
|
111
|
-
const a1 = lineA[i + 1];
|
|
112
|
-
for (let j = 0; j < lineB.length - 1; j++) {
|
|
113
|
-
const b0 = lineB[j];
|
|
114
|
-
const b1 = lineB[j + 1];
|
|
115
|
-
if (lineSegmentIntersectsLineSegment(a0, a1, b0, b1)) {
|
|
116
|
-
return true;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
return false;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
function lineSegmentIntersectsLineSegment(a0, a1, b0, b1) {
|
|
124
|
-
return (
|
|
125
|
-
isCounterClockwise(a0, b0, b1) !== isCounterClockwise(a1, b0, b1) &&
|
|
126
|
-
isCounterClockwise(a0, a1, b0) !== isCounterClockwise(a0, a1, b1)
|
|
127
|
-
);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
function pointIntersectsBufferedLine(p, line, radius) {
|
|
131
|
-
const radiusSquared = radius * radius;
|
|
132
|
-
|
|
133
|
-
if (line.length === 1) {
|
|
134
|
-
return p.distSqr(line[0]) < radiusSquared;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
for (let i = 1; i < line.length; i++) {
|
|
138
|
-
// Find line segments that have a distance <= radius^2 to p
|
|
139
|
-
// In that case, we treat the line as "containing point p".
|
|
140
|
-
const v = line[i - 1];
|
|
141
|
-
const w = line[i];
|
|
142
|
-
if (distToSegmentSquared(p, v, w) < radiusSquared) {
|
|
143
|
-
return true;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
return false;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
// Code from http://stackoverflow.com/a/1501725/331379.
|
|
150
|
-
export function distToSegmentSquared(p, v, w) {
|
|
151
|
-
const l2 = v.distSqr(w);
|
|
152
|
-
if (l2 === 0) {
|
|
153
|
-
return p.distSqr(v);
|
|
154
|
-
}
|
|
155
|
-
const t = ((p.x - v.x) * (w.x - v.x) + (p.y - v.y) * (w.y - v.y)) / l2;
|
|
156
|
-
if (t < 0) {
|
|
157
|
-
return p.distSqr(v);
|
|
158
|
-
}
|
|
159
|
-
if (t > 1) {
|
|
160
|
-
return p.distSqr(w);
|
|
161
|
-
}
|
|
162
|
-
return p.distSqr(w.sub(v)._mult(t)._add(v));
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
// point in polygon ray casting algorithm
|
|
166
|
-
function multiPolygonContainsPoint(rings, p) {
|
|
167
|
-
let c = false;
|
|
168
|
-
let ring;
|
|
169
|
-
let p1;
|
|
170
|
-
let p2;
|
|
171
|
-
|
|
172
|
-
for (let k = 0; k < rings.length; k++) {
|
|
173
|
-
ring = rings[k];
|
|
174
|
-
for (let i = 0, j = ring.length - 1; i < ring.length; j = i++) {
|
|
175
|
-
p1 = ring[i];
|
|
176
|
-
p2 = ring[j];
|
|
177
|
-
if (p1.y > p.y !== p2.y > p.y && p.x < ((p2.x - p1.x) * (p.y - p1.y)) / (p2.y - p1.y) + p1.x) {
|
|
178
|
-
c = !c;
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
return c;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
function polygonContainsPoint(ring, p) {
|
|
186
|
-
let c = false;
|
|
187
|
-
for (let i = 0, j = ring.length - 1; i < ring.length; j = i++) {
|
|
188
|
-
const p1 = ring[i];
|
|
189
|
-
const p2 = ring[j];
|
|
190
|
-
if (p1.y > p.y !== p2.y > p.y && p.x < ((p2.x - p1.x) * (p.y - p1.y)) / (p2.y - p1.y) + p1.x) {
|
|
191
|
-
c = !c;
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
return c;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
export function polygonIntersectsBox(ring, boxX1, boxY1, boxX2, boxY2) {
|
|
198
|
-
for (const p of ring) {
|
|
199
|
-
if (boxX1 <= p.x && boxY1 <= p.y && boxX2 >= p.x && boxY2 >= p.y) {
|
|
200
|
-
return true;
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
const corners = [new Point(boxX1, boxY1), new Point(boxX1, boxY2), new Point(boxX2, boxY2), new Point(boxX2, boxY1)];
|
|
205
|
-
|
|
206
|
-
if (ring.length > 2) {
|
|
207
|
-
for (const corner of corners) {
|
|
208
|
-
if (polygonContainsPoint(ring, corner)) {
|
|
209
|
-
return true;
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
for (let i = 0; i < ring.length - 1; i++) {
|
|
215
|
-
const p1 = ring[i];
|
|
216
|
-
const p2 = ring[i + 1];
|
|
217
|
-
if (edgeIntersectsBox(p1, p2, corners)) {
|
|
218
|
-
return true;
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
return false;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
function edgeIntersectsBox(e1, e2, corners) {
|
|
226
|
-
const tl = corners[0];
|
|
227
|
-
const br = corners[2];
|
|
228
|
-
// the edge and box do not intersect in either the x or y dimensions
|
|
229
|
-
if (
|
|
230
|
-
(e1.x < tl.x && e2.x < tl.x) ||
|
|
231
|
-
(e1.x > br.x && e2.x > br.x) ||
|
|
232
|
-
(e1.y < tl.y && e2.y < tl.y) ||
|
|
233
|
-
(e1.y > br.y && e2.y > br.y)
|
|
234
|
-
) {
|
|
235
|
-
return false;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
// check if all corners of the box are on the same side of the edge
|
|
239
|
-
const dir = isCounterClockwise(e1, e2, corners[0]);
|
|
240
|
-
return (
|
|
241
|
-
dir !== isCounterClockwise(e1, e2, corners[1]) ||
|
|
242
|
-
dir !== isCounterClockwise(e1, e2, corners[2]) ||
|
|
243
|
-
dir !== isCounterClockwise(e1, e2, corners[3])
|
|
244
|
-
);
|
|
245
|
-
}
|