@panoramax/web-viewer 4.0.1-develop-955ebafc → 4.0.1-develop-6b70d6bf
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/CHANGELOG.md +2 -0
- package/build/index.js +18 -18
- package/build/index.js.map +1 -1
- package/config/jest/mocks.js +2 -1
- package/docs/09_Develop.md +4 -0
- package/docs/reference/components/ui/Map.md +13 -0
- package/docs/reference/components/ui/MapMore.md +13 -0
- package/package.json +1 -1
- package/src/components/core/CoverageMap.js +2 -2
- package/src/components/core/Viewer.js +1 -1
- package/src/components/ui/Map.js +35 -4
- package/src/components/ui/widgets/OSMEditors.js +2 -2
- package/src/utils/InitParameters.js +2 -2
- package/src/utils/geocoder.js +5 -3
- package/src/utils/index.js +2 -1
- package/src/utils/services.js +57 -0
- package/src/utils/utils.js +5 -5
- package/tests/components/ui/Map.test.js +7 -3
- package/tests/utils/InitParameters.test.js +15 -15
package/config/jest/mocks.js
CHANGED
|
@@ -97,9 +97,10 @@ jest.mock("maplibre-gl", () => ({
|
|
|
97
97
|
addControl() {;}
|
|
98
98
|
addSource() {;}
|
|
99
99
|
addLayer() {;}
|
|
100
|
-
getLayer() {;}
|
|
100
|
+
getLayer(l) { return {id: l}; }
|
|
101
101
|
setLayoutProperty() {;}
|
|
102
102
|
setPaintProperty() {;}
|
|
103
|
+
loaded() { return true; }
|
|
103
104
|
getStyle() {
|
|
104
105
|
return {
|
|
105
106
|
layers: [],
|
package/docs/09_Develop.md
CHANGED
|
@@ -54,6 +54,10 @@ This allows a flexible way to interact with viewer for users. Prioritization of
|
|
|
54
54
|
|
|
55
55
|
This means that, when developing, if you want to check if your attributes are well-defined, you may want to get rid of URL search parameters, as well as remove the `pnx-map-parameters` local storage item. Otherwise, they may not be read as they are lower priority than others.
|
|
56
56
|
|
|
57
|
+
### Third-party services URL
|
|
58
|
+
|
|
59
|
+
All third-party services URL (like geocoding API, OSM iD editor) are grouped into a dedicated `src/utils/services.js` file. You can easily change them to deploy a custom version of the viewer.
|
|
60
|
+
|
|
57
61
|
## Testing
|
|
58
62
|
|
|
59
63
|
We're trying to make Panoramax as reliable and secure as possible. To ensure this, we rely heavily on code testing. A variety of testing tools is made available:
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
* [.getBackground()](#Panoramax.components.ui.Map+getBackground) ⇒ <code>string</code>
|
|
15
15
|
* [.setBackground(bg)](#Panoramax.components.ui.Map+setBackground)
|
|
16
16
|
* [.getVisibleUsers()](#Panoramax.components.ui.Map+getVisibleUsers) ⇒ <code>Array.<string></code>
|
|
17
|
+
* [.onceLayerReady(layerId)](#Panoramax.components.ui.Map+onceLayerReady) ⇒ <code>Promise</code>
|
|
17
18
|
* [.setVisibleUsers(visibleIds)](#Panoramax.components.ui.Map+setVisibleUsers)
|
|
18
19
|
* [.filterUserLayersContent(dataType, filter)](#Panoramax.components.ui.Map+filterUserLayersContent)
|
|
19
20
|
* [.displayPictureMarker(lon, lat, heading, [skipCenter])](#Panoramax.components.ui.Map+displayPictureMarker)
|
|
@@ -109,6 +110,18 @@ Get the currently visible users
|
|
|
109
110
|
|
|
110
111
|
**Kind**: instance method of [<code>Map</code>](#Panoramax.components.ui.Map)
|
|
111
112
|
**Returns**: <code>Array.<string></code> - List of visible users
|
|
113
|
+
<a name="Panoramax.components.ui.Map+onceLayerReady"></a>
|
|
114
|
+
|
|
115
|
+
### map.onceLayerReady(layerId) ⇒ <code>Promise</code>
|
|
116
|
+
Wait for a given map layer to be really available.
|
|
117
|
+
|
|
118
|
+
**Kind**: instance method of [<code>Map</code>](#Panoramax.components.ui.Map)
|
|
119
|
+
**Fulfil**: <code>null</code> When layer is ready.
|
|
120
|
+
|
|
121
|
+
| Param | Type | Description |
|
|
122
|
+
| --- | --- | --- |
|
|
123
|
+
| layerId | <code>string</code> | the layer ID |
|
|
124
|
+
|
|
112
125
|
<a name="Panoramax.components.ui.Map+setVisibleUsers"></a>
|
|
113
126
|
|
|
114
127
|
### map.setVisibleUsers(visibleIds)
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
* [.getBackground()](Map.md/#Panoramax.components.ui.Map+getBackground) ⇒ <code>string</code>
|
|
15
15
|
* [.setBackground(bg)](Map.md/#Panoramax.components.ui.Map+setBackground)
|
|
16
16
|
* [.getVisibleUsers()](Map.md/#Panoramax.components.ui.Map+getVisibleUsers) ⇒ <code>Array.<string></code>
|
|
17
|
+
* [.onceLayerReady(layerId)](Map.md/#Panoramax.components.ui.Map+onceLayerReady) ⇒ <code>Promise</code>
|
|
17
18
|
* [.setVisibleUsers(visibleIds)](Map.md/#Panoramax.components.ui.Map+setVisibleUsers)
|
|
18
19
|
* [.filterUserLayersContent(dataType, filter)](Map.md/#Panoramax.components.ui.Map+filterUserLayersContent)
|
|
19
20
|
* [.displayPictureMarker(lon, lat, heading, [skipCenter])](#Panoramax.components.ui.Map+displayPictureMarker)
|
|
@@ -109,6 +110,18 @@ Get the currently visible users
|
|
|
109
110
|
|
|
110
111
|
**Kind**: instance method of [<code>MapMore</code>](#Panoramax.components.ui.MapMore)
|
|
111
112
|
**Returns**: <code>Array.<string></code> - List of visible users
|
|
113
|
+
<a name="Panoramax.components.ui.Map+onceLayerReady"></a>
|
|
114
|
+
|
|
115
|
+
### mapMore.onceLayerReady(layerId) ⇒ <code>Promise</code>
|
|
116
|
+
Wait for a given map layer to be really available.
|
|
117
|
+
|
|
118
|
+
**Kind**: instance method of [<code>MapMore</code>](#Panoramax.components.ui.MapMore)
|
|
119
|
+
**Fulfil**: <code>null</code> When layer is ready.
|
|
120
|
+
|
|
121
|
+
| Param | Type | Description |
|
|
122
|
+
| --- | --- | --- |
|
|
123
|
+
| layerId | <code>string</code> | the layer ID |
|
|
124
|
+
|
|
112
125
|
<a name="Panoramax.components.ui.Map+setVisibleUsers"></a>
|
|
113
126
|
|
|
114
127
|
### mapMore.setVisibleUsers(visibleIds)
|
package/package.json
CHANGED
|
@@ -108,8 +108,8 @@ export default class CoverageMap extends Basic {
|
|
|
108
108
|
this.map.on("picture-click", e => this.select(e.seqId, e.picId));
|
|
109
109
|
this.map.on("sequence-click", e => this.select(e.seqId));
|
|
110
110
|
|
|
111
|
-
this.map.waitForEnoughMapLoaded().then(() => {
|
|
112
|
-
alterMapState(this.map, this._initParams.getMapPostInit());
|
|
111
|
+
this.map.waitForEnoughMapLoaded().then(async () => {
|
|
112
|
+
await alterMapState(this.map, this._initParams.getMapPostInit());
|
|
113
113
|
this.map.reloadLayersStyles();
|
|
114
114
|
this.loader.dismiss();
|
|
115
115
|
});
|
|
@@ -294,7 +294,7 @@ export default class Viewer extends PhotoViewer {
|
|
|
294
294
|
});
|
|
295
295
|
});
|
|
296
296
|
|
|
297
|
-
alterMapState(this.map, this._initParams.getMapPostInit());
|
|
297
|
+
await alterMapState(this.map, this._initParams.getMapPostInit());
|
|
298
298
|
initMapKeyboardHandler(this);
|
|
299
299
|
linkMapAndPhoto(this);
|
|
300
300
|
}
|
package/src/components/ui/Map.js
CHANGED
|
@@ -326,10 +326,29 @@ export default class Map extends maplibregl.Map {
|
|
|
326
326
|
*/
|
|
327
327
|
getVisibleUsers() {
|
|
328
328
|
return [...this._userLayers].filter(l => (
|
|
329
|
-
this.
|
|
329
|
+
this.getLayer(getUserLayerId(l, "pictures"))
|
|
330
|
+
&& this.getLayoutProperty(getUserLayerId(l, "pictures"), "visibility") === "visible"
|
|
330
331
|
));
|
|
331
332
|
}
|
|
332
333
|
|
|
334
|
+
/**
|
|
335
|
+
* Wait for a given map layer to be really available.
|
|
336
|
+
* @param {string} layerId the layer ID
|
|
337
|
+
* @returns {Promise}
|
|
338
|
+
* @fulfil {null} When layer is ready.
|
|
339
|
+
* @memberof Panoramax.components.ui.Map#
|
|
340
|
+
*/
|
|
341
|
+
onceLayerReady(layerId) {
|
|
342
|
+
if(this.getLayer(layerId)) {
|
|
343
|
+
return Promise.resolve();
|
|
344
|
+
}
|
|
345
|
+
else {
|
|
346
|
+
return new Promise(resolve => {
|
|
347
|
+
setTimeout(resolve, 250);
|
|
348
|
+
}).then(() => this.onceLayerReady(layerId));
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
|
|
333
352
|
/**
|
|
334
353
|
* Make given user layers visible on map, and hide all others (if any)
|
|
335
354
|
* @memberof Panoramax.components.ui.Map#
|
|
@@ -343,7 +362,10 @@ export default class Map extends maplibregl.Map {
|
|
|
343
362
|
await Promise.all(
|
|
344
363
|
visibleIds
|
|
345
364
|
.filter(id => id != "" && !this._userLayers.has(id))
|
|
346
|
-
.map(id =>
|
|
365
|
+
.map(id => {
|
|
366
|
+
this._createPicturesTilesLayer(id);
|
|
367
|
+
return this.onceLayerReady(getUserLayerId(id, "pictures"));
|
|
368
|
+
})
|
|
347
369
|
);
|
|
348
370
|
|
|
349
371
|
// Switch visibility
|
|
@@ -375,6 +397,10 @@ export default class Map extends maplibregl.Map {
|
|
|
375
397
|
*/
|
|
376
398
|
filterUserLayersContent(dataType, filter) {
|
|
377
399
|
[...this._userLayers].forEach(l => {
|
|
400
|
+
if(!this.getLayer(getUserLayerId(l, dataType))) {
|
|
401
|
+
console.warn("Layer", getUserLayerId(l, dataType), "not ready");
|
|
402
|
+
return;
|
|
403
|
+
}
|
|
378
404
|
this.setFilter(getUserLayerId(l, dataType), filter);
|
|
379
405
|
if(dataType === "sequences" && this.getLayer(getUserLayerId(l, "sequences_plus"))) {
|
|
380
406
|
this.setFilter(getUserLayerId(l, "sequences_plus"), filter);
|
|
@@ -428,11 +454,16 @@ export default class Map extends maplibregl.Map {
|
|
|
428
454
|
reloadLayersStyles() {
|
|
429
455
|
const updateStyle = (layer, style) => {
|
|
430
456
|
[...this._userLayers].forEach(l => {
|
|
457
|
+
const layerId = getUserLayerId(l, layer);
|
|
458
|
+
if(!this.getLayer(layerId)) {
|
|
459
|
+
console.warn("Layer", layerId, "not ready");
|
|
460
|
+
return;
|
|
461
|
+
}
|
|
431
462
|
for(let p in style.layout) {
|
|
432
|
-
this.setLayoutProperty(
|
|
463
|
+
this.setLayoutProperty(layerId, p, style.layout[p]);
|
|
433
464
|
}
|
|
434
465
|
for(let p in style.paint) {
|
|
435
|
-
this.setPaintProperty(
|
|
466
|
+
this.setPaintProperty(layerId, p, style.paint[p]);
|
|
436
467
|
}
|
|
437
468
|
});
|
|
438
469
|
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { LitElement, html, nothing, css } from "lit";
|
|
2
2
|
import { fa } from "../../../utils/widgets";
|
|
3
3
|
import { josmBboxParameters } from "../../../utils/utils";
|
|
4
|
+
import { IdEditorURL } from "../../../utils/services";
|
|
4
5
|
import { faLocationDot } from "@fortawesome/free-solid-svg-icons/faLocationDot";
|
|
5
6
|
import { faSatelliteDish } from "@fortawesome/free-solid-svg-icons/faSatelliteDish";
|
|
6
7
|
import { faExternalLinkAlt } from "@fortawesome/free-solid-svg-icons/faExternalLinkAlt";
|
|
7
8
|
|
|
8
9
|
const JOSM_REMOTE_URL = "http://127.0.0.1:8111";
|
|
9
|
-
const ID_URL = "https://www.openstreetmap.org/edit?editor=id";
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* OSM Editors component offers direct links to OpenStreetMap's iD and JOSM editors.
|
|
@@ -126,7 +126,7 @@ export default class OSMEditors extends LitElement {
|
|
|
126
126
|
"photo_overlay": "panoramax",
|
|
127
127
|
"photo": `panoramax/${this._pic.id}`,
|
|
128
128
|
};
|
|
129
|
-
const idUrl = idOpts && `${
|
|
129
|
+
const idUrl = idOpts && `${IdEditorURL()}#${new URLSearchParams(idOpts).toString()}`;
|
|
130
130
|
|
|
131
131
|
return html`
|
|
132
132
|
<pnx-link-button
|
|
@@ -323,7 +323,7 @@ export function alterPSVState(psv, params) {
|
|
|
323
323
|
* @param {Map} map The MapLibre component to change.
|
|
324
324
|
* @param {object} params The parameters to apply.
|
|
325
325
|
*/
|
|
326
|
-
export function alterMapState(map, params) {
|
|
326
|
+
export async function alterMapState(map, params) {
|
|
327
327
|
// Map position
|
|
328
328
|
const mapOpts = getMapPositionFromString(params.map, map);
|
|
329
329
|
if(mapOpts) {
|
|
@@ -333,7 +333,7 @@ export function alterMapState(map, params) {
|
|
|
333
333
|
// Visible users
|
|
334
334
|
let vu = Array.isArray(params.users) ? params.users : (params.users || "").split(",");
|
|
335
335
|
if(vu.length === 0 || (vu.length === 1 && vu[0].trim() === "")) { vu = ["geovisio"]; }
|
|
336
|
-
map.setVisibleUsers(vu);
|
|
336
|
+
await map.setVisibleUsers(vu);
|
|
337
337
|
|
|
338
338
|
// Change map filters
|
|
339
339
|
map.setFilters?.(paramsToMapFilters(params));
|
package/src/utils/geocoder.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
// DO NOT REMOVE THE "!": bundled builds breaks otherwise !!!
|
|
2
2
|
import maplibregl from "!maplibre-gl";
|
|
3
3
|
|
|
4
|
+
import { NominatimBaseUrl, AdresseDataGouvBaseURL } from "./services";
|
|
5
|
+
|
|
4
6
|
/**
|
|
5
7
|
* Transforms a set of parameters into an URL-ready string
|
|
6
8
|
* It also removes null/undefined values
|
|
@@ -94,7 +96,7 @@ export function forwardGeocodingNominatim(config) {
|
|
|
94
96
|
viewbox: config.bbox,
|
|
95
97
|
};
|
|
96
98
|
|
|
97
|
-
return fetch(
|
|
99
|
+
return fetch(`${NominatimBaseUrl()}/search?${geocoderParamsToURLString(params)}&format=geojson&polygon_geojson=1&addressdetails=1`)
|
|
98
100
|
.then(res => res.json())
|
|
99
101
|
.then(res => {
|
|
100
102
|
const finalRes = { features: [] };
|
|
@@ -115,7 +117,7 @@ export function forwardGeocodingNominatim(config) {
|
|
|
115
117
|
}
|
|
116
118
|
|
|
117
119
|
export function reverseGeocodingNominatim(lat, lon) {
|
|
118
|
-
return fetch(
|
|
120
|
+
return fetch(`${NominatimBaseUrl()}/reverse?lat=${lat}&lon=${lon}&zoom=18&format=jsonv2`)
|
|
119
121
|
.then(res => res.json())
|
|
120
122
|
.then(res => nominatimAddressToPlaceName(res?.address));
|
|
121
123
|
}
|
|
@@ -138,7 +140,7 @@ export function forwardGeocodingBAN(config) {
|
|
|
138
140
|
const toPlaceName = p => [p.name, p.district, p.city].filter(v => v).join(", ");
|
|
139
141
|
const placeTypeToZoom = { "housenumber": 20, "street": 18, "locality": 15, "municipality": 12 };
|
|
140
142
|
|
|
141
|
-
return fetch(
|
|
143
|
+
return fetch(`${AdresseDataGouvBaseURL()}/search/?${geocoderParamsToURLString(params)}`)
|
|
142
144
|
.then(res => res.json())
|
|
143
145
|
.then(res => {
|
|
144
146
|
res.features = res.features.map(f => ({
|
package/src/utils/index.js
CHANGED
|
@@ -2,10 +2,11 @@ import * as geocoder from "./geocoder";
|
|
|
2
2
|
import * as i18n from "./i18n";
|
|
3
3
|
import * as map from "./map";
|
|
4
4
|
import * as picture from "./picture";
|
|
5
|
+
import * as services from "./services";
|
|
5
6
|
import * as utils from "./utils";
|
|
6
7
|
import * as widgets from "./widgets";
|
|
7
8
|
|
|
8
|
-
export { geocoder, i18n, map, picture, utils, widgets };
|
|
9
|
+
export { geocoder, i18n, map, picture, services, utils, widgets };
|
|
9
10
|
export {default as API} from "./API";
|
|
10
11
|
export {default as PhotoAdapter} from "./PhotoAdapter";
|
|
11
12
|
export {default as URLHandler} from "./URLHandler";
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Settings that may be useful to change for special cases (e.g. offline implementation).
|
|
3
|
+
* Most users will be fine with the defaults.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* OpenStreetMap iD editor URL
|
|
9
|
+
* @returns {string} The editor URL
|
|
10
|
+
*/
|
|
11
|
+
export function IdEditorURL() {
|
|
12
|
+
return "https://www.openstreetmap.org/edit?editor=id";
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
/* -----------------------------------------------------
|
|
17
|
+
* Internet speed tests
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Get the threshold fast internet speed value.
|
|
22
|
+
*
|
|
23
|
+
* @returns {number} the minimum speed in MBps for internet to be considered "fast"
|
|
24
|
+
*/
|
|
25
|
+
export function InternetFastThreshold() {
|
|
26
|
+
return 10;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Get the fast internet speed test file.
|
|
31
|
+
*
|
|
32
|
+
* @returns {string} URL for the file to use for internet speed testing.
|
|
33
|
+
*/
|
|
34
|
+
export function InternetFastTestFile() {
|
|
35
|
+
return "https://panoramax.openstreetmap.fr/images/05/ca/2c/98/0111-4baf-b6f3-587bb8847d2e.jpg";
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
/* -----------------------------------------------------
|
|
40
|
+
* Geocoding-related settings
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Get the Adresse Data Gouv FR base URL for geocoding API.
|
|
45
|
+
* @returns {string} The Adresse Data Gouv URL (must support /search calls).
|
|
46
|
+
*/
|
|
47
|
+
export function AdresseDataGouvBaseURL() {
|
|
48
|
+
return "https://api-adresse.data.gouv.fr";
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Get the Nominatim base URL for geocoding API.
|
|
53
|
+
* @returns {string} The Nominatim URL (must support /search & /reverse calls).
|
|
54
|
+
*/
|
|
55
|
+
export function NominatimBaseUrl() {
|
|
56
|
+
return "https://nominatim.openstreetmap.org";
|
|
57
|
+
}
|
package/src/utils/utils.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { InternetFastTestFile, InternetFastThreshold } from "./services";
|
|
2
|
+
|
|
1
3
|
export const BASE_PANORAMA_ID = "geovisio-fake-id-0";
|
|
2
4
|
|
|
3
5
|
export const COLORS = {
|
|
@@ -245,9 +247,7 @@ export function isInIframe() {
|
|
|
245
247
|
}
|
|
246
248
|
|
|
247
249
|
|
|
248
|
-
const INTERNET_FAST_THRESHOLD = 10; // MBit/s
|
|
249
250
|
const INTERNET_FAST_STORAGE = "pnx-internet-fast";
|
|
250
|
-
const INTERNET_FAST_TESTFILE = "https://panoramax.openstreetmap.fr/images/05/ca/2c/98/0111-4baf-b6f3-587bb8847d2e.jpg";
|
|
251
251
|
|
|
252
252
|
/**
|
|
253
253
|
* Check if Internet connection is high-speed or not.
|
|
@@ -258,7 +258,7 @@ export function isInternetFast() {
|
|
|
258
258
|
// Check if downlink property is available
|
|
259
259
|
try {
|
|
260
260
|
const speed = navigator.connection.downlink; // MBit/s
|
|
261
|
-
return Promise.resolve(speed >=
|
|
261
|
+
return Promise.resolve(speed >= InternetFastThreshold());
|
|
262
262
|
}
|
|
263
263
|
// Fallback for other browsers
|
|
264
264
|
catch(e) {
|
|
@@ -271,14 +271,14 @@ export function isInternetFast() {
|
|
|
271
271
|
|
|
272
272
|
// Run download testing
|
|
273
273
|
const startTime = (new Date()).getTime();
|
|
274
|
-
return fetch(
|
|
274
|
+
return fetch(`${InternetFastTestFile()}?nocache=${startTime}`)
|
|
275
275
|
.then(async res => [res, await res.blob()])
|
|
276
276
|
.then(([res, blob]) => {
|
|
277
277
|
const size = parseInt(res.headers.get("Content-Length") || blob.size); // Bytes
|
|
278
278
|
const endTime = (new Date()).getTime();
|
|
279
279
|
const duration = (endTime - startTime) / 1000; // Transfer time in seconds
|
|
280
280
|
const speed = (size * 8 / 1024 / 1024) / duration; // MBits/s
|
|
281
|
-
const isFast = speed >=
|
|
281
|
+
const isFast = speed >= InternetFastThreshold();
|
|
282
282
|
sessionStorage.setItem(INTERNET_FAST_STORAGE, isFast ? "true" : "false");
|
|
283
283
|
return isFast;
|
|
284
284
|
})
|
|
@@ -81,6 +81,7 @@ describe("getBackground", () => {
|
|
|
81
81
|
const p = createParent();
|
|
82
82
|
const c = document.createElement("div");
|
|
83
83
|
const m = new Map(p, c);
|
|
84
|
+
m.getLayer = () => undefined;
|
|
84
85
|
expect(m.getBackground()).toBe("streets");
|
|
85
86
|
});
|
|
86
87
|
});
|
|
@@ -99,7 +100,7 @@ describe("setBackground", () => {
|
|
|
99
100
|
resolve();
|
|
100
101
|
});
|
|
101
102
|
m.setBackground("aerial");
|
|
102
|
-
})
|
|
103
|
+
});
|
|
103
104
|
});
|
|
104
105
|
|
|
105
106
|
it("skips if setting streets and no raster available", () => {
|
|
@@ -107,6 +108,7 @@ describe("setBackground", () => {
|
|
|
107
108
|
const c = document.createElement("div");
|
|
108
109
|
const m = new Map(p, c);
|
|
109
110
|
m.setLayoutProperty = jest.fn();
|
|
111
|
+
m.getLayer = () => undefined;
|
|
110
112
|
m.setBackground("streets");
|
|
111
113
|
expect(m.setLayoutProperty.mock.calls.length).toBe(0);
|
|
112
114
|
});
|
|
@@ -115,6 +117,7 @@ describe("setBackground", () => {
|
|
|
115
117
|
const p = createParent();
|
|
116
118
|
const c = document.createElement("div");
|
|
117
119
|
const m = new Map(p, c);
|
|
120
|
+
m.getLayer = () => undefined;
|
|
118
121
|
expect(() => m.setBackground("aerial")).toThrowError("No aerial imagery available");
|
|
119
122
|
});
|
|
120
123
|
});
|
|
@@ -138,9 +141,10 @@ describe("setVisibleUsers", () => {
|
|
|
138
141
|
const c = document.createElement("div");
|
|
139
142
|
const m = new Map(p, c);
|
|
140
143
|
m._createPicturesTilesLayer = (url, id) => m._userLayers.add(id);
|
|
141
|
-
m.
|
|
144
|
+
m._addedLayers = [];
|
|
145
|
+
m.addLayer = jest.fn();
|
|
142
146
|
await m.setVisibleUsers(["blabla"]);
|
|
143
|
-
expect(m.
|
|
147
|
+
expect(m.addLayer.mock.calls).toMatchSnapshot();
|
|
144
148
|
expect(p.dispatchEvent.mock.calls).toMatchSnapshot();
|
|
145
149
|
});
|
|
146
150
|
|
|
@@ -372,47 +372,47 @@ describe("alterMapState", () => {
|
|
|
372
372
|
|
|
373
373
|
afterEach(() => jest.clearAllMocks());
|
|
374
374
|
|
|
375
|
-
it("should jump to map position when map param is provided", () => {
|
|
375
|
+
it("should jump to map position when map param is provided", async () => {
|
|
376
376
|
const params = { map: "10/20/30" };
|
|
377
377
|
const mapOpts = { center: [30,20], zoom: 10, pitch: 0 };
|
|
378
378
|
|
|
379
|
-
alterMapState(map, params);
|
|
379
|
+
await alterMapState(map, params);
|
|
380
380
|
expect(map.jumpTo).toHaveBeenCalledWith(mapOpts);
|
|
381
381
|
});
|
|
382
382
|
|
|
383
|
-
it("should set visible users when users param is provided", () => {
|
|
383
|
+
it("should set visible users when users param is provided", async () => {
|
|
384
384
|
const params = { users: "user1,user2" };
|
|
385
|
-
alterMapState(map, params);
|
|
385
|
+
await alterMapState(map, params);
|
|
386
386
|
expect(map.setVisibleUsers).toHaveBeenCalledWith(["user1", "user2"]);
|
|
387
387
|
});
|
|
388
388
|
|
|
389
|
-
it("should set default visible user when users param is empty", () => {
|
|
389
|
+
it("should set default visible user when users param is empty", async () => {
|
|
390
390
|
const params = { users: "" };
|
|
391
|
-
alterMapState(map, params);
|
|
391
|
+
await alterMapState(map, params);
|
|
392
392
|
expect(map.setVisibleUsers).toHaveBeenCalledWith(["geovisio"]);
|
|
393
393
|
});
|
|
394
394
|
|
|
395
|
-
it("should set map filters when params are provided", () => {
|
|
395
|
+
it("should set map filters when params are provided", async () => {
|
|
396
396
|
const params = { "date_from": "2024-01-01", "pic_score": "ABC" };
|
|
397
397
|
const filters = { "minDate": "2024-01-01", "qualityscore": [5,4,3] };
|
|
398
|
-
|
|
399
|
-
alterMapState(map, params);
|
|
398
|
+
await alterMapState(map, params);
|
|
400
399
|
expect(map.setFilters).toHaveBeenCalledWith(filters);
|
|
401
400
|
});
|
|
402
401
|
|
|
403
|
-
it("should set map background when background param is valid", () => {
|
|
402
|
+
it("should set map background when background param is valid", async () => {
|
|
404
403
|
const params = { background: "aerial" };
|
|
405
|
-
|
|
404
|
+
map.setVisibleUsers = () => Promise.resolve();
|
|
405
|
+
await alterMapState(map, params);
|
|
406
406
|
expect(map.setBackground).toHaveBeenCalledWith("aerial");
|
|
407
407
|
});
|
|
408
408
|
|
|
409
|
-
it("should not set map background when background param is invalid", () => {
|
|
409
|
+
it("should not set map background when background param is invalid", async () => {
|
|
410
410
|
const params = { background: "invalid" };
|
|
411
|
-
alterMapState(map, params);
|
|
411
|
+
await alterMapState(map, params);
|
|
412
412
|
expect(map.setBackground).not.toHaveBeenCalled();
|
|
413
413
|
});
|
|
414
414
|
|
|
415
|
-
it("should handle multiple params correctly", () => {
|
|
415
|
+
it("should handle multiple params correctly", async () => {
|
|
416
416
|
const params = {
|
|
417
417
|
map: "15/7/6",
|
|
418
418
|
users: "user1,user2",
|
|
@@ -422,7 +422,7 @@ describe("alterMapState", () => {
|
|
|
422
422
|
const mapOpts = { center: [6, 7], zoom: 15, pitch: 0 };
|
|
423
423
|
const filters = { camera: "value1" };
|
|
424
424
|
|
|
425
|
-
alterMapState(map, params);
|
|
425
|
+
await alterMapState(map, params);
|
|
426
426
|
expect(map.jumpTo).toHaveBeenCalledWith(mapOpts);
|
|
427
427
|
expect(map.setVisibleUsers).toHaveBeenCalledWith(["user1", "user2"]);
|
|
428
428
|
expect(map.setFilters).toHaveBeenCalledWith(filters);
|