@panoramax/web-viewer 4.0.1 → 4.0.2
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 +26 -3
- package/build/index.css +1 -1
- package/build/index.css.map +1 -1
- package/build/index.js +150 -51
- package/build/index.js.map +1 -1
- package/config/jest/mocks.js +2 -1
- package/docs/03_URL_settings.md +1 -1
- package/docs/09_Develop.md +5 -1
- package/docs/reference/components/ui/CopyButton.md +1 -0
- package/docs/reference/components/ui/Map.md +13 -0
- package/docs/reference/components/ui/MapMore.md +13 -0
- package/docs/reference/components/ui/Photo.md +1 -1
- package/docs/reference/components/ui/widgets/CopyCoordinates.md +32 -0
- package/docs/reference/utils/API.md +1 -1
- package/docs/reference.md +1 -0
- package/docs/tutorials/migrate_v4.md +1 -1
- package/docs/tutorials/synced_coverage.md +1 -1
- package/mkdocs.yml +1 -0
- package/package.json +1 -1
- package/src/components/core/CoverageMap.js +2 -2
- package/src/components/core/PhotoViewer.js +5 -1
- package/src/components/core/Viewer.js +9 -4
- package/src/components/menus/PictureLegend.js +7 -4
- package/src/components/menus/PictureMetadata.js +23 -2
- package/src/components/styles.js +61 -0
- package/src/components/ui/ButtonGroup.css +2 -0
- package/src/components/ui/CopyButton.js +3 -1
- package/src/components/ui/Map.js +35 -4
- package/src/components/ui/Photo.js +4 -2
- package/src/components/ui/TogglableGroup.js +1 -1
- package/src/components/ui/widgets/CopyCoordinates.js +75 -0
- package/src/components/ui/widgets/Legend.js +1 -1
- package/src/components/ui/widgets/OSMEditors.js +2 -2
- package/src/components/ui/widgets/PictureLegendActions.js +1 -1
- package/src/components/ui/widgets/Player.js +1 -0
- package/src/components/ui/widgets/index.js +1 -0
- package/src/translations/en.json +6 -2
- package/src/translations/fr.json +6 -2
- package/src/translations/it.json +3 -1
- package/src/translations/ti.json +9 -0
- package/src/utils/API.js +1 -1
- package/src/utils/InitParameters.js +2 -2
- package/src/utils/geocoder.js +5 -3
- package/src/utils/index.js +2 -1
- package/src/utils/picture.js +6 -1
- package/src/utils/services.js +57 -0
- package/src/utils/utils.js +18 -5
- package/tests/components/ui/Map.test.js +7 -3
- package/tests/utils/InitParameters.test.js +15 -15
- package/tests/utils/geocoder.test.js +1 -1
- package/tests/utils/utils.test.js +136 -109
|
@@ -8,18 +8,18 @@ jest.mock("../../src/utils/map", () => ({
|
|
|
8
8
|
|
|
9
9
|
describe("getGrade", () => {
|
|
10
10
|
it("works with null-like", () => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
expect(utils.getGrade(utils.QUALITYSCORE_RES_FLAT_VALUES, null)).toBeNull();
|
|
12
|
+
expect(utils.getGrade(utils.QUALITYSCORE_RES_FLAT_VALUES, undefined)).toBeNull();
|
|
13
|
+
expect(utils.getGrade(utils.QUALITYSCORE_RES_FLAT_VALUES, "")).toBeNull();
|
|
14
|
+
});
|
|
15
15
|
|
|
16
16
|
it("works with grade values", () => {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
expect(utils.getGrade(utils.QUALITYSCORE_RES_FLAT_VALUES, 0)).toBe(1);
|
|
18
|
+
expect(utils.getGrade(utils.QUALITYSCORE_RES_FLAT_VALUES, 5)).toBe(1);
|
|
19
|
+
expect(utils.getGrade(utils.QUALITYSCORE_RES_FLAT_VALUES, 12)).toBe(2);
|
|
20
|
+
expect(utils.getGrade(utils.QUALITYSCORE_RES_FLAT_VALUES, 25)).toBe(3);
|
|
21
|
+
expect(utils.getGrade(utils.QUALITYSCORE_RES_FLAT_VALUES, 40)).toBe(4);
|
|
22
|
+
});
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
describe("getDistance", () => {
|
|
@@ -32,25 +32,25 @@ describe("getDistance", () => {
|
|
|
32
32
|
});
|
|
33
33
|
|
|
34
34
|
describe("svgToPSVLink", () => {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
35
|
+
it("works", () => {
|
|
36
|
+
const base64Svg = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnPjxjaXJjbGUgY3g9JzUnIGN5PSc1JyByPSc1JyBmaWxsPScjMDAwJy8+PC9zdmc+";
|
|
37
|
+
const fillColor = "red";
|
|
38
|
+
const result = utils.svgToPSVLink(base64Svg, fillColor);
|
|
39
|
+
|
|
40
|
+
expect(result).toBeInstanceOf(HTMLButtonElement);
|
|
41
|
+
expect(result.classList.contains("pnx-psv-tour-arrows")).toBe(true);
|
|
42
|
+
expect(result.style.color).toBe(fillColor);
|
|
43
|
+
expect(result.querySelector("svg")).not.toBeNull();
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it("works with invalid input", () => {
|
|
47
|
+
const invalidBase64Svg = "http://test.net/invalid_string";
|
|
48
|
+
const result = utils.svgToPSVLink(invalidBase64Svg, "blue");
|
|
49
|
+
|
|
50
|
+
expect(result).toBeInstanceOf(HTMLImageElement);
|
|
51
|
+
expect(result.src).toBe(invalidBase64Svg);
|
|
52
|
+
expect(result.alt).toBe("");
|
|
53
|
+
});
|
|
54
54
|
});
|
|
55
55
|
|
|
56
56
|
describe("getAzimuth", () => {
|
|
@@ -197,92 +197,119 @@ describe("xyzToPosition", () => {
|
|
|
197
197
|
});
|
|
198
198
|
});
|
|
199
199
|
|
|
200
|
+
describe("degToDms", () => {
|
|
201
|
+
it("converts positive decimal degrees to DMS correctly", () => {
|
|
202
|
+
const result = utils.degToDms(45.7896541);
|
|
203
|
+
expect(result).toEqual({ d: 45, m: 47, s: 22.755 });
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
it("converts negative decimal degrees to DMS correctly 1", () => {
|
|
207
|
+
const result = utils.degToDms(-12.751234);
|
|
208
|
+
expect(result).toEqual({ d: -12, m: 45, s: 4.442 });
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
it("converts negative decimal degrees to DMS correctly 2", () => {
|
|
212
|
+
const result = utils.degToDms(-21.007598);
|
|
213
|
+
expect(result).toEqual({ d: -21, m: 0, s: 27.353 });
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
it("converts zero degrees to DMS correctly", () => {
|
|
217
|
+
const result = utils.degToDms(0);
|
|
218
|
+
expect(result).toEqual({ d: 0, m: 0, s: 0 });
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
it("handles integer degrees correctly", () => {
|
|
222
|
+
const result = utils.degToDms(90);
|
|
223
|
+
expect(result).toEqual({ d: 90, m: 0, s: 0 });
|
|
224
|
+
});
|
|
225
|
+
});
|
|
226
|
+
|
|
200
227
|
describe("josmBboxParameters", () => {
|
|
201
228
|
it("works with null-like", () => {
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
229
|
+
expect(utils.josmBboxParameters(null)).toBeNull();
|
|
230
|
+
expect(utils.josmBboxParameters(undefined)).toBeNull();
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
it("works without azimuth", () => {
|
|
234
|
+
const meta = { gps: [2.3522, 48.8566] };
|
|
235
|
+
const result = utils.josmBboxParameters(meta);
|
|
236
|
+
expect(result).toBe("left=2.3522&right=2.3522&top=48.8566&bottom=48.8566&changeset_source=Panoramax");
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
it("works with azimuth = 0", () => {
|
|
240
|
+
const meta = { gps: [2.3522, 48.8566], properties: { "view:azimuth": 0 } };
|
|
241
|
+
const result = utils.josmBboxParameters(meta);
|
|
242
|
+
expect(result).toBe("left=2.3522&right=2.3524&top=48.8568&bottom=48.8566&changeset_source=Panoramax");
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
it("works with azimuth = 180", () => {
|
|
246
|
+
const meta = { gps: [2.3522, 48.8566], properties: { "view:azimuth": 180 } };
|
|
247
|
+
const result = utils.josmBboxParameters(meta);
|
|
248
|
+
expect(result).toBe("left=2.352&right=2.3524&top=48.8566&bottom=48.8564&changeset_source=Panoramax");
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
it("works with azimuth = 90", () => {
|
|
252
|
+
const meta = { gps: [2.3522, 48.8566], properties: { "view:azimuth": 90 } };
|
|
253
|
+
const result = utils.josmBboxParameters(meta);
|
|
254
|
+
expect(result).toBe("left=2.3522&right=2.3524&top=48.8568&bottom=48.8564&changeset_source=Panoramax");
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
it("works with azimuth = 270", () => {
|
|
258
|
+
const meta = { gps: [2.3522, 48.8566], properties: { "view:azimuth": 270 } };
|
|
259
|
+
const result = utils.josmBboxParameters(meta);
|
|
260
|
+
expect(result).toBe("left=2.352&right=2.3522&top=48.8568&bottom=48.8564&changeset_source=Panoramax");
|
|
261
|
+
});
|
|
235
262
|
});
|
|
236
263
|
|
|
237
264
|
describe("getCookie", () => {
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
265
|
+
it("should return the value of the specified cookie", () => {
|
|
266
|
+
jest.spyOn(document, "cookie", "get").mockReturnValueOnce("session=abc123");
|
|
267
|
+
expect(utils.getCookie("session")).toBe("abc123");
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
it("should return null if the cookie is not found", () => {
|
|
271
|
+
jest.spyOn(document, "cookie", "get").mockReturnValueOnce("session=abc123");
|
|
272
|
+
expect(utils.getCookie("user_id")).toBeUndefined();
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
it("should return the correct value when multiple cookies are set", () => {
|
|
276
|
+
jest.spyOn(document, "cookie", "get").mockReturnValueOnce("session=abc123; user_id=789; user_name=John");
|
|
277
|
+
expect(utils.getCookie("user_id")).toBe("789");
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
it("should return null if cookie with the specified name has no value", () => {
|
|
281
|
+
jest.spyOn(document, "cookie", "get").mockReturnValueOnce("session=; user_id=789");
|
|
282
|
+
expect(utils.getCookie("session")).toBe("");
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
it("should return the correct value when the cookie contains =", () => {
|
|
286
|
+
jest.spyOn(document, "cookie", "get").mockReturnValueOnce("custom_cookie=abc=123");
|
|
287
|
+
expect(utils.getCookie("custom_cookie")).toBe("abc=123");
|
|
288
|
+
});
|
|
262
289
|
});
|
|
263
290
|
|
|
264
291
|
describe("getUserAccount", () => {
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
292
|
+
it("should return an object with user id and name when all cookies are present", () => {
|
|
293
|
+
jest.spyOn(document, "cookie", "get").mockReturnValue("session=abc123; user_id=789; user_name=John");
|
|
294
|
+
expect(utils.getUserAccount()).toEqual({ id: "789", name: "John" });
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
it("should return null if session cookie is missing", () => {
|
|
298
|
+
jest.spyOn(document, "cookie", "get").mockReturnValue("user_id=789; user_name=John");
|
|
299
|
+
expect(utils.getUserAccount()).toBeNull();
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
it("should return null if user_id cookie is missing", () => {
|
|
303
|
+
jest.spyOn(document, "cookie", "get").mockReturnValue("session=abc123; user_name=John");
|
|
304
|
+
expect(utils.getUserAccount()).toBeNull();
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
it("should return null if user_name cookie is missing", () => {
|
|
308
|
+
jest.spyOn(document, "cookie", "get").mockReturnValue("session=abc123; user_id=789");
|
|
309
|
+
expect(utils.getUserAccount()).toBeNull();
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
it("should return null if all cookies are missing", () => {
|
|
313
|
+
expect(utils.getUserAccount()).toBeNull();
|
|
314
|
+
});
|
|
288
315
|
});
|