@panoramax/web-viewer 4.0.3-develop-5497573e → 4.0.3-develop-b8d837b4

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.
@@ -75,6 +75,27 @@ Example:
75
75
  xyz=10/25/50
76
76
  ```
77
77
 
78
+ ### :material-tag-arrow-right: `xywh`: picture position (annotation format)
79
+
80
+ The position to show on picture at first load, in common annotation format.
81
+
82
+ ```
83
+ x,y,w,h
84
+ ```
85
+
86
+ With:
87
+
88
+ - `x`: the horizontal offset compared to original picture left border (in pixels)
89
+ - `y`: the vertical offset compared to original picture top border (in pixels)
90
+ - `w`: the area width (in pixels)
91
+ - `h`: the area height (in pixels)
92
+
93
+ Example:
94
+
95
+ ```urlencoded
96
+ xywh=3520,1264,96,112
97
+ ```
98
+
78
99
  ## :map: Map settings
79
100
 
80
101
  ### :fontawesome-solid-location-dot: `map`: map position and visibility
@@ -10,6 +10,7 @@
10
10
  * [new SemanticsEditor()](#new_Panoramax.components.ui.SemanticsEditor_new)
11
11
  * [.properties](#Panoramax.components.ui.SemanticsEditor+properties) : <code>Object</code>
12
12
  * [.getDiff()](#Panoramax.components.ui.SemanticsEditor+getDiff) ⇒ <code>Array.&lt;object&gt;</code>
13
+ * [.checkValidity()](#Panoramax.components.ui.SemanticsEditor+checkValidity) ⇒ <code>boolean</code>
13
14
  * ["change"](#Panoramax.components.ui.SemanticsEditor+event_change)
14
15
 
15
16
  <a name="new_Panoramax.components.ui.SemanticsEditor_new"></a>
@@ -62,6 +63,13 @@ Get current delta between initial tags and user changes.
62
63
 
63
64
  **Kind**: instance method of [<code>SemanticsEditor</code>](#Panoramax.components.ui.SemanticsEditor)
64
65
  **Returns**: <code>Array.&lt;object&gt;</code> - The list of tag changes (in API format)
66
+ <a name="Panoramax.components.ui.SemanticsEditor+checkValidity"></a>
67
+
68
+ ### semanticsEditor.checkValidity() ⇒ <code>boolean</code>
69
+ Check if input is having a valid value.
70
+
71
+ **Kind**: instance method of [<code>SemanticsEditor</code>](#Panoramax.components.ui.SemanticsEditor)
72
+ **Returns**: <code>boolean</code> - True if it's valid
65
73
  <a name="Panoramax.components.ui.SemanticsEditor+event_change"></a>
66
74
 
67
75
  ### "change"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@panoramax/web-viewer",
3
- "version": "4.0.3-develop-5497573e",
3
+ "version": "4.0.3-develop-b8d837b4",
4
4
  "description": "Panoramax web viewer for geolocated pictures",
5
5
  "main": "build/index.js",
6
6
  "author": "Panoramax team",
@@ -341,7 +341,9 @@ export default class Basic extends LitElement {
341
341
  static GetJSONConverter() {
342
342
  return {
343
343
  fromAttribute: (value) => {
344
- return typeof value === "object" || Array.isArray(value) ? value : JSON5.parse(value);
344
+ if(value === null || value === "") { return null; }
345
+ else if(typeof value === "object" || Array.isArray(value)) { return value; }
346
+ else { return JSON5.parse(value); }
345
347
  },
346
348
  toAttribute: (value) => JSON.stringify(value)
347
349
  };
@@ -83,6 +83,15 @@ export default class SemanticsEditor extends LitElement {
83
83
  return computeDiffTags(this._firstSemantics || [], this.semantics);
84
84
  }
85
85
 
86
+ /**
87
+ * Check if input is having a valid value.
88
+ * @memberof Panoramax.components.ui.SemanticsEditor#
89
+ * @returns {boolean} True if it's valid
90
+ */
91
+ checkValidity() {
92
+ return this._valid;
93
+ }
94
+
86
95
  /** @private */
87
96
  _onInput(e) {
88
97
  const tarea = e.target;
@@ -89,6 +89,7 @@ export default class InitParameters { // eslint-disable-line import/no-unused-mo
89
89
  let map_pic_type = urlParams.pic_type;
90
90
  let map_camera = urlParams.camera;
91
91
  let map_pic_score = urlParams.pic_score;
92
+ let psv_xywh = urlParams.xywh;
92
93
 
93
94
  // Check coherence
94
95
  if(!["map", "pic"].includes(focus)) {
@@ -121,7 +122,7 @@ export default class InitParameters { // eslint-disable-line import/no-unused-mo
121
122
  transitionDuration: psv_speed,
122
123
  picturesNavigation: psv_nav,
123
124
  };
124
- this._psvPostInit = { xyz: psv_xyz };
125
+ this._psvPostInit = { xyz: psv_xyz, xywh: psv_xywh };
125
126
 
126
127
  this._mapInit = {
127
128
  raster: map_raster,
@@ -280,6 +281,28 @@ export function xyzParamToPSVPosition(str) {
280
281
  else { return null; }
281
282
  }
282
283
 
284
+ /**
285
+ * Extracts from string xywh position
286
+ * @param {string} str The xywh position as hash string
287
+ * @param {object} [picmeta] The current picture metadata, used to compute zoom based on image size
288
+ * @returns {object} { textureX, textureY, z }
289
+ * @private
290
+ */
291
+ function xywhParamToPSVPosition(str, picmeta) {
292
+ const loc = (str || "").split(",");
293
+ if (loc.length === 4 && !loc.some(v => isNaN(v))) {
294
+ const size = picmeta?.properties?.["pers:interior_orientation"]?.sensor_array_dimensions;
295
+ const res = {
296
+ textureX: +loc[0] + loc[2] / 2,
297
+ textureY: +loc[1] + loc[3] / 2,
298
+ z: size && size.length == 2 ? (1 - (((loc[2] / size[0]) + (loc[3] / size[1])) / 2)) * 75 : null,
299
+ };
300
+
301
+ return res;
302
+ }
303
+ else { return null; }
304
+ }
305
+
283
306
  /**
284
307
  * Extracts from hash parsed keys all map filters values
285
308
  * @param {*} vals Hash keys
@@ -315,6 +338,15 @@ export function alterPSVState(psv, params) {
315
338
  }, {once: true});
316
339
  }
317
340
 
341
+ // Change xywh position
342
+ if(params.xywh) {
343
+ psv.addEventListener("picture-loaded", () => {
344
+ const coords = xywhParamToPSVPosition(params.xywh, psv.getPictureMetadata());
345
+ psv.rotate(coords);
346
+ psv.zoom(coords.z);
347
+ }, {once: true});
348
+ }
349
+
318
350
  // Change transitionDuration
319
351
  let td = params.transitionDuration || params.speed;
320
352
  if(td !== undefined) {
@@ -5,7 +5,7 @@ import {
5
5
  // List of supported parameters
6
6
  const MANAGED_PARAMETERS = [
7
7
  "speed", "nav", "focus", "pic", "xyz", "map",
8
- "background", "users", "pic_score", "s"
8
+ "background", "users", "pic_score", "s", "xywh",
9
9
  ].concat(Object.values(MAP_FILTERS_JS2URL));
10
10
 
11
11
  // Events to listen on parent and PSV