@panoramax/web-viewer 3.1.1-develop-95d65b81 → 3.1.1-develop-7ba76d1c
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 +1 -0
- package/build/index.js +1 -1
- package/build/index.js.map +1 -1
- package/docs/05_Compatibility.md +1 -0
- package/package.json +1 -1
- package/src/Viewer.js +10 -1
- package/src/components/Map.js +31 -2
- package/src/utils/Map.js +24 -1
- package/tests/Viewer.test.js +1 -0
- package/tests/utils/Map.test.js +8 -0
package/docs/05_Compatibility.md
CHANGED
|
@@ -83,6 +83,7 @@ A supplementary layer _grid_ can be made available for low-zoom overview:
|
|
|
83
83
|
|
|
84
84
|
- Available on zoom levels < 6
|
|
85
85
|
- Available properties: `id` (grid cell ID), `nb_pictures` (amount of pictures), `coef` (value from 0 to 1, relative quantity of available pictures)
|
|
86
|
+
- Optional properties: `nb_360_pictures`, `coef_360_pictures`, `nb_flat_pictures`, `coef_flat_pictures` (similar to `nb_pictures` and `coef` but separated by picture type)
|
|
86
87
|
|
|
87
88
|
### Labels translation
|
|
88
89
|
|
package/package.json
CHANGED
package/src/Viewer.js
CHANGED
|
@@ -1103,6 +1103,7 @@ class Viewer extends CoreView {
|
|
|
1103
1103
|
setFilters(filters, skipZoomIn = false) {
|
|
1104
1104
|
let mapSeqFilters = [];
|
|
1105
1105
|
let mapPicFilters = [];
|
|
1106
|
+
let reloadMapStyle = false;
|
|
1106
1107
|
this._mapFilters = {};
|
|
1107
1108
|
|
|
1108
1109
|
if(filters.minDate && filters.minDate !== "") {
|
|
@@ -1128,6 +1129,9 @@ class Viewer extends CoreView {
|
|
|
1128
1129
|
mapSeqFilters.push(["==", ["get", "type"], filters.type]);
|
|
1129
1130
|
mapPicFilters.push(["==", ["get", "type"], filters.type]);
|
|
1130
1131
|
}
|
|
1132
|
+
if(this.map?._hasGridStats()) {
|
|
1133
|
+
reloadMapStyle = true;
|
|
1134
|
+
}
|
|
1131
1135
|
|
|
1132
1136
|
if(filters.camera && filters.camera !== "") {
|
|
1133
1137
|
this._mapFilters.camera = filters.camera;
|
|
@@ -1151,7 +1155,7 @@ class Viewer extends CoreView {
|
|
|
1151
1155
|
this._mapFilters.theme = filters.theme;
|
|
1152
1156
|
if(this.map) {
|
|
1153
1157
|
this._mapTheme = this._mapFilters.theme;
|
|
1154
|
-
|
|
1158
|
+
reloadMapStyle = true;
|
|
1155
1159
|
}
|
|
1156
1160
|
}
|
|
1157
1161
|
|
|
@@ -1170,6 +1174,10 @@ class Viewer extends CoreView {
|
|
|
1170
1174
|
}
|
|
1171
1175
|
|
|
1172
1176
|
if(this.map) {
|
|
1177
|
+
if(reloadMapStyle) {
|
|
1178
|
+
this.map.reloadLayersStyles();
|
|
1179
|
+
}
|
|
1180
|
+
|
|
1173
1181
|
const allUsers = this.map.getVisibleUsers().includes("geovisio");
|
|
1174
1182
|
if(mapSeqFilters && allUsers) {
|
|
1175
1183
|
mapSeqFilters = ["step", ["zoom"],
|
|
@@ -1189,6 +1197,7 @@ class Viewer extends CoreView {
|
|
|
1189
1197
|
)
|
|
1190
1198
|
&& allUsers
|
|
1191
1199
|
&& this.map.getZoom() < 7
|
|
1200
|
+
&& !this.map._hasGridStats()
|
|
1192
1201
|
) {
|
|
1193
1202
|
this.map.easeTo({ zoom: 7 });
|
|
1194
1203
|
}
|
package/src/components/Map.js
CHANGED
|
@@ -2,7 +2,7 @@ import "./Map.css";
|
|
|
2
2
|
import {
|
|
3
3
|
forwardGeocodingBAN, forwardGeocodingNominatim, VECTOR_STYLES,
|
|
4
4
|
TILES_PICTURES_ZOOM, getThumbGif, RASTER_LAYER_ID, combineStyles,
|
|
5
|
-
getMissingLayerStyles, isLabelLayer, getUserLayerId, getUserSourceId,
|
|
5
|
+
getMissingLayerStyles, isLabelLayer, getUserLayerId, getUserSourceId, switchCoefValue,
|
|
6
6
|
} from "../utils/Map";
|
|
7
7
|
import { COLORS } from "../utils/Utils";
|
|
8
8
|
import MarkerBaseSVG from "../img/marker.svg";
|
|
@@ -188,7 +188,7 @@ export default class Map extends maplibregl.Map {
|
|
|
188
188
|
}
|
|
189
189
|
|
|
190
190
|
/**
|
|
191
|
-
* Is
|
|
191
|
+
* Is Quality Score available in vector tiles ?
|
|
192
192
|
* @private
|
|
193
193
|
*/
|
|
194
194
|
_hasQualityScore() {
|
|
@@ -196,6 +196,16 @@ export default class Map extends maplibregl.Map {
|
|
|
196
196
|
return fields?.pictures?.includes("gps_accuracy") && fields?.pictures?.includes("h_pixel_density");
|
|
197
197
|
}
|
|
198
198
|
|
|
199
|
+
/**
|
|
200
|
+
* Are 360/flat pictures stats available in vector tiles for grid layer ?
|
|
201
|
+
* @private
|
|
202
|
+
*/
|
|
203
|
+
_hasGridStats() {
|
|
204
|
+
const fields = this.getStyle()?.metadata?.["panoramax:fields"] || {};
|
|
205
|
+
return fields?.grid?.includes("nb_360_pictures") && fields?.grid?.includes("nb_flat_pictures")
|
|
206
|
+
&& fields?.grid?.includes("coef_360_pictures") && fields?.grid?.includes("coef_flat_pictures");
|
|
207
|
+
}
|
|
208
|
+
|
|
199
209
|
/**
|
|
200
210
|
* Force refresh of vector tiles data
|
|
201
211
|
*/
|
|
@@ -361,6 +371,25 @@ export default class Map extends maplibregl.Map {
|
|
|
361
371
|
["pictures", "pictures_symbols", "sequences"].forEach(l => {
|
|
362
372
|
updateStyle(l, this._getLayerStyleProperties(l));
|
|
363
373
|
});
|
|
374
|
+
|
|
375
|
+
// Also handle the grid stats
|
|
376
|
+
if(this._hasGridStats() && this._parent?._mapFilters) {
|
|
377
|
+
let newType = "coef";
|
|
378
|
+
if(this._parent._mapFilters?.type) {
|
|
379
|
+
newType = this._parent._mapFilters.type == "flat" ? "coef_flat_pictures" : "coef_360_pictures";
|
|
380
|
+
}
|
|
381
|
+
this.getStyle().layers
|
|
382
|
+
.filter(l => l.id.endsWith("_grid"))
|
|
383
|
+
.forEach(l => {
|
|
384
|
+
const newl = switchCoefValue(l, newType);
|
|
385
|
+
for(let p in newl.layout) {
|
|
386
|
+
this.setLayoutProperty(l.id, p, newl.layout[p]);
|
|
387
|
+
}
|
|
388
|
+
for(let p in newl.paint) {
|
|
389
|
+
this.setPaintProperty(l.id, p, newl.paint[p]);
|
|
390
|
+
}
|
|
391
|
+
});
|
|
392
|
+
}
|
|
364
393
|
}
|
|
365
394
|
|
|
366
395
|
/**
|
package/src/utils/Map.js
CHANGED
|
@@ -340,7 +340,6 @@ export function getMissingLayerStyles(sources, layers) {
|
|
|
340
340
|
l.layout = Object.assign(l.layout || {}, VECTOR_STYLES.PICTURES.layout);
|
|
341
341
|
});
|
|
342
342
|
|
|
343
|
-
|
|
344
343
|
return newLayers;
|
|
345
344
|
}
|
|
346
345
|
|
|
@@ -365,6 +364,30 @@ export function getUserSourceId(userId) {
|
|
|
365
364
|
return userId === "geovisio" ? "geovisio" : "geovisio_"+userId;
|
|
366
365
|
}
|
|
367
366
|
|
|
367
|
+
/**
|
|
368
|
+
* Switches used coef value in MapLibre style JSON expression
|
|
369
|
+
* @param {*} expr The MapLibre style expression
|
|
370
|
+
* @param {string} newCoefVal The new coef value to use
|
|
371
|
+
* @returns {*} The switched expression
|
|
372
|
+
* @private
|
|
373
|
+
*/
|
|
374
|
+
export function switchCoefValue(expr, newCoefVal) {
|
|
375
|
+
if(Array.isArray(expr)) {
|
|
376
|
+
return expr.map(v => switchCoefValue(v, newCoefVal));
|
|
377
|
+
}
|
|
378
|
+
else if(typeof expr === "object" && expr !== null) {
|
|
379
|
+
const newExpr = {};
|
|
380
|
+
for (const key in expr) {
|
|
381
|
+
newExpr[key] = switchCoefValue(expr[key], newCoefVal);
|
|
382
|
+
}
|
|
383
|
+
return newExpr;
|
|
384
|
+
}
|
|
385
|
+
else if(typeof expr === "string" && expr.startsWith("coef")) {
|
|
386
|
+
return newCoefVal;
|
|
387
|
+
}
|
|
388
|
+
return expr;
|
|
389
|
+
}
|
|
390
|
+
|
|
368
391
|
/**
|
|
369
392
|
* Transforms a set of parameters into an URL-ready string
|
|
370
393
|
* It also removes null/undefined values
|
package/tests/Viewer.test.js
CHANGED
|
@@ -344,6 +344,7 @@ describe("setFilters", () => {
|
|
|
344
344
|
reloadLayersStyles: jest.fn(),
|
|
345
345
|
filterUserLayersContent: jest.fn(),
|
|
346
346
|
getVisibleUsers: () => ["geovisio"],
|
|
347
|
+
_hasGridStats: () => false,
|
|
347
348
|
};
|
|
348
349
|
v.dispatchEvent = jest.fn();
|
|
349
350
|
Date.prototype.getDate = () => 8;
|
package/tests/utils/Map.test.js
CHANGED
|
@@ -50,6 +50,14 @@ describe("getUserSourceId", () => {
|
|
|
50
50
|
});
|
|
51
51
|
});
|
|
52
52
|
|
|
53
|
+
describe("switchCoefValue", () => {
|
|
54
|
+
it("works", () => {
|
|
55
|
+
const l = {id: "bla", paint: { "circle-radius": ["bla", ["get", "coef"]]}, layout: {"circle-sort": "coef"}};
|
|
56
|
+
const res = Map.switchCoefValue(l, "coef_360");
|
|
57
|
+
expect(res).toEqual({id: "bla", paint: { "circle-radius": ["bla", ["get", "coef_360"]]}, layout: {"circle-sort": "coef_360"}})
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
|
|
53
61
|
describe("geocoderParamsToURLString", () => {
|
|
54
62
|
it("works", () => {
|
|
55
63
|
const p = { bla: "blorg", you: 1 };
|