itowns 2.44.3-next.34 → 2.44.3-next.36
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/dist/itowns.js +1 -1
- package/dist/itowns.js.map +1 -1
- package/lib/Core/Feature.js +2 -2
- package/lib/Core/MainLoop.js +1 -3
- package/lib/Core/Prefab/TileBuilder.js +8 -5
- package/lib/Core/Scheduler/Cache.js +1 -240
- package/lib/Core/Style.js +11 -490
- package/lib/Core/StyleOptions.js +486 -0
- package/lib/Core/TileGeometry.js +2 -2
- package/lib/Layer/Layer.js +10 -5
- package/lib/Source/FileSource.js +8 -6
- package/lib/Source/OrientedImageSource.js +2 -2
- package/lib/Source/Source.js +24 -41
- package/lib/Source/VectorTilesSource.js +7 -13
- package/lib/Source/WFSSource.js +3 -3
- package/package.json +2 -1
package/lib/Core/Feature.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
2
|
import Extent from "./Geographic/Extent.js";
|
|
3
3
|
import Coordinates from "./Geographic/Coordinates.js";
|
|
4
|
-
import
|
|
4
|
+
import StyleOptions from "./StyleOptions.js";
|
|
5
5
|
function defaultExtent(crs) {
|
|
6
6
|
return new Extent(crs, Infinity, -Infinity, Infinity, -Infinity);
|
|
7
7
|
}
|
|
@@ -247,7 +247,7 @@ class Feature {
|
|
|
247
247
|
}
|
|
248
248
|
this._pos = 0;
|
|
249
249
|
this._pushValues = (this.size === 3 ? push3DValues : push2DValues).bind(this);
|
|
250
|
-
this.style =
|
|
250
|
+
this.style = StyleOptions.setFromProperties;
|
|
251
251
|
}
|
|
252
252
|
/**
|
|
253
253
|
* Instance a new {@link FeatureGeometry} and push in {@link Feature}.
|
package/lib/Core/MainLoop.js
CHANGED
|
@@ -42,7 +42,6 @@ function updateElements(context, geometryLayer, elements) {
|
|
|
42
42
|
for (const attachedLayer of geometryLayer.attachedLayers) {
|
|
43
43
|
if (attachedLayer.ready) {
|
|
44
44
|
attachedLayer.update(context, attachedLayer, sub.element, sub.parent);
|
|
45
|
-
attachedLayer.cache.flush();
|
|
46
45
|
}
|
|
47
46
|
}
|
|
48
47
|
} else if (sub.elements) {
|
|
@@ -56,7 +55,6 @@ function updateElements(context, geometryLayer, elements) {
|
|
|
56
55
|
for (const attachedLayer of geometryLayer.attachedLayers) {
|
|
57
56
|
if (attachedLayer.ready) {
|
|
58
57
|
attachedLayer.update(context, attachedLayer, sub.elements[i], sub.parent);
|
|
59
|
-
attachedLayer.cache.flush();
|
|
60
58
|
}
|
|
61
59
|
}
|
|
62
60
|
}
|
|
@@ -140,7 +138,7 @@ class MainLoop extends EventDispatcher {
|
|
|
140
138
|
}
|
|
141
139
|
|
|
142
140
|
// Clear the cache of expired resources
|
|
143
|
-
|
|
141
|
+
|
|
144
142
|
view.execFrameRequesters(MAIN_LOOP_EVENTS.AFTER_LAYER_UPDATE, dt, this.#updateLoopRestarted, geometryLayer);
|
|
145
143
|
}
|
|
146
144
|
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
2
|
import { TileGeometry } from "../TileGeometry.js";
|
|
3
|
-
import
|
|
3
|
+
import { LRUCache } from 'lru-cache';
|
|
4
4
|
import { computeBuffers } from "./computeBufferTileGeometry.js";
|
|
5
5
|
import OBB from "../../Renderer/OBB.js";
|
|
6
6
|
const cacheBuffer = new Map();
|
|
7
|
-
const cacheTile = new
|
|
7
|
+
const cacheTile = new LRUCache({
|
|
8
|
+
max: 500
|
|
9
|
+
});
|
|
8
10
|
|
|
9
11
|
/**
|
|
10
12
|
* Reference to a tile's extent with rigid transformations.
|
|
@@ -19,7 +21,8 @@ export function newTileGeometry(builder, params) {
|
|
|
19
21
|
} = builder.computeShareableExtent(params.extent);
|
|
20
22
|
const south = shareableExtent.south.toFixed(6);
|
|
21
23
|
const bufferKey = `${builder.crs}_${params.disableSkirt ? 0 : 1}_${params.segments}`;
|
|
22
|
-
|
|
24
|
+
const key = `s${south}l${params.level}bK${bufferKey}`;
|
|
25
|
+
let promiseGeometry = cacheTile.get(key);
|
|
23
26
|
|
|
24
27
|
// build geometry if doesn't exist
|
|
25
28
|
if (!promiseGeometry) {
|
|
@@ -27,7 +30,7 @@ export function newTileGeometry(builder, params) {
|
|
|
27
30
|
promiseGeometry = new Promise(r => {
|
|
28
31
|
resolve = r;
|
|
29
32
|
});
|
|
30
|
-
cacheTile.set(
|
|
33
|
+
cacheTile.set(key, promiseGeometry);
|
|
31
34
|
params.extent = shareableExtent;
|
|
32
35
|
params.center = builder.center(params.extent).clone();
|
|
33
36
|
// Read previously cached values (index and uv.wgs84 only
|
|
@@ -63,7 +66,7 @@ export function newTileGeometry(builder, params) {
|
|
|
63
66
|
};
|
|
64
67
|
const geometry = new TileGeometry(builder, params, gpuBuffers);
|
|
65
68
|
geometry.OBB = new OBB(geometry.boundingBox.min, geometry.boundingBox.max);
|
|
66
|
-
geometry.initRefCount(cacheTile,
|
|
69
|
+
geometry.initRefCount(cacheTile, key);
|
|
67
70
|
resolve(geometry);
|
|
68
71
|
return Promise.resolve({
|
|
69
72
|
geometry,
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
let entry;
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
* Cache policies for flushing. Those policies can be used when something is
|
|
5
3
|
* [set]{@link Cache.set} into the Cache, as the lifetime property.
|
|
@@ -16,241 +14,4 @@ export const CACHE_POLICIES = {
|
|
|
16
14
|
INFINITE: Infinity,
|
|
17
15
|
TEXTURE: 900000,
|
|
18
16
|
GEOMETRY: 900000
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* This is a copy of the Map object, except that it also store a value for last
|
|
23
|
-
* time used. This value is used for cache expiration mechanism.
|
|
24
|
-
*
|
|
25
|
-
* @example
|
|
26
|
-
* import Cache, { CACHE_POLICIES } from 'Core/Scheduler/Cache';
|
|
27
|
-
*
|
|
28
|
-
* const cache = new Cache(CACHE_POLICIES.TEXTURE)
|
|
29
|
-
* cache.set({ bar: 1 }, 'foo');
|
|
30
|
-
* cache.set({ bar: 32 }, 'foo', 'toto');
|
|
31
|
-
*
|
|
32
|
-
* cache.get('foo');
|
|
33
|
-
*
|
|
34
|
-
* cache.delete('foo');
|
|
35
|
-
*
|
|
36
|
-
* cache.clear();
|
|
37
|
-
*
|
|
38
|
-
* cache.flush();
|
|
39
|
-
*/
|
|
40
|
-
class Cache {
|
|
41
|
-
/**
|
|
42
|
-
* @param {number} [lifetime=CACHE_POLICIES.INFINITE] The cache expiration time for all values.
|
|
43
|
-
*/
|
|
44
|
-
constructor() {
|
|
45
|
-
let lifetime = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : CACHE_POLICIES.INFINITE;
|
|
46
|
-
this.lifeTime = lifetime;
|
|
47
|
-
this.lastTimeFlush = Date.now();
|
|
48
|
-
this.data = new Map();
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Returns the entry related to the specified key, content in array, from the cache.
|
|
53
|
-
* The array contents one to three key.
|
|
54
|
-
* The last time used property of the entry is updated to extend the longevity of the
|
|
55
|
-
* entry.
|
|
56
|
-
*
|
|
57
|
-
* @param {string[]|number[]} keyArray key array ([key0, key1, key3])
|
|
58
|
-
*
|
|
59
|
-
* @return {Object}
|
|
60
|
-
*/
|
|
61
|
-
|
|
62
|
-
getByArray(keyArray) {
|
|
63
|
-
return this.get(keyArray[0], keyArray[1], keyArray[2]);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Adds or updates an entry with specified keys array ([key0, key1, key3]).
|
|
68
|
-
* Caution: it overrides any existing entry already set at this/those key/s.
|
|
69
|
-
*
|
|
70
|
-
* @param {Object} value to add in cache
|
|
71
|
-
* @param {string[]|number[]} keyArray key array ([key0, key1, key3])
|
|
72
|
-
*
|
|
73
|
-
* @return {Object} the added value
|
|
74
|
-
*/
|
|
75
|
-
setByArray(value, keyArray) {
|
|
76
|
-
return this.set(value, keyArray[0], keyArray[1], keyArray[2]);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Returns the entry related to the specified key from the cache. The last
|
|
81
|
-
* time used property of the entry is updated to extend the longevity of the
|
|
82
|
-
* entry.
|
|
83
|
-
*
|
|
84
|
-
* @param {string|number} key1
|
|
85
|
-
* @param {string|number} [key2]
|
|
86
|
-
* @param {string|number} [key3]
|
|
87
|
-
*
|
|
88
|
-
* @return {Object}
|
|
89
|
-
*/
|
|
90
|
-
get(key1, key2, key3) {
|
|
91
|
-
const entry_1 = this.data.get(key1);
|
|
92
|
-
if (entry_1 == undefined) {
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
if (entry_1.lastTimeUsed != undefined) {
|
|
96
|
-
entry = entry_1;
|
|
97
|
-
} else {
|
|
98
|
-
const entry_2 = entry_1.get(key2);
|
|
99
|
-
if (entry_2 == undefined) {
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
if (entry_2.lastTimeUsed != undefined) {
|
|
103
|
-
entry = entry_2;
|
|
104
|
-
} else {
|
|
105
|
-
const entry_3 = entry_2.get(key3);
|
|
106
|
-
if (entry_3 == undefined) {
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
entry = entry_3;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
if (entry.value) {
|
|
113
|
-
entry.lastTimeUsed = Date.now();
|
|
114
|
-
return entry.value;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Adds or updates an entry with specified keys (up to 3).
|
|
120
|
-
* Caution: it overrides any existing entry already set at this/those key/s.
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
* @param {Object} value to add in cache
|
|
124
|
-
* @param {string|number} key1
|
|
125
|
-
* @param {string|number} [key2]
|
|
126
|
-
* @param {string|number} [key3]
|
|
127
|
-
*
|
|
128
|
-
* @return {Object} the added value
|
|
129
|
-
*/
|
|
130
|
-
set(value, key1, key2, key3) {
|
|
131
|
-
entry = {
|
|
132
|
-
value,
|
|
133
|
-
lastTimeUsed: Date.now()
|
|
134
|
-
};
|
|
135
|
-
if (key2 == undefined) {
|
|
136
|
-
this.data.set(key1, entry);
|
|
137
|
-
return value;
|
|
138
|
-
}
|
|
139
|
-
if (!this.data.get(key1)) {
|
|
140
|
-
this.data.set(key1, new Map());
|
|
141
|
-
}
|
|
142
|
-
const entry_map = this.data.get(key1);
|
|
143
|
-
if (key3 == undefined) {
|
|
144
|
-
entry_map.set(key2, entry);
|
|
145
|
-
return value;
|
|
146
|
-
}
|
|
147
|
-
if (!entry_map.get(key2)) {
|
|
148
|
-
entry_map.set(key2, new Map());
|
|
149
|
-
}
|
|
150
|
-
entry_map.get(key2).set(key3, entry);
|
|
151
|
-
return value;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* Deletes the specified entry from the cache.
|
|
156
|
-
*
|
|
157
|
-
* @param {string|number} key1
|
|
158
|
-
* @param {string|number} [key2]
|
|
159
|
-
* @param {string|number} [key3]
|
|
160
|
-
*/
|
|
161
|
-
delete(key1, key2, key3) {
|
|
162
|
-
const entry_1 = this.data.get(key1);
|
|
163
|
-
if (entry_1 === undefined) {
|
|
164
|
-
return;
|
|
165
|
-
}
|
|
166
|
-
if (entry_1.lastTimeUsed != undefined) {
|
|
167
|
-
delete this.data.get(key1);
|
|
168
|
-
this.data.delete(key1);
|
|
169
|
-
} else {
|
|
170
|
-
const entry_2 = entry_1.get(key2);
|
|
171
|
-
if (entry_2 === undefined) {
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
if (entry_2.lastTimeUsed != undefined) {
|
|
175
|
-
delete entry_1.get(key2);
|
|
176
|
-
entry_1.delete(key2);
|
|
177
|
-
if (entry_1.size == 0) {
|
|
178
|
-
this.data.delete(key1);
|
|
179
|
-
}
|
|
180
|
-
} else {
|
|
181
|
-
const entry_3 = entry_2.get(key3);
|
|
182
|
-
if (entry_3 === undefined) {
|
|
183
|
-
return;
|
|
184
|
-
}
|
|
185
|
-
delete entry_2.get(key3);
|
|
186
|
-
entry_2.delete(key3);
|
|
187
|
-
if (entry_2.size == 0) {
|
|
188
|
-
entry_1.delete(key2);
|
|
189
|
-
if (entry_1.size == 0) {
|
|
190
|
-
this.data.delete(key1);
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
/**
|
|
198
|
-
* Removes all entries of the cache.
|
|
199
|
-
*
|
|
200
|
-
*/
|
|
201
|
-
clear() {
|
|
202
|
-
this.data.clear();
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
/**
|
|
206
|
-
* Flush the cache: entries that have been present for too long since the
|
|
207
|
-
* last time they were used, are removed from the cache. By default, the
|
|
208
|
-
* time is the current time, but the interval can be reduced by doing
|
|
209
|
-
* something like `Cache.flush(Date.now() - reductionTime)`. If you want to
|
|
210
|
-
* clear the whole cache, use {@link Cache.clear} instead.
|
|
211
|
-
*
|
|
212
|
-
* @param {number} [time=Date.now()]
|
|
213
|
-
*/
|
|
214
|
-
flush() {
|
|
215
|
-
let time = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : Date.now();
|
|
216
|
-
if (this.lifeTime == CACHE_POLICIES.INFINITE || this.lifeTime > time - this.lastTimeFlush || !this.data.size) {
|
|
217
|
-
return;
|
|
218
|
-
}
|
|
219
|
-
this.lastTimeFlush = Infinity;
|
|
220
|
-
this.data.forEach((v1, i) => {
|
|
221
|
-
if (this.lifeTime < time - v1.lastTimeUsed) {
|
|
222
|
-
delete this.data.get(i);
|
|
223
|
-
this.data.delete(i);
|
|
224
|
-
} else {
|
|
225
|
-
v1.forEach((v2, j) => {
|
|
226
|
-
if (this.lifeTime < time - v2.lastTimeUsed) {
|
|
227
|
-
delete v1.get(j);
|
|
228
|
-
v1.delete(j);
|
|
229
|
-
} else {
|
|
230
|
-
v2.forEach((v3, k) => {
|
|
231
|
-
if (this.lifeTime < time - v3.lastTimeUsed) {
|
|
232
|
-
delete v2.get(k);
|
|
233
|
-
v2.delete(k);
|
|
234
|
-
} else {
|
|
235
|
-
// Work for the moment because all flushed caches have 3 key!
|
|
236
|
-
this.lastTimeFlush = Math.min(this.lastTimeFlush, v3.lastTimeUsed);
|
|
237
|
-
}
|
|
238
|
-
});
|
|
239
|
-
if (!v2.size) {
|
|
240
|
-
delete v1.get(j);
|
|
241
|
-
v1.delete(j);
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
});
|
|
245
|
-
if (!v1.size) {
|
|
246
|
-
delete this.data.get(i);
|
|
247
|
-
this.data.delete(i);
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
});
|
|
251
|
-
if (this.data.size == 0) {
|
|
252
|
-
this.lastTimeFlush = Date.now();
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
export default Cache;
|
|
17
|
+
};
|