@panoramax/web-viewer 4.0.2-develop-9b499e28 → 4.0.2-develop-e389d775
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 +4 -0
- package/build/index.css +1 -1
- package/build/index.css.map +1 -1
- package/build/index.js +274 -59
- package/build/index.js.map +1 -1
- package/config/jest/mocks.js +5 -0
- package/docs/reference/components/core/PhotoViewer.md +1 -0
- package/docs/reference/components/core/Viewer.md +1 -0
- package/docs/reference/components/menus/AnnotationsList.md +16 -0
- package/docs/reference/components/ui/HashTags.md +15 -0
- package/docs/reference/components/ui/ListItem.md +38 -0
- package/docs/reference/components/ui/Photo.md +53 -1
- package/docs/reference/components/ui/SemanticsTable.md +32 -0
- package/docs/reference/utils/PresetsManager.md +35 -0
- package/docs/reference.md +4 -0
- package/mkdocs.yml +4 -0
- package/package.json +2 -1
- package/src/components/core/Basic.css +2 -0
- package/src/components/core/PhotoViewer.js +11 -0
- package/src/components/core/Viewer.js +7 -0
- package/src/components/layout/Tabs.js +1 -1
- package/src/components/menus/AnnotationsList.js +146 -0
- package/src/components/menus/PictureLegend.js +2 -4
- package/src/components/menus/PictureMetadata.js +66 -2
- package/src/components/menus/index.js +1 -0
- package/src/components/styles.js +34 -0
- package/src/components/ui/HashTags.js +98 -0
- package/src/components/ui/ListItem.js +83 -0
- package/src/components/ui/Photo.js +137 -0
- package/src/components/ui/SemanticsTable.js +87 -0
- package/src/components/ui/index.js +3 -0
- package/src/img/osm.svg +49 -0
- package/src/img/wd.svg +1 -0
- package/src/translations/en.json +22 -0
- package/src/translations/fr.json +20 -0
- package/src/utils/PresetsManager.js +137 -0
- package/src/utils/index.js +3 -1
- package/src/utils/picture.js +28 -0
- package/src/utils/semantics.js +162 -0
- package/src/utils/services.js +38 -0
- package/src/utils/widgets.js +18 -1
- package/tests/components/core/__snapshots__/PhotoViewer.test.js.snap +10 -0
- package/tests/components/core/__snapshots__/Viewer.test.js.snap +10 -0
- package/tests/utils/PresetsManager.test.js +123 -0
- package/tests/utils/semantics.test.js +125 -0
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { decodeKey, decodeBasicTag, groupByPrefix } from "../../src/utils/semantics";
|
|
2
|
+
|
|
3
|
+
describe("decodeBasicTag", () => {
|
|
4
|
+
test("should return null if no equal sign is present", () => {
|
|
5
|
+
expect(decodeBasicTag("key")).toBeNull();
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
test("should correctly decode a tag with an equal sign", () => {
|
|
9
|
+
expect(decodeBasicTag("key=value")).toEqual({
|
|
10
|
+
key: { prefix: "", subkey: "key", qualifies: null },
|
|
11
|
+
value: "value"
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
test("should correctly decode a tag with a prefix", () => {
|
|
16
|
+
expect(decodeBasicTag("osm|key=value")).toEqual({
|
|
17
|
+
key: { prefix: "osm", subkey: "key", qualifies: null },
|
|
18
|
+
value: "value"
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
describe("decodeKey", () => {
|
|
24
|
+
test("should return default structure if key does not match regex", () => {
|
|
25
|
+
expect(decodeKey("panoKey")).toEqual({
|
|
26
|
+
prefix: "",
|
|
27
|
+
subkey: "panoKey",
|
|
28
|
+
qualifies: null
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
test("should correctly decode a key with a prefix", () => {
|
|
33
|
+
expect(decodeKey("osm|traffic_sign")).toEqual({
|
|
34
|
+
prefix: "osm",
|
|
35
|
+
subkey: "traffic_sign",
|
|
36
|
+
qualifies: null
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
test("should correctly decode a key with qualifiers", () => {
|
|
41
|
+
expect(decodeKey("detection_model[camera_mount=pole]")).toEqual({
|
|
42
|
+
prefix: "",
|
|
43
|
+
subkey: "detection_model",
|
|
44
|
+
qualifies: { key: { prefix: "", subkey: "camera_mount", qualifies: null }, value: "pole" }
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
test("should correctly decode a key with a prefix and qualifiers", () => {
|
|
49
|
+
expect(decodeKey("osm|source[osm|traffic_sign=stop]")).toEqual({
|
|
50
|
+
prefix: "osm",
|
|
51
|
+
subkey: "source",
|
|
52
|
+
qualifies: { key: { prefix: "osm", subkey: "traffic_sign", qualifies: null }, value: "stop" }
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
describe("groupByPrefix", () => {
|
|
58
|
+
test("should group tags by prefix", () => {
|
|
59
|
+
const tags = [
|
|
60
|
+
{ key: "osm|highway", value: "residential" },
|
|
61
|
+
{ key: "wd|P31", value: "Q5" },
|
|
62
|
+
{ key: "exif|model", value: "CameraModel" }
|
|
63
|
+
];
|
|
64
|
+
|
|
65
|
+
const expected = [
|
|
66
|
+
{
|
|
67
|
+
prefix: "osm",
|
|
68
|
+
title: "OpenStreetMap",
|
|
69
|
+
tags: [{ key: "highway", value: "residential" }],
|
|
70
|
+
key_transform: expect.any(Function),
|
|
71
|
+
logo: "osm.svg",
|
|
72
|
+
value_transform: expect.any(Function)
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
prefix: "wd",
|
|
76
|
+
title: "Wikidata",
|
|
77
|
+
tags: [{ key: "P31", value: "Q5" }],
|
|
78
|
+
key_transform: expect.any(Function),
|
|
79
|
+
logo: "wd.svg",
|
|
80
|
+
value_transform: expect.any(Function)
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
prefix: "exif",
|
|
84
|
+
title: "EXIF",
|
|
85
|
+
tags: [{ key: "model", value: "CameraModel" }]
|
|
86
|
+
}
|
|
87
|
+
];
|
|
88
|
+
|
|
89
|
+
expect(groupByPrefix(tags)).toEqual(expected);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
test("should handle qualifiers correctly", () => {
|
|
93
|
+
const tags = [
|
|
94
|
+
{ key: "osm|highway", value: "residential" },
|
|
95
|
+
{ key: "osm|source[osm|highway=residential]", value: "opendata" }
|
|
96
|
+
];
|
|
97
|
+
|
|
98
|
+
const expected = [{
|
|
99
|
+
prefix: "osm",
|
|
100
|
+
title: "OpenStreetMap",
|
|
101
|
+
tags: [{
|
|
102
|
+
key: "highway",
|
|
103
|
+
value: "residential",
|
|
104
|
+
qualifiers: [{ key: "osm|source[osm|highway=residential]", prefix: "osm", subkey: "source", value: "opendata" }]
|
|
105
|
+
}],
|
|
106
|
+
key_transform: expect.any(Function),
|
|
107
|
+
logo: "osm.svg",
|
|
108
|
+
value_transform: expect.any(Function)
|
|
109
|
+
}];
|
|
110
|
+
|
|
111
|
+
expect(groupByPrefix(tags)).toEqual(expected);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
test("should handle unknown prefixes", () => {
|
|
115
|
+
const tags = [ { key: "unknown|key", value: "value" } ];
|
|
116
|
+
|
|
117
|
+
const expected = [{
|
|
118
|
+
prefix: "unknown",
|
|
119
|
+
title: "unknown",
|
|
120
|
+
tags: [{ key: "key", value: "value" }]
|
|
121
|
+
}];
|
|
122
|
+
|
|
123
|
+
expect(groupByPrefix(tags)).toEqual(expected);
|
|
124
|
+
});
|
|
125
|
+
});
|