@panoramax/web-viewer 4.0.3-develop-d8c835a2 → 4.0.3-develop-c7e38842

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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@panoramax/web-viewer",
3
- "version": "4.0.3-develop-d8c835a2",
3
+ "version": "4.0.3-develop-c7e38842",
4
4
  "description": "Panoramax web viewer for geolocated pictures",
5
5
  "main": "build/index.js",
6
6
  "author": "Panoramax team",
@@ -80,7 +80,7 @@
80
80
  "🎨 Interface herontwerpen",
81
81
  "📅 Fotomappingparty's plannen",
82
82
  "🧀 Kazen laten rijpen",
83
- null,
83
+ "🌄 Prachtige zonneschijn berekenen",
84
84
  "🌊 Meten van het hoogwater"
85
85
  ],
86
86
  "share_rss_title": "RSS-feed van nieuwe reeksen in het nu zichtbare kaartgebied",
@@ -215,7 +215,8 @@
215
215
  "picture_all": "Alles",
216
216
  "semantics_zero_annotations": "Geen annotatie op deze afbeelding",
217
217
  "semantics_hashtags": "Foto-hashtags",
218
- "panoramax": "Panoramax"
218
+ "panoramax": "Panoramax",
219
+ "semantics_editor_error": "De syntax is ongeldig. Je tags moeten eruit zien als:\nsleutel=waarde\nprefix|sleutel=waarde\nprefix|sleutel[qualif_sleutel=qualif_waarde]=waarde\n\nMaximale lengte van de sleutel: 256 karakters, maximale lengte van de waarde: 2048 karakters."
219
220
  },
220
221
  "psv": {
221
222
  "twoFingers": "Gebruik twee vingers om te navigeren",
@@ -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