umap-project 1.14.0a5__py3-none-any.whl → 2.0.0a0__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.
- umap/__init__.py +1 -1
- umap/decorators.py +0 -14
- umap/locale/br/LC_MESSAGES/django.mo +0 -0
- umap/locale/br/LC_MESSAGES/django.po +137 -85
- umap/locale/cs_CZ/LC_MESSAGES/django.mo +0 -0
- umap/locale/cs_CZ/LC_MESSAGES/django.po +136 -84
- umap/locale/el/LC_MESSAGES/django.mo +0 -0
- umap/locale/el/LC_MESSAGES/django.po +136 -84
- umap/locale/en/LC_MESSAGES/django.po +128 -88
- umap/locale/es/LC_MESSAGES/django.mo +0 -0
- umap/locale/es/LC_MESSAGES/django.po +136 -84
- umap/locale/fr/LC_MESSAGES/django.mo +0 -0
- umap/locale/fr/LC_MESSAGES/django.po +131 -91
- umap/locale/hu/LC_MESSAGES/django.mo +0 -0
- umap/locale/hu/LC_MESSAGES/django.po +137 -85
- umap/locale/it/LC_MESSAGES/django.mo +0 -0
- umap/locale/it/LC_MESSAGES/django.po +136 -84
- umap/locale/ms/LC_MESSAGES/django.mo +0 -0
- umap/locale/ms/LC_MESSAGES/django.po +136 -84
- umap/locale/pl/LC_MESSAGES/django.mo +0 -0
- umap/locale/pl/LC_MESSAGES/django.po +136 -84
- umap/locale/sv/LC_MESSAGES/django.mo +0 -0
- umap/locale/sv/LC_MESSAGES/django.po +135 -83
- umap/locale/zh_TW/LC_MESSAGES/django.mo +0 -0
- umap/locale/zh_TW/LC_MESSAGES/django.po +143 -91
- umap/models.py +23 -1
- umap/settings/__init__.py +1 -4
- umap/settings/base.py +1 -0
- umap/static/umap/base.css +5 -0
- umap/static/umap/content.css +185 -13
- umap/static/umap/favicons/icon.svg +2 -2
- umap/static/umap/img/edit.svg +3 -3
- umap/static/umap/img/icon-delete.svg +4 -0
- umap/static/umap/img/icon-download.svg +13 -0
- umap/static/umap/img/icon-duplicate.svg +5 -0
- umap/static/umap/img/icon-edit.svg +12 -0
- umap/static/umap/img/icon-share.svg +11 -0
- umap/static/umap/img/icon-view.svg +12 -0
- umap/static/umap/img/logo.svg +2 -2
- umap/static/umap/img/logo_small.svg +2 -2
- umap/static/umap/img/marker.svg +4 -0
- umap/static/umap/img/opensource.svg +2 -2
- umap/static/umap/img/osm.svg +2 -2
- umap/static/umap/js/components/fragment.js +1 -1
- umap/static/umap/js/modules/browser.js +159 -0
- umap/static/umap/js/modules/global.js +3 -1
- umap/static/umap/js/modules/request.js +155 -0
- umap/static/umap/js/umap.autocomplete.js +28 -38
- umap/static/umap/js/umap.controls.js +73 -58
- umap/static/umap/js/umap.core.js +4 -9
- umap/static/umap/js/umap.datalayer.permissions.js +13 -12
- umap/static/umap/js/umap.features.js +51 -49
- umap/static/umap/js/umap.forms.js +19 -19
- umap/static/umap/js/umap.icon.js +17 -17
- umap/static/umap/js/umap.importer.js +2 -1
- umap/static/umap/js/umap.js +242 -291
- umap/static/umap/js/umap.layer.js +173 -141
- umap/static/umap/js/umap.permissions.js +24 -25
- umap/static/umap/js/umap.popup.js +14 -14
- umap/static/umap/js/umap.share.js +4 -4
- umap/static/umap/js/umap.slideshow.js +4 -4
- umap/static/umap/js/umap.tableeditor.js +2 -2
- umap/static/umap/js/umap.ui.js +1 -1
- umap/static/umap/locale/am_ET.js +1 -11
- umap/static/umap/locale/am_ET.json +1 -11
- umap/static/umap/locale/ar.js +1 -11
- umap/static/umap/locale/ar.json +1 -11
- umap/static/umap/locale/ast.js +1 -11
- umap/static/umap/locale/ast.json +1 -11
- umap/static/umap/locale/bg.js +1 -11
- umap/static/umap/locale/bg.json +1 -11
- umap/static/umap/locale/br.js +1 -11
- umap/static/umap/locale/br.json +1 -11
- umap/static/umap/locale/ca.js +1 -11
- umap/static/umap/locale/ca.json +1 -11
- umap/static/umap/locale/cs_CZ.js +1 -11
- umap/static/umap/locale/cs_CZ.json +1 -11
- umap/static/umap/locale/da.js +1 -11
- umap/static/umap/locale/da.json +1 -11
- umap/static/umap/locale/de.js +1 -11
- umap/static/umap/locale/de.json +1 -11
- umap/static/umap/locale/el.js +1 -11
- umap/static/umap/locale/el.json +1 -11
- umap/static/umap/locale/en.js +1 -11
- umap/static/umap/locale/en.json +1 -11
- umap/static/umap/locale/en_US.json +1 -11
- umap/static/umap/locale/es.js +1 -11
- umap/static/umap/locale/es.json +1 -11
- umap/static/umap/locale/et.js +1 -11
- umap/static/umap/locale/et.json +1 -11
- umap/static/umap/locale/fa_IR.js +6 -16
- umap/static/umap/locale/fa_IR.json +6 -16
- umap/static/umap/locale/fi.js +1 -11
- umap/static/umap/locale/fi.json +1 -11
- umap/static/umap/locale/fr.js +1 -11
- umap/static/umap/locale/fr.json +1 -11
- umap/static/umap/locale/gl.js +1 -11
- umap/static/umap/locale/gl.json +1 -11
- umap/static/umap/locale/he.js +1 -11
- umap/static/umap/locale/he.json +1 -11
- umap/static/umap/locale/hr.js +1 -11
- umap/static/umap/locale/hr.json +1 -11
- umap/static/umap/locale/hu.js +1 -11
- umap/static/umap/locale/hu.json +1 -11
- umap/static/umap/locale/id.js +1 -11
- umap/static/umap/locale/id.json +1 -11
- umap/static/umap/locale/is.js +1 -11
- umap/static/umap/locale/is.json +1 -11
- umap/static/umap/locale/it.js +1 -11
- umap/static/umap/locale/it.json +1 -11
- umap/static/umap/locale/ja.js +1 -11
- umap/static/umap/locale/ja.json +1 -11
- umap/static/umap/locale/ko.js +1 -11
- umap/static/umap/locale/ko.json +1 -11
- umap/static/umap/locale/lt.js +1 -11
- umap/static/umap/locale/lt.json +1 -11
- umap/static/umap/locale/ms.js +1 -11
- umap/static/umap/locale/ms.json +1 -11
- umap/static/umap/locale/nl.js +1 -11
- umap/static/umap/locale/nl.json +1 -11
- umap/static/umap/locale/no.js +1 -11
- umap/static/umap/locale/no.json +1 -11
- umap/static/umap/locale/pl.js +1 -11
- umap/static/umap/locale/pl.json +1 -11
- umap/static/umap/locale/pl_PL.json +1 -11
- umap/static/umap/locale/pt.js +1 -11
- umap/static/umap/locale/pt.json +1 -11
- umap/static/umap/locale/pt_BR.js +1 -11
- umap/static/umap/locale/pt_BR.json +1 -11
- umap/static/umap/locale/pt_PT.js +1 -11
- umap/static/umap/locale/pt_PT.json +1 -11
- umap/static/umap/locale/ro.js +1 -11
- umap/static/umap/locale/ro.json +1 -11
- umap/static/umap/locale/ru.js +1 -11
- umap/static/umap/locale/ru.json +1 -11
- umap/static/umap/locale/sk_SK.js +1 -11
- umap/static/umap/locale/sk_SK.json +1 -11
- umap/static/umap/locale/sl.js +1 -11
- umap/static/umap/locale/sl.json +1 -11
- umap/static/umap/locale/sr.js +1 -11
- umap/static/umap/locale/sr.json +1 -11
- umap/static/umap/locale/sv.js +1 -11
- umap/static/umap/locale/sv.json +1 -11
- umap/static/umap/locale/th_TH.js +1 -11
- umap/static/umap/locale/th_TH.json +1 -11
- umap/static/umap/locale/tr.js +1 -11
- umap/static/umap/locale/tr.json +1 -11
- umap/static/umap/locale/uk_UA.js +1 -11
- umap/static/umap/locale/uk_UA.json +1 -11
- umap/static/umap/locale/vi.js +1 -11
- umap/static/umap/locale/vi.json +1 -11
- umap/static/umap/locale/vi_VN.json +1 -11
- umap/static/umap/locale/zh.js +1 -11
- umap/static/umap/locale/zh.json +1 -11
- umap/static/umap/locale/zh_CN.json +1 -11
- umap/static/umap/locale/zh_TW.Big5.json +1 -11
- umap/static/umap/locale/zh_TW.js +17 -27
- umap/static/umap/locale/zh_TW.json +17 -27
- umap/static/umap/map.css +2 -2
- umap/static/umap/nav.css +2 -1
- umap/static/umap/test/.eslintrc +0 -1
- umap/static/umap/test/Choropleth.js +29 -27
- umap/static/umap/test/DataLayer.js +207 -239
- umap/static/umap/test/Feature.js +33 -58
- umap/static/umap/test/Map.Export.js +11 -11
- umap/static/umap/test/Map.js +66 -67
- umap/static/umap/test/Marker.js +36 -32
- umap/static/umap/test/Polygon.js +95 -95
- umap/static/umap/test/Polyline.js +31 -31
- umap/static/umap/test/TableEditor.js +29 -25
- umap/static/umap/test/_pre.js +2 -7
- umap/static/umap/test/index.html +4 -4
- umap/static/umap/vendors/contextmenu/leaflet.contextmenu.css +54 -0
- umap/static/umap/vendors/contextmenu/leaflet.contextmenu.js +586 -0
- umap/static/umap/vendors/csv2geojson/index.js +259 -0
- umap/static/umap/vendors/dompurify/purify.js +1633 -0
- umap/static/umap/vendors/locatecontrol/L.Control.Locate.css +63 -0
- umap/static/umap/vendors/locatecontrol/L.Control.Locate.js +950 -0
- umap/static/umap/vendors/minimap/Control.MiniMap.css +88 -0
- umap/static/umap/vendors/minimap/Control.MiniMap.js +352 -0
- umap/static/umap/vendors/togeojson/togeojson.js +2 -0
- umap/templates/auth/user_form.html +3 -2
- umap/templates/base.html +1 -0
- umap/templates/registration/login.html +51 -36
- umap/templates/umap/about_summary.html +1 -1
- umap/templates/umap/branding.html +3 -0
- umap/templates/umap/content.html +15 -39
- umap/templates/umap/header.html +0 -0
- umap/templates/umap/home.html +4 -2
- umap/templates/umap/js.html +0 -1
- umap/templates/umap/map_detail.html +9 -0
- umap/templates/umap/map_init.html +1 -1
- umap/templates/umap/map_messages.html +4 -2
- umap/templates/umap/map_table.html +130 -69
- umap/templates/umap/navigation.html +2 -4
- umap/templates/umap/user_dashboard.html +29 -6
- umap/tests/base.py +1 -1
- umap/tests/integration/conftest.py +18 -0
- umap/tests/integration/test_anonymous_owned_map.py +6 -3
- umap/tests/integration/test_browser.py +166 -6
- umap/tests/integration/test_collaborative_editing.py +23 -5
- umap/tests/integration/test_dashboard.py +17 -0
- umap/tests/integration/test_edit_datalayer.py +4 -3
- umap/tests/integration/test_export_map.py +1 -1
- umap/tests/integration/test_import.py +9 -4
- umap/tests/integration/test_map.py +64 -0
- umap/tests/integration/test_map_preview.py +75 -0
- umap/tests/integration/test_owned_map.py +11 -25
- umap/tests/integration/test_picto.py +3 -3
- umap/tests/integration/test_querystring.py +52 -0
- umap/tests/integration/test_share.py +22 -0
- umap/tests/test_map_views.py +157 -14
- umap/tests/test_views.py +50 -11
- umap/urls.py +6 -12
- umap/views.py +170 -47
- {umap_project-1.14.0a5.dist-info → umap_project-2.0.0a0.dist-info}/METADATA +13 -15
- {umap_project-1.14.0a5.dist-info → umap_project-2.0.0a0.dist-info}/RECORD +220 -199
- umap/static/umap/js/umap.browser.js +0 -148
- umap/static/umap/js/umap.xhr.js +0 -304
- umap/static/umap/test/Controls.js +0 -100
- umap/static/umap/test/Map.Init.js +0 -46
- {umap_project-1.14.0a5.dist-info → umap_project-2.0.0a0.dist-info}/WHEEL +0 -0
- {umap_project-1.14.0a5.dist-info → umap_project-2.0.0a0.dist-info}/entry_points.txt +0 -0
- {umap_project-1.14.0a5.dist-info → umap_project-2.0.0a0.dist-info}/licenses/LICENSE +0 -0
umap/static/umap/test/Feature.js
CHANGED
|
@@ -1,21 +1,25 @@
|
|
|
1
|
-
describe('
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
describe('U.FeatureMixin', function () {
|
|
2
|
+
let map, datalayer
|
|
3
|
+
before(async () => {
|
|
4
|
+
await fetchMock.mock(
|
|
5
5
|
/\/datalayer\/62\/\?.*/,
|
|
6
6
|
JSON.stringify(RESPONSES.datalayer62_GET)
|
|
7
7
|
)
|
|
8
|
-
this.
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
this.options = {
|
|
9
|
+
umap_id: 99,
|
|
10
|
+
}
|
|
11
|
+
MAP = map = initMap({ umap_id: 99 })
|
|
12
|
+
const datalayer_options = defaultDatalayerData()
|
|
13
|
+
await map.initDataLayers([datalayer_options])
|
|
14
|
+
datalayer = map.getDataLayerByUmapId(62)
|
|
11
15
|
})
|
|
12
16
|
after(function () {
|
|
13
|
-
|
|
17
|
+
fetchMock.restore()
|
|
14
18
|
resetMap()
|
|
15
19
|
})
|
|
16
20
|
|
|
17
21
|
describe('#edit()', function () {
|
|
18
|
-
|
|
22
|
+
let link
|
|
19
23
|
|
|
20
24
|
it('should have datalayer features created', function () {
|
|
21
25
|
assert.equal(
|
|
@@ -45,7 +49,7 @@ describe('L.U.FeatureMixin', function () {
|
|
|
45
49
|
|
|
46
50
|
it('should take into account styles changes made in the datalayer', function () {
|
|
47
51
|
happen.click(
|
|
48
|
-
qs('#browse_data_toggle_' + L.stamp(
|
|
52
|
+
qs('#browse_data_toggle_' + L.stamp(datalayer) + ' .layer-edit')
|
|
49
53
|
)
|
|
50
54
|
var colorInput = qs('form#datalayer-advanced-properties input[name=color]')
|
|
51
55
|
changeInputValue(colorInput, 'DarkRed')
|
|
@@ -101,7 +105,7 @@ describe('L.U.FeatureMixin', function () {
|
|
|
101
105
|
|
|
102
106
|
it('should not override already set style on features', function () {
|
|
103
107
|
happen.click(
|
|
104
|
-
qs('#browse_data_toggle_' + L.stamp(
|
|
108
|
+
qs('#browse_data_toggle_' + L.stamp(datalayer) + ' .layer-edit')
|
|
105
109
|
)
|
|
106
110
|
changeInputValue(qs('#umap-ui-container form input[name=color]'), 'Chocolate')
|
|
107
111
|
assert.notOk(qs('path[fill="DarkBlue"]'))
|
|
@@ -120,22 +124,22 @@ describe('L.U.FeatureMixin', function () {
|
|
|
120
124
|
|
|
121
125
|
it('should set map.editedFeature on edit', function () {
|
|
122
126
|
enableEdit()
|
|
123
|
-
assert.notOk(
|
|
127
|
+
assert.notOk(map.editedFeature)
|
|
124
128
|
happen.click(qs('path[fill="DarkBlue"]'))
|
|
125
129
|
happen.click(qs('ul.leaflet-inplace-toolbar a.umap-toggle-edit'))
|
|
126
|
-
assert.ok(
|
|
130
|
+
assert.ok(map.editedFeature)
|
|
127
131
|
disableEdit()
|
|
128
132
|
})
|
|
129
133
|
|
|
130
134
|
it('should reset map.editedFeature on panel open', function (done) {
|
|
131
135
|
enableEdit()
|
|
132
|
-
assert.notOk(
|
|
136
|
+
assert.notOk(map.editedFeature)
|
|
133
137
|
happen.click(qs('path[fill="DarkBlue"]'))
|
|
134
138
|
happen.click(qs('ul.leaflet-inplace-toolbar a.umap-toggle-edit'))
|
|
135
|
-
assert.ok(
|
|
136
|
-
|
|
139
|
+
assert.ok(map.editedFeature)
|
|
140
|
+
map.displayCaption()
|
|
137
141
|
window.setTimeout(function () {
|
|
138
|
-
assert.notOk(
|
|
142
|
+
assert.notOk(map.editedFeature)
|
|
139
143
|
disableEdit()
|
|
140
144
|
done()
|
|
141
145
|
}, 1001) // CSS transition time.
|
|
@@ -155,7 +159,7 @@ describe('L.U.FeatureMixin', function () {
|
|
|
155
159
|
})
|
|
156
160
|
}
|
|
157
161
|
it('should generate a valid geojson', function () {
|
|
158
|
-
setFeatures(
|
|
162
|
+
setFeatures(datalayer)
|
|
159
163
|
assert.ok(poly)
|
|
160
164
|
assert.deepEqual(poly.toGeoJSON().geometry, {
|
|
161
165
|
type: 'Polygon',
|
|
@@ -176,7 +180,7 @@ describe('L.U.FeatureMixin', function () {
|
|
|
176
180
|
})
|
|
177
181
|
|
|
178
182
|
it('should remove empty _umap_options from exported geojson', function () {
|
|
179
|
-
setFeatures(
|
|
183
|
+
setFeatures(datalayer)
|
|
180
184
|
assert.ok(poly)
|
|
181
185
|
assert.deepEqual(poly.toGeoJSON().properties, { name: 'name poly' })
|
|
182
186
|
assert.ok(marker)
|
|
@@ -190,7 +194,7 @@ describe('L.U.FeatureMixin', function () {
|
|
|
190
194
|
describe('#openPopup()', function () {
|
|
191
195
|
let poly
|
|
192
196
|
before(function () {
|
|
193
|
-
|
|
197
|
+
datalayer.eachLayer(function (layer) {
|
|
194
198
|
if (!poly && layer instanceof L.Polygon) {
|
|
195
199
|
poly = layer
|
|
196
200
|
}
|
|
@@ -233,8 +237,8 @@ describe('L.U.FeatureMixin', function () {
|
|
|
233
237
|
})
|
|
234
238
|
|
|
235
239
|
it('should still highlight marker after hide() and show()', function () {
|
|
236
|
-
|
|
237
|
-
|
|
240
|
+
datalayer.hide()
|
|
241
|
+
datalayer.show()
|
|
238
242
|
happen.click(qs('div.leaflet-marker-icon'))
|
|
239
243
|
assert.ok(qs('.umap-icon-active'))
|
|
240
244
|
})
|
|
@@ -254,9 +258,9 @@ describe('L.U.FeatureMixin', function () {
|
|
|
254
258
|
|
|
255
259
|
describe('#tooltip', function () {
|
|
256
260
|
it('should have a tooltip when active and allow variables', function () {
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
261
|
+
map.options.showLabel = true
|
|
262
|
+
map.options.labelKey = 'Foo {name}'
|
|
263
|
+
datalayer.redraw()
|
|
260
264
|
assert.equal(
|
|
261
265
|
qs('.leaflet-tooltip-pane .leaflet-tooltip').textContent,
|
|
262
266
|
'Foo name poly'
|
|
@@ -266,7 +270,7 @@ describe('L.U.FeatureMixin', function () {
|
|
|
266
270
|
|
|
267
271
|
describe('#properties()', function () {
|
|
268
272
|
it('should rename property', function () {
|
|
269
|
-
var poly =
|
|
273
|
+
var poly = datalayer._lineToLayer({}, [
|
|
270
274
|
[0, 0],
|
|
271
275
|
[0, 1],
|
|
272
276
|
[0, 2],
|
|
@@ -278,7 +282,7 @@ describe('L.U.FeatureMixin', function () {
|
|
|
278
282
|
})
|
|
279
283
|
|
|
280
284
|
it('should not create property when renaming', function () {
|
|
281
|
-
var poly =
|
|
285
|
+
var poly = datalayer._lineToLayer({}, [
|
|
282
286
|
[0, 0],
|
|
283
287
|
[0, 1],
|
|
284
288
|
[0, 2],
|
|
@@ -289,7 +293,7 @@ describe('L.U.FeatureMixin', function () {
|
|
|
289
293
|
})
|
|
290
294
|
|
|
291
295
|
it('should delete property', function () {
|
|
292
|
-
var poly =
|
|
296
|
+
var poly = datalayer._lineToLayer({}, [
|
|
293
297
|
[0, 0],
|
|
294
298
|
[0, 1],
|
|
295
299
|
[0, 2],
|
|
@@ -305,7 +309,7 @@ describe('L.U.FeatureMixin', function () {
|
|
|
305
309
|
var poly
|
|
306
310
|
|
|
307
311
|
it('should filter on properties', function () {
|
|
308
|
-
poly =
|
|
312
|
+
poly = datalayer._lineToLayer({}, [
|
|
309
313
|
[0, 0],
|
|
310
314
|
[0, 1],
|
|
311
315
|
[0, 2],
|
|
@@ -329,35 +333,6 @@ describe('L.U.FeatureMixin', function () {
|
|
|
329
333
|
})
|
|
330
334
|
})
|
|
331
335
|
|
|
332
|
-
describe('#quick-delete()', function () {
|
|
333
|
-
let poly, _confirm
|
|
334
|
-
before(function () {
|
|
335
|
-
_confirm = window.confirm
|
|
336
|
-
window.confirm = function (text) {
|
|
337
|
-
return true
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
this.datalayer.eachLayer(function (layer) {
|
|
341
|
-
if (!poly && layer instanceof L.Polygon) {
|
|
342
|
-
poly = layer
|
|
343
|
-
}
|
|
344
|
-
})
|
|
345
|
-
})
|
|
346
|
-
|
|
347
|
-
after(function () {
|
|
348
|
-
window.confirm = _confirm
|
|
349
|
-
})
|
|
350
|
-
|
|
351
|
-
it('should allow to delete from data browser', function () {
|
|
352
|
-
enableEdit()
|
|
353
|
-
assert.ok(qs('path[fill="DarkBlue"]'))
|
|
354
|
-
this.map.openBrowser()
|
|
355
|
-
happen.click(qs('.feature-delete'))
|
|
356
|
-
assert.notOk(qs('path[fill="DarkBlue"]'))
|
|
357
|
-
clickCancel()
|
|
358
|
-
})
|
|
359
|
-
})
|
|
360
|
-
|
|
361
336
|
describe('#changeDataLayer()', function () {
|
|
362
337
|
it('should change style on datalayer select change', function () {
|
|
363
338
|
enableEdit()
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
describe('
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
describe('U.Map.Export', function () {
|
|
2
|
+
let map
|
|
3
|
+
before(async () => {
|
|
4
|
+
await fetchMock.mock(
|
|
5
5
|
/\/datalayer\/62\/\?.*/,
|
|
6
6
|
JSON.stringify(RESPONSES.datalayer62_GET)
|
|
7
7
|
)
|
|
8
8
|
this.options = {
|
|
9
9
|
umap_id: 99,
|
|
10
10
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
map = initMap({ umap_id: 99 })
|
|
12
|
+
const datalayer_options = defaultDatalayerData()
|
|
13
|
+
await map.initDataLayers([datalayer_options])
|
|
14
14
|
})
|
|
15
15
|
after(function () {
|
|
16
|
-
|
|
16
|
+
fetchMock.restore()
|
|
17
17
|
clickCancel()
|
|
18
18
|
resetMap()
|
|
19
19
|
})
|
|
20
20
|
|
|
21
21
|
describe('#formatters()', function () {
|
|
22
22
|
it('should export to geojson', function () {
|
|
23
|
-
const { content, filetype, filename } =
|
|
23
|
+
const { content, filetype, filename } = map.share.format('geojson')
|
|
24
24
|
assert.equal(filetype, 'application/json')
|
|
25
25
|
assert.equal(filename, 'name_of_the_map.geojson')
|
|
26
26
|
assert.deepEqual(JSON.parse(content), {
|
|
@@ -86,7 +86,7 @@ describe('L.U.Map.Export', function () {
|
|
|
86
86
|
})
|
|
87
87
|
|
|
88
88
|
it('should export to gpx', function () {
|
|
89
|
-
const { content, filetype, filename } =
|
|
89
|
+
const { content, filetype, filename } = map.share.format('gpx')
|
|
90
90
|
assert.equal(filetype, 'application/gpx+xml')
|
|
91
91
|
assert.equal(filename, 'name_of_the_map.gpx')
|
|
92
92
|
const expected =
|
|
@@ -95,7 +95,7 @@ describe('L.U.Map.Export', function () {
|
|
|
95
95
|
})
|
|
96
96
|
|
|
97
97
|
it('should export to kml', function () {
|
|
98
|
-
const { content, filetype, filename } =
|
|
98
|
+
const { content, filetype, filename } = map.share.format('kml')
|
|
99
99
|
assert.equal(filetype, 'application/vnd.google-earth.kml+xml')
|
|
100
100
|
assert.equal(filename, 'name_of_the_map.kml')
|
|
101
101
|
const expected =
|
umap/static/umap/test/Map.js
CHANGED
|
@@ -1,26 +1,27 @@
|
|
|
1
|
-
describe('
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
describe('U.Map', () => {
|
|
2
|
+
let map, datalayer
|
|
3
|
+
before(async () => {
|
|
4
|
+
await fetchMock.mock(
|
|
5
5
|
/\/datalayer\/62\/\?.*/,
|
|
6
6
|
JSON.stringify(RESPONSES.datalayer62_GET)
|
|
7
7
|
)
|
|
8
8
|
this.options = {
|
|
9
9
|
umap_id: 99,
|
|
10
10
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
map = initMap({ umap_id: 99 })
|
|
12
|
+
const datalayer_options = defaultDatalayerData()
|
|
13
|
+
await map.initDataLayers([datalayer_options])
|
|
14
|
+
datalayer = map.getDataLayerByUmapId(62)
|
|
14
15
|
})
|
|
15
|
-
after(
|
|
16
|
-
|
|
16
|
+
after(() => {
|
|
17
|
+
fetchMock.restore()
|
|
17
18
|
clickCancel()
|
|
18
19
|
resetMap()
|
|
19
20
|
})
|
|
20
21
|
|
|
21
|
-
describe('#init()',
|
|
22
|
+
describe('#init()', () => {
|
|
22
23
|
it('should be initialized', function () {
|
|
23
|
-
assert.equal(
|
|
24
|
+
assert.equal(map.options.umap_id, 99)
|
|
24
25
|
})
|
|
25
26
|
|
|
26
27
|
it('should have created the edit button', function () {
|
|
@@ -42,7 +43,7 @@ describe('L.U.Map', function () {
|
|
|
42
43
|
it('should hide icon container div when hiding datalayer', function () {
|
|
43
44
|
var el = qs(
|
|
44
45
|
'.leaflet-control-browse #browse_data_toggle_' +
|
|
45
|
-
L.stamp(
|
|
46
|
+
L.stamp(datalayer) +
|
|
46
47
|
' .layer-toggle'
|
|
47
48
|
)
|
|
48
49
|
happen.click(el)
|
|
@@ -56,7 +57,7 @@ describe('L.U.Map', function () {
|
|
|
56
57
|
})
|
|
57
58
|
|
|
58
59
|
it('should have only one datalayer in its index', function () {
|
|
59
|
-
assert.equal(
|
|
60
|
+
assert.equal(map.datalayers_index.length, 1)
|
|
60
61
|
})
|
|
61
62
|
})
|
|
62
63
|
|
|
@@ -78,20 +79,20 @@ describe('L.U.Map', function () {
|
|
|
78
79
|
var new_name = 'This is a new name'
|
|
79
80
|
input.value = new_name
|
|
80
81
|
happen.once(input, { type: 'input' })
|
|
81
|
-
assert.equal(
|
|
82
|
+
assert.equal(map.options.name, new_name)
|
|
82
83
|
})
|
|
83
84
|
|
|
84
85
|
it('should have made Map dirty', function () {
|
|
85
|
-
assert.ok(
|
|
86
|
+
assert.ok(map.isDirty)
|
|
86
87
|
})
|
|
87
88
|
|
|
88
89
|
it('should have added dirty class on map container', function () {
|
|
89
|
-
assert.ok(L.DomUtil.hasClass(
|
|
90
|
+
assert.ok(L.DomUtil.hasClass(map._container, 'umap-is-dirty'))
|
|
90
91
|
})
|
|
91
92
|
})
|
|
92
93
|
|
|
93
94
|
describe('#delete()', function () {
|
|
94
|
-
|
|
95
|
+
let path = '/map/99/update/delete/',
|
|
95
96
|
oldConfirm,
|
|
96
97
|
newConfirm = function () {
|
|
97
98
|
return true
|
|
@@ -105,24 +106,22 @@ describe('L.U.Map', function () {
|
|
|
105
106
|
window.confirm = oldConfirm
|
|
106
107
|
})
|
|
107
108
|
|
|
108
|
-
it('should ask for confirmation on delete link click', function () {
|
|
109
|
-
|
|
109
|
+
it('should ask for confirmation on delete link click', async function () {
|
|
110
|
+
let button = qs('a.update-map-settings')
|
|
110
111
|
assert.ok(button, 'update map info button exists')
|
|
111
112
|
happen.click(button)
|
|
112
|
-
|
|
113
|
+
let deleteLink = qs('button.umap-delete')
|
|
113
114
|
assert.ok(deleteLink, 'delete map button exists')
|
|
114
115
|
sinon.spy(window, 'confirm')
|
|
115
|
-
|
|
116
|
+
await fetchMock.post(path, { redirect: '#' })
|
|
116
117
|
happen.click(deleteLink)
|
|
117
|
-
this.server.respond()
|
|
118
118
|
assert(window.confirm.calledOnce)
|
|
119
119
|
window.confirm.restore()
|
|
120
|
-
|
|
121
120
|
})
|
|
122
121
|
})
|
|
123
122
|
|
|
124
123
|
describe('#importData()', function () {
|
|
125
|
-
|
|
124
|
+
let fileInput, textarea, submit, formatSelect, layerSelect, clearFlag
|
|
126
125
|
|
|
127
126
|
it('should build a form on click', function () {
|
|
128
127
|
happen.click(qs('a.upload-data'))
|
|
@@ -139,82 +138,82 @@ describe('L.U.Map', function () {
|
|
|
139
138
|
})
|
|
140
139
|
|
|
141
140
|
it('should import geojson from textarea', function () {
|
|
142
|
-
|
|
143
|
-
assert.equal(
|
|
141
|
+
datalayer.empty()
|
|
142
|
+
assert.equal(datalayer._index.length, 0)
|
|
144
143
|
textarea.value =
|
|
145
144
|
'{"type": "FeatureCollection", "features": [{"geometry": {"type": "Point", "coordinates": [6.922931671142578, 47.481161607175736]}, "type": "Feature", "properties": {"color": "", "name": "Chez R\u00e9my", "description": ""}}, {"geometry": {"type": "LineString", "coordinates": [[2.4609375, 48.88639177703194], [2.48291015625, 48.76343113791796], [2.164306640625, 48.719961222646276]]}, "type": "Feature", "properties": {"color": "", "name": "P\u00e9rif", "description": ""}}]}'
|
|
146
145
|
changeSelectValue(formatSelect, 'geojson')
|
|
147
146
|
happen.click(submit)
|
|
148
|
-
assert.equal(
|
|
147
|
+
assert.equal(datalayer._index.length, 2)
|
|
149
148
|
})
|
|
150
149
|
|
|
151
150
|
it('should remove dot in property name', function () {
|
|
152
|
-
|
|
153
|
-
assert.equal(
|
|
151
|
+
datalayer.empty()
|
|
152
|
+
assert.equal(datalayer._index.length, 0)
|
|
154
153
|
textarea.value =
|
|
155
154
|
'{"type": "FeatureCollection", "features": [{"geometry": {"type": "Point", "coordinates": [6.922931671142578, 47.481161607175736]}, "type": "Feature", "properties": {"color": "", "name": "Chez R\u00e9my", "A . in the name": ""}}, {"geometry": {"type": "LineString", "coordinates": [[2.4609375, 48.88639177703194], [2.48291015625, 48.76343113791796], [2.164306640625, 48.719961222646276]]}, "type": "Feature", "properties": {"color": "", "name": "P\u00e9rif", "with a dot.": ""}}]}'
|
|
156
155
|
changeSelectValue(formatSelect, 'geojson')
|
|
157
156
|
happen.click(submit)
|
|
158
|
-
assert.equal(
|
|
159
|
-
assert.ok(
|
|
160
|
-
assert.ok(
|
|
157
|
+
assert.equal(datalayer._index.length, 2)
|
|
158
|
+
assert.ok(datalayer._propertiesIndex.includes('A _ in the name'))
|
|
159
|
+
assert.ok(datalayer._propertiesIndex.includes('with a dot_'))
|
|
161
160
|
})
|
|
162
161
|
|
|
163
162
|
it('should import osm from textarea', function () {
|
|
164
|
-
|
|
163
|
+
datalayer.empty()
|
|
165
164
|
happen.click(qs('a.upload-data'))
|
|
166
165
|
textarea = qs('.umap-upload textarea')
|
|
167
166
|
submit = qs('.umap-upload input[type="button"]')
|
|
168
167
|
formatSelect = qs('.umap-upload select[name="format"]')
|
|
169
|
-
assert.equal(
|
|
168
|
+
assert.equal(datalayer._index.length, 0)
|
|
170
169
|
textarea.value =
|
|
171
170
|
'{"version": 0.6,"generator": "Overpass API 0.7.55.4 3079d8ea","osm3s": {"timestamp_osm_base": "2018-09-22T05:26:02Z","copyright": "The data included in this document is from www.openstreetmap.org. The data is made available under ODbL."},"elements": [{"type": "node","id": 3619112991,"lat": 48.9352995,"lon": 2.3570684,"tags": {"information": "map","map_size": "city","map_type": "scheme","tourism": "information"}},{"type": "node","id": 3682500756,"lat": 48.9804426,"lon": 2.2719725,"tags": {"information": "map","level": "0","tourism": "information"}}]}'
|
|
172
171
|
changeSelectValue(formatSelect, 'osm')
|
|
173
172
|
happen.click(submit)
|
|
174
|
-
assert.equal(
|
|
173
|
+
assert.equal(datalayer._index.length, 2)
|
|
175
174
|
assert.equal(
|
|
176
|
-
|
|
175
|
+
datalayer._layers[datalayer._index[0]].properties.tourism,
|
|
177
176
|
'information'
|
|
178
177
|
)
|
|
179
178
|
})
|
|
180
179
|
|
|
181
180
|
it('should import kml from textarea', function () {
|
|
182
|
-
|
|
181
|
+
datalayer.empty()
|
|
183
182
|
happen.click(qs('a.upload-data'))
|
|
184
183
|
textarea = qs('.umap-upload textarea')
|
|
185
184
|
submit = qs('.umap-upload input[type="button"]')
|
|
186
185
|
formatSelect = qs('.umap-upload select[name="format"]')
|
|
187
|
-
assert.equal(
|
|
186
|
+
assert.equal(datalayer._index.length, 0)
|
|
188
187
|
textarea.value = kml_example
|
|
189
188
|
changeSelectValue(formatSelect, 'kml')
|
|
190
189
|
happen.click(submit)
|
|
191
|
-
assert.equal(
|
|
190
|
+
assert.equal(datalayer._index.length, 3)
|
|
192
191
|
})
|
|
193
192
|
|
|
194
193
|
it('should import gpx from textarea', function () {
|
|
195
|
-
|
|
194
|
+
datalayer.empty()
|
|
196
195
|
happen.click(qs('a.upload-data'))
|
|
197
196
|
textarea = qs('.umap-upload textarea')
|
|
198
197
|
submit = qs('.umap-upload input[type="button"]')
|
|
199
198
|
formatSelect = qs('.umap-upload select[name="format"]')
|
|
200
|
-
assert.equal(
|
|
199
|
+
assert.equal(datalayer._index.length, 0)
|
|
201
200
|
textarea.value = gpx_example
|
|
202
201
|
changeSelectValue(formatSelect, 'gpx')
|
|
203
202
|
happen.click(submit)
|
|
204
|
-
assert.equal(
|
|
203
|
+
assert.equal(datalayer._index.length, 2)
|
|
205
204
|
})
|
|
206
205
|
|
|
207
206
|
it('should import csv from textarea', function () {
|
|
208
|
-
|
|
207
|
+
datalayer.empty()
|
|
209
208
|
happen.click(qs('a.upload-data'))
|
|
210
209
|
textarea = qs('.umap-upload textarea')
|
|
211
210
|
submit = qs('.umap-upload input[type="button"]')
|
|
212
211
|
formatSelect = qs('.umap-upload select[name="format"]')
|
|
213
|
-
assert.equal(
|
|
212
|
+
assert.equal(datalayer._index.length, 0)
|
|
214
213
|
textarea.value = csv_example
|
|
215
214
|
changeSelectValue(formatSelect, 'csv')
|
|
216
215
|
happen.click(submit)
|
|
217
|
-
assert.equal(
|
|
216
|
+
assert.equal(datalayer._index.length, 1)
|
|
218
217
|
})
|
|
219
218
|
|
|
220
219
|
it('should replace content if asked so', function () {
|
|
@@ -224,52 +223,52 @@ describe('L.U.Map', function () {
|
|
|
224
223
|
formatSelect = qs('.umap-upload select[name="format"]')
|
|
225
224
|
clearFlag = qs('.umap-upload input[name="clear"]')
|
|
226
225
|
clearFlag.checked = true
|
|
227
|
-
assert.equal(
|
|
226
|
+
assert.equal(datalayer._index.length, 1)
|
|
228
227
|
textarea.value = csv_example
|
|
229
228
|
changeSelectValue(formatSelect, 'csv')
|
|
230
229
|
happen.click(submit)
|
|
231
|
-
assert.equal(
|
|
230
|
+
assert.equal(datalayer._index.length, 1)
|
|
232
231
|
})
|
|
233
232
|
|
|
234
233
|
it('should import GeometryCollection from textarea', function () {
|
|
235
|
-
|
|
234
|
+
datalayer.empty()
|
|
236
235
|
textarea.value =
|
|
237
236
|
'{"type": "GeometryCollection","geometries": [{"type": "Point","coordinates": [-80.66080570220947,35.04939206472683]},{"type": "Polygon","coordinates": [[[-80.66458225250244,35.04496519190309],[-80.66344499588013,35.04603679820616],[-80.66258668899536,35.045580049697556],[-80.66387414932251,35.044280059194946],[-80.66458225250244,35.04496519190309]]]},{"type": "LineString","coordinates": [[-80.66237211227417,35.05950973022538],[-80.66269397735596,35.0592638296087],[-80.66284418106079,35.05893010615862],[-80.66308021545409,35.05833291342246],[-80.66359519958496,35.057753281001425],[-80.66387414932251,35.05740198662245],[-80.66441059112549,35.05703312589789],[-80.66486120223999,35.056787217822475],[-80.66541910171509,35.05650617911516],[-80.66563367843628,35.05631296444281],[-80.66601991653441,35.055891403570705],[-80.66619157791138,35.05545227534804],[-80.66619157791138,35.05517123204622],[-80.66625595092773,35.05489018777713],[-80.6662130355835,35.054222703761525],[-80.6662130355835,35.05392409072499],[-80.66595554351807,35.05290528508858],[-80.66569805145262,35.052044560077285],[-80.66550493240356,35.0514824490509],[-80.665762424469,35.05048117920187],[-80.66617012023926,35.04972582715769],[-80.66651344299316,35.049286665781096],[-80.66692113876343,35.0485313026898],[-80.66700696945189,35.048215102112344],[-80.66707134246826,35.04777593261294],[-80.66704988479614,35.04738946150025],[-80.66696405410767,35.04698542156371],[-80.66681385040283,35.046353007216055],[-80.66659927368164,35.04596652937105],[-80.66640615463257,35.04561518428889],[-80.6659984588623,35.045193568195565],[-80.66552639007568,35.044877354697526],[-80.6649899482727,35.04454357245502],[-80.66449642181396,35.04417465365292],[-80.66385269165039,35.04387600387859],[-80.66303730010986,35.043717894732545]]}]}'
|
|
238
237
|
formatSelect = qs('.umap-upload select[name="format"]')
|
|
239
238
|
changeSelectValue(formatSelect, 'geojson')
|
|
240
239
|
happen.click(submit)
|
|
241
|
-
assert.equal(
|
|
240
|
+
assert.equal(datalayer._index.length, 3)
|
|
242
241
|
})
|
|
243
242
|
|
|
244
243
|
it('should import multipolygon', function () {
|
|
245
|
-
|
|
244
|
+
datalayer.empty()
|
|
246
245
|
textarea.value =
|
|
247
246
|
'{"type": "Feature", "properties": { "name": "Some states" }, "geometry": { "type": "MultiPolygon", "coordinates": [[[[-109, 36], [-109, 40], [-102, 37], [-109, 36]], [[-108, 39], [-107, 37], [-104, 37], [-108, 39]]], [[[-119, 42], [-120, 39], [-114, 41], [-119, 42]]]] }}'
|
|
248
247
|
changeSelectValue(formatSelect, 'geojson')
|
|
249
248
|
happen.click(submit)
|
|
250
|
-
assert.equal(
|
|
251
|
-
var layer =
|
|
249
|
+
assert.equal(datalayer._index.length, 1)
|
|
250
|
+
var layer = datalayer.getFeatureByIndex(0)
|
|
252
251
|
assert.equal(layer._latlngs.length, 2) // Two shapes.
|
|
253
252
|
assert.equal(layer._latlngs[0].length, 2) // Hole.
|
|
254
253
|
})
|
|
255
254
|
|
|
256
255
|
it('should import multipolyline', function () {
|
|
257
|
-
|
|
256
|
+
datalayer.empty()
|
|
258
257
|
textarea.value =
|
|
259
258
|
'{"type": "FeatureCollection", "features": [{ "type": "Feature", "properties": {}, "geometry": { "type": "MultiLineString", "coordinates": [[[-108, 46], [-113, 43]], [[-112, 45], [-115, 44]]] } }]}'
|
|
260
259
|
changeSelectValue(formatSelect, 'geojson')
|
|
261
260
|
happen.click(submit)
|
|
262
|
-
assert.equal(
|
|
263
|
-
var layer =
|
|
261
|
+
assert.equal(datalayer._index.length, 1)
|
|
262
|
+
var layer = datalayer.getFeatureByIndex(0)
|
|
264
263
|
assert.equal(layer._latlngs.length, 2) // Two shapes.
|
|
265
264
|
})
|
|
266
265
|
|
|
267
266
|
it('should import raw umap data from textarea', function () {
|
|
268
267
|
//Right now, the import function will try to save and reload. Stop this from happening.
|
|
269
|
-
var disabledSaveFunction =
|
|
270
|
-
|
|
268
|
+
var disabledSaveFunction = map.save
|
|
269
|
+
map.save = function () {}
|
|
271
270
|
happen.click(qs('a.upload-data'))
|
|
272
|
-
var initialLayerCount = Object.keys(
|
|
271
|
+
var initialLayerCount = Object.keys(map.datalayers).length
|
|
273
272
|
formatSelect = qs('.umap-upload select[name="format"]')
|
|
274
273
|
textarea = qs('.umap-upload textarea')
|
|
275
274
|
textarea.value =
|
|
@@ -277,12 +276,12 @@ describe('L.U.Map', function () {
|
|
|
277
276
|
formatSelect.value = 'umap'
|
|
278
277
|
submit = qs('.umap-upload input[type="button"]')
|
|
279
278
|
happen.click(submit)
|
|
280
|
-
assert.equal(Object.keys(
|
|
281
|
-
assert.equal(
|
|
279
|
+
assert.equal(Object.keys(map.datalayers).length, initialLayerCount + 2)
|
|
280
|
+
assert.equal(map.options.name, 'Imported map')
|
|
282
281
|
var foundFirstLayer = false
|
|
283
282
|
var foundSecondLayer = false
|
|
284
|
-
for (var idx in
|
|
285
|
-
var datalayer =
|
|
283
|
+
for (var idx in map.datalayers) {
|
|
284
|
+
var datalayer = map.datalayers[idx]
|
|
286
285
|
if (datalayer.options.name === 'Cities') {
|
|
287
286
|
foundFirstLayer = true
|
|
288
287
|
assert.equal(datalayer._index.length, 2)
|
|
@@ -297,7 +296,7 @@ describe('L.U.Map', function () {
|
|
|
297
296
|
})
|
|
298
297
|
|
|
299
298
|
it('should only import options on the whitelist (umap format import)', function () {
|
|
300
|
-
assert.equal(
|
|
299
|
+
assert.equal(map.options.umap_id, 99)
|
|
301
300
|
})
|
|
302
301
|
|
|
303
302
|
it('should update title bar (umap format import)', function () {
|
|
@@ -318,7 +317,7 @@ describe('L.U.Map', function () {
|
|
|
318
317
|
|
|
319
318
|
it('should set the tilelayer (umap format import)', function () {
|
|
320
319
|
assert.equal(
|
|
321
|
-
|
|
320
|
+
map.selected_tilelayer._url,
|
|
322
321
|
'http://{s}.tile.stamen.com/watercolor/{z}/{x}/{y}.jpg'
|
|
323
322
|
)
|
|
324
323
|
})
|
|
@@ -327,14 +326,14 @@ describe('L.U.Map', function () {
|
|
|
327
326
|
describe('#localizeUrl()', function () {
|
|
328
327
|
it('should replace known variables', function () {
|
|
329
328
|
assert.equal(
|
|
330
|
-
|
|
331
|
-
'http://example.org/' +
|
|
329
|
+
map.localizeUrl('http://example.org/{zoom}'),
|
|
330
|
+
'http://example.org/' + map.getZoom()
|
|
332
331
|
)
|
|
333
332
|
})
|
|
334
333
|
|
|
335
334
|
it('should keep unknown variables', function () {
|
|
336
335
|
assert.equal(
|
|
337
|
-
|
|
336
|
+
map.localizeUrl('http://example.org/{unkown}'),
|
|
338
337
|
'http://example.org/{unkown}'
|
|
339
338
|
)
|
|
340
339
|
})
|