itowns 2.45.1-next.0 → 2.45.1-next.1
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/455.js +2 -0
- package/dist/455.js.map +1 -0
- package/dist/debug.js +3 -0
- package/dist/debug.js.LICENSE.txt +13 -0
- package/dist/debug.js.map +1 -0
- package/dist/itowns.js +3 -0
- package/dist/itowns.js.LICENSE.txt +5 -0
- package/dist/itowns.js.map +1 -0
- package/dist/itowns_lasparser.js +2 -0
- package/dist/itowns_lasparser.js.map +1 -0
- package/dist/itowns_lasworker.js +2 -0
- package/dist/itowns_lasworker.js.map +1 -0
- package/dist/itowns_potree2worker.js +2 -0
- package/dist/itowns_potree2worker.js.map +1 -0
- package/dist/itowns_widgets.js +2 -0
- package/dist/itowns_widgets.js.map +1 -0
- package/lib/Controls/FirstPersonControls.js +308 -0
- package/lib/Controls/FlyControls.js +175 -0
- package/lib/Controls/GlobeControls.js +1178 -0
- package/lib/Controls/PlanarControls.js +1025 -0
- package/lib/Controls/StateControl.js +432 -0
- package/lib/Controls/StreetControls.js +392 -0
- package/lib/Converter/Feature2Mesh.js +612 -0
- package/lib/Converter/Feature2Texture.js +174 -0
- package/lib/Converter/convertToTile.js +70 -0
- package/lib/Converter/textureConverter.js +43 -0
- package/lib/Core/3DTiles/C3DTBatchTable.js +131 -0
- package/lib/Core/3DTiles/C3DTBatchTableHierarchyExtension.js +96 -0
- package/lib/Core/3DTiles/C3DTBoundingVolume.js +156 -0
- package/lib/Core/3DTiles/C3DTExtensions.js +97 -0
- package/lib/Core/3DTiles/C3DTFeature.js +110 -0
- package/lib/Core/3DTiles/C3DTilesEnums.js +20 -0
- package/lib/Core/3DTiles/C3DTileset.js +99 -0
- package/lib/Core/3DTiles/utils/BinaryPropertyAccessor.js +100 -0
- package/lib/Core/AnimationPlayer.js +142 -0
- package/lib/Core/CopcNode.js +174 -0
- package/lib/Core/Deprecated/Undeprecator.js +74 -0
- package/lib/Core/EntwinePointTileNode.js +126 -0
- package/lib/Core/Feature.js +488 -0
- package/lib/Core/Geographic/GeoidGrid.js +108 -0
- package/lib/Core/Label.js +222 -0
- package/lib/Core/MainLoop.js +209 -0
- package/lib/Core/Picking.js +255 -0
- package/lib/Core/PointCloudNode.js +42 -0
- package/lib/Core/Potree2Node.js +206 -0
- package/lib/Core/Potree2PointAttributes.js +139 -0
- package/lib/Core/PotreeNode.js +101 -0
- package/lib/Core/Prefab/Globe/Atmosphere.js +293 -0
- package/lib/Core/Prefab/Globe/GlobeLayer.js +152 -0
- package/lib/Core/Prefab/Globe/GlobeTileBuilder.js +110 -0
- package/lib/Core/Prefab/Globe/SkyShader.js +78 -0
- package/lib/Core/Prefab/GlobeView.js +155 -0
- package/lib/Core/Prefab/Planar/PlanarLayer.js +59 -0
- package/lib/Core/Prefab/Planar/PlanarTileBuilder.js +71 -0
- package/lib/Core/Prefab/PlanarView.js +62 -0
- package/lib/Core/Prefab/TileBuilder.js +82 -0
- package/lib/Core/Prefab/computeBufferTileGeometry.js +248 -0
- package/lib/Core/Scheduler/Cache.js +17 -0
- package/lib/Core/Scheduler/CancelledCommandException.js +15 -0
- package/lib/Core/Scheduler/Scheduler.js +294 -0
- package/lib/Core/Style.js +660 -0
- package/lib/Core/StyleOptions.js +486 -0
- package/lib/Core/System/Capabilities.js +63 -0
- package/lib/Core/Tile/Tile.js +205 -0
- package/lib/Core/Tile/TileGrid.js +49 -0
- package/lib/Core/TileGeometry.js +124 -0
- package/lib/Core/TileMesh.js +108 -0
- package/lib/Core/View.js +1115 -0
- package/lib/Layer/C3DTilesLayer.js +459 -0
- package/lib/Layer/ColorLayer.js +154 -0
- package/lib/Layer/CopcLayer.js +63 -0
- package/lib/Layer/ElevationLayer.js +139 -0
- package/lib/Layer/EntwinePointTileLayer.js +71 -0
- package/lib/Layer/FeatureGeometryLayer.js +77 -0
- package/lib/Layer/GeoidLayer.js +80 -0
- package/lib/Layer/GeometryLayer.js +233 -0
- package/lib/Layer/InfoLayer.js +64 -0
- package/lib/Layer/LabelLayer.js +469 -0
- package/lib/Layer/Layer.js +335 -0
- package/lib/Layer/LayerUpdateState.js +89 -0
- package/lib/Layer/LayerUpdateStrategy.js +80 -0
- package/lib/Layer/OGC3DTilesLayer.js +543 -0
- package/lib/Layer/OrientedImageLayer.js +227 -0
- package/lib/Layer/PointCloudLayer.js +405 -0
- package/lib/Layer/Potree2Layer.js +171 -0
- package/lib/Layer/PotreeLayer.js +72 -0
- package/lib/Layer/RasterLayer.js +37 -0
- package/lib/Layer/ReferencingLayerProperties.js +62 -0
- package/lib/Layer/TiledGeometryLayer.js +459 -0
- package/lib/Loader/LASLoader.js +193 -0
- package/lib/Loader/Potree2BrotliLoader.js +261 -0
- package/lib/Loader/Potree2Loader.js +207 -0
- package/lib/Main.js +113 -0
- package/lib/MainBundle.js +4 -0
- package/lib/Parser/B3dmParser.js +174 -0
- package/lib/Parser/CameraCalibrationParser.js +94 -0
- package/lib/Parser/GDFParser.js +72 -0
- package/lib/Parser/GTXParser.js +75 -0
- package/lib/Parser/GeoJsonParser.js +212 -0
- package/lib/Parser/GpxParser.js +25 -0
- package/lib/Parser/ISGParser.js +71 -0
- package/lib/Parser/KMLParser.js +25 -0
- package/lib/Parser/LASParser.js +137 -0
- package/lib/Parser/MapBoxUrlParser.js +83 -0
- package/lib/Parser/PntsParser.js +131 -0
- package/lib/Parser/Potree2BinParser.js +92 -0
- package/lib/Parser/PotreeBinParser.js +106 -0
- package/lib/Parser/PotreeCinParser.js +29 -0
- package/lib/Parser/ShapefileParser.js +78 -0
- package/lib/Parser/VectorTileParser.js +215 -0
- package/lib/Parser/XbilParser.js +120 -0
- package/lib/Parser/deprecated/LegacyGLTFLoader.js +1386 -0
- package/lib/Parser/iGLTFLoader.js +168 -0
- package/lib/Process/3dTilesProcessing.js +304 -0
- package/lib/Process/FeatureProcessing.js +76 -0
- package/lib/Process/LayeredMaterialNodeProcessing.js +229 -0
- package/lib/Process/ObjectRemovalHelper.js +97 -0
- package/lib/Process/handlerNodeError.js +23 -0
- package/lib/Provider/3dTilesProvider.js +149 -0
- package/lib/Provider/DataSourceProvider.js +24 -0
- package/lib/Provider/Fetcher.js +233 -0
- package/lib/Provider/PointCloudProvider.js +45 -0
- package/lib/Provider/TileProvider.js +16 -0
- package/lib/Provider/URLBuilder.js +116 -0
- package/lib/Renderer/Camera.js +281 -0
- package/lib/Renderer/Color.js +56 -0
- package/lib/Renderer/ColorLayersOrdering.js +115 -0
- package/lib/Renderer/CommonMaterial.js +31 -0
- package/lib/Renderer/Label2DRenderer.js +192 -0
- package/lib/Renderer/LayeredMaterial.js +243 -0
- package/lib/Renderer/OBB.js +150 -0
- package/lib/Renderer/OrientedImageCamera.js +118 -0
- package/lib/Renderer/OrientedImageMaterial.js +167 -0
- package/lib/Renderer/PointsMaterial.js +485 -0
- package/lib/Renderer/RasterTile.js +243 -0
- package/lib/Renderer/RenderMode.js +31 -0
- package/lib/Renderer/Shader/ShaderChunk.js +160 -0
- package/lib/Renderer/Shader/ShaderUtils.js +47 -0
- package/lib/Renderer/SphereHelper.js +17 -0
- package/lib/Renderer/WebXR.js +51 -0
- package/lib/Renderer/c3DEngine.js +214 -0
- package/lib/Source/C3DTilesGoogleSource.js +74 -0
- package/lib/Source/C3DTilesIonSource.js +54 -0
- package/lib/Source/C3DTilesSource.js +30 -0
- package/lib/Source/CopcSource.js +126 -0
- package/lib/Source/EntwinePointTileSource.js +72 -0
- package/lib/Source/FileSource.js +188 -0
- package/lib/Source/OGC3DTilesGoogleSource.js +29 -0
- package/lib/Source/OGC3DTilesIonSource.js +34 -0
- package/lib/Source/OGC3DTilesSource.js +21 -0
- package/lib/Source/OrientedImageSource.js +59 -0
- package/lib/Source/Potree2Source.js +167 -0
- package/lib/Source/PotreeSource.js +82 -0
- package/lib/Source/Source.js +202 -0
- package/lib/Source/TMSSource.js +144 -0
- package/lib/Source/VectorTilesSource.js +182 -0
- package/lib/Source/WFSSource.js +170 -0
- package/lib/Source/WMSSource.js +167 -0
- package/lib/Source/WMTSSource.js +92 -0
- package/lib/ThreeExtended/capabilities/WebGL.js +69 -0
- package/lib/ThreeExtended/libs/ktx-parse.module.js +506 -0
- package/lib/ThreeExtended/libs/zstddec.module.js +29 -0
- package/lib/ThreeExtended/loaders/DDSLoader.js +200 -0
- package/lib/ThreeExtended/loaders/DRACOLoader.js +400 -0
- package/lib/ThreeExtended/loaders/GLTFLoader.js +2879 -0
- package/lib/ThreeExtended/loaders/KTX2Loader.js +709 -0
- package/lib/ThreeExtended/math/ColorSpaces.js +59 -0
- package/lib/ThreeExtended/utils/BufferGeometryUtils.js +846 -0
- package/lib/ThreeExtended/utils/WorkerPool.js +70 -0
- package/lib/Utils/CameraUtils.js +554 -0
- package/lib/Utils/DEMUtils.js +350 -0
- package/lib/Utils/FeaturesUtils.js +156 -0
- package/lib/Utils/Gradients.js +16 -0
- package/lib/Utils/ThreeUtils.js +115 -0
- package/lib/Utils/gui/C3DTilesStyle.js +218 -0
- package/lib/Utils/gui/Main.js +7 -0
- package/lib/Utils/gui/Minimap.js +152 -0
- package/lib/Utils/gui/Navigation.js +245 -0
- package/lib/Utils/gui/Scale.js +104 -0
- package/lib/Utils/gui/Searchbar.js +234 -0
- package/lib/Utils/gui/Widget.js +80 -0
- package/lib/Utils/placeObjectOnGround.js +136 -0
- package/lib/Worker/LASLoaderWorker.js +19 -0
- package/lib/Worker/Potree2Worker.js +21 -0
- package/package.json +2 -2
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cache policies for flushing. Those policies can be used when something is
|
|
3
|
+
* [set]{@link Cache.set} into the Cache, as the lifetime property.
|
|
4
|
+
*
|
|
5
|
+
* @typedef {Object} CACHE_POLICIES
|
|
6
|
+
*
|
|
7
|
+
* @property {number} INFINITE - The entry is never flushed, except when the
|
|
8
|
+
* `all` flag is set to `true` when calling {@link Cache.flush}.
|
|
9
|
+
* @property {number} TEXTURE - Shortcut for texture resources. Time is 15 minutes.
|
|
10
|
+
* @property {number} GEOMETRY - Shortcut for geometry resources. Time is 15 minutes.
|
|
11
|
+
* minutes.
|
|
12
|
+
*/
|
|
13
|
+
export const CACHE_POLICIES = {
|
|
14
|
+
INFINITE: Infinity,
|
|
15
|
+
TEXTURE: 900000,
|
|
16
|
+
GEOMETRY: 900000
|
|
17
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom error thrown when cancelling commands. Allows the caller to act differently if needed.
|
|
3
|
+
* @class
|
|
4
|
+
* @param {Command} command
|
|
5
|
+
*/
|
|
6
|
+
class CancelledCommandException {
|
|
7
|
+
constructor(command) {
|
|
8
|
+
this.command = command;
|
|
9
|
+
this.isCancelledCommandException = true;
|
|
10
|
+
}
|
|
11
|
+
toString() {
|
|
12
|
+
return `Cancelled command ${this.command.requester.id}/${this.command.layer.id}`;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export default CancelledCommandException;
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated On: 2015-10-5
|
|
3
|
+
* Class: Scheduler
|
|
4
|
+
* Description: Cette classe singleton gère les requetes/Commandes de la scène. Ces commandes peuvent etre synchrone ou asynchrone. Elle permet d'executer, de prioriser et d'annuler les commandes de la pile. Les commandes executées sont placées dans une autre file d'attente.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import PriorityQueue from 'js-priority-queue';
|
|
8
|
+
import DataSourceProvider from "../../Provider/DataSourceProvider.js";
|
|
9
|
+
import TileProvider from "../../Provider/TileProvider.js";
|
|
10
|
+
import $3dTilesProvider from "../../Provider/3dTilesProvider.js";
|
|
11
|
+
import PointCloudProvider from "../../Provider/PointCloudProvider.js";
|
|
12
|
+
import URLBuilder from "../../Provider/URLBuilder.js";
|
|
13
|
+
import CancelledCommandException from "./CancelledCommandException.js";
|
|
14
|
+
function queueOrdering(a, b) {
|
|
15
|
+
const cmp = b.priority - a.priority;
|
|
16
|
+
// Prioritize recent commands
|
|
17
|
+
if (cmp === 0) {
|
|
18
|
+
return b.timestamp - a.timestamp;
|
|
19
|
+
}
|
|
20
|
+
return cmp;
|
|
21
|
+
}
|
|
22
|
+
function drawNextLayer(storages) {
|
|
23
|
+
// Dithering algorithm to select the next layer
|
|
24
|
+
// see https://gamedev.stackexchange.com/a/95696 for more details
|
|
25
|
+
let sum = 0;
|
|
26
|
+
let selected;
|
|
27
|
+
let max;
|
|
28
|
+
for (const item of storages) {
|
|
29
|
+
const st = item[1];
|
|
30
|
+
if (st.q.length > 0) {
|
|
31
|
+
sum += st.priority;
|
|
32
|
+
st.accumulator += st.priority;
|
|
33
|
+
// Select the biggest accumulator
|
|
34
|
+
if (!selected || st.accumulator > max) {
|
|
35
|
+
selected = st;
|
|
36
|
+
max = st.accumulator;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (selected) {
|
|
41
|
+
selected.accumulator -= sum;
|
|
42
|
+
return selected.q;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function _instanciateQueue() {
|
|
46
|
+
return {
|
|
47
|
+
queue(command) {
|
|
48
|
+
const layer = command.layer;
|
|
49
|
+
let st = this.storages.get(layer.id);
|
|
50
|
+
if (!st) {
|
|
51
|
+
st = {
|
|
52
|
+
q: new PriorityQueue({
|
|
53
|
+
comparator: queueOrdering
|
|
54
|
+
}),
|
|
55
|
+
priority: 1,
|
|
56
|
+
accumulator: 0
|
|
57
|
+
};
|
|
58
|
+
this.storages.set(layer.id, st);
|
|
59
|
+
}
|
|
60
|
+
// update priority (layer.priority may have changed)
|
|
61
|
+
st.priority = layer.priority || 1;
|
|
62
|
+
st.q.queue(command);
|
|
63
|
+
this.counters.pending++;
|
|
64
|
+
},
|
|
65
|
+
storages: new Map(),
|
|
66
|
+
counters: {
|
|
67
|
+
// commands in progress
|
|
68
|
+
executing: 0,
|
|
69
|
+
// commands successfully executed
|
|
70
|
+
executed: 0,
|
|
71
|
+
// commands failed
|
|
72
|
+
failed: 0,
|
|
73
|
+
// commands cancelled
|
|
74
|
+
cancelled: 0,
|
|
75
|
+
// commands pending
|
|
76
|
+
pending: 0
|
|
77
|
+
},
|
|
78
|
+
execute(cmd, provider) {
|
|
79
|
+
this.counters.pending--;
|
|
80
|
+
this.counters.executing++;
|
|
81
|
+
return provider.executeCommand(cmd).then(result => {
|
|
82
|
+
this.counters.executing--;
|
|
83
|
+
cmd.resolve(result);
|
|
84
|
+
// only count successul commands
|
|
85
|
+
this.counters.executed++;
|
|
86
|
+
}, err => {
|
|
87
|
+
this.counters.executing--;
|
|
88
|
+
cmd.reject(err);
|
|
89
|
+
this.counters.failed++;
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* The Scheduler is in charge of managing the [Providers]{@link Provider} that
|
|
97
|
+
* are used to gather resources needed to display the layers on a {@link View}.
|
|
98
|
+
* There is only one instance of a Scheduler per webview, and it is instanciated
|
|
99
|
+
* with the creation of the first view.
|
|
100
|
+
*
|
|
101
|
+
* @constructor
|
|
102
|
+
*/
|
|
103
|
+
function Scheduler() {
|
|
104
|
+
// Constructor
|
|
105
|
+
this.defaultQueue = _instanciateQueue();
|
|
106
|
+
this.hostQueues = new Map();
|
|
107
|
+
this.providers = {};
|
|
108
|
+
this.maxCommandsPerHost = 6;
|
|
109
|
+
|
|
110
|
+
// TODO: add an options to not instanciate default providers
|
|
111
|
+
this.initDefaultProviders();
|
|
112
|
+
}
|
|
113
|
+
Scheduler.prototype.constructor = Scheduler;
|
|
114
|
+
Scheduler.prototype.initDefaultProviders = function () {
|
|
115
|
+
// Register all providers
|
|
116
|
+
this.addProtocolProvider('tile', TileProvider);
|
|
117
|
+
this.addProtocolProvider('3d-tiles', $3dTilesProvider);
|
|
118
|
+
this.addProtocolProvider('pointcloud', PointCloudProvider);
|
|
119
|
+
};
|
|
120
|
+
Scheduler.prototype.runCommand = function (command, queue, executingCounterUpToDate) {
|
|
121
|
+
const provider = this.getProtocolProvider(command.layer.protocol);
|
|
122
|
+
if (!provider) {
|
|
123
|
+
throw new Error(`No known provider for layer ${command.layer.id}`);
|
|
124
|
+
}
|
|
125
|
+
queue.execute(command, provider, executingCounterUpToDate).then(() => {
|
|
126
|
+
// notify view that one command ended.
|
|
127
|
+
command.view.notifyChange(command.requester, command.redraw);
|
|
128
|
+
|
|
129
|
+
// try to execute next command
|
|
130
|
+
if (queue.counters.executing < this.maxCommandsPerHost) {
|
|
131
|
+
const cmd = this.deQueue(queue);
|
|
132
|
+
if (cmd) {
|
|
133
|
+
this.runCommand(cmd, queue);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
};
|
|
138
|
+
Scheduler.prototype.execute = function (command) {
|
|
139
|
+
// TODO: check for mandatory commands fields
|
|
140
|
+
|
|
141
|
+
// parse host
|
|
142
|
+
const layer = command.layer;
|
|
143
|
+
const host = layer.source && layer.source.url && layer.source.url !== 'none' ? new URL(URLBuilder.subDomains(layer.source.url), document.location).host : undefined;
|
|
144
|
+
command.promise = new Promise((resolve, reject) => {
|
|
145
|
+
command.resolve = resolve;
|
|
146
|
+
command.reject = reject;
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
// init queue if needed
|
|
150
|
+
if (host && !this.hostQueues.has(host)) {
|
|
151
|
+
this.hostQueues.set(host, _instanciateQueue());
|
|
152
|
+
}
|
|
153
|
+
const q = host ? this.hostQueues.get(host) : this.defaultQueue;
|
|
154
|
+
command.timestamp = Date.now();
|
|
155
|
+
q.queue(command);
|
|
156
|
+
if (q.counters.executing < this.maxCommandsPerHost) {
|
|
157
|
+
// Defer the processing after the end of the current frame.
|
|
158
|
+
// Promise.resolve or setTimeout(..., 0) will do the job, the difference
|
|
159
|
+
// is:
|
|
160
|
+
// - setTimeout is a new task, queued in the event-loop queues
|
|
161
|
+
// - Promise is a micro-task, executed before other tasks
|
|
162
|
+
Promise.resolve().then(() => {
|
|
163
|
+
if (q.counters.executing < this.maxCommandsPerHost) {
|
|
164
|
+
const cmd = this.deQueue(q);
|
|
165
|
+
if (cmd) {
|
|
166
|
+
this.runCommand(cmd, q);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
return command.promise;
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* A Provider has the responsability to handle protocols and datablobs. Given a
|
|
176
|
+
* data request (see {@link Provider#executeCommand} for details about this
|
|
177
|
+
* request), it fetches serialized datasets, file content or even file chunks.
|
|
178
|
+
*
|
|
179
|
+
* @interface Provider
|
|
180
|
+
*/
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* When adding a layer to a view, some preprocessing can be done on it, before
|
|
184
|
+
* fetching or creating resources attached to it. For example, in the WMTS and
|
|
185
|
+
* WFS providers (included in iTowns), default options to the layer are added if
|
|
186
|
+
* some are missing.
|
|
187
|
+
*
|
|
188
|
+
* @param {Layer} layer
|
|
189
|
+
* @param {View} [view]
|
|
190
|
+
* @param {Scheduler} [scheduler]
|
|
191
|
+
* @param {Layer} [parentLayer]
|
|
192
|
+
*/
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* In the {@link Scheduler} loop, this function is called every time the layer
|
|
196
|
+
* needs new information about itself. For tiled layers, it gets the necessary
|
|
197
|
+
* tiles, given the current position of the camera on the map. For simple layers
|
|
198
|
+
* like a GPX trace, it gets the data once.
|
|
199
|
+
* <br><br>
|
|
200
|
+
* It passes a `command` object as a parameter, with the `view` and the `layer`
|
|
201
|
+
* always present. The other parameters are optional.
|
|
202
|
+
*
|
|
203
|
+
* @function
|
|
204
|
+
* @name Provider#executeCommand
|
|
205
|
+
*
|
|
206
|
+
* @param {Object} command
|
|
207
|
+
* @param {View} command.view
|
|
208
|
+
* @param {Layer} command.layer
|
|
209
|
+
* @param {TileMesh} [command.requester] - Every layer is attached to a tile.
|
|
210
|
+
* @param {number} [command.targetLevel] - The target level is used when there
|
|
211
|
+
* is a tiled layer, such as WMTS or TMS, but not in case like a GPX layer.
|
|
212
|
+
*
|
|
213
|
+
* @return {Promise} The {@link Scheduler} always expect a Promise as a result,
|
|
214
|
+
* resolving to an object containing sufficient information for the associated
|
|
215
|
+
* processing to the current layer. For example, see the
|
|
216
|
+
* [LayeredMaterialNodeProcessing#updateLayeredMaterialNodeElevation]{@link
|
|
217
|
+
* https://github.com/iTowns/itowns/blob/master/src/Process/LayeredMaterialNodeProcessing.js}
|
|
218
|
+
* class or other processing class.
|
|
219
|
+
*/
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Adds a provider for a specified protocol. The provider will be used when
|
|
223
|
+
* executing the queue to provide resources. See {@link Provider} for more
|
|
224
|
+
* informations.
|
|
225
|
+
* By default, some protocols are already set in iTowns: WMTS, WMS, WFS, TMS,
|
|
226
|
+
* XYZ, PotreeConverter, Rasterizer, 3D-Tiles and Static.
|
|
227
|
+
* <br><br>
|
|
228
|
+
* Warning: if the specified protocol has already a provider attached to it, the
|
|
229
|
+
* current provider will be overwritten by the given provider.
|
|
230
|
+
*
|
|
231
|
+
* @param {string} protocol - The name of the protocol to add. This is the
|
|
232
|
+
* `protocol` parameter put inside the configuration when adding a layer. The
|
|
233
|
+
* capitalization of the name is not taken into account here.
|
|
234
|
+
* @param {Provider} provider - The provider to link to the protocol, that must
|
|
235
|
+
* respect the {@link Provider} interface description.
|
|
236
|
+
*
|
|
237
|
+
* @throws {Error} an error if any method of the {@link Provider} is not present
|
|
238
|
+
* in the provider.
|
|
239
|
+
*/
|
|
240
|
+
Scheduler.prototype.addProtocolProvider = function (protocol, provider) {
|
|
241
|
+
if (typeof provider.executeCommand !== 'function') {
|
|
242
|
+
throw new Error(`Can't add provider for ${protocol}: missing a executeCommand function.`);
|
|
243
|
+
}
|
|
244
|
+
this.providers[protocol] = provider;
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Get a specific {@link Provider} given a particular protocol.
|
|
249
|
+
*
|
|
250
|
+
* @param {string} protocol
|
|
251
|
+
*
|
|
252
|
+
* @return {Provider}
|
|
253
|
+
*/
|
|
254
|
+
Scheduler.prototype.getProtocolProvider = function (protocol) {
|
|
255
|
+
return this.providers[protocol] || DataSourceProvider;
|
|
256
|
+
};
|
|
257
|
+
Scheduler.prototype.commandsWaitingExecutionCount = function () {
|
|
258
|
+
let sum = this.defaultQueue.counters.pending + this.defaultQueue.counters.executing;
|
|
259
|
+
for (const q of this.hostQueues) {
|
|
260
|
+
sum += q[1].counters.pending + q[1].counters.executing;
|
|
261
|
+
}
|
|
262
|
+
return sum;
|
|
263
|
+
};
|
|
264
|
+
Scheduler.prototype.commandsRunningCount = function () {
|
|
265
|
+
let sum = this.defaultQueue.counters.executing;
|
|
266
|
+
for (const q of this.hostQueues) {
|
|
267
|
+
sum += q[1].counters.executing;
|
|
268
|
+
}
|
|
269
|
+
return sum;
|
|
270
|
+
};
|
|
271
|
+
Scheduler.prototype.resetCommandsCount = function (type) {
|
|
272
|
+
let sum = this.defaultQueue.counters[type];
|
|
273
|
+
this.defaultQueue.counters[type] = 0;
|
|
274
|
+
for (const q of this.hostQueues) {
|
|
275
|
+
sum += q[1].counters[type];
|
|
276
|
+
q[1].counters[type] = 0;
|
|
277
|
+
}
|
|
278
|
+
return sum;
|
|
279
|
+
};
|
|
280
|
+
Scheduler.prototype.deQueue = function (queue) {
|
|
281
|
+
const st = drawNextLayer(queue.storages);
|
|
282
|
+
while (st && st.length > 0) {
|
|
283
|
+
const cmd = st.dequeue();
|
|
284
|
+
if (cmd.earlyDropFunction && cmd.earlyDropFunction(cmd)) {
|
|
285
|
+
queue.counters.pending--;
|
|
286
|
+
queue.counters.cancelled++;
|
|
287
|
+
cmd.reject(new CancelledCommandException(cmd));
|
|
288
|
+
} else {
|
|
289
|
+
return cmd;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
return undefined;
|
|
293
|
+
};
|
|
294
|
+
export default Scheduler;
|