@panoramax/web-viewer 3.2.3 → 4.0.0-develop-39167b4d

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 (255) hide show
  1. package/.gitlab-ci.yml +13 -6
  2. package/CHANGELOG.md +53 -1
  3. package/CODE_OF_CONDUCT.md +1 -1
  4. package/README.md +1 -1
  5. package/build/editor.html +10 -1
  6. package/build/index.css +12 -12
  7. package/build/index.css.map +1 -1
  8. package/build/index.html +1 -1
  9. package/build/index.js +2126 -14
  10. package/build/index.js.map +1 -1
  11. package/build/map.html +1 -1
  12. package/build/photo.html +1 -0
  13. package/build/static/media/atkinson-hyperlegible-next-latin-400-normal..woff +0 -0
  14. package/build/static/media/atkinson-hyperlegible-next-latin-400-normal..woff2 +0 -0
  15. package/build/static/media/atkinson-hyperlegible-next-latin-ext-400-normal..woff +0 -0
  16. package/build/static/media/atkinson-hyperlegible-next-latin-ext-400-normal..woff2 +0 -0
  17. package/build/viewer.html +12 -1
  18. package/build/widgets.html +1 -0
  19. package/config/jest/mocks.js +201 -0
  20. package/config/paths.js +2 -0
  21. package/config/webpack.config.js +52 -0
  22. package/docs/03_URL_settings.md +14 -16
  23. package/docs/05_Compatibility.md +59 -76
  24. package/docs/09_Develop.md +46 -11
  25. package/docs/90_Releases.md +2 -2
  26. package/docs/images/class_diagram.drawio +60 -45
  27. package/docs/images/class_diagram.jpg +0 -0
  28. package/docs/images/screenshot.jpg +0 -0
  29. package/docs/index.md +135 -0
  30. package/docs/reference/components/core/Basic.md +196 -0
  31. package/docs/reference/components/core/CoverageMap.md +210 -0
  32. package/docs/reference/components/core/Editor.md +224 -0
  33. package/docs/reference/components/core/PhotoViewer.md +307 -0
  34. package/docs/reference/components/core/Viewer.md +350 -0
  35. package/docs/reference/components/layout/BottomDrawer.md +35 -0
  36. package/docs/reference/components/layout/CorneredGrid.md +29 -0
  37. package/docs/reference/components/layout/Mini.md +45 -0
  38. package/docs/reference/components/layout/Tabs.md +45 -0
  39. package/docs/reference/components/menus/MapBackground.md +32 -0
  40. package/docs/reference/components/menus/MapFilters.md +15 -0
  41. package/docs/reference/components/menus/MapLayers.md +15 -0
  42. package/docs/reference/components/menus/MapLegend.md +15 -0
  43. package/docs/reference/components/menus/PictureLegend.md +16 -0
  44. package/docs/reference/components/menus/PictureMetadata.md +15 -0
  45. package/docs/reference/components/menus/PlayerOptions.md +15 -0
  46. package/docs/reference/components/menus/QualityScoreDoc.md +15 -0
  47. package/docs/reference/components/menus/ReportForm.md +15 -0
  48. package/docs/reference/components/menus/ShareMenu.md +15 -0
  49. package/docs/reference/components/ui/Button.md +40 -0
  50. package/docs/reference/components/ui/ButtonGroup.md +36 -0
  51. package/docs/reference/components/ui/CopyButton.md +38 -0
  52. package/docs/reference/components/ui/Grade.md +32 -0
  53. package/docs/reference/components/ui/LinkButton.md +45 -0
  54. package/docs/reference/components/ui/ListGroup.md +22 -0
  55. package/docs/reference/components/ui/Loader.md +56 -0
  56. package/docs/reference/components/ui/Map.md +239 -0
  57. package/docs/reference/components/ui/MapMore.md +256 -0
  58. package/docs/reference/components/ui/Photo.md +385 -0
  59. package/docs/reference/components/ui/Popup.md +56 -0
  60. package/docs/reference/components/ui/ProgressBar.md +32 -0
  61. package/docs/reference/components/ui/QualityScore.md +45 -0
  62. package/docs/reference/components/ui/SearchBar.md +63 -0
  63. package/docs/reference/components/ui/TogglableGroup.md +39 -0
  64. package/docs/reference/components/ui/widgets/GeoSearch.md +32 -0
  65. package/docs/reference/components/ui/widgets/Legend.md +49 -0
  66. package/docs/reference/components/ui/widgets/MapFiltersButton.md +33 -0
  67. package/docs/reference/components/ui/widgets/MapLayersButton.md +15 -0
  68. package/docs/reference/components/ui/widgets/OSMEditors.md +15 -0
  69. package/docs/reference/components/ui/widgets/PictureLegendActions.md +32 -0
  70. package/docs/reference/components/ui/widgets/Player.md +33 -0
  71. package/docs/reference/components/ui/widgets/Zoom.md +15 -0
  72. package/docs/reference/utils/API.md +334 -0
  73. package/docs/reference/utils/InitParameters.md +68 -0
  74. package/docs/reference/utils/URLHandler.md +107 -0
  75. package/docs/reference.md +79 -0
  76. package/docs/shortcuts.md +11 -0
  77. package/docs/tutorials/aerial_imagery.md +19 -0
  78. package/docs/tutorials/authentication.md +10 -0
  79. package/docs/tutorials/custom_widgets.md +59 -0
  80. package/docs/tutorials/map_style.md +39 -0
  81. package/docs/tutorials/migrate_v4.md +153 -0
  82. package/docs/tutorials/synced_coverage.md +43 -0
  83. package/mkdocs.yml +66 -5
  84. package/package.json +22 -17
  85. package/public/editor.html +21 -29
  86. package/public/index.html +17 -12
  87. package/public/map.html +19 -18
  88. package/public/photo.html +55 -0
  89. package/public/viewer.html +22 -26
  90. package/public/widgets.html +306 -0
  91. package/scripts/doc.js +79 -0
  92. package/src/components/core/Basic.css +48 -0
  93. package/src/components/core/Basic.js +349 -0
  94. package/src/components/core/CoverageMap.css +9 -0
  95. package/src/components/core/CoverageMap.js +139 -0
  96. package/src/components/core/Editor.css +23 -0
  97. package/src/components/core/Editor.js +390 -0
  98. package/src/components/core/PhotoViewer.css +48 -0
  99. package/src/components/core/PhotoViewer.js +499 -0
  100. package/src/components/core/Viewer.css +98 -0
  101. package/src/components/core/Viewer.js +564 -0
  102. package/src/components/core/index.js +12 -0
  103. package/src/components/index.js +13 -0
  104. package/src/components/layout/BottomDrawer.js +257 -0
  105. package/src/components/layout/CorneredGrid.js +112 -0
  106. package/src/components/layout/Mini.js +117 -0
  107. package/src/components/layout/Tabs.js +133 -0
  108. package/src/components/layout/index.js +9 -0
  109. package/src/components/menus/MapBackground.js +106 -0
  110. package/src/components/menus/MapFilters.js +400 -0
  111. package/src/components/menus/MapLayers.js +143 -0
  112. package/src/components/menus/MapLegend.js +34 -0
  113. package/src/components/menus/PictureLegend.js +257 -0
  114. package/src/components/menus/PictureMetadata.js +317 -0
  115. package/src/components/menus/PlayerOptions.js +95 -0
  116. package/src/components/menus/QualityScoreDoc.js +36 -0
  117. package/src/components/menus/ReportForm.js +133 -0
  118. package/src/components/menus/Share.js +100 -0
  119. package/src/components/menus/index.js +15 -0
  120. package/src/components/styles.js +383 -0
  121. package/src/components/ui/Button.js +77 -0
  122. package/src/components/ui/ButtonGroup.css +57 -0
  123. package/src/components/ui/ButtonGroup.js +68 -0
  124. package/src/components/ui/CopyButton.js +106 -0
  125. package/src/components/ui/Grade.js +54 -0
  126. package/src/components/ui/LinkButton.js +67 -0
  127. package/src/components/ui/ListGroup.js +66 -0
  128. package/src/components/ui/Loader.js +203 -0
  129. package/src/components/{Map.css → ui/Map.css} +5 -17
  130. package/src/components/{Map.js → ui/Map.js} +148 -156
  131. package/src/components/ui/MapMore.js +324 -0
  132. package/src/components/{Photo.css → ui/Photo.css} +6 -6
  133. package/src/components/{Photo.js → ui/Photo.js} +313 -101
  134. package/src/components/ui/Popup.js +145 -0
  135. package/src/components/ui/ProgressBar.js +104 -0
  136. package/src/components/ui/QualityScore.js +147 -0
  137. package/src/components/ui/SearchBar.js +367 -0
  138. package/src/components/ui/TogglableGroup.js +157 -0
  139. package/src/components/ui/index.js +22 -0
  140. package/src/components/ui/widgets/GeoSearch.css +21 -0
  141. package/src/components/ui/widgets/GeoSearch.js +139 -0
  142. package/src/components/ui/widgets/Legend.js +113 -0
  143. package/src/components/ui/widgets/MapFiltersButton.js +104 -0
  144. package/src/components/ui/widgets/MapLayersButton.js +79 -0
  145. package/src/components/ui/widgets/OSMEditors.js +155 -0
  146. package/src/components/ui/widgets/PictureLegendActions.js +117 -0
  147. package/src/components/ui/widgets/Player.css +7 -0
  148. package/src/components/ui/widgets/Player.js +151 -0
  149. package/src/components/ui/widgets/Zoom.js +82 -0
  150. package/src/components/ui/widgets/index.js +13 -0
  151. package/src/img/loader_base.jpg +0 -0
  152. package/src/img/panoramax.svg +13 -0
  153. package/src/img/switch_big.svg +20 -10
  154. package/src/index.js +7 -9
  155. package/src/translations/br.json +1 -0
  156. package/src/translations/da.json +38 -15
  157. package/src/translations/de.json +5 -3
  158. package/src/translations/en.json +35 -15
  159. package/src/translations/eo.json +38 -15
  160. package/src/translations/es.json +1 -1
  161. package/src/translations/fr.json +36 -16
  162. package/src/translations/hu.json +1 -1
  163. package/src/translations/it.json +39 -16
  164. package/src/translations/ja.json +182 -1
  165. package/src/translations/nl.json +106 -6
  166. package/src/translations/pl.json +1 -1
  167. package/src/translations/sv.json +182 -0
  168. package/src/translations/zh_Hant.json +35 -14
  169. package/src/utils/API.js +109 -49
  170. package/src/utils/InitParameters.js +388 -0
  171. package/src/utils/PhotoAdapter.js +1 -0
  172. package/src/utils/URLHandler.js +362 -0
  173. package/src/utils/geocoder.js +152 -0
  174. package/src/utils/{I18n.js → i18n.js} +7 -3
  175. package/src/utils/index.js +11 -0
  176. package/src/utils/{Map.js → map.js} +256 -77
  177. package/src/utils/picture.js +442 -0
  178. package/src/utils/utils.js +324 -0
  179. package/src/utils/widgets.js +55 -0
  180. package/tests/components/core/Basic.test.js +121 -0
  181. package/tests/components/core/BasicMock.js +25 -0
  182. package/tests/components/core/CoverageMap.test.js +20 -0
  183. package/tests/components/core/Editor.test.js +20 -0
  184. package/tests/components/core/PhotoViewer.test.js +57 -0
  185. package/tests/components/core/Viewer.test.js +84 -0
  186. package/tests/components/core/__snapshots__/PhotoViewer.test.js.snap +73 -0
  187. package/tests/components/core/__snapshots__/Viewer.test.js.snap +145 -0
  188. package/tests/components/ui/CopyButton.test.js +52 -0
  189. package/tests/components/ui/Loader.test.js +55 -0
  190. package/tests/components/{Map.test.js → ui/Map.test.js} +73 -61
  191. package/tests/components/{Photo.test.js → ui/Photo.test.js} +97 -63
  192. package/tests/components/ui/Popup.test.js +26 -0
  193. package/tests/components/ui/QualityScore.test.js +18 -0
  194. package/tests/components/ui/SearchBar.test.js +110 -0
  195. package/tests/components/ui/__snapshots__/CopyButton.test.js.snap +33 -0
  196. package/tests/components/ui/__snapshots__/Loader.test.js.snap +56 -0
  197. package/tests/components/{__snapshots__ → ui/__snapshots__}/Map.test.js.snap +11 -38
  198. package/tests/components/{__snapshots__ → ui/__snapshots__}/Photo.test.js.snap +70 -6
  199. package/tests/components/ui/__snapshots__/Popup.test.js.snap +29 -0
  200. package/tests/components/ui/__snapshots__/QualityScore.test.js.snap +11 -0
  201. package/tests/components/ui/__snapshots__/SearchBar.test.js.snap +65 -0
  202. package/tests/utils/API.test.js +83 -83
  203. package/tests/utils/InitParameters.test.js +499 -0
  204. package/tests/utils/URLHandler.test.js +401 -0
  205. package/tests/utils/__snapshots__/API.test.js.snap +10 -0
  206. package/tests/utils/__snapshots__/URLHandler.test.js.snap +21 -0
  207. package/tests/utils/__snapshots__/{Map.test.js.snap → geocoder.test.js.snap} +1 -1
  208. package/tests/utils/__snapshots__/map.test.js.snap +11 -0
  209. package/tests/utils/__snapshots__/picture.test.js.snap +327 -0
  210. package/tests/utils/__snapshots__/widgets.test.js.snap +19 -0
  211. package/tests/utils/geocoder.test.js +37 -0
  212. package/tests/utils/{I18n.test.js → i18n.test.js} +8 -8
  213. package/tests/utils/map.test.js +126 -0
  214. package/tests/utils/picture.test.js +745 -0
  215. package/tests/utils/utils.test.js +288 -0
  216. package/tests/utils/widgets.test.js +31 -0
  217. package/docs/01_Start.md +0 -149
  218. package/docs/02_Usage.md +0 -831
  219. package/docs/04_Advanced_examples.md +0 -216
  220. package/src/Editor.css +0 -37
  221. package/src/Editor.js +0 -361
  222. package/src/StandaloneMap.js +0 -114
  223. package/src/Viewer.css +0 -203
  224. package/src/Viewer.js +0 -1246
  225. package/src/components/CoreView.css +0 -70
  226. package/src/components/CoreView.js +0 -175
  227. package/src/components/Loader.css +0 -74
  228. package/src/components/Loader.js +0 -120
  229. package/src/img/loader_hd.jpg +0 -0
  230. package/src/utils/Exif.js +0 -193
  231. package/src/utils/Utils.js +0 -631
  232. package/src/utils/Widgets.js +0 -562
  233. package/src/viewer/URLHash.js +0 -469
  234. package/src/viewer/Widgets.css +0 -880
  235. package/src/viewer/Widgets.js +0 -1470
  236. package/tests/Editor.test.js +0 -126
  237. package/tests/StandaloneMap.test.js +0 -45
  238. package/tests/Viewer.test.js +0 -366
  239. package/tests/__snapshots__/Editor.test.js.snap +0 -298
  240. package/tests/__snapshots__/StandaloneMap.test.js.snap +0 -30
  241. package/tests/__snapshots__/Viewer.test.js.snap +0 -195
  242. package/tests/components/CoreView.test.js +0 -92
  243. package/tests/components/Loader.test.js +0 -38
  244. package/tests/components/__snapshots__/Loader.test.js.snap +0 -15
  245. package/tests/utils/Exif.test.js +0 -124
  246. package/tests/utils/Map.test.js +0 -113
  247. package/tests/utils/Utils.test.js +0 -300
  248. package/tests/utils/Widgets.test.js +0 -107
  249. package/tests/utils/__snapshots__/Exif.test.js.snap +0 -43
  250. package/tests/utils/__snapshots__/Utils.test.js.snap +0 -41
  251. package/tests/utils/__snapshots__/Widgets.test.js.snap +0 -44
  252. package/tests/viewer/URLHash.test.js +0 -559
  253. package/tests/viewer/Widgets.test.js +0 -127
  254. package/tests/viewer/__snapshots__/URLHash.test.js.snap +0 -108
  255. package/tests/viewer/__snapshots__/Widgets.test.js.snap +0 -403
@@ -0,0 +1,327 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`apiFeatureToPSVNode works 1`] = `
4
+ Object {
5
+ "caption": Object {
6
+ "date": mockConstructor {},
7
+ "license": "<a href=\\"https://spdx.org/licenses/CC-BY-SA-4.0.html\\" title=\\"\\" target=\\"_blank\\">CC-BY-SA-4.0</a>",
8
+ "producer": Array [
9
+ "Hopen111",
10
+ ],
11
+ "tz": "+00:00",
12
+ },
13
+ "gps": Array [
14
+ -92.70188245,
15
+ 41.322064692,
16
+ ],
17
+ "horizontalFov": 360,
18
+ "id": "00000000-76a0-4bec-b19e-a56f51ef997d",
19
+ "links": Array [
20
+ Object {
21
+ "arrowStyle": Object {
22
+ "element": <img
23
+ alt=""
24
+ src="arrow_triangle.svg"
25
+ />,
26
+ "size": Object {
27
+ "height": 75,
28
+ "width": 75,
29
+ },
30
+ },
31
+ "gps": Array [
32
+ -92.701854443,
33
+ 41.322047796,
34
+ ],
35
+ "linkOffset": Object {
36
+ "yaw": -5.3930673886624785,
37
+ },
38
+ "nodeId": "66ea29cd-941c-4201-977f-efb87bd5465e",
39
+ },
40
+ Object {
41
+ "arrowStyle": Object {
42
+ "element": <img
43
+ alt=""
44
+ src="arrow_triangle.svg"
45
+ />,
46
+ "size": Object {
47
+ "height": 75,
48
+ "width": 75,
49
+ },
50
+ },
51
+ "gps": Array [
52
+ -92.701910458,
53
+ 41.322081588,
54
+ ],
55
+ "linkOffset": Object {
56
+ "yaw": -5.3930673886624785,
57
+ },
58
+ "nodeId": "5fb8e767-6fe3-4bcb-b19f-7031d9a64fc8",
59
+ },
60
+ ],
61
+ "origInstance": undefined,
62
+ "panorama": Object {
63
+ "basePanoData": [Function],
64
+ "baseUrl": "https://panoramax.openstreetmap.fr/api/pictures/00000000-76a0-4bec-b19e-a56f51ef997d/sd.jpg",
65
+ "cols": 8,
66
+ "hdUrl": "https://panoramax.openstreetmap.fr/api/pictures/00000000-76a0-4bec-b19e-a56f51ef997d/hd.jpg",
67
+ "origBaseUrl": "https://panoramax.openstreetmap.fr/api/pictures/00000000-76a0-4bec-b19e-a56f51ef997d/sd.jpg",
68
+ "rows": 4,
69
+ "thumbUrl": "https://panoramax.openstreetmap.fr/api/pictures/00000000-76a0-4bec-b19e-a56f51ef997d/thumb.jpg",
70
+ "tileUrl": [Function],
71
+ "width": 5376,
72
+ },
73
+ "properties": Object {
74
+ "created": "2024-09-04T02:40:11.836165+00:00",
75
+ "datetime": "2024-09-01T23:35:37.797105+00:00",
76
+ "datetimetz": "2024-09-01T23:35:37.797105+00:00",
77
+ "exif": Object {
78
+ "Xmp.GPano.CroppedAreaImageHeightPixels": "2688",
79
+ "Xmp.GPano.CroppedAreaImageWidthPixels": "5376",
80
+ "Xmp.GPano.CroppedAreaLeftPixels": "0",
81
+ "Xmp.GPano.CroppedAreaTopPixels": "0",
82
+ "Xmp.GPano.FullPanoHeightPixels": "2688",
83
+ "Xmp.GPano.FullPanoWidthPixels": "5376",
84
+ "Xmp.GPano.ProjectionType": "equirectangular",
85
+ "Xmp.GPano.UsePanoramaViewer": "True",
86
+ },
87
+ "geovisio:image": "https://panoramax.openstreetmap.fr/api/pictures/00000000-76a0-4bec-b19e-a56f51ef997d/hd.jpg",
88
+ "geovisio:producer": "Hopen111",
89
+ "geovisio:thumbnail": "https://panoramax.openstreetmap.fr/api/pictures/00000000-76a0-4bec-b19e-a56f51ef997d/thumb.jpg",
90
+ "license": "CC-BY-SA-4.0",
91
+ "original_file:name": "GS010837-003545.jpg",
92
+ "original_file:size": 788436,
93
+ "panoramax:horizontal_pixel_density": 15,
94
+ "pers:interior_orientation": Object {
95
+ "field_of_view": 360,
96
+ "sensor_array_dimensions": Array [
97
+ 5376,
98
+ 2688,
99
+ ],
100
+ },
101
+ "tiles:tile_matrix_sets": Object {
102
+ "geovisio": Object {
103
+ "identifier": "geovisio-00000000-76a0-4bec-b19e-a56f51ef997d",
104
+ "tileMatrix": Array [
105
+ Object {
106
+ "identifier": "0",
107
+ "matrixHeight": 4,
108
+ "matrixWidth": 8,
109
+ "scaleDenominator": 1,
110
+ "tileHeight": 672,
111
+ "tileWidth": 672,
112
+ "topLeftCorner": Array [
113
+ 0,
114
+ 0,
115
+ ],
116
+ "type": "TileMatrixType",
117
+ },
118
+ ],
119
+ "title": "GeoVisio tile matrix for picture 00000000-76a0-4bec-b19e-a56f51ef997d",
120
+ "type": "TileMatrixSetType",
121
+ },
122
+ },
123
+ "view:azimuth": 309,
124
+ },
125
+ "sequence": Object {
126
+ "id": "ec31c324-b43a-425e-a24c-3de56d7914c1",
127
+ "nextPic": "5fb8e767-6fe3-4bcb-b19f-7031d9a64fc8",
128
+ "prevPic": "66ea29cd-941c-4201-977f-efb87bd5465e",
129
+ },
130
+ "sphereCorrection": Object {},
131
+ }
132
+ `;
133
+
134
+ exports[`filterRelatedPicsLinks works 1`] = `
135
+ Array [
136
+ Object {
137
+ "arrowStyle": Object {
138
+ "element": <img
139
+ alt=""
140
+ src="arrow_turn.svg"
141
+ />,
142
+ "size": Object {
143
+ "height": 128,
144
+ "width": 42.666666666666664,
145
+ },
146
+ },
147
+ "gps": Array [
148
+ 4.840134667,
149
+ 45.756240466,
150
+ ],
151
+ "linkOffset": Object {
152
+ "yaw": -1.8849555921538759,
153
+ },
154
+ "nodeId": "aaa1ae2f-b48a-4291-972e-030fcd44760b",
155
+ },
156
+ Object {
157
+ "arrowStyle": Object {
158
+ "element": <img
159
+ alt=""
160
+ src="arrow_triangle.svg"
161
+ />,
162
+ "size": Object {
163
+ "height": 75,
164
+ "width": 75,
165
+ },
166
+ },
167
+ "gps": Array [
168
+ 4.8401792,
169
+ 45.7562024,
170
+ ],
171
+ "linkOffset": Object {
172
+ "yaw": -1.8849555921538759,
173
+ },
174
+ "nodeId": "38abdc16-b878-4762-a433-33e52e62ae9b",
175
+ },
176
+ Object {
177
+ "arrowStyle": Object {
178
+ "element": <img
179
+ alt=""
180
+ src="arrow_turn.svg"
181
+ />,
182
+ "size": Object {
183
+ "height": 128,
184
+ "width": 42.666666666666664,
185
+ },
186
+ },
187
+ "gps": Array [
188
+ 4.8401379,
189
+ 45.7561616,
190
+ ],
191
+ "linkOffset": Object {
192
+ "yaw": -1.8849555921538759,
193
+ },
194
+ "nodeId": "5e1d8461-fe5d-4d57-9c87-f2403baff37d",
195
+ },
196
+ Object {
197
+ "arrowStyle": Object {
198
+ "element": <img
199
+ alt=""
200
+ src="arrow_turn.svg"
201
+ />,
202
+ "size": Object {
203
+ "height": 128,
204
+ "width": 42.666666666666664,
205
+ },
206
+ },
207
+ "gps": Array [
208
+ 4.8400918,
209
+ 45.7561938,
210
+ ],
211
+ "linkOffset": Object {
212
+ "yaw": -1.8849555921538759,
213
+ },
214
+ "nodeId": "abff42de-2862-4b15-8c2a-dca22ed2deaf",
215
+ },
216
+ Object {
217
+ "arrowStyle": Object {
218
+ "element": <img
219
+ alt=""
220
+ src="arrow_triangle.svg"
221
+ />,
222
+ "size": Object {
223
+ "height": 75,
224
+ "width": 75,
225
+ },
226
+ },
227
+ "gps": Array [
228
+ 4.8400633,
229
+ 45.7562389,
230
+ ],
231
+ "linkOffset": Object {
232
+ "yaw": -1.8849555921538759,
233
+ },
234
+ "nodeId": "1c5025ed-3e03-4cf0-8879-7ed9091a9e33",
235
+ },
236
+ ]
237
+ `;
238
+
239
+ exports[`getCroppedPanoData works with API props 1`] = `
240
+ Object {
241
+ "croppedHeight": 2606,
242
+ "croppedWidth": 15872,
243
+ "croppedX": 0,
244
+ "croppedY": 2538,
245
+ "fullHeight": 7936,
246
+ "fullWidth": 15872,
247
+ }
248
+ `;
249
+
250
+ exports[`getCroppedPanoData works with API props and unneeded 1`] = `Object {}`;
251
+
252
+ exports[`getCroppedPanoData works with exif tags 1`] = `
253
+ Object {
254
+ "croppedHeight": 2606,
255
+ "croppedWidth": 15872,
256
+ "croppedX": 0,
257
+ "croppedY": 2538,
258
+ "fullHeight": 7936,
259
+ "fullWidth": 15872,
260
+ }
261
+ `;
262
+
263
+ exports[`getCroppedPanoData works with exif tags and unneeded 1`] = `Object {}`;
264
+
265
+ exports[`getNodeCaption works with date + 2 producers 1`] = `
266
+ Object {
267
+ "date": Object {
268
+ "toLocaleDateString": [Function],
269
+ },
270
+ "producer": Array [
271
+ "GeoVisio Corp.",
272
+ "PanierAvide",
273
+ ],
274
+ }
275
+ `;
276
+
277
+ exports[`getNodeCaption works with date + producer 1`] = `
278
+ Object {
279
+ "date": Object {
280
+ "toLocaleDateString": [Function],
281
+ },
282
+ "producer": Array [
283
+ "PanierAvide",
284
+ ],
285
+ }
286
+ `;
287
+
288
+ exports[`getNodeCaption works with date 1`] = `
289
+ Object {
290
+ "date": Object {
291
+ "toLocaleDateString": [Function],
292
+ },
293
+ }
294
+ `;
295
+
296
+ exports[`getNodeCaption works with date+tz 1`] = `
297
+ Object {
298
+ "date": Object {
299
+ "toLocaleDateString": [Function],
300
+ },
301
+ "tz": "-03:00",
302
+ }
303
+ `;
304
+
305
+ exports[`getNodeCaption works with producer 1`] = `
306
+ Object {
307
+ "producer": Array [
308
+ "PanierAvide",
309
+ ],
310
+ }
311
+ `;
312
+
313
+ exports[`getSphereCorrection works with API props 1`] = `
314
+ Object {
315
+ "pan": 0.7330382858376184,
316
+ "roll": 1.260127719939906,
317
+ "tilt": -0.5235987755982988,
318
+ }
319
+ `;
320
+
321
+ exports[`getSphereCorrection works with exif tags 1`] = `
322
+ Object {
323
+ "pan": 0.7330382858376184,
324
+ "roll": 1.260127719939906,
325
+ "tilt": -0.5235987755982988,
326
+ }
327
+ `;
@@ -0,0 +1,19 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`fa works 1`] = `
4
+ <svg
5
+ aria-hidden="true"
6
+ class="svg-inline--fa fa-chevron-down"
7
+ data-icon="chevron-down"
8
+ data-prefix="fas"
9
+ focusable="false"
10
+ role="img"
11
+ viewBox="0 0 512 512"
12
+ xmlns="http://www.w3.org/2000/svg"
13
+ >
14
+ <path
15
+ d="M233.4 406.6c12.5 12.5 32.8 12.5 45.3 0l192-192c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L256 338.7 86.6 169.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l192 192z"
16
+ fill="currentColor"
17
+ />
18
+ </svg>
19
+ `;
@@ -0,0 +1,37 @@
1
+ import * as geocoder from "../../src/utils/geocoder";
2
+ import GEOCODER_NOMINATIM from "../data/Map_geocoder_nominatim.json";
3
+ import GEOCODER_BAN from "../data/Map_geocoder_ban.json";
4
+
5
+ describe("forwardGeocodingNominatim", () => {
6
+ it("works", () => {
7
+ // Mock API search
8
+ global.fetch = jest.fn(() => Promise.resolve({
9
+ json: () => GEOCODER_NOMINATIM
10
+ }));
11
+
12
+ // Search config
13
+ const cfg = { query: "bla", limit: 5, bbox: "17.7,-45.2,17.8,-45.1" };
14
+
15
+ return geocoder.forwardGeocodingNominatim(cfg).then(res => {
16
+ expect(global.fetch.mock.calls).toEqual([["https://nominatim.openstreetmap.org/search?q=bla&limit=5&viewbox=17.7%2C-45.2%2C17.8%2C-45.1&format=geojson&polygon_geojson=1&addressdetails=1"]]);
17
+ expect(res).toMatchSnapshot();
18
+ });
19
+ });
20
+ });
21
+
22
+ describe("forwardGeocodingBAN", () => {
23
+ it("works", () => {
24
+ // Mock API search
25
+ global.fetch = jest.fn(() => Promise.resolve({
26
+ json: () => GEOCODER_BAN
27
+ }));
28
+
29
+ // Search config
30
+ const cfg = { query: "bla", limit: 5, proximity: "17.7,-45.2" };
31
+
32
+ return geocoder.forwardGeocodingBAN(cfg).then(res => {
33
+ expect(global.fetch.mock.calls).toEqual([["https://api-adresse.data.gouv.fr/search/?q=bla&limit=5&lat=17.7&lon=-45.2"]]);
34
+ expect(res).toMatchSnapshot();
35
+ });
36
+ });
37
+ });
@@ -1,4 +1,4 @@
1
- import { autoDetectLocale, getTranslations } from "../../src/utils/I18n";
1
+ import { autoDetectLocale, getTranslations } from "../../src/utils/i18n";
2
2
 
3
3
  describe("autoDetectLocale", () => {
4
4
  // Mock the window.navigator.languages
@@ -32,24 +32,24 @@ describe("autoDetectLocale", () => {
32
32
  expect(autoDetectLocale(supportedTranslations, fallback)).toBe("en");
33
33
  });
34
34
 
35
- it("returns zh_Hant for Chinese Traditional locales", () => {
35
+ it("returns zh-Hant for Chinese Traditional locales", () => {
36
36
  Object.defineProperty(window.navigator, "languages", {
37
37
  value: ["zh-TW"],
38
38
  configurable: true
39
39
  });
40
- const supportedTranslations = ["zh_Hant", "zh_Hans", "en"];
40
+ const supportedTranslations = ["zh-Hant", "zh-Hans", "en"];
41
41
  const fallback = "en";
42
- expect(autoDetectLocale(supportedTranslations, fallback)).toBe("zh_Hant");
42
+ expect(autoDetectLocale(supportedTranslations, fallback)).toBe("zh-Hant");
43
43
  });
44
44
 
45
- it("returns zh_Hans for Chinese Simplified locales", () => {
45
+ it("returns zh-Hans for Chinese Simplified locales", () => {
46
46
  Object.defineProperty(window.navigator, "languages", {
47
47
  value: ["zh-CN"],
48
48
  configurable: true
49
49
  });
50
- const supportedTranslations = ["zh_Hant", "zh_Hans", "en"];
50
+ const supportedTranslations = ["zh-Hant", "zh-Hans", "en"];
51
51
  const fallback = "en";
52
- expect(autoDetectLocale(supportedTranslations, fallback)).toBe("zh_Hans");
52
+ expect(autoDetectLocale(supportedTranslations, fallback)).toBe("zh-Hans");
53
53
  });
54
54
 
55
55
  it("returns first matched language even when navigator language has region", () => {
@@ -105,7 +105,7 @@ describe("getTranslations", () => {
105
105
  });
106
106
 
107
107
  it("works when primary lang code exists", () => {
108
- const res = getTranslations("fr_FR");
108
+ const res = getTranslations("fr-FR");
109
109
  expect(res.map.loading).toBe("Chargement…");
110
110
  });
111
111
  });
@@ -0,0 +1,126 @@
1
+ import * as map from "../../src/utils/map";
2
+
3
+ describe("getThumbGif", () => {
4
+ it("works", () => {
5
+ const lang = { loading: "Loading..." };
6
+ const res = map.getThumbGif(lang);
7
+ expect(res).toBeDefined();
8
+ expect(res.tagName).toBe("IMG");
9
+ expect(res.alt).toBe(lang.loading);
10
+ expect(res.title).toBe(lang.loading);
11
+ });
12
+ });
13
+
14
+ describe("isLabelLayer", () => {
15
+ it("works with just text-field", () => {
16
+ const layer = { type: "symbol", layout: { "text-field": "Label" } };
17
+ expect(map.isLabelLayer(layer)).toBe(true);
18
+ });
19
+
20
+ it("works with text-field + minzoom < 15", () => {
21
+ const layer = { type: "symbol", layout: { "text-field": "Label" }, minzoom: 10 };
22
+ expect(map.isLabelLayer(layer)).toBe(true);
23
+ });
24
+
25
+ it("works with text-field + minzoom >= 15", () => {
26
+ const layer = { type: "symbol", layout: { "text-field": "Label" }, minzoom: 15 };
27
+ expect(map.isLabelLayer(layer)).toBe(false);
28
+ });
29
+
30
+ it("works with non-symbol layer", () => {
31
+ const layer = { type: "fill", layout: { "text-field": "Label" } };
32
+ expect(map.isLabelLayer(layer)).toBe(false);
33
+ });
34
+
35
+ it("works without text-field", () => {
36
+ const layer = { type: "symbol", layout: {} };
37
+ expect(map.isLabelLayer(layer)).toBe(false);
38
+ });
39
+ });
40
+
41
+ describe("getUserLayerId", () => {
42
+ it("works with default tiles", () => {
43
+ expect(map.getUserLayerId("geovisio", "pictures")).toBe("geovisio_pictures");
44
+ });
45
+
46
+ it("works with specific user tiles", () => {
47
+ expect(map.getUserLayerId("toto", "pictures")).toBe("geovisio_toto_pictures");
48
+ });
49
+ });
50
+
51
+ describe("getUserSourceId", () => {
52
+ it("works with default tiles", () => {
53
+ expect(map.getUserSourceId("geovisio")).toBe("geovisio");
54
+ });
55
+
56
+ it("works with specific user tiles", () => {
57
+ expect(map.getUserSourceId("toto")).toBe("geovisio_toto");
58
+ });
59
+ });
60
+
61
+ describe("switchCoefValue", () => {
62
+ it("works", () => {
63
+ const l = {id: "bla", paint: { "circle-radius": ["bla", ["get", "coef"]]}, layout: {"circle-sort": "coef"}};
64
+ const res = map.switchCoefValue(l, "coef_360");
65
+ expect(res).toEqual({id: "bla", paint: { "circle-radius": ["bla", ["get", "coef_360"]]}, layout: {"circle-sort": "coef_360"}})
66
+ });
67
+ });
68
+
69
+
70
+ Object.defineProperty(window, "localStorage", { value: {
71
+ setItem: jest.fn(),
72
+ getItem: jest.fn(),
73
+ } });
74
+
75
+ describe("getMapParamsFromLocalStorage", () => {
76
+ it("should return an empty object if no params are stored", () => {
77
+ localStorage.getItem.mockReturnValue(null);
78
+ const result = map.getMapParamsFromLocalStorage();
79
+ expect(result).toEqual({});
80
+ });
81
+
82
+ it("should return parsed params if they exist in localStorage", () => {
83
+ const params = { center: { lat: "48.8566000", lng: "2.3522000" }, zoom: "10.0", background: "aerial", theme: "age" };
84
+ localStorage.getItem.mockReturnValue(JSON.stringify(params));
85
+ const result = map.getMapParamsFromLocalStorage();
86
+ expect(localStorage.getItem.mock.calls).toMatchSnapshot();
87
+ expect(result).toEqual(params);
88
+ });
89
+
90
+ it("should return an empty object if JSON parsing fails", () => {
91
+ console.warn = jest.fn();
92
+ localStorage.getItem.mockReturnValue("invalid-json");
93
+ const result = map.getMapParamsFromLocalStorage();
94
+ expect(result).toEqual({});
95
+ expect(console.warn.mock.calls[0][0]).toEqual("Can't read map parameters stored in localStorage");
96
+ });
97
+ });
98
+
99
+ describe("saveMapParamsToLocalStorage", () => {
100
+ const mockMap = {
101
+ getCenter: jest.fn().mockReturnValue({ lat: 48.8566, lng: 2.3522 }),
102
+ getZoom: jest.fn().mockReturnValue(10),
103
+ getBackground: jest.fn().mockReturnValue("streets"),
104
+ _mapFilters: { theme: "qualityscore" },
105
+ on: jest.fn(),
106
+ };
107
+
108
+ beforeEach(() => {
109
+ jest.clearAllMocks();
110
+ });
111
+
112
+ it("should add event listeners to the map", () => {
113
+ map.saveMapParamsToLocalStorage(mockMap);
114
+ expect(mockMap.on).toHaveBeenCalledWith("background-changed", expect.any(Function));
115
+ expect(mockMap.on).toHaveBeenCalledWith("filters-changed", expect.any(Function));
116
+ expect(mockMap.on).toHaveBeenCalledWith("moveend", expect.any(Function));
117
+ expect(mockMap.on).toHaveBeenCalledWith("zoomend", expect.any(Function));
118
+ expect(mockMap.on).toHaveBeenCalledWith("dragend", expect.any(Function));
119
+ expect(mockMap.on).toHaveBeenCalledWith("boxzoomend", expect.any(Function));
120
+ });
121
+
122
+ it("should save map parameters to localStorage", () => {
123
+ map.saveMapParamsToLocalStorage(mockMap);
124
+ expect(localStorage.setItem.mock.calls).toMatchSnapshot();
125
+ });
126
+ });