@panoramax/web-viewer 5.0.0-develop-d26305dd → 5.0.0-develop-be5ba1a7

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.
Files changed (153) hide show
  1. package/build/cjs/index.js +1 -1
  2. package/build/cjs/index_photoviewer.js +1 -1
  3. package/build/esm/components/core/Basic.js +1 -1
  4. package/build/esm/translations/el.json +92 -1
  5. package/package.json +1 -1
  6. package/build/bundle.cjs +0 -3399
  7. package/build/bundle.cjs.map +0 -1
  8. package/build/bundle_photoviewer.cjs +0 -2510
  9. package/build/bundle_photoviewer.cjs.map +0 -1
  10. package/build/components/core/Basic.css +0 -56
  11. package/build/components/core/Basic.js +0 -378
  12. package/build/components/core/CoverageMap.css +0 -10
  13. package/build/components/core/CoverageMap.js +0 -169
  14. package/build/components/core/Editor.css +0 -33
  15. package/build/components/core/Editor.js +0 -398
  16. package/build/components/core/PhotoViewer.css +0 -70
  17. package/build/components/core/PhotoViewer.js +0 -650
  18. package/build/components/core/Viewer.css +0 -130
  19. package/build/components/core/Viewer.js +0 -711
  20. package/build/components/core/index.js +0 -10
  21. package/build/components/index.js +0 -11
  22. package/build/components/index_photoviewer.js +0 -6
  23. package/build/components/layout/BottomDrawer.js +0 -258
  24. package/build/components/layout/CorneredGrid.js +0 -143
  25. package/build/components/layout/Mini.js +0 -121
  26. package/build/components/layout/Tabs.js +0 -140
  27. package/build/components/layout/index.js +0 -9
  28. package/build/components/menus/LocationPrecisionDoc.js +0 -42
  29. package/build/components/menus/MapBackground.js +0 -110
  30. package/build/components/menus/MapFilters.js +0 -567
  31. package/build/components/menus/MapLayers.js +0 -238
  32. package/build/components/menus/MapLegend.js +0 -68
  33. package/build/components/menus/MiniPictureLegend.js +0 -73
  34. package/build/components/menus/PictureLegend.js +0 -379
  35. package/build/components/menus/PictureMetadata.js +0 -380
  36. package/build/components/menus/PlayerOptions.js +0 -93
  37. package/build/components/menus/QualityScoreDoc.js +0 -42
  38. package/build/components/menus/ReportForm.js +0 -132
  39. package/build/components/menus/SemanticsDoc.js +0 -38
  40. package/build/components/menus/SemanticsDownload.js +0 -33
  41. package/build/components/menus/SemanticsFilters.js +0 -153
  42. package/build/components/menus/SemanticsList.js +0 -413
  43. package/build/components/menus/SemanticsMetadata.js +0 -368
  44. package/build/components/menus/Share.js +0 -105
  45. package/build/components/menus/index.js +0 -22
  46. package/build/components/menus/index_photoviewer.js +0 -11
  47. package/build/components/styles.js +0 -557
  48. package/build/components/ui/AnnotationsSwitch.js +0 -159
  49. package/build/components/ui/Button.js +0 -77
  50. package/build/components/ui/ButtonGroup.css +0 -59
  51. package/build/components/ui/ButtonGroup.js +0 -69
  52. package/build/components/ui/CopyButton.js +0 -110
  53. package/build/components/ui/Grade.js +0 -54
  54. package/build/components/ui/GradeFilter.js +0 -122
  55. package/build/components/ui/IconSwitch.js +0 -193
  56. package/build/components/ui/LinkButton.js +0 -67
  57. package/build/components/ui/ListGroup.js +0 -66
  58. package/build/components/ui/ListItem.js +0 -90
  59. package/build/components/ui/Loader.js +0 -203
  60. package/build/components/ui/Map.css +0 -63
  61. package/build/components/ui/Map.js +0 -853
  62. package/build/components/ui/MapMore.js +0 -175
  63. package/build/components/ui/Photo.css +0 -50
  64. package/build/components/ui/Photo.js +0 -1502
  65. package/build/components/ui/Popup.js +0 -145
  66. package/build/components/ui/ProgressBar.js +0 -104
  67. package/build/components/ui/QualityScore.js +0 -147
  68. package/build/components/ui/SearchBar.js +0 -374
  69. package/build/components/ui/SemanticsEditor.js +0 -191
  70. package/build/components/ui/SemanticsTable.js +0 -88
  71. package/build/components/ui/Switch.js +0 -139
  72. package/build/components/ui/TogglableGroup.js +0 -157
  73. package/build/components/ui/index.js +0 -29
  74. package/build/components/ui/index_photoviewer.js +0 -21
  75. package/build/components/ui/widgets/CopyCoordinates.js +0 -75
  76. package/build/components/ui/widgets/GeoSearch.css +0 -21
  77. package/build/components/ui/widgets/GeoSearch.js +0 -150
  78. package/build/components/ui/widgets/Legend.js +0 -190
  79. package/build/components/ui/widgets/LevelSelect.css +0 -51
  80. package/build/components/ui/widgets/LevelSelect.js +0 -143
  81. package/build/components/ui/widgets/MapFiltersButton.js +0 -114
  82. package/build/components/ui/widgets/MapLayersButton.js +0 -79
  83. package/build/components/ui/widgets/OSMEditors.js +0 -155
  84. package/build/components/ui/widgets/PictureLegendActions.js +0 -99
  85. package/build/components/ui/widgets/Player.css +0 -7
  86. package/build/components/ui/widgets/Player.js +0 -154
  87. package/build/components/ui/widgets/SemanticsFiltersButton.js +0 -65
  88. package/build/components/ui/widgets/Zoom.js +0 -84
  89. package/build/components/ui/widgets/index.js +0 -16
  90. package/build/components/ui/widgets/index_photoviewer.js +0 -7
  91. package/build/img/arrow_360.svg +0 -14
  92. package/build/img/arrow_flat.svg +0 -11
  93. package/build/img/arrow_triangle.svg +0 -9
  94. package/build/img/arrow_turn.svg +0 -8
  95. package/build/img/bg_aerial.jpg +0 -0
  96. package/build/img/bg_streets.jpg +0 -0
  97. package/build/img/loader_base.jpg +0 -0
  98. package/build/img/logo_dead.svg +0 -91
  99. package/build/img/marker.svg +0 -17
  100. package/build/img/marker_blue.svg +0 -20
  101. package/build/img/osm.svg +0 -49
  102. package/build/img/panoramax.svg +0 -13
  103. package/build/img/switch_big.svg +0 -54
  104. package/build/img/switch_mini.svg +0 -48
  105. package/build/img/wd.svg +0 -1
  106. package/build/index_photoviewer.js +0 -4
  107. package/build/package.json +0 -148
  108. package/build/servers.js +0 -14
  109. package/build/translations/ar.json +0 -1
  110. package/build/translations/be.json +0 -257
  111. package/build/translations/br.json +0 -81
  112. package/build/translations/cy.json +0 -117
  113. package/build/translations/da.json +0 -300
  114. package/build/translations/de.json +0 -309
  115. package/build/translations/en.json +0 -294
  116. package/build/translations/eo.json +0 -235
  117. package/build/translations/es.json +0 -292
  118. package/build/translations/fi.json +0 -1
  119. package/build/translations/fr.json +0 -294
  120. package/build/translations/hr.json +0 -294
  121. package/build/translations/hu.json +0 -294
  122. package/build/translations/it.json +0 -306
  123. package/build/translations/ja.json +0 -182
  124. package/build/translations/ko.json +0 -1
  125. package/build/translations/nl.json +0 -305
  126. package/build/translations/nn.json +0 -1
  127. package/build/translations/pl.json +0 -169
  128. package/build/translations/pt.json +0 -296
  129. package/build/translations/pt_BR.json +0 -304
  130. package/build/translations/sv.json +0 -182
  131. package/build/translations/ti.json +0 -9
  132. package/build/translations/tr.json +0 -297
  133. package/build/translations/uk.json +0 -268
  134. package/build/translations/zh_Hant.json +0 -309
  135. package/build/utils/API.js +0 -928
  136. package/build/utils/InitParameters.js +0 -521
  137. package/build/utils/MapStyleComposer.js +0 -889
  138. package/build/utils/PanoraMapProtocol.js +0 -49
  139. package/build/utils/PhotoAdapter.js +0 -49
  140. package/build/utils/PresetsManager.js +0 -148
  141. package/build/utils/SemanticsMapProtocol.js +0 -144
  142. package/build/utils/URLHandler.js +0 -426
  143. package/build/utils/geocoder.js +0 -203
  144. package/build/utils/i18n.js +0 -128
  145. package/build/utils/index.js +0 -17
  146. package/build/utils/index_photoviewer.js +0 -14
  147. package/build/utils/indoor.js +0 -200
  148. package/build/utils/map.js +0 -788
  149. package/build/utils/picture.js +0 -507
  150. package/build/utils/semantics.js +0 -321
  151. package/build/utils/services.js +0 -148
  152. package/build/utils/utils.js +0 -433
  153. package/build/utils/widgets.js +0 -110
@@ -1,521 +0,0 @@
1
- import { isPanoramaxEndpointSingleUser } from "./map.js";
2
-
3
- export const MAP_FILTERS_JS2URL = {
4
- "minDate": "date_from",
5
- "maxDate": "date_to",
6
- "pic_type": "pic_type",
7
- "camera": "camera",
8
- "theme": "theme",
9
- "qualityscore": "pic_score",
10
- "gps": "gps"
11
- };
12
-
13
- const MAP_FILTERS_URL2JS = Object.fromEntries(Object.entries(MAP_FILTERS_JS2URL).map(v => [v[1], v[0]]));
14
- const MAP_NONE = ["none", "null", "false", false];
15
-
16
- const MAPLIBRE_OPTIONS = [
17
- "antialias", "bearing", "bearingSnap", "bounds",
18
- "boxZoom", "clickTolerance", "collectResourceTiming",
19
- "cooperativeGestures", "crossSourceCollisions", "doubleClickZoom", "dragPan",
20
- "dragRotate", "fadeDuration", "failIfMajorPerformanceCaveat", "fitBoundsOptions",
21
- "hash", "interactive", "localIdeographFontFamily", "locale", "logoPosition",
22
- "maplibreLogo", "maxBounds", "maxCanvasSize", "maxPitch", "maxTileCacheSize",
23
- "maxTileCacheZoomLevels", "maxZoom", "minPitch", "minZoom", "pitch", "pitchWithRotate",
24
- "pixelRatio", "preserveDrawingBuffer", "refreshExpiredTiles", "renderWorldCopies",
25
- "scrollZoom", "touchPitch", "touchZoomRotate", "trackResize",
26
- "transformCameraUpdate", "transformRequest", "validateStyle"
27
- ];
28
-
29
- function filterMapLibreOptions(opts) {
30
- return Object.fromEntries(Object.entries(opts).filter(([key]) => MAPLIBRE_OPTIONS.includes(key)));
31
- }
32
-
33
-
34
- /**
35
- * Merges all URL parameters and component attributes into a single set of coherent settings.
36
- *
37
- * @class Panoramax.utils.InitParameters
38
- * @param {object} [componentAttrs] HTML attributes from parent component
39
- * @param {object} [urlParams] Parameters extracted from URL
40
- * @param {object} [browserStorage] Parameters read from local/session storage
41
- */
42
- export default class InitParameters {
43
- constructor(componentAttrs = {}, urlParams = {}, browserStorage = {}) {
44
- // Skip URL parameters if disabled by component
45
- if(componentAttrs["url-parameters"] === "false") { urlParams = {}; }
46
-
47
- // Sanitize PSV parameters
48
- let componentPsv = {};
49
- if(typeof componentAttrs?.["psv-options"] === "object") { componentPsv = componentAttrs["psv-options"]; }
50
-
51
- // Sanitize Map parameters
52
- let componentMap = {};
53
- if(typeof componentAttrs?.["map-options"] === "object") { componentMap = componentAttrs["map-options"]; }
54
- let browserMap = {};
55
- if(typeof browserStorage?.map === "object") { browserMap = browserStorage.map; }
56
-
57
- // Extract map position from URL
58
- let urlMap = urlParams.map && urlParams.map !== "none" ? getMapPositionFromString(urlParams.map) : null;
59
-
60
- // Parse and prioritize all parameters
61
- // - Overlapping between URL & component
62
- let map = MAP_NONE.includes(urlParams.map) || MAP_NONE.includes(componentAttrs["map-options"]) ? false : true;
63
- let focus = urlParams.focus || componentAttrs.focus;
64
- let picture = urlParams.pic || componentAttrs.picture;
65
- let sequence = urlParams.seq || componentAttrs.sequence;
66
- let users = urlParams.users || componentAttrs["endpoint-to-use"] || browserMap.endpoint;
67
- let psv_speed = urlParams.speed || componentPsv?.transitionDuration;
68
- let psv_nav = urlParams.nav || componentPsv?.picturesNavigation;
69
- let map_theme = urlParams.theme || componentMap.theme || browserMap?.theme;
70
- let map_background = urlParams.background || componentMap.background || browserMap?.background;
71
- let map_center = urlMap?.center || (!picture && (componentMap.center || browserMap?.center)) || [0,0];
72
- let map_zoom = urlMap?.zoom || componentMap.zoom || browserMap?.zoom;
73
- let map_pitch = urlMap?.pitch || componentMap.pitch;
74
- let map_bearing = urlMap?.bearing || componentMap.bearing;
75
- let map_indoor_level = urlParams.level || componentMap.indoor?.level;
76
-
77
- // - Component only
78
- let geocoder = componentAttrs.geocoder;
79
- let widgets = componentAttrs.widgets;
80
- let fetchOptions = componentAttrs["fetch-options"];
81
- let style = componentAttrs.style;
82
- let lang = componentAttrs.lang;
83
- let endpoint = componentAttrs.endpoint;
84
- let map_raster = componentMap.raster;
85
- let map_basemaps = componentMap.basemaps;
86
- let map_indoor = componentMap.indoor;
87
- let map_attribution = componentMap.attributionControl;
88
- let map_others = filterMapLibreOptions(componentMap);
89
- let keyboardShortcuts = componentAttrs["keyboard-shortcuts"];
90
- let skipTagsMenuOpening = componentAttrs["skip-tags-menu-opening"];
91
-
92
- // - Overlapping between browser storage & component
93
- let psv_displayAnnotations = browserStorage?.disableAnnotations === "false" || componentPsv?.displayAnnotations || false;
94
-
95
- // - URL only
96
- let psv_xyz = urlParams.xyz;
97
- let map_date_from = urlParams.date_from;
98
- let map_date_to = urlParams.date_to;
99
- let map_pic_type = urlParams.pic_type;
100
- let map_camera = urlParams.camera;
101
- let map_pic_score = urlParams.pic_score;
102
- let map_gps = urlParams.gps;
103
- let map_overlay = urlParams.overlay;
104
- let psv_xywh = urlParams.xywh;
105
- let psv_annot = urlParams.annot;
106
-
107
- // Check coherence
108
- if(map && !picture && !sequence) {
109
- focus = "map";
110
- }
111
- else if(!["map", "pic"].includes(focus)) {
112
- console.warn("Invalid value for parameter focus:", focus);
113
- focus = map && (!picture && !sequence) ? "map" : "pic";
114
- }
115
- else if(focus === "map" && !map) {
116
- console.warn("Parameter focus can't be 'map' as map is disabled");
117
- focus = "pic";
118
- }
119
-
120
- if(map_background === "aerial" && !map_raster) {
121
- console.warn("Parameter background can't be 'aerial' as no aerial imagery is available");
122
- map_background = "streets";
123
- }
124
- if(map_indoor_level && !map_indoor) {
125
- console.error("Can't set indoor level if indoor= plugin is not available");
126
- }
127
- if(!psv_displayAnnotations && psv_annot) {
128
- psv_displayAnnotations = true;
129
- }
130
- if(psv_annot && !picture) {
131
- // Related to https://gitlab.com/panoramax/clients/web-viewer/-/issues/347
132
- console.error("Parameter annot can only be used in combination with 'picture'");
133
- }
134
-
135
- // Put all attributes in appropriate container
136
- this._parentInit = { map, fetchOptions, style, lang, endpoint };
137
- this._parentPostInit = {
138
- focus, picture, sequence, geocoder, widgets, users,
139
- forceFocus: true, keyboardShortcuts: true,
140
- willLoadPicture: (picture || sequence) !== undefined,
141
- skipTagsMenuOpening: skipTagsMenuOpening === "true"
142
- };
143
-
144
- this._psvInit = Object.assign(
145
- Object.fromEntries(
146
- Object.entries(componentPsv).filter(
147
- ([k,]) => !["transitionDuration", "picturesNavigation", "displayAnnotations"].includes(k)
148
- )
149
- ),
150
- {
151
- displayAnnotations: psv_displayAnnotations
152
- }
153
- );
154
-
155
- this._psvAny = {
156
- transitionDuration: psv_speed,
157
- picturesNavigation: psv_nav,
158
- };
159
- this._psvPostInit = { xyz: psv_xyz, xywh: psv_xywh, annotation: psv_annot };
160
-
161
- this._mapInit = {
162
- raster: map_raster,
163
- indoor: map_indoor,
164
- attributionControl: map_attribution,
165
- basemaps: map_basemaps,
166
- ...map_others
167
- };
168
-
169
- this._mapAny = {
170
- theme: map_theme,
171
- background: map_background,
172
- center: map_center,
173
- zoom: map_zoom,
174
- pitch: map_pitch,
175
- bearing: map_bearing,
176
- level: map_indoor_level,
177
- };
178
- this._mapPostInit = {
179
- date_from: map_date_from,
180
- date_to: map_date_to,
181
- pic_type: map_pic_type,
182
- camera: map_camera,
183
- pic_score: map_pic_score,
184
- gps: map_gps,
185
- overlay: map_overlay,
186
- };
187
-
188
- if(keyboardShortcuts === "false") {
189
- this._psvInit.keyboard = false;
190
- this._psvInit.keyboardActions = {};
191
- this._mapInit.keyboard = false;
192
- this._parentPostInit.keyboardShortcuts = false;
193
- }
194
- }
195
-
196
- /**
197
- * Cleans out undefined values from object.
198
- * @param {object} obj The input object
199
- * @returns {object} Clean object without undefined values
200
- * @private
201
- */
202
- _sanitize(obj) {
203
- return Object.fromEntries(Object.entries(obj).filter(([,v]) => v !== undefined));
204
- }
205
-
206
- /**
207
- * Get core component initialization parameters.
208
- * They must be passed as soon as possible.
209
- * @memberof Panoramax.utils.InitParameters#
210
- */
211
- getParentInit() {
212
- return this._sanitize(this._parentInit);
213
- }
214
-
215
- /**
216
- * Get core component post-initialization parameters.
217
- * They must be passed after first rendering or init.
218
- * @memberof Panoramax.utils.InitParameters#
219
- */
220
- getParentPostInit() {
221
- return this._sanitize(this._parentPostInit);
222
- }
223
-
224
- /**
225
- * Get Photo Sphere Viewer initialization parameters.
226
- * They must be passed as soon as possible.
227
- * @memberof Panoramax.utils.InitParameters#
228
- */
229
- getPSVInit() {
230
- return this._sanitize(Object.assign({}, this._psvInit, this._psvAny));
231
- }
232
-
233
- /**
234
- * Get Photo Sphere Viewer post-initialization parameters.
235
- * They must be passed after first rendering or init.
236
- * @memberof Panoramax.utils.InitParameters#
237
- */
238
- getPSVPostInit() {
239
- return this._sanitize(Object.assign({}, this._psvPostInit, this._psvAny));
240
- }
241
-
242
- /**
243
- * Get MapLibre GL initialization parameters.
244
- * They must be passed as soon as possible.
245
- * @memberof Panoramax.utils.InitParameters#
246
- */
247
- getMapInit() {
248
- return this._sanitize(Object.assign({}, this._mapInit, this._mapAny));
249
- }
250
-
251
- /**
252
- * Get MapLibre GL post-initialization parameters.
253
- * They must be passed after first rendering or init.
254
- * @memberof Panoramax.utils.InitParameters#
255
- */
256
- getMapPostInit() {
257
- return this._sanitize(Object.assign({}, this._mapPostInit, this._mapAny));
258
- }
259
-
260
- /**
261
- * Reads public properties from LitElement and returns a classic key-value object.
262
- * @param {class} compClass The component class (with static `properties` definition)
263
- * @param {LitElement} comp The component itself
264
- */
265
- static GetComponentProperties(compClass, comp) {
266
- const props = {};
267
- for(let classK in compClass.properties) {
268
- let classV = compClass.properties[classK];
269
- // eslint-disable-next-line eqeqeq
270
- if(!classV.state && comp[classK] != null) {
271
- props[classK] = comp[classK];
272
- }
273
- }
274
- return props;
275
- }
276
- }
277
-
278
- /**
279
- * Extracts map center, zoom & more from formatted string.
280
- * @param {string} str The map position as hash string
281
- * @param {Panoramax.components.ui.Map} [map] The current map
282
- * @returns {object} { center, zoom, pitch, bearing }
283
- * @private
284
- */
285
- export function getMapPositionFromString(str, map) {
286
- const loc = (str || "").split("/");
287
- if (loc.length >= 3 && !loc.some(v => isNaN(v))) {
288
- const res = {
289
- center: [+loc[2], +loc[1]],
290
- zoom: +loc[0],
291
- pitch: +(loc[4] || 0)
292
- };
293
-
294
- if(map) {
295
- res.bearing = map.dragRotate.isEnabled() && map.touchZoomRotate.isEnabled() ? +(loc[3] || 0) : map.getBearing();
296
- }
297
-
298
- return res;
299
- }
300
- else { return null; }
301
- }
302
-
303
- /**
304
- * Extracts from string xyz position
305
- * @param {string} str The xyz position as hash string
306
- * @returns {object} { x, y, z }
307
- * @private
308
- */
309
- export function xyzParamToPSVPosition(str) {
310
- const loc = (str || "").split("/");
311
- if (loc.length === 3 && !loc.some(v => isNaN(v))) {
312
- const res = {
313
- x: +loc[0],
314
- y: +loc[1],
315
- z: +loc[2]
316
- };
317
-
318
- return res;
319
- }
320
- else { return null; }
321
- }
322
-
323
- /**
324
- * Extracts from string xywh position
325
- * @param {string} str The xywh position as hash string
326
- * @param {object} [picmeta] The current picture metadata, used to compute zoom based on image size
327
- * @returns {object} { yaw, pitch, z }
328
- * @private
329
- */
330
- export function xywhParamToPSVPosition(str, picmeta) {
331
- let loc = (str || "").split(",");
332
- if (loc.length === 4 && !loc.some(v => isNaN(v))) {
333
- let [ locX, locY, locW, locH ] = loc.map(v => parseFloat(v));
334
- let basePanoData = picmeta.panorama.basePanoData;
335
- if(typeof basePanoData === "function") {
336
- const size = picmeta?.properties?.["pers:interior_orientation"]?.sensor_array_dimensions;
337
- if(size && size.length === 2) { basePanoData = basePanoData({width: size[0], height: size[1]}); }
338
- else { basePanoData = null; }
339
- }
340
-
341
- if(!basePanoData?.fullWidth || !basePanoData?.fullHeight) { return null; }
342
-
343
- const croppedX = basePanoData?.croppedX || 0;
344
- const croppedY = basePanoData?.croppedY || 0;
345
-
346
- // Compute offset from texture center
347
- const xOffsetPx = croppedX + locX + locW / 2 - basePanoData.fullWidth / 2;
348
- const yOffsetPx = -(croppedY + locY + locH / 2 - basePanoData.fullHeight / 2);
349
- const xOffsetPct = xOffsetPx / basePanoData.fullWidth;
350
- const yOffsetPct = yOffsetPx / basePanoData.fullHeight;
351
- const xSizePct = locW / basePanoData.fullWidth;
352
- const ySizePct = locH / basePanoData.fullHeight;
353
- const sizePct = (xSizePct + ySizePct) / 2;
354
-
355
- const res = {
356
- yaw: xOffsetPct * 2 * Math.PI,
357
- pitch: yOffsetPct * Math.PI,
358
- z: (1 - sizePct) * 100
359
- };
360
-
361
- return res;
362
- }
363
- else { return null; }
364
- }
365
-
366
- /**
367
- * Extracts from hash parsed keys all map filters values
368
- * @param {*} vals Hash keys
369
- * @returns {object} Map filters
370
- * @private
371
- */
372
- export function paramsToMapFilters(vals) {
373
- const newMapFilters = {};
374
- for(let k in MAP_FILTERS_URL2JS) {
375
- if(vals[k]) {
376
- newMapFilters[MAP_FILTERS_URL2JS[k]] = vals[k];
377
- }
378
- }
379
- if(newMapFilters.qualityscore) {
380
- let values = newMapFilters.qualityscore.split("");
381
- const mapping = {"A": 5, "B": 4, "C": 3, "D": 2, "E": 1};
382
- newMapFilters.qualityscore = values.map(v => mapping[v]);
383
- }
384
- return newMapFilters;
385
- }
386
-
387
- /**
388
- * Change PSV current state based on standardized parameters.
389
- * @param {Photo} psv The Photo Sphere Viewer component to change.
390
- * @param {object} params The parameters to apply.
391
- */
392
- export function alterPSVState(psv, params) {
393
- // Change xyz position
394
- if(params.xyz) {
395
- psv.addEventListener("picture-loaded", () => {
396
- const coords = xyzParamToPSVPosition(params.xyz);
397
- psv.setXYZ(coords.x, coords.y, coords.z);
398
- }, {once: true});
399
- }
400
-
401
- // Change xywh position
402
- if(params.xywh) {
403
- psv.addEventListener("picture-loaded", () => {
404
- const coords = xywhParamToPSVPosition(params.xywh, psv.getPictureMetadata());
405
- psv.rotate(coords);
406
- psv.zoom(coords.z);
407
- }, {once: true});
408
- }
409
-
410
- // Select focused annotation
411
- if(params.annotation) {
412
- if(psv.getPictureMetadata()) {
413
- psv.focusOnAnnotation(params.annotation);
414
- }
415
- else {
416
- psv.addEventListener("picture-loaded", () => {
417
- psv.focusOnAnnotation(params.annotation);
418
- }, {once: true});
419
- }
420
- }
421
-
422
- // Change transitionDuration
423
- let td = params.transitionDuration || params.speed;
424
- if(td !== undefined) {
425
- psv.setTransitionDuration(td);
426
- }
427
-
428
- // Change pictures navigation mode
429
- let nav = params.picturesNavigation || params.nav;
430
- if(["none", "pic", "any", "seq"].includes(nav)) {
431
- psv.setPicturesNavigation(nav);
432
- }
433
- }
434
-
435
- /**
436
- * Change MapLibre GL current state based on standardized parameters.
437
- * @param {Map} map The MapLibre component to change.
438
- * @param {object} params The parameters to apply.
439
- */
440
- export function alterMapState(map, params) {
441
- // Map position
442
- const mapOpts = getMapPositionFromString(params.map, map);
443
- if(mapOpts) {
444
- map.jumpTo(mapOpts);
445
- }
446
-
447
- // Change map filters
448
- map.setFilters?.(paramsToMapFilters(params));
449
-
450
- // Change map background
451
- if(map._parent?.mapStyleComposer?.layerRanges.basemaps[params.background]) {
452
- map._parent.mapStyleComposer.switchBasemap(params.background);
453
- }
454
-
455
- // Change overlays
456
- if(params.overlay) {
457
- params.overlay.split(",").forEach(o => map._parent.mapStyleComposer.switchDataOverlayVisibility("sem-"+o, true));
458
- }
459
- }
460
-
461
- /**
462
- * Change PhotoViewer current state based on standardized parameters.
463
- * @param {PhotoViewer} viewer The PhotoViewer component to change.
464
- * @param {object} params The parameters to apply.
465
- */
466
- export function alterPhotoViewerState(viewer, params) {
467
- // Restore selected picture
468
- let pic = params.picture || params.pic;
469
- let seq = params.sequence || params.seq || null;
470
- if(pic) {
471
- const picIds = pic.split(";"); // Handle multiple IDs coming from OSM
472
- if(picIds.length > 1) {
473
- console.warn("Multiple picture IDs passed in URL, only first one kept");
474
- }
475
-
476
- viewer.select(
477
- picIds.length === 1 ? seq : null,
478
- picIds[0],
479
- true
480
- );
481
- }
482
- else if(seq) {
483
- viewer.select(seq, null, true);
484
- }
485
- else {
486
- viewer.select();
487
- }
488
- }
489
-
490
- /**
491
- * Change Viewer current state based on standardized parameters.
492
- * @param {Viewer} viewer The Viewer component to change.
493
- * @param {object} params The parameters to apply.
494
- */
495
- export function alterViewerState(viewer, params) {
496
- alterPhotoViewerState(viewer, params);
497
-
498
- // Change focus
499
- if(params.focus === "map" && viewer?.map) {
500
- viewer.setPopup(false);
501
- viewer._setFocus("map", null, params.forceFocus);
502
- }
503
- else if(params.focus === "pic" && viewer?.mini) {
504
- viewer.setPopup(false);
505
- viewer._setFocus("pic", null, params.forceFocus);
506
- }
507
- else if(params.focus && params.focus === "meta" && viewer?.mini) {
508
- viewer._setFocus("pic", null, params.forceFocus);
509
- }
510
-
511
- // Change users
512
- // eslint-disable-next-line eqeqeq
513
- if(params.users != null) {
514
- if(isPanoramaxEndpointSingleUser(params.users)) {
515
- viewer.mapStyleComposer._createPanoramaxEndpointForUser(params.users);
516
- }
517
- else {
518
- viewer.mapStyleComposer.switchPanoramaxEndpoint(params.users);
519
- }
520
- }
521
- }