umap-project 2.5.1__py3-none-any.whl → 2.6.0b0__py3-none-any.whl

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.

Potentially problematic release.


This version of umap-project might be problematic. Click here for more details.

Files changed (193) hide show
  1. umap/__init__.py +1 -1
  2. umap/admin.py +6 -1
  3. umap/context_processors.py +2 -1
  4. umap/decorators.py +13 -2
  5. umap/forms.py +26 -2
  6. umap/locale/br/LC_MESSAGES/django.mo +0 -0
  7. umap/locale/br/LC_MESSAGES/django.po +252 -146
  8. umap/locale/ca/LC_MESSAGES/django.mo +0 -0
  9. umap/locale/ca/LC_MESSAGES/django.po +274 -162
  10. umap/locale/cs_CZ/LC_MESSAGES/django.mo +0 -0
  11. umap/locale/cs_CZ/LC_MESSAGES/django.po +261 -150
  12. umap/locale/de/LC_MESSAGES/django.mo +0 -0
  13. umap/locale/de/LC_MESSAGES/django.po +299 -187
  14. umap/locale/el/LC_MESSAGES/django.mo +0 -0
  15. umap/locale/el/LC_MESSAGES/django.po +215 -159
  16. umap/locale/en/LC_MESSAGES/django.po +211 -155
  17. umap/locale/es/LC_MESSAGES/django.mo +0 -0
  18. umap/locale/es/LC_MESSAGES/django.po +255 -144
  19. umap/locale/eu/LC_MESSAGES/django.mo +0 -0
  20. umap/locale/eu/LC_MESSAGES/django.po +254 -198
  21. umap/locale/fa_IR/LC_MESSAGES/django.mo +0 -0
  22. umap/locale/fa_IR/LC_MESSAGES/django.po +346 -234
  23. umap/locale/fr/LC_MESSAGES/django.mo +0 -0
  24. umap/locale/fr/LC_MESSAGES/django.po +216 -160
  25. umap/locale/hu/LC_MESSAGES/django.mo +0 -0
  26. umap/locale/hu/LC_MESSAGES/django.po +215 -159
  27. umap/locale/it/LC_MESSAGES/django.mo +0 -0
  28. umap/locale/it/LC_MESSAGES/django.po +252 -146
  29. umap/locale/ms/LC_MESSAGES/django.mo +0 -0
  30. umap/locale/ms/LC_MESSAGES/django.po +252 -146
  31. umap/locale/pl/LC_MESSAGES/django.mo +0 -0
  32. umap/locale/pl/LC_MESSAGES/django.po +254 -148
  33. umap/locale/pt/LC_MESSAGES/django.mo +0 -0
  34. umap/locale/pt/LC_MESSAGES/django.po +215 -159
  35. umap/locale/sv/LC_MESSAGES/django.mo +0 -0
  36. umap/locale/sv/LC_MESSAGES/django.po +254 -143
  37. umap/locale/th_TH/LC_MESSAGES/django.mo +0 -0
  38. umap/locale/th_TH/LC_MESSAGES/django.po +125 -70
  39. umap/locale/zh_TW/LC_MESSAGES/django.mo +0 -0
  40. umap/locale/zh_TW/LC_MESSAGES/django.po +256 -145
  41. umap/migrations/0022_add_team.py +94 -0
  42. umap/models.py +45 -10
  43. umap/settings/__init__.py +2 -0
  44. umap/settings/base.py +3 -2
  45. umap/static/umap/base.css +32 -41
  46. umap/static/umap/content.css +19 -25
  47. umap/static/umap/css/icon.css +63 -37
  48. umap/static/umap/css/importers.css +1 -1
  49. umap/static/umap/css/slideshow.css +7 -5
  50. umap/static/umap/css/tableeditor.css +4 -3
  51. umap/static/umap/img/16-white.svg +1 -4
  52. umap/static/umap/img/16.svg +2 -6
  53. umap/static/umap/img/24-white.svg +4 -4
  54. umap/static/umap/img/24.svg +6 -6
  55. umap/static/umap/img/source/16-white.svg +2 -5
  56. umap/static/umap/img/source/16.svg +3 -7
  57. umap/static/umap/img/source/24-white.svg +7 -14
  58. umap/static/umap/img/source/24.svg +10 -17
  59. umap/static/umap/js/components/alerts/alert.css +20 -8
  60. umap/static/umap/js/modules/autocomplete.js +3 -3
  61. umap/static/umap/js/modules/browser.js +4 -3
  62. umap/static/umap/js/modules/caption.js +9 -11
  63. umap/static/umap/js/modules/data/features.js +994 -0
  64. umap/static/umap/js/modules/data/layer.js +1210 -0
  65. umap/static/umap/js/modules/formatter.js +12 -3
  66. umap/static/umap/js/modules/global.js +21 -5
  67. umap/static/umap/js/modules/permissions.js +280 -0
  68. umap/static/umap/js/{umap.icon.js → modules/rendering/icon.js} +77 -56
  69. umap/static/umap/js/modules/rendering/layers/base.js +105 -0
  70. umap/static/umap/js/modules/rendering/layers/classified.js +484 -0
  71. umap/static/umap/js/modules/rendering/layers/cluster.js +103 -0
  72. umap/static/umap/js/modules/rendering/layers/heat.js +182 -0
  73. umap/static/umap/js/modules/rendering/popup.js +99 -0
  74. umap/static/umap/js/modules/rendering/template.js +217 -0
  75. umap/static/umap/js/modules/rendering/ui.js +573 -0
  76. umap/static/umap/js/modules/schema.js +24 -0
  77. umap/static/umap/js/modules/share.js +66 -45
  78. umap/static/umap/js/modules/sync/updaters.js +9 -10
  79. umap/static/umap/js/modules/tableeditor.js +7 -7
  80. umap/static/umap/js/modules/ui/dialog.js +8 -4
  81. umap/static/umap/js/modules/utils.js +22 -13
  82. umap/static/umap/js/umap.controls.js +79 -146
  83. umap/static/umap/js/umap.core.js +9 -9
  84. umap/static/umap/js/umap.forms.js +32 -12
  85. umap/static/umap/js/umap.js +65 -63
  86. umap/static/umap/locale/br.js +35 -35
  87. umap/static/umap/locale/br.json +35 -35
  88. umap/static/umap/locale/ca.js +50 -50
  89. umap/static/umap/locale/ca.json +50 -50
  90. umap/static/umap/locale/de.js +136 -136
  91. umap/static/umap/locale/de.json +136 -136
  92. umap/static/umap/locale/el.js +47 -47
  93. umap/static/umap/locale/el.json +47 -47
  94. umap/static/umap/locale/en.js +7 -1
  95. umap/static/umap/locale/en.json +7 -1
  96. umap/static/umap/locale/fa_IR.js +44 -44
  97. umap/static/umap/locale/fa_IR.json +44 -44
  98. umap/static/umap/locale/fr.js +8 -2
  99. umap/static/umap/locale/fr.json +8 -2
  100. umap/static/umap/locale/pt.js +17 -17
  101. umap/static/umap/locale/pt.json +17 -17
  102. umap/static/umap/locale/pt_PT.js +207 -207
  103. umap/static/umap/locale/pt_PT.json +207 -207
  104. umap/static/umap/locale/th_TH.js +25 -25
  105. umap/static/umap/locale/th_TH.json +25 -25
  106. umap/static/umap/map.css +107 -104
  107. umap/static/umap/nav.css +19 -10
  108. umap/static/umap/unittests/utils.js +230 -107
  109. umap/static/umap/vendors/csv2geojson/csv2geojson.js +62 -40
  110. umap/static/umap/vendors/markercluster/MarkerCluster.Default.css +1 -1
  111. umap/storage.py +1 -0
  112. umap/templates/404.html +5 -1
  113. umap/templates/500.html +3 -1
  114. umap/templates/auth/user_detail.html +8 -2
  115. umap/templates/auth/user_form.html +19 -10
  116. umap/templates/auth/user_stars.html +8 -2
  117. umap/templates/base.html +1 -0
  118. umap/templates/registration/login.html +18 -3
  119. umap/templates/umap/about.html +1 -0
  120. umap/templates/umap/about_summary.html +22 -7
  121. umap/templates/umap/components/alerts/alert.html +42 -21
  122. umap/templates/umap/content.html +2 -0
  123. umap/templates/umap/content_footer.html +6 -2
  124. umap/templates/umap/css.html +1 -0
  125. umap/templates/umap/dashboard_menu.html +15 -0
  126. umap/templates/umap/home.html +14 -4
  127. umap/templates/umap/js.html +4 -9
  128. umap/templates/umap/login_popup_end.html +10 -4
  129. umap/templates/umap/map_detail.html +8 -2
  130. umap/templates/umap/map_fragment.html +3 -1
  131. umap/templates/umap/map_init.html +2 -1
  132. umap/templates/umap/map_list.html +4 -3
  133. umap/templates/umap/map_table.html +36 -12
  134. umap/templates/umap/messages.html +0 -1
  135. umap/templates/umap/navigation.html +2 -1
  136. umap/templates/umap/password_change.html +5 -1
  137. umap/templates/umap/password_change_done.html +8 -2
  138. umap/templates/umap/search.html +8 -2
  139. umap/templates/umap/search_bar.html +1 -0
  140. umap/templates/umap/team_confirm_delete.html +19 -0
  141. umap/templates/umap/team_detail.html +27 -0
  142. umap/templates/umap/team_form.html +60 -0
  143. umap/templates/umap/user_dashboard.html +7 -9
  144. umap/templates/umap/user_teams.html +51 -0
  145. umap/tests/base.py +8 -1
  146. umap/tests/conftest.py +6 -0
  147. umap/tests/fixtures/test_circles_layer.geojson +219 -0
  148. umap/tests/fixtures/test_upload_georss.xml +20 -0
  149. umap/tests/integration/conftest.py +18 -4
  150. umap/tests/integration/helpers.py +12 -0
  151. umap/tests/integration/test_anonymous_owned_map.py +23 -0
  152. umap/tests/integration/test_basics.py +29 -0
  153. umap/tests/integration/test_caption.py +20 -0
  154. umap/tests/integration/test_circles_layer.py +69 -0
  155. umap/tests/integration/test_draw_polygon.py +110 -13
  156. umap/tests/integration/test_draw_polyline.py +8 -18
  157. umap/tests/integration/test_edit_datalayer.py +1 -1
  158. umap/tests/integration/test_import.py +64 -5
  159. umap/tests/integration/test_owned_map.py +21 -13
  160. umap/tests/integration/test_team.py +47 -0
  161. umap/tests/integration/test_tilelayer.py +19 -2
  162. umap/tests/integration/test_view_marker.py +28 -1
  163. umap/tests/integration/test_websocket_sync.py +5 -5
  164. umap/tests/test_datalayer.py +32 -7
  165. umap/tests/test_datalayer_views.py +1 -1
  166. umap/tests/test_map.py +30 -4
  167. umap/tests/test_map_views.py +2 -2
  168. umap/tests/test_statics.py +40 -0
  169. umap/tests/test_team_views.py +131 -0
  170. umap/tests/test_views.py +15 -1
  171. umap/urls.py +23 -13
  172. umap/views.py +116 -10
  173. {umap_project-2.5.1.dist-info → umap_project-2.6.0b0.dist-info}/METADATA +9 -9
  174. {umap_project-2.5.1.dist-info → umap_project-2.6.0b0.dist-info}/RECORD +177 -170
  175. umap/static/umap/js/umap.datalayer.permissions.js +0 -70
  176. umap/static/umap/js/umap.features.js +0 -1290
  177. umap/static/umap/js/umap.layer.js +0 -1837
  178. umap/static/umap/js/umap.permissions.js +0 -208
  179. umap/static/umap/js/umap.popup.js +0 -341
  180. umap/static/umap/test/TableEditor.js +0 -104
  181. umap/static/umap/vendors/leaflet/leaflet-src.js +0 -14512
  182. umap/static/umap/vendors/leaflet/leaflet-src.js.map +0 -1
  183. umap/static/umap/vendors/leaflet/leaflet.js +0 -6
  184. umap/static/umap/vendors/leaflet/leaflet.js.map +0 -1
  185. umap/static/umap/vendors/markercluster/WhereAreTheJavascriptFiles.txt +0 -5
  186. umap/static/umap/vendors/markercluster/leaflet.markercluster-src.js +0 -2718
  187. umap/static/umap/vendors/markercluster/leaflet.markercluster-src.js.map +0 -1
  188. umap/static/umap/vendors/toolbar/leaflet.toolbar-src.css +0 -117
  189. umap/static/umap/vendors/toolbar/leaflet.toolbar-src.js +0 -365
  190. umap/tests/integration/test_statics.py +0 -47
  191. {umap_project-2.5.1.dist-info → umap_project-2.6.0b0.dist-info}/WHEEL +0 -0
  192. {umap_project-2.5.1.dist-info → umap_project-2.6.0b0.dist-info}/entry_points.txt +0 -0
  193. {umap_project-2.5.1.dist-info → umap_project-2.6.0b0.dist-info}/licenses/LICENSE +0 -0
@@ -8,137 +8,137 @@ const { assert, expect } = pkg
8
8
  import { JSDOM } from 'jsdom'
9
9
  global.JSDOM = JSDOM
10
10
 
11
- describe('Utils', function () {
12
- describe('#toHTML()', function () {
13
- it('should handle title', function () {
11
+ describe('Utils', () => {
12
+ describe('#toHTML()', () => {
13
+ it('should handle title', () => {
14
14
  assert.equal(Utils.toHTML('# A title'), '<h4>A title</h4>')
15
15
  })
16
- it('should handle title followed by text', function () {
16
+ it('should handle title followed by text', () => {
17
17
  assert.equal(Utils.toHTML('# A title\nSome text.'), '<h4>A title</h4>Some text.')
18
18
  })
19
19
 
20
- it('should handle title in the middle of the content', function () {
20
+ it('should handle title in the middle of the content', () => {
21
21
  assert.equal(Utils.toHTML('A phrase\n## A title'), 'A phrase\n<h5>A title</h5>')
22
22
  })
23
23
 
24
- it('should handle hr', function () {
24
+ it('should handle hr', () => {
25
25
  assert.equal(Utils.toHTML('---'), '<hr>')
26
26
  })
27
27
 
28
- it('should handle bold', function () {
28
+ it('should handle bold', () => {
29
29
  assert.equal(Utils.toHTML('Some **bold**'), 'Some <strong>bold</strong>')
30
30
  })
31
31
 
32
- it('should handle italic', function () {
32
+ it('should handle italic', () => {
33
33
  assert.equal(Utils.toHTML('Some *italic*'), 'Some <em>italic</em>')
34
34
  })
35
35
 
36
- it('should handle links without formatting', function () {
36
+ it('should handle links without formatting', () => {
37
37
  assert.equal(
38
38
  Utils.toHTML('A simple http://osm.org link'),
39
39
  'A simple <a href="http://osm.org" target="_blank">http://osm.org</a> link'
40
40
  )
41
41
  })
42
42
 
43
- it('should handle simple link in title', function () {
43
+ it('should handle simple link in title', () => {
44
44
  assert.equal(
45
45
  Utils.toHTML('# http://osm.org'),
46
46
  '<h4><a href="http://osm.org" target="_blank">http://osm.org</a></h4>'
47
47
  )
48
48
  })
49
49
 
50
- it('should handle links with url parameter', function () {
50
+ it('should handle links with url parameter', () => {
51
51
  assert.equal(
52
52
  Utils.toHTML('A simple https://osm.org/?url=https%3A//anotherurl.com link'),
53
53
  'A simple <a href="https://osm.org/?url=https%3A//anotherurl.com" target="_blank">https://osm.org/?url=https%3A//anotherurl.com</a> link'
54
54
  )
55
55
  })
56
56
 
57
- it('should handle simple link inside parenthesis', function () {
57
+ it('should handle simple link inside parenthesis', () => {
58
58
  assert.equal(
59
59
  Utils.toHTML('A simple link (http://osm.org)'),
60
60
  'A simple link (<a href="http://osm.org" target="_blank">http://osm.org</a>)'
61
61
  )
62
62
  })
63
63
 
64
- it('should handle simple link with formatting', function () {
64
+ it('should handle simple link with formatting', () => {
65
65
  assert.equal(
66
66
  Utils.toHTML('A simple [[http://osm.org]] link'),
67
67
  'A simple <a href="http://osm.org" target="_blank">http://osm.org</a> link'
68
68
  )
69
69
  })
70
70
 
71
- it('should handle simple link with formatting and content', function () {
71
+ it('should handle simple link with formatting and content', () => {
72
72
  assert.equal(
73
73
  Utils.toHTML('A simple [[http://osm.org|link]]'),
74
74
  'A simple <a href="http://osm.org" target="_blank">link</a>'
75
75
  )
76
76
  })
77
77
 
78
- it('should handle simple link followed by a carriage return', function () {
78
+ it('should handle simple link followed by a carriage return', () => {
79
79
  assert.equal(
80
80
  Utils.toHTML('A simple link http://osm.org\nAnother line'),
81
81
  'A simple link <a href="http://osm.org" target="_blank">http://osm.org</a>\nAnother line'
82
82
  )
83
83
  })
84
84
 
85
- it('should handle target option', function () {
85
+ it('should handle target option', () => {
86
86
  assert.equal(
87
87
  Utils.toHTML('A simple http://osm.org link', { target: 'self' }),
88
88
  'A simple <a href="http://osm.org" target="_self">http://osm.org</a> link'
89
89
  )
90
90
  })
91
91
 
92
- it('should handle image', function () {
92
+ it('should handle image', () => {
93
93
  assert.equal(
94
94
  Utils.toHTML('A simple image: {{http://osm.org/pouet.png}}'),
95
95
  'A simple image: <img src="http://osm.org/pouet.png">'
96
96
  )
97
97
  })
98
98
 
99
- it('should handle image without text', function () {
99
+ it('should handle image without text', () => {
100
100
  assert.equal(
101
101
  Utils.toHTML('{{http://osm.org/pouet.png}}'),
102
102
  '<img src="http://osm.org/pouet.png">'
103
103
  )
104
104
  })
105
105
 
106
- it('should handle image with width', function () {
106
+ it('should handle image with width', () => {
107
107
  assert.equal(
108
108
  Utils.toHTML('A simple image: {{http://osm.org/pouet.png|100}}'),
109
109
  'A simple image: <img style="width:100px;min-width:100px;" src="http://osm.org/pouet.png">'
110
110
  )
111
111
  })
112
112
 
113
- it('should handle iframe', function () {
113
+ it('should handle iframe', () => {
114
114
  assert.equal(
115
115
  Utils.toHTML('A simple iframe: {{{http://osm.org/pouet.html}}}'),
116
116
  'A simple iframe: <div><iframe height="300px" width="100%" src="http://osm.org/pouet.html" frameborder="0"></iframe></div>'
117
117
  )
118
118
  })
119
119
 
120
- it('should handle iframe with height', function () {
120
+ it('should handle iframe with height', () => {
121
121
  assert.equal(
122
122
  Utils.toHTML('A simple iframe: {{{http://osm.org/pouet.html|200}}}'),
123
123
  'A simple iframe: <div><iframe height="200px" width="100%" src="http://osm.org/pouet.html" frameborder="0"></iframe></div>'
124
124
  )
125
125
  })
126
126
 
127
- it('should handle iframe with height and width', function () {
127
+ it('should handle iframe with height and width', () => {
128
128
  assert.equal(
129
129
  Utils.toHTML('A simple iframe: {{{http://osm.org/pouet.html|200*400}}}'),
130
130
  'A simple iframe: <div><iframe height="200px" width="400px" src="http://osm.org/pouet.html" frameborder="0"></iframe></div>'
131
131
  )
132
132
  })
133
133
 
134
- it('should handle iframe with height with px', function () {
134
+ it('should handle iframe with height with px', () => {
135
135
  assert.equal(
136
136
  Utils.toHTML('A simple iframe: {{{http://osm.org/pouet.html|200px}}}'),
137
137
  'A simple iframe: <div><iframe height="200px" width="100%" src="http://osm.org/pouet.html" frameborder="0"></iframe></div>'
138
138
  )
139
139
  })
140
140
 
141
- it('should handle iframe with url parameter', function () {
141
+ it('should handle iframe with url parameter', () => {
142
142
  assert.equal(
143
143
  Utils.toHTML(
144
144
  'A simple iframe: {{{https://osm.org/?url=https%3A//anotherurl.com}}}'
@@ -147,7 +147,7 @@ describe('Utils', function () {
147
147
  )
148
148
  })
149
149
 
150
- it('should handle iframe with height with px', function () {
150
+ it('should handle iframe with height with px', () => {
151
151
  assert.equal(
152
152
  Utils.toHTML(
153
153
  'A double iframe: {{{https://osm.org/pouet}}}{{{https://osm.org/boudin}}}'
@@ -156,52 +156,56 @@ describe('Utils', function () {
156
156
  )
157
157
  })
158
158
 
159
- it('http link with http link as parameter as variable', function () {
159
+ it('http link with http link as parameter as variable', () => {
160
160
  assert.equal(
161
161
  Utils.toHTML('A phrase with a [[http://iframeurl.com?to=http://another.com]].'),
162
162
  'A phrase with a <a href="http://iframeurl.com?to=http://another.com" target="_blank">http://iframeurl.com?to=http://another.com</a>.'
163
163
  )
164
164
  })
165
165
 
166
- it('simple bullet points', function () {
166
+ it('simple bullet points', () => {
167
167
  assert.equal(
168
168
  Utils.toHTML('* First point\n* Second point\n* Last point'),
169
169
  '<ul><li>First point</li><li>Second point</li><li>Last point</li></ul>'
170
170
  )
171
171
  })
172
172
 
173
- it('bullet points with bold and italic', function () {
173
+ it('bullet points with bold and italic', () => {
174
174
  assert.equal(
175
- Utils.toHTML('* First *point*\n* Second **point**\n* Last [[https://here.org|point]]'),
175
+ Utils.toHTML(
176
+ '* First *point*\n* Second **point**\n* Last [[https://here.org|point]]'
177
+ ),
176
178
  '<ul><li>First <em>point</em></li><li>Second <strong>point</strong></li><li>Last <a href="https://here.org" target="_blank">point</a></li></ul>'
177
179
  )
178
180
  })
179
181
 
180
- it('title followed by bullet points', function () {
182
+ it('title followed by bullet points', () => {
181
183
  assert.equal(
182
- Utils.toHTML('## Some title\n* First *point*\n* Second **point**\n* Last [[https://here.org|point]]'),
184
+ Utils.toHTML(
185
+ '## Some title\n* First *point*\n* Second **point**\n* Last [[https://here.org|point]]'
186
+ ),
183
187
  '<h5>Some title</h5><ul><li>First <em>point</em></li><li>Second <strong>point</strong></li><li>Last <a href="https://here.org" target="_blank">point</a></li></ul>'
184
188
  )
185
189
  })
186
190
  })
187
191
 
188
- describe('#escapeHTML', function () {
189
- it('should escape HTML tags', function () {
192
+ describe('#escapeHTML', () => {
193
+ it('should escape HTML tags', () => {
190
194
  assert.equal(Utils.escapeHTML('<span onload="alert(oups)">'), '<span></span>')
191
195
  })
192
196
 
193
- it('should not escape geo: links', function () {
197
+ it('should not escape geo: links', () => {
194
198
  assert.equal(Utils.escapeHTML('<a href="geo:1,2"></a>'), '<a href="geo:1,2"></a>')
195
199
  })
196
200
 
197
- it('should not escape dir and title attributes', function () {
201
+ it('should not escape dir and title attributes', () => {
198
202
  assert.equal(
199
203
  Utils.escapeHTML('<a title="Title" dir="rtl"></a>'),
200
204
  '<a dir="rtl" title="Title"></a>'
201
205
  )
202
206
  })
203
207
 
204
- it('should not escape video tag with dedicated attributes', function () {
208
+ it('should not escape video tag with dedicated attributes', () => {
205
209
  assert.equal(
206
210
  Utils.escapeHTML(
207
211
  '<video width="100%" height="281" controls><source type="video/mp4" src="movie.mp4"></video>'
@@ -210,7 +214,7 @@ describe('Utils', function () {
210
214
  )
211
215
  })
212
216
 
213
- it('should not escape audio tag with dedicated attributes', function () {
217
+ it('should not escape audio tag with dedicated attributes', () => {
214
218
  assert.equal(
215
219
  Utils.escapeHTML(
216
220
  '<audio controls><source type="audio/ogg" src="horse.ogg"></audio>'
@@ -219,38 +223,38 @@ describe('Utils', function () {
219
223
  )
220
224
  })
221
225
 
222
- it('should not fail with int value', function () {
226
+ it('should not fail with int value', () => {
223
227
  assert.equal(Utils.escapeHTML(25), '25')
224
228
  })
225
229
 
226
- it('should not fail with null value', function () {
230
+ it('should not fail with null value', () => {
227
231
  assert.equal(Utils.escapeHTML(null), '')
228
232
  })
229
233
  })
230
234
 
231
- describe('#greedyTemplate', function () {
232
- it('should replace simple props', function () {
235
+ describe('#greedyTemplate', () => {
236
+ it('should replace simple props', () => {
233
237
  assert.equal(
234
238
  Utils.greedyTemplate('A phrase with a {variable}.', { variable: 'thing' }),
235
239
  'A phrase with a thing.'
236
240
  )
237
241
  })
238
242
 
239
- it('should not fail when missing key', function () {
243
+ it('should not fail when missing key', () => {
240
244
  assert.equal(
241
245
  Utils.greedyTemplate('A phrase with a {missing}', {}),
242
246
  'A phrase with a '
243
247
  )
244
248
  })
245
249
 
246
- it('should process brakets in brakets', function () {
250
+ it('should process brakets in brakets', () => {
247
251
  assert.equal(
248
252
  Utils.greedyTemplate('A phrase with a {{{variable}}}.', { variable: 'value' }),
249
253
  'A phrase with a {{value}}.'
250
254
  )
251
255
  })
252
256
 
253
- it('should not process http links', function () {
257
+ it('should not process http links', () => {
254
258
  assert.equal(
255
259
  Utils.greedyTemplate('A phrase with a {{{http://iframeurl.com}}}.', {
256
260
  'http://iframeurl.com': 'value',
@@ -259,14 +263,14 @@ describe('Utils', function () {
259
263
  )
260
264
  })
261
265
 
262
- it('should not accept dash', function () {
266
+ it('should not accept dash', () => {
263
267
  assert.equal(
264
268
  Utils.greedyTemplate('A phrase with a {var-iable}.', { 'var-iable': 'value' }),
265
269
  'A phrase with a {var-iable}.'
266
270
  )
267
271
  })
268
272
 
269
- it('should accept colon', function () {
273
+ it('should accept colon', () => {
270
274
  assert.equal(
271
275
  Utils.greedyTemplate('A phrase with a {variable:fr}.', {
272
276
  'variable:fr': 'value',
@@ -275,7 +279,7 @@ describe('Utils', function () {
275
279
  )
276
280
  })
277
281
 
278
- it('should accept arobase', function () {
282
+ it('should accept arobase', () => {
279
283
  assert.equal(
280
284
  Utils.greedyTemplate('A phrase with a {@variable}.', {
281
285
  '@variable': 'value',
@@ -284,7 +288,7 @@ describe('Utils', function () {
284
288
  )
285
289
  })
286
290
 
287
- it('should accept space', function () {
291
+ it('should accept space', () => {
288
292
  assert.equal(
289
293
  Utils.greedyTemplate('A phrase with a {var iable}.', {
290
294
  'var iable': 'value',
@@ -293,7 +297,7 @@ describe('Utils', function () {
293
297
  )
294
298
  })
295
299
 
296
- it('should accept non ascii chars', function () {
300
+ it('should accept non ascii chars', () => {
297
301
  assert.equal(
298
302
  Utils.greedyTemplate('A phrase with a {Accessibilité} and {переменная}.', {
299
303
  Accessibilité: 'value',
@@ -303,7 +307,7 @@ describe('Utils', function () {
303
307
  )
304
308
  })
305
309
 
306
- it('should replace even with ignore if key is found', function () {
310
+ it('should replace even with ignore if key is found', () => {
307
311
  assert.equal(
308
312
  Utils.greedyTemplate(
309
313
  'A phrase with a {variable:fr}.',
@@ -314,21 +318,21 @@ describe('Utils', function () {
314
318
  )
315
319
  })
316
320
 
317
- it('should keep string when using ignore if key is not found', function () {
321
+ it('should keep string when using ignore if key is not found', () => {
318
322
  assert.equal(
319
323
  Utils.greedyTemplate('A phrase with a {variable:fr}.', {}, true),
320
324
  'A phrase with a {variable:fr}.'
321
325
  )
322
326
  })
323
327
 
324
- it('should replace nested variables', function () {
328
+ it('should replace nested variables', () => {
325
329
  assert.equal(
326
330
  Utils.greedyTemplate('A phrase with a {fr.var}.', { fr: { var: 'value' } }),
327
331
  'A phrase with a value.'
328
332
  )
329
333
  })
330
334
 
331
- it('should not fail if nested variable is missing', function () {
335
+ it('should not fail if nested variable is missing', () => {
332
336
  assert.equal(
333
337
  Utils.greedyTemplate('A phrase with a {fr.var.foo}.', {
334
338
  fr: { var: 'value' },
@@ -337,21 +341,21 @@ describe('Utils', function () {
337
341
  )
338
342
  })
339
343
 
340
- it('should not fail with nested variables and no data', function () {
344
+ it('should not fail with nested variables and no data', () => {
341
345
  assert.equal(
342
346
  Utils.greedyTemplate('A phrase with a {fr.var.foo}.', {}),
343
347
  'A phrase with a .'
344
348
  )
345
349
  })
346
350
 
347
- it('should handle fallback value if any', function () {
351
+ it('should handle fallback value if any', () => {
348
352
  assert.equal(
349
353
  Utils.greedyTemplate('A phrase with a {fr.var.bar|"default"}.', {}),
350
354
  'A phrase with a default.'
351
355
  )
352
356
  })
353
357
 
354
- it('should handle fallback var if any', function () {
358
+ it('should handle fallback var if any', () => {
355
359
  assert.equal(
356
360
  Utils.greedyTemplate('A phrase with a {fr.var.bar|fallback}.', {
357
361
  fallback: 'default',
@@ -360,14 +364,14 @@ describe('Utils', function () {
360
364
  )
361
365
  })
362
366
 
363
- it('should handle multiple fallbacks', function () {
367
+ it('should handle multiple fallbacks', () => {
364
368
  assert.equal(
365
369
  Utils.greedyTemplate('A phrase with a {fr.var.bar|try.again|"default"}.', {}),
366
370
  'A phrase with a default.'
367
371
  )
368
372
  })
369
373
 
370
- it('should use the first defined value', function () {
374
+ it('should use the first defined value', () => {
371
375
  assert.equal(
372
376
  Utils.greedyTemplate('A phrase with a {fr.var.bar|try.again|"default"}.', {
373
377
  try: { again: 'please' },
@@ -376,7 +380,7 @@ describe('Utils', function () {
376
380
  )
377
381
  })
378
382
 
379
- it('should use the first defined value', function () {
383
+ it('should use the first defined value', () => {
380
384
  assert.equal(
381
385
  Utils.greedyTemplate('A phrase with a {fr.var.bar|try.again|"default"}.', {
382
386
  try: { again: 'again' },
@@ -386,14 +390,14 @@ describe('Utils', function () {
386
390
  )
387
391
  })
388
392
 
389
- it('should support the first example from #820 when translated to final syntax', function () {
393
+ it('should support the first example from #820 when translated to final syntax', () => {
390
394
  assert.equal(
391
395
  Utils.greedyTemplate('# {name} ({ele|"-"} m ü. M.)', { name: 'Portalet' }),
392
396
  '# Portalet (- m ü. M.)'
393
397
  )
394
398
  })
395
399
 
396
- it('should support the first example from #820 when translated to final syntax when no fallback required', function () {
400
+ it('should support the first example from #820 when translated to final syntax when no fallback required', () => {
397
401
  assert.equal(
398
402
  Utils.greedyTemplate('# {name} ({ele|"-"} m ü. M.)', {
399
403
  name: 'Portalet',
@@ -403,14 +407,14 @@ describe('Utils', function () {
403
407
  )
404
408
  })
405
409
 
406
- it('should support white space in fallback', function () {
410
+ it('should support white space in fallback', () => {
407
411
  assert.equal(
408
412
  Utils.greedyTemplate('A phrase with {var|"white space in the fallback."}', {}),
409
413
  'A phrase with white space in the fallback.'
410
414
  )
411
415
  })
412
416
 
413
- it('should support empty string as fallback', function () {
417
+ it('should support empty string as fallback', () => {
414
418
  assert.equal(
415
419
  Utils.greedyTemplate(
416
420
  'A phrase with empty string ("{var|""}") in the fallback.',
@@ -420,7 +424,7 @@ describe('Utils', function () {
420
424
  )
421
425
  })
422
426
 
423
- it('should support e.g. links as fallback', function () {
427
+ it('should support e.g. links as fallback', () => {
424
428
  assert.equal(
425
429
  Utils.greedyTemplate(
426
430
  'A phrase with {var|"[[https://osm.org|link]]"} as fallback.',
@@ -429,19 +433,29 @@ describe('Utils', function () {
429
433
  'A phrase with [[https://osm.org|link]] as fallback.'
430
434
  )
431
435
  })
436
+
437
+ it('should not consider null values', () => {
438
+ assert.equal(
439
+ Utils.greedyTemplate('A phrase with a {foo|fallback}.', {
440
+ foo: null,
441
+ fallback: 'default',
442
+ }),
443
+ 'A phrase with a default.'
444
+ )
445
+ })
432
446
  })
433
447
 
434
- describe('#flattenCoordinates()', function () {
435
- it('should not alter already flat coords', function () {
436
- var coords = [
448
+ describe('#flattenCoordinates()', () => {
449
+ it('should not alter already flat coords', () => {
450
+ const coords = [
437
451
  [1, 2],
438
452
  [3, 4],
439
453
  ]
440
454
  assert.deepEqual(Utils.flattenCoordinates(coords), coords)
441
455
  })
442
456
 
443
- it('should flatten nested coords', function () {
444
- var coords = [
457
+ it('should flatten nested coords', () => {
458
+ let coords = [
445
459
  [
446
460
  [1, 2],
447
461
  [3, 4],
@@ -459,36 +473,143 @@ describe('Utils', function () {
459
473
  assert.deepEqual(Utils.flattenCoordinates(coords), coords[0][0])
460
474
  })
461
475
 
462
- it('should not fail on empty coords', function () {
463
- var coords = []
476
+ it('should not fail on empty coords', () => {
477
+ const coords = []
464
478
  assert.deepEqual(Utils.flattenCoordinates(coords), coords)
465
479
  })
466
480
  })
467
481
 
468
- describe('#usableOption()', function () {
469
- it('should consider false', function () {
482
+ describe('#polygonMustBeFlattened', () => {
483
+ it('should return false for simple polygon', () => {
484
+ const coords = [
485
+ [
486
+ [100.0, 0.0],
487
+ [101.0, 0.0],
488
+ [101.0, 1.0],
489
+ [100.0, 1.0],
490
+ [100.0, 0.0],
491
+ ],
492
+ ]
493
+ assert.notOk(Utils.polygonMustBeFlattened(coords))
494
+ })
495
+
496
+ it('should return false for simple polygon with hole', () => {
497
+ const coords = [
498
+ [
499
+ [100.0, 0.0],
500
+ [101.0, 0.0],
501
+ [101.0, 1.0],
502
+ [100.0, 1.0],
503
+ [100.0, 0.0],
504
+ ],
505
+ [
506
+ [100.8, 0.8],
507
+ [100.8, 0.2],
508
+ [100.2, 0.2],
509
+ [100.2, 0.8],
510
+ [100.8, 0.8],
511
+ ],
512
+ ]
513
+ assert.notOk(Utils.polygonMustBeFlattened(coords))
514
+ })
515
+
516
+ it('should return false for multipolygon', () => {
517
+ const coords = [
518
+ [
519
+ [
520
+ [102.0, 2.0],
521
+ [103.0, 2.0],
522
+ [103.0, 3.0],
523
+ [102.0, 3.0],
524
+ [102.0, 2.0],
525
+ ],
526
+ ],
527
+ [
528
+ [
529
+ [100.0, 0.0],
530
+ [101.0, 0.0],
531
+ [101.0, 1.0],
532
+ [100.0, 1.0],
533
+ [100.0, 0.0],
534
+ ],
535
+ [
536
+ [100.2, 0.2],
537
+ [100.2, 0.8],
538
+ [100.8, 0.8],
539
+ [100.8, 0.2],
540
+ [100.2, 0.2],
541
+ ],
542
+ ],
543
+ ]
544
+ assert.notOk(Utils.polygonMustBeFlattened(coords))
545
+ })
546
+
547
+ it('should return true for false multi polygon', () => {
548
+ const coords = [
549
+ [
550
+ [
551
+ [100.0, 0.0],
552
+ [101.0, 0.0],
553
+ [101.0, 1.0],
554
+ [100.0, 1.0],
555
+ [100.0, 0.0],
556
+ ],
557
+ ],
558
+ ]
559
+ assert.ok(Utils.polygonMustBeFlattened(coords))
560
+ })
561
+
562
+ it('should return true for false multi polygon with hole', () => {
563
+ const coords = [
564
+ [
565
+ [
566
+ [100.0, 0.0],
567
+ [101.0, 0.0],
568
+ [101.0, 1.0],
569
+ [100.0, 1.0],
570
+ [100.0, 0.0],
571
+ ],
572
+ [
573
+ [100.8, 0.8],
574
+ [100.8, 0.2],
575
+ [100.2, 0.2],
576
+ [100.2, 0.8],
577
+ [100.8, 0.8],
578
+ ],
579
+ ],
580
+ ]
581
+ assert.ok(Utils.polygonMustBeFlattened(coords))
582
+ })
583
+
584
+ it('should return false for empty coords', () => {
585
+ assert.notOk(Utils.polygonMustBeFlattened([]))
586
+ })
587
+ })
588
+
589
+ describe('#usableOption()', () => {
590
+ it('should consider false', () => {
470
591
  assert.ok(Utils.usableOption({ key: false }, 'key'))
471
592
  })
472
593
 
473
- it('should consider 0', function () {
594
+ it('should consider 0', () => {
474
595
  assert.ok(Utils.usableOption({ key: 0 }, 'key'))
475
596
  })
476
597
 
477
- it('should not consider undefined', function () {
598
+ it('should not consider undefined', () => {
478
599
  assert.notOk(Utils.usableOption({}, 'key'))
479
600
  })
480
601
 
481
- it('should not consider empty string', function () {
602
+ it('should not consider empty string', () => {
482
603
  assert.notOk(Utils.usableOption({ key: '' }, 'key'))
483
604
  })
484
605
 
485
- it('should consider null', function () {
606
+ it('should consider null', () => {
486
607
  assert.ok(Utils.usableOption({ key: null }, 'key'))
487
608
  })
488
609
  })
489
610
 
490
- describe('#normalize()', function () {
491
- it('should remove accents', function () {
611
+ describe('#normalize()', () => {
612
+ it('should remove accents', () => {
492
613
  // French é
493
614
  assert.equal(Utils.normalize('aéroport'), 'aeroport')
494
615
  // American é
@@ -496,35 +617,37 @@ describe('Utils', function () {
496
617
  })
497
618
  })
498
619
 
499
- describe('#sortFeatures()', function () {
500
- let feat1, feat2, feat3
501
- before(function () {
620
+ describe('#sortFeatures()', () => {
621
+ let feat1
622
+ let feat2
623
+ let feat3
624
+ before(() => {
502
625
  feat1 = { properties: {} }
503
626
  feat2 = { properties: {} }
504
627
  feat3 = { properties: {} }
505
628
  })
506
- it('should sort feature from custom key', function () {
629
+ it('should sort feature from custom key', () => {
507
630
  feat1.properties.mykey = '13. foo'
508
631
  feat2.properties.mykey = '7. foo'
509
632
  feat3.properties.mykey = '111. foo'
510
- let features = Utils.sortFeatures([feat1, feat2, feat3], 'mykey')
633
+ const features = Utils.sortFeatures([feat1, feat2, feat3], 'mykey')
511
634
  assert.equal(features[0], feat2)
512
635
  assert.equal(features[1], feat1)
513
636
  assert.equal(features[2], feat3)
514
637
  })
515
- it('should sort feature from multiple keys', function () {
638
+ it('should sort feature from multiple keys', () => {
516
639
  feat1.properties.mykey = '13. foo'
517
640
  feat2.properties.mykey = '111. foo'
518
641
  feat3.properties.mykey = '111. foo'
519
642
  feat1.properties.otherkey = 'C'
520
643
  feat2.properties.otherkey = 'B'
521
644
  feat3.properties.otherkey = 'A'
522
- let features = Utils.sortFeatures([feat1, feat2, feat3], 'mykey,otherkey')
645
+ const features = Utils.sortFeatures([feat1, feat2, feat3], 'mykey,otherkey')
523
646
  assert.equal(features[0], feat1)
524
647
  assert.equal(features[1], feat3)
525
648
  assert.equal(features[2], feat2)
526
649
  })
527
- it('should sort feature from custom key reverse', function () {
650
+ it('should sort feature from custom key reverse', () => {
528
651
  feat1.properties.mykey = '13. foo'
529
652
  feat2.properties.mykey = '7. foo'
530
653
  feat3.properties.mykey = '111. foo'
@@ -533,36 +656,36 @@ describe('Utils', function () {
533
656
  assert.equal(features[1], feat1)
534
657
  assert.equal(features[2], feat2)
535
658
  })
536
- it('should sort feature from multiple keys with reverse', function () {
659
+ it('should sort feature from multiple keys with reverse', () => {
537
660
  feat1.properties.mykey = '13. foo'
538
661
  feat2.properties.mykey = '111. foo'
539
662
  feat3.properties.mykey = '111. foo'
540
663
  feat1.properties.otherkey = 'C'
541
664
  feat2.properties.otherkey = 'B'
542
665
  feat3.properties.otherkey = 'A'
543
- let features = Utils.sortFeatures([feat1, feat2, feat3], 'mykey,-otherkey')
666
+ const features = Utils.sortFeatures([feat1, feat2, feat3], 'mykey,-otherkey')
544
667
  assert.equal(features[0], feat1)
545
668
  assert.equal(features[1], feat2)
546
669
  assert.equal(features[2], feat3)
547
670
  })
548
- it('should sort feature with space first', function () {
671
+ it('should sort feature with space first', () => {
549
672
  feat1.properties.mykey = '1 foo'
550
673
  feat2.properties.mykey = '2 foo'
551
674
  feat3.properties.mykey = '1a foo'
552
- let features = Utils.sortFeatures([feat1, feat2, feat3], 'mykey')
675
+ const features = Utils.sortFeatures([feat1, feat2, feat3], 'mykey')
553
676
  assert.equal(features[0], feat1)
554
677
  assert.equal(features[1], feat3)
555
678
  assert.equal(features[2], feat2)
556
679
  })
557
680
  })
558
681
 
559
- describe('#copyJSON', function () {
560
- it('should actually copy the JSON', function () {
561
- let originalJSON = { some: 'json' }
562
- let returned = Utils.CopyJSON(originalJSON)
682
+ describe('#copyJSON', () => {
683
+ it('should actually copy the JSON', () => {
684
+ const originalJSON = { some: 'json' }
685
+ const returned = Utils.CopyJSON(originalJSON)
563
686
 
564
687
  // Change the original JSON
565
- originalJSON['anotherKey'] = 'value'
688
+ originalJSON.anotherKey = 'value'
566
689
 
567
690
  // ensure the two aren't the same object
568
691
  assert.notEqual(returned, originalJSON)
@@ -570,9 +693,9 @@ describe('Utils', function () {
570
693
  })
571
694
  })
572
695
 
573
- describe('#getImpactsFromSchema()', function () {
574
- let getImpactsFromSchema = Utils.getImpactsFromSchema
575
- it('should return an array', function () {
696
+ describe('#getImpactsFromSchema()', () => {
697
+ const getImpactsFromSchema = Utils.getImpactsFromSchema
698
+ it('should return an array', () => {
576
699
  expect(getImpactsFromSchema(['foo'], {})).to.be.an('array')
577
700
  expect(getImpactsFromSchema(['foo'], { foo: {} })).to.be.an('array')
578
701
  expect(getImpactsFromSchema(['foo'], { foo: { impacts: [] } })).to.be.an('array')
@@ -581,8 +704,8 @@ describe('Utils', function () {
581
704
  )
582
705
  })
583
706
 
584
- it('should return a list of unique impacted values', function () {
585
- let schema = {
707
+ it('should return a list of unique impacted values', () => {
708
+ const schema = {
586
709
  foo: { impacts: ['A'] },
587
710
  bar: { impacts: ['A', 'B'] },
588
711
  baz: { impacts: ['B', 'C'] },
@@ -596,8 +719,8 @@ describe('Utils', function () {
596
719
  'C',
597
720
  ])
598
721
  })
599
- it('should return an empty list if nothing is found', function () {
600
- let schema = {
722
+ it('should return an empty list if nothing is found', () => {
723
+ const schema = {
601
724
  foo: { impacts: ['A'] },
602
725
  bar: { impacts: ['A', 'B'] },
603
726
  baz: { impacts: ['B', 'C'] },
@@ -606,15 +729,15 @@ describe('Utils', function () {
606
729
  assert.deepEqual(getImpactsFromSchema(['bad'], schema), [])
607
730
  })
608
731
 
609
- it('should return an empty list if the schema key does not exist', function () {
610
- let schema = {
732
+ it('should return an empty list if the schema key does not exist', () => {
733
+ const schema = {
611
734
  foo: { impacts: ['A'] },
612
735
  }
613
736
 
614
737
  assert.deepEqual(getImpactsFromSchema(['bad'], schema), [])
615
738
  })
616
- it('should work if the "impacts" key is not defined', function () {
617
- let schema = {
739
+ it('should work if the "impacts" key is not defined', () => {
740
+ const schema = {
618
741
  foo: {},
619
742
  bar: { impacts: ['A'] },
620
743
  baz: { impacts: ['B'] },