umap-project 1.14.0a1__py3-none-any.whl → 1.14.0a2__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/static/.gitignore +0 -0
- umap/static/umap/base.css +994 -0
- umap/static/umap/bitbucket.png +0 -0
- umap/static/umap/content.css +395 -0
- umap/static/umap/favicons/apple-touch-icon.png +0 -0
- umap/static/umap/favicons/favicon.ico +0 -0
- umap/static/umap/favicons/icon-192.png +0 -0
- umap/static/umap/favicons/icon-512.png +0 -0
- umap/static/umap/favicons/icon.svg +5 -0
- umap/static/umap/font/FiraSans-Light.woff +0 -0
- umap/static/umap/font/FiraSans-Light.woff2 +0 -0
- umap/static/umap/font/FiraSans-LightItalic.woff +0 -0
- umap/static/umap/font/FiraSans-LightItalic.woff2 +0 -0
- umap/static/umap/font/FiraSans-SemiBold.woff +0 -0
- umap/static/umap/font/FiraSans-SemiBold.woff2 +0 -0
- umap/static/umap/font.css +33 -0
- umap/static/umap/github.png +0 -0
- umap/static/umap/img/16-white.svg +190 -0
- umap/static/umap/img/16.svg +182 -0
- umap/static/umap/img/24-white.svg +62 -0
- umap/static/umap/img/24.svg +90 -0
- umap/static/umap/img/edit.svg +7 -0
- umap/static/umap/img/icon-bg.png +0 -0
- umap/static/umap/img/logo.svg +4 -0
- umap/static/umap/img/logo_filigree.png +0 -0
- umap/static/umap/img/logo_small.svg +14 -0
- umap/static/umap/img/marker.png +0 -0
- umap/static/umap/img/opensource.svg +7 -0
- umap/static/umap/img/osm.svg +7 -0
- umap/static/umap/img/search.gif +0 -0
- umap/static/umap/img/source/16-white.svg +980 -0
- umap/static/umap/img/source/16.svg +201 -0
- umap/static/umap/img/source/24-white.svg +83 -0
- umap/static/umap/img/source/24.svg +110 -0
- umap/static/umap/js/components/fragment.js +13 -0
- umap/static/umap/js/modules/global.js +8 -0
- umap/static/umap/js/modules/urls.js +29 -0
- umap/static/umap/js/umap.autocomplete.js +336 -0
- umap/static/umap/js/umap.browser.js +148 -0
- umap/static/umap/js/umap.controls.js +1542 -0
- umap/static/umap/js/umap.core.js +851 -0
- umap/static/umap/js/umap.datalayer.permissions.js +72 -0
- umap/static/umap/js/umap.features.js +1216 -0
- umap/static/umap/js/umap.forms.js +1267 -0
- umap/static/umap/js/umap.icon.js +234 -0
- umap/static/umap/js/umap.importer.js +166 -0
- umap/static/umap/js/umap.js +2010 -0
- umap/static/umap/js/umap.layer.js +1636 -0
- umap/static/umap/js/umap.permissions.js +212 -0
- umap/static/umap/js/umap.popup.js +340 -0
- umap/static/umap/js/umap.share.js +254 -0
- umap/static/umap/js/umap.slideshow.js +165 -0
- umap/static/umap/js/umap.tableeditor.js +120 -0
- umap/static/umap/js/umap.ui.js +240 -0
- umap/static/umap/js/umap.xhr.js +304 -0
- umap/static/umap/locale/am_ET.js +447 -0
- umap/static/umap/locale/am_ET.json +445 -0
- umap/static/umap/locale/ar.js +447 -0
- umap/static/umap/locale/ar.json +445 -0
- umap/static/umap/locale/ast.js +447 -0
- umap/static/umap/locale/ast.json +445 -0
- umap/static/umap/locale/bg.js +447 -0
- umap/static/umap/locale/bg.json +445 -0
- umap/static/umap/locale/br.js +447 -0
- umap/static/umap/locale/br.json +445 -0
- umap/static/umap/locale/ca.js +447 -0
- umap/static/umap/locale/ca.json +445 -0
- umap/static/umap/locale/cs_CZ.js +447 -0
- umap/static/umap/locale/cs_CZ.json +445 -0
- umap/static/umap/locale/da.js +447 -0
- umap/static/umap/locale/da.json +445 -0
- umap/static/umap/locale/de.js +447 -0
- umap/static/umap/locale/de.json +445 -0
- umap/static/umap/locale/el.js +447 -0
- umap/static/umap/locale/el.json +445 -0
- umap/static/umap/locale/en.js +447 -0
- umap/static/umap/locale/en.json +445 -0
- umap/static/umap/locale/en_US.json +445 -0
- umap/static/umap/locale/es.js +447 -0
- umap/static/umap/locale/es.json +445 -0
- umap/static/umap/locale/et.js +447 -0
- umap/static/umap/locale/et.json +445 -0
- umap/static/umap/locale/eu.js +413 -0
- umap/static/umap/locale/eu.json +411 -0
- umap/static/umap/locale/fa_IR.js +447 -0
- umap/static/umap/locale/fa_IR.json +445 -0
- umap/static/umap/locale/fi.js +447 -0
- umap/static/umap/locale/fi.json +445 -0
- umap/static/umap/locale/fr.js +447 -0
- umap/static/umap/locale/fr.json +445 -0
- umap/static/umap/locale/gl.js +447 -0
- umap/static/umap/locale/gl.json +445 -0
- umap/static/umap/locale/he.js +447 -0
- umap/static/umap/locale/he.json +445 -0
- umap/static/umap/locale/hr.js +447 -0
- umap/static/umap/locale/hr.json +445 -0
- umap/static/umap/locale/hu.js +447 -0
- umap/static/umap/locale/hu.json +445 -0
- umap/static/umap/locale/id.js +447 -0
- umap/static/umap/locale/id.json +445 -0
- umap/static/umap/locale/is.js +447 -0
- umap/static/umap/locale/is.json +445 -0
- umap/static/umap/locale/it.js +447 -0
- umap/static/umap/locale/it.json +445 -0
- umap/static/umap/locale/ja.js +447 -0
- umap/static/umap/locale/ja.json +445 -0
- umap/static/umap/locale/ko.js +447 -0
- umap/static/umap/locale/ko.json +445 -0
- umap/static/umap/locale/lt.js +447 -0
- umap/static/umap/locale/lt.json +445 -0
- umap/static/umap/locale/ms.js +447 -0
- umap/static/umap/locale/ms.json +445 -0
- umap/static/umap/locale/nl.js +447 -0
- umap/static/umap/locale/nl.json +445 -0
- umap/static/umap/locale/no.js +447 -0
- umap/static/umap/locale/no.json +445 -0
- umap/static/umap/locale/pl.js +447 -0
- umap/static/umap/locale/pl.json +445 -0
- umap/static/umap/locale/pl_PL.json +445 -0
- umap/static/umap/locale/pt.js +447 -0
- umap/static/umap/locale/pt.json +445 -0
- umap/static/umap/locale/pt_BR.js +447 -0
- umap/static/umap/locale/pt_BR.json +445 -0
- umap/static/umap/locale/pt_PT.js +447 -0
- umap/static/umap/locale/pt_PT.json +445 -0
- umap/static/umap/locale/ro.js +447 -0
- umap/static/umap/locale/ro.json +445 -0
- umap/static/umap/locale/ru.js +447 -0
- umap/static/umap/locale/ru.json +445 -0
- umap/static/umap/locale/si.js +439 -0
- umap/static/umap/locale/si.json +437 -0
- umap/static/umap/locale/sk_SK.js +447 -0
- umap/static/umap/locale/sk_SK.json +445 -0
- umap/static/umap/locale/sl.js +447 -0
- umap/static/umap/locale/sl.json +445 -0
- umap/static/umap/locale/sr.js +447 -0
- umap/static/umap/locale/sr.json +445 -0
- umap/static/umap/locale/sv.js +447 -0
- umap/static/umap/locale/sv.json +445 -0
- umap/static/umap/locale/th_TH.js +447 -0
- umap/static/umap/locale/th_TH.json +445 -0
- umap/static/umap/locale/tr.js +447 -0
- umap/static/umap/locale/tr.json +445 -0
- umap/static/umap/locale/uk_UA.js +447 -0
- umap/static/umap/locale/uk_UA.json +445 -0
- umap/static/umap/locale/vi.js +447 -0
- umap/static/umap/locale/vi.json +445 -0
- umap/static/umap/locale/vi_VN.json +445 -0
- umap/static/umap/locale/zh.js +447 -0
- umap/static/umap/locale/zh.json +445 -0
- umap/static/umap/locale/zh_CN.json +445 -0
- umap/static/umap/locale/zh_TW.Big5.json +445 -0
- umap/static/umap/locale/zh_TW.js +447 -0
- umap/static/umap/locale/zh_TW.json +445 -0
- umap/static/umap/map.css +1843 -0
- umap/static/umap/nav.css +81 -0
- umap/static/umap/openstreetmap.png +0 -0
- umap/static/umap/test/.eslintrc +22 -0
- umap/static/umap/test/Choropleth.js +243 -0
- umap/static/umap/test/Controls.js +100 -0
- umap/static/umap/test/DataLayer.js +495 -0
- umap/static/umap/test/Feature.js +382 -0
- umap/static/umap/test/Map.Export.js +106 -0
- umap/static/umap/test/Map.Init.js +46 -0
- umap/static/umap/test/Map.js +342 -0
- umap/static/umap/test/Marker.js +122 -0
- umap/static/umap/test/Permissions.js +74 -0
- umap/static/umap/test/Polygon.js +367 -0
- umap/static/umap/test/Polyline.js +402 -0
- umap/static/umap/test/TableEditor.js +100 -0
- umap/static/umap/test/URLs.js +54 -0
- umap/static/umap/test/Util.js +549 -0
- umap/static/umap/test/_pre.js +460 -0
- umap/static/umap/test/index.html +135 -0
- umap/static/umap/theme.css +1 -0
- umap/static/umap/twitter.png +0 -0
- {umap_project-1.14.0a1.dist-info → umap_project-1.14.0a2.dist-info}/METADATA +1 -1
- {umap_project-1.14.0a1.dist-info → umap_project-1.14.0a2.dist-info}/RECORD +182 -6
- {umap_project-1.14.0a1.dist-info → umap_project-1.14.0a2.dist-info}/WHEEL +0 -0
- {umap_project-1.14.0a1.dist-info → umap_project-1.14.0a2.dist-info}/entry_points.txt +0 -0
- {umap_project-1.14.0a1.dist-info → umap_project-1.14.0a2.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
describe('L.U.Map', function () {
|
|
2
|
+
before(function () {
|
|
3
|
+
this.server = sinon.fakeServer.create()
|
|
4
|
+
this.server.respondWith(
|
|
5
|
+
/\/datalayer\/62\/\?.*/,
|
|
6
|
+
JSON.stringify(RESPONSES.datalayer62_GET)
|
|
7
|
+
)
|
|
8
|
+
this.options = {
|
|
9
|
+
umap_id: 99,
|
|
10
|
+
}
|
|
11
|
+
this.map = initMap({ umap_id: 99 })
|
|
12
|
+
this.server.respond()
|
|
13
|
+
this.datalayer = this.map.getDataLayerByUmapId(62)
|
|
14
|
+
})
|
|
15
|
+
after(function () {
|
|
16
|
+
this.server.restore()
|
|
17
|
+
clickCancel()
|
|
18
|
+
resetMap()
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
describe('#init()', function () {
|
|
22
|
+
it('should be initialized', function () {
|
|
23
|
+
assert.equal(this.map.options.umap_id, 99)
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
it('should have created the edit button', function () {
|
|
27
|
+
assert.ok(qs('div.leaflet-control-edit-enable'))
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
it('should have datalayer control div', function () {
|
|
31
|
+
assert.ok(qs('div.leaflet-control-browse'))
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
it('should have datalayer actions div', function () {
|
|
35
|
+
assert.ok(qs('div.umap-browse-actions'))
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
it('should have icon container div', function () {
|
|
39
|
+
assert.ok(qs('div.icon_container'))
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
it('should hide icon container div when hiding datalayer', function () {
|
|
43
|
+
var el = qs(
|
|
44
|
+
'.leaflet-control-browse #browse_data_toggle_' +
|
|
45
|
+
L.stamp(this.datalayer) +
|
|
46
|
+
' .layer-toggle'
|
|
47
|
+
)
|
|
48
|
+
happen.click(el)
|
|
49
|
+
assert.notOk(qs('div.icon_container'))
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
it('enable edit on click on toggle button', function () {
|
|
53
|
+
var el = qs('div.leaflet-control-edit-enable button')
|
|
54
|
+
happen.click(el)
|
|
55
|
+
assert.isTrue(L.DomUtil.hasClass(document.body, 'umap-edit-enabled'))
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
it('should have only one datalayer in its index', function () {
|
|
59
|
+
assert.equal(this.map.datalayers_index.length, 1)
|
|
60
|
+
})
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
describe('#editMetadata()', function () {
|
|
64
|
+
var form, input
|
|
65
|
+
|
|
66
|
+
it('should build a form on editMetadata control click', function (done) {
|
|
67
|
+
var button = qs('a.update-map-settings')
|
|
68
|
+
assert.ok(button)
|
|
69
|
+
happen.click(button)
|
|
70
|
+
form = qs('form.umap-form')
|
|
71
|
+
input = qs('form[class="umap-form"] input[name="name"]')
|
|
72
|
+
assert.ok(form)
|
|
73
|
+
assert.ok(input)
|
|
74
|
+
done()
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
it('should update map name on input change', function () {
|
|
78
|
+
var new_name = 'This is a new name'
|
|
79
|
+
input.value = new_name
|
|
80
|
+
happen.once(input, { type: 'input' })
|
|
81
|
+
assert.equal(this.map.options.name, new_name)
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
it('should have made Map dirty', function () {
|
|
85
|
+
assert.ok(this.map.isDirty)
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
it('should have added dirty class on map container', function () {
|
|
89
|
+
assert.ok(L.DomUtil.hasClass(this.map._container, 'umap-is-dirty'))
|
|
90
|
+
})
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
describe('#delete()', function () {
|
|
94
|
+
var path = '/map/99/delete/',
|
|
95
|
+
oldConfirm,
|
|
96
|
+
newConfirm = function () {
|
|
97
|
+
return true
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
before(function () {
|
|
101
|
+
oldConfirm = window.confirm
|
|
102
|
+
window.confirm = newConfirm
|
|
103
|
+
})
|
|
104
|
+
after(function () {
|
|
105
|
+
window.confirm = oldConfirm
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
it('should ask for confirmation on delete link click', function () {
|
|
109
|
+
var button = qs('a.update-map-settings')
|
|
110
|
+
assert.ok(button, 'update map info button exists')
|
|
111
|
+
happen.click(button)
|
|
112
|
+
var deleteLink = qs('button.umap-delete')
|
|
113
|
+
assert.ok(deleteLink, 'delete map button exists')
|
|
114
|
+
sinon.spy(window, 'confirm')
|
|
115
|
+
this.server.respondWith('POST', path, JSON.stringify({ redirect: '#' }))
|
|
116
|
+
happen.click(deleteLink)
|
|
117
|
+
this.server.respond()
|
|
118
|
+
assert(window.confirm.calledOnce)
|
|
119
|
+
window.confirm.restore()
|
|
120
|
+
|
|
121
|
+
})
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
describe('#importData()', function () {
|
|
125
|
+
var fileInput, textarea, submit, formatSelect, layerSelect, clearFlag
|
|
126
|
+
|
|
127
|
+
it('should build a form on click', function () {
|
|
128
|
+
happen.click(qs('a.upload-data'))
|
|
129
|
+
fileInput = qs('.umap-upload input[type="file"]')
|
|
130
|
+
textarea = qs('.umap-upload textarea')
|
|
131
|
+
submit = qs('.umap-upload input[type="button"]')
|
|
132
|
+
formatSelect = qs('.umap-upload select[name="format"]')
|
|
133
|
+
layerSelect = qs('.umap-upload select[name="datalayer"]')
|
|
134
|
+
assert.ok(fileInput)
|
|
135
|
+
assert.ok(submit)
|
|
136
|
+
assert.ok(textarea)
|
|
137
|
+
assert.ok(formatSelect)
|
|
138
|
+
assert.ok(layerSelect)
|
|
139
|
+
})
|
|
140
|
+
|
|
141
|
+
it('should import geojson from textarea', function () {
|
|
142
|
+
this.datalayer.empty()
|
|
143
|
+
assert.equal(this.datalayer._index.length, 0)
|
|
144
|
+
textarea.value =
|
|
145
|
+
'{"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
|
+
changeSelectValue(formatSelect, 'geojson')
|
|
147
|
+
happen.click(submit)
|
|
148
|
+
assert.equal(this.datalayer._index.length, 2)
|
|
149
|
+
})
|
|
150
|
+
|
|
151
|
+
it('should remove dot in property name', function () {
|
|
152
|
+
this.datalayer.empty()
|
|
153
|
+
assert.equal(this.datalayer._index.length, 0)
|
|
154
|
+
textarea.value =
|
|
155
|
+
'{"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
|
+
changeSelectValue(formatSelect, 'geojson')
|
|
157
|
+
happen.click(submit)
|
|
158
|
+
assert.equal(this.datalayer._index.length, 2)
|
|
159
|
+
assert.ok(this.datalayer._propertiesIndex.includes('A _ in the name'))
|
|
160
|
+
assert.ok(this.datalayer._propertiesIndex.includes('with a dot_'))
|
|
161
|
+
})
|
|
162
|
+
|
|
163
|
+
it('should import osm from textarea', function () {
|
|
164
|
+
this.datalayer.empty()
|
|
165
|
+
happen.click(qs('a.upload-data'))
|
|
166
|
+
textarea = qs('.umap-upload textarea')
|
|
167
|
+
submit = qs('.umap-upload input[type="button"]')
|
|
168
|
+
formatSelect = qs('.umap-upload select[name="format"]')
|
|
169
|
+
assert.equal(this.datalayer._index.length, 0)
|
|
170
|
+
textarea.value =
|
|
171
|
+
'{"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
|
+
changeSelectValue(formatSelect, 'osm')
|
|
173
|
+
happen.click(submit)
|
|
174
|
+
assert.equal(this.datalayer._index.length, 2)
|
|
175
|
+
assert.equal(
|
|
176
|
+
this.datalayer._layers[this.datalayer._index[0]].properties.tourism,
|
|
177
|
+
'information'
|
|
178
|
+
)
|
|
179
|
+
})
|
|
180
|
+
|
|
181
|
+
it('should import kml from textarea', function () {
|
|
182
|
+
this.datalayer.empty()
|
|
183
|
+
happen.click(qs('a.upload-data'))
|
|
184
|
+
textarea = qs('.umap-upload textarea')
|
|
185
|
+
submit = qs('.umap-upload input[type="button"]')
|
|
186
|
+
formatSelect = qs('.umap-upload select[name="format"]')
|
|
187
|
+
assert.equal(this.datalayer._index.length, 0)
|
|
188
|
+
textarea.value = kml_example
|
|
189
|
+
changeSelectValue(formatSelect, 'kml')
|
|
190
|
+
happen.click(submit)
|
|
191
|
+
assert.equal(this.datalayer._index.length, 3)
|
|
192
|
+
})
|
|
193
|
+
|
|
194
|
+
it('should import gpx from textarea', function () {
|
|
195
|
+
this.datalayer.empty()
|
|
196
|
+
happen.click(qs('a.upload-data'))
|
|
197
|
+
textarea = qs('.umap-upload textarea')
|
|
198
|
+
submit = qs('.umap-upload input[type="button"]')
|
|
199
|
+
formatSelect = qs('.umap-upload select[name="format"]')
|
|
200
|
+
assert.equal(this.datalayer._index.length, 0)
|
|
201
|
+
textarea.value = gpx_example
|
|
202
|
+
changeSelectValue(formatSelect, 'gpx')
|
|
203
|
+
happen.click(submit)
|
|
204
|
+
assert.equal(this.datalayer._index.length, 2)
|
|
205
|
+
})
|
|
206
|
+
|
|
207
|
+
it('should import csv from textarea', function () {
|
|
208
|
+
this.datalayer.empty()
|
|
209
|
+
happen.click(qs('a.upload-data'))
|
|
210
|
+
textarea = qs('.umap-upload textarea')
|
|
211
|
+
submit = qs('.umap-upload input[type="button"]')
|
|
212
|
+
formatSelect = qs('.umap-upload select[name="format"]')
|
|
213
|
+
assert.equal(this.datalayer._index.length, 0)
|
|
214
|
+
textarea.value = csv_example
|
|
215
|
+
changeSelectValue(formatSelect, 'csv')
|
|
216
|
+
happen.click(submit)
|
|
217
|
+
assert.equal(this.datalayer._index.length, 1)
|
|
218
|
+
})
|
|
219
|
+
|
|
220
|
+
it('should replace content if asked so', function () {
|
|
221
|
+
happen.click(qs('a.upload-data'))
|
|
222
|
+
textarea = qs('.umap-upload textarea')
|
|
223
|
+
submit = qs('.umap-upload input[type="button"]')
|
|
224
|
+
formatSelect = qs('.umap-upload select[name="format"]')
|
|
225
|
+
clearFlag = qs('.umap-upload input[name="clear"]')
|
|
226
|
+
clearFlag.checked = true
|
|
227
|
+
assert.equal(this.datalayer._index.length, 1)
|
|
228
|
+
textarea.value = csv_example
|
|
229
|
+
changeSelectValue(formatSelect, 'csv')
|
|
230
|
+
happen.click(submit)
|
|
231
|
+
assert.equal(this.datalayer._index.length, 1)
|
|
232
|
+
})
|
|
233
|
+
|
|
234
|
+
it('should import GeometryCollection from textarea', function () {
|
|
235
|
+
this.datalayer.empty()
|
|
236
|
+
textarea.value =
|
|
237
|
+
'{"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
|
+
formatSelect = qs('.umap-upload select[name="format"]')
|
|
239
|
+
changeSelectValue(formatSelect, 'geojson')
|
|
240
|
+
happen.click(submit)
|
|
241
|
+
assert.equal(this.datalayer._index.length, 3)
|
|
242
|
+
})
|
|
243
|
+
|
|
244
|
+
it('should import multipolygon', function () {
|
|
245
|
+
this.datalayer.empty()
|
|
246
|
+
textarea.value =
|
|
247
|
+
'{"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
|
+
changeSelectValue(formatSelect, 'geojson')
|
|
249
|
+
happen.click(submit)
|
|
250
|
+
assert.equal(this.datalayer._index.length, 1)
|
|
251
|
+
var layer = this.datalayer.getFeatureByIndex(0)
|
|
252
|
+
assert.equal(layer._latlngs.length, 2) // Two shapes.
|
|
253
|
+
assert.equal(layer._latlngs[0].length, 2) // Hole.
|
|
254
|
+
})
|
|
255
|
+
|
|
256
|
+
it('should import multipolyline', function () {
|
|
257
|
+
this.datalayer.empty()
|
|
258
|
+
textarea.value =
|
|
259
|
+
'{"type": "FeatureCollection", "features": [{ "type": "Feature", "properties": {}, "geometry": { "type": "MultiLineString", "coordinates": [[[-108, 46], [-113, 43]], [[-112, 45], [-115, 44]]] } }]}'
|
|
260
|
+
changeSelectValue(formatSelect, 'geojson')
|
|
261
|
+
happen.click(submit)
|
|
262
|
+
assert.equal(this.datalayer._index.length, 1)
|
|
263
|
+
var layer = this.datalayer.getFeatureByIndex(0)
|
|
264
|
+
assert.equal(layer._latlngs.length, 2) // Two shapes.
|
|
265
|
+
})
|
|
266
|
+
|
|
267
|
+
it('should import raw umap data from textarea', function () {
|
|
268
|
+
//Right now, the import function will try to save and reload. Stop this from happening.
|
|
269
|
+
var disabledSaveFunction = this.map.save
|
|
270
|
+
this.map.save = function () {}
|
|
271
|
+
happen.click(qs('a.upload-data'))
|
|
272
|
+
var initialLayerCount = Object.keys(this.map.datalayers).length
|
|
273
|
+
formatSelect = qs('.umap-upload select[name="format"]')
|
|
274
|
+
textarea = qs('.umap-upload textarea')
|
|
275
|
+
textarea.value =
|
|
276
|
+
'{ "type": "umap", "geometry": { "type": "Point", "coordinates": [3.0528, 50.6269] }, "properties": { "umap_id": 666, "longCredit": "the illustrious mapmaker", "shortCredit": "the mapmaker", "slideshow": {}, "captionBar": true, "dashArray": "5,5", "fillOpacity": "0.5", "fillColor": "Crimson", "fill": true, "weight": "2", "opacity": "0.9", "smoothFactor": "1", "iconClass": "Drop", "color": "Red", "limitBounds": {}, "tilelayer": { "maxZoom": 18, "url_template": "http://{s}.tile.stamen.com/watercolor/{z}/{x}/{y}.jpg", "minZoom": 0, "attribution": "Map tiles by [[http://stamen.com|Stamen Design]], under [[http://creativecommons.org/licenses/by/3.0|CC BY 3.0]]. Data by [[http://openstreetmap.org|OpenStreetMap]], under [[http://creativecommons.org/licenses/by-sa/3.0|CC BY SA]].", "name": "Watercolor" }, "licence": { "url": "", "name": "No licence set" }, "description": "Map description", "name": "Imported map", "tilelayersControl": true, "onLoadPanel": "caption", "displayPopupFooter": true, "miniMap": true, "moreControl": true, "scaleControl": true, "zoomControl": true, "scrollWheelZoom": true, "datalayersControl": true, "zoom": 6 }, "layers": [{ "type": "FeatureCollection", "features": [{ "type": "Feature", "geometry": { "type": "Polygon", "coordinates": [ [ [4.2939, 50.8893], [4.2441, 50.8196], [4.3869, 50.7642], [4.4813, 50.7929], [4.413, 50.9119], [4.2939, 50.8893] ] ] }, "properties": { "name": "Bruxelles", "description": "polygon" } }, { "type": "Feature", "geometry": { "type": "Point", "coordinates": [3.0528, 50.6269] }, "properties": { "_umap_options": { "color": "Orange" }, "name": "Lille", "description": "une ville" } }], "_umap_options": { "displayOnLoad": true, "name": "Cities", "id": 108, "remoteData": {}, "description": "A layer with some cities", "color": "Navy", "iconClass": "Drop", "smoothFactor": "1", "dashArray": "5,1", "fillOpacity": "0.5", "fillColor": "Blue", "fill": true } }, { "type": "FeatureCollection", "features": [{ "type": "Feature", "geometry": { "type": "LineString", "coordinates": [ [1.7715, 50.9255], [1.6589, 50.9696], [1.4941, 51.0128], [1.4199, 51.0638], [1.2881, 51.1104] ] }, "properties": { "_umap_options": { "weight": "4" }, "name": "tunnel sous la Manche" } }], "_umap_options": { "displayOnLoad": true, "name": "Tunnels", "id": 109, "remoteData": {} } }]}'
|
|
277
|
+
formatSelect.value = 'umap'
|
|
278
|
+
submit = qs('.umap-upload input[type="button"]')
|
|
279
|
+
happen.click(submit)
|
|
280
|
+
assert.equal(Object.keys(this.map.datalayers).length, initialLayerCount + 2)
|
|
281
|
+
assert.equal(this.map.options.name, 'Imported map')
|
|
282
|
+
var foundFirstLayer = false
|
|
283
|
+
var foundSecondLayer = false
|
|
284
|
+
for (var idx in this.map.datalayers) {
|
|
285
|
+
var datalayer = this.map.datalayers[idx]
|
|
286
|
+
if (datalayer.options.name === 'Cities') {
|
|
287
|
+
foundFirstLayer = true
|
|
288
|
+
assert.equal(datalayer._index.length, 2)
|
|
289
|
+
}
|
|
290
|
+
if (datalayer.options.name === 'Tunnels') {
|
|
291
|
+
foundSecondLayer = true
|
|
292
|
+
assert.equal(datalayer._index.length, 1)
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
assert.equal(foundFirstLayer, true)
|
|
296
|
+
assert.equal(foundSecondLayer, true)
|
|
297
|
+
})
|
|
298
|
+
|
|
299
|
+
it('should only import options on the whitelist (umap format import)', function () {
|
|
300
|
+
assert.equal(this.map.options.umap_id, 99)
|
|
301
|
+
})
|
|
302
|
+
|
|
303
|
+
it('should update title bar (umap format import)', function () {
|
|
304
|
+
var title = qs('#map div.umap-main-edit-toolbox button.map-name')
|
|
305
|
+
assert.equal(title.innerHTML, 'Imported map')
|
|
306
|
+
})
|
|
307
|
+
|
|
308
|
+
it('should reinitialize controls (umap format import)', function () {
|
|
309
|
+
var minimap = qs('#map div.leaflet-control-container div.leaflet-control-minimap')
|
|
310
|
+
assert.ok(minimap)
|
|
311
|
+
})
|
|
312
|
+
|
|
313
|
+
it('should update the tilelayer switcher control (umap format import)', function () {
|
|
314
|
+
//The tilelayer in the imported data isn't in the tilelayer list (set in _pre.js), there should be no selection on the tilelayer switcher
|
|
315
|
+
var selectedLayer = qs('.umap-tilelayer-switcher-container li.selected')
|
|
316
|
+
assert.equal(selectedLayer, null)
|
|
317
|
+
})
|
|
318
|
+
|
|
319
|
+
it('should set the tilelayer (umap format import)', function () {
|
|
320
|
+
assert.equal(
|
|
321
|
+
this.map.selected_tilelayer._url,
|
|
322
|
+
'http://{s}.tile.stamen.com/watercolor/{z}/{x}/{y}.jpg'
|
|
323
|
+
)
|
|
324
|
+
})
|
|
325
|
+
})
|
|
326
|
+
|
|
327
|
+
describe('#localizeUrl()', function () {
|
|
328
|
+
it('should replace known variables', function () {
|
|
329
|
+
assert.equal(
|
|
330
|
+
this.map.localizeUrl('http://example.org/{zoom}'),
|
|
331
|
+
'http://example.org/' + this.map.getZoom()
|
|
332
|
+
)
|
|
333
|
+
})
|
|
334
|
+
|
|
335
|
+
it('should keep unknown variables', function () {
|
|
336
|
+
assert.equal(
|
|
337
|
+
this.map.localizeUrl('http://example.org/{unkown}'),
|
|
338
|
+
'http://example.org/{unkown}'
|
|
339
|
+
)
|
|
340
|
+
})
|
|
341
|
+
})
|
|
342
|
+
})
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
describe('L.U.Marker', function () {
|
|
2
|
+
before(function () {
|
|
3
|
+
this.server = sinon.fakeServer.create()
|
|
4
|
+
var datalayer_response = JSON.parse(JSON.stringify(RESPONSES.datalayer62_GET)) // Copy.
|
|
5
|
+
datalayer_response._umap_options.iconClass = 'Drop'
|
|
6
|
+
this.server.respondWith(/\/datalayer\/62\/\?.*/, JSON.stringify(datalayer_response))
|
|
7
|
+
this.map = initMap({ umap_id: 99 })
|
|
8
|
+
this.datalayer = this.map.getDataLayerByUmapId(62)
|
|
9
|
+
this.server.respond()
|
|
10
|
+
})
|
|
11
|
+
after(function () {
|
|
12
|
+
this.server.restore()
|
|
13
|
+
resetMap()
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
describe('#iconClassChange()', function () {
|
|
17
|
+
it('should change icon class', function () {
|
|
18
|
+
enableEdit()
|
|
19
|
+
happen.click(qs('div.umap-drop-icon'))
|
|
20
|
+
happen.click(qs('ul.leaflet-inplace-toolbar a.umap-toggle-edit'))
|
|
21
|
+
changeSelectValue(
|
|
22
|
+
qs(
|
|
23
|
+
'form#umap-feature-shape-properties .umap-field-iconClass select[name=iconClass]'
|
|
24
|
+
),
|
|
25
|
+
'Circle'
|
|
26
|
+
)
|
|
27
|
+
assert.notOk(qs('div.umap-drop-icon'))
|
|
28
|
+
assert.ok(qs('div.umap-circle-icon'))
|
|
29
|
+
happen.click(
|
|
30
|
+
qs('form#umap-feature-shape-properties .umap-field-iconClass .undefine')
|
|
31
|
+
)
|
|
32
|
+
assert.notOk(qs('div.umap-circle-icon'))
|
|
33
|
+
assert.ok(qs('div.umap-drop-icon'))
|
|
34
|
+
clickCancel()
|
|
35
|
+
})
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
describe('#iconSymbolChange()', function () {
|
|
39
|
+
it('should change icon symbol', function () {
|
|
40
|
+
enableEdit()
|
|
41
|
+
happen.click(qs('div.umap-drop-icon'))
|
|
42
|
+
happen.click(qs('ul.leaflet-inplace-toolbar a.umap-toggle-edit'))
|
|
43
|
+
changeInputValue(
|
|
44
|
+
qs(
|
|
45
|
+
'form#umap-feature-shape-properties .umap-field-iconUrl input[name=iconUrl]'
|
|
46
|
+
),
|
|
47
|
+
'1'
|
|
48
|
+
)
|
|
49
|
+
assert.equal(qs('div.umap-drop-icon span').textContent, '1')
|
|
50
|
+
changeInputValue(
|
|
51
|
+
qs(
|
|
52
|
+
'form#umap-feature-shape-properties .umap-field-iconUrl input[name=iconUrl]'
|
|
53
|
+
),
|
|
54
|
+
'{name}'
|
|
55
|
+
)
|
|
56
|
+
assert.equal(qs('div.umap-drop-icon span').textContent, 'test')
|
|
57
|
+
clickCancel()
|
|
58
|
+
})
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
describe('#iconClassChange()', function () {
|
|
62
|
+
it('should change icon class', function () {
|
|
63
|
+
enableEdit()
|
|
64
|
+
happen.click(qs('div.umap-drop-icon'))
|
|
65
|
+
happen.click(qs('ul.leaflet-inplace-toolbar a.umap-toggle-edit'))
|
|
66
|
+
changeSelectValue(
|
|
67
|
+
qs(
|
|
68
|
+
'form#umap-feature-shape-properties .umap-field-iconClass select[name=iconClass]'
|
|
69
|
+
),
|
|
70
|
+
'Circle'
|
|
71
|
+
)
|
|
72
|
+
assert.notOk(qs('div.umap-drop-icon'))
|
|
73
|
+
assert.ok(qs('div.umap-circle-icon'))
|
|
74
|
+
happen.click(
|
|
75
|
+
qs('form#umap-feature-shape-properties .umap-field-iconClass .undefine')
|
|
76
|
+
)
|
|
77
|
+
assert.notOk(qs('div.umap-circle-icon'))
|
|
78
|
+
assert.ok(qs('div.umap-drop-icon'))
|
|
79
|
+
clickCancel()
|
|
80
|
+
})
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
describe('#clone', function () {
|
|
84
|
+
it('should clone marker', function () {
|
|
85
|
+
var layer = new L.U.Marker(this.map, [10, 20], {
|
|
86
|
+
datalayer: this.datalayer,
|
|
87
|
+
}).addTo(this.datalayer)
|
|
88
|
+
assert.equal(this.datalayer._index.length, 4)
|
|
89
|
+
other = layer.clone()
|
|
90
|
+
assert.ok(this.map.hasLayer(other))
|
|
91
|
+
assert.equal(this.datalayer._index.length, 5)
|
|
92
|
+
// Must not be the same reference
|
|
93
|
+
assert.notEqual(layer._latlng, other._latlng)
|
|
94
|
+
assert.equal(L.Util.formatNum(layer._latlng.lat), other._latlng.lat)
|
|
95
|
+
assert.equal(L.Util.formatNum(layer._latlng.lng), other._latlng.lng)
|
|
96
|
+
})
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
describe('#edit()', function (done) {
|
|
100
|
+
it('should allow changing coordinates manually', function () {
|
|
101
|
+
var layer = new L.U.Marker(this.map, [10, 20], {
|
|
102
|
+
datalayer: this.datalayer,
|
|
103
|
+
}).addTo(this.datalayer)
|
|
104
|
+
enableEdit()
|
|
105
|
+
layer.edit()
|
|
106
|
+
changeInputValue(qs('form.umap-form input[name="lat"]'), '54.43')
|
|
107
|
+
assert.equal(layer._latlng.lat, 54.43)
|
|
108
|
+
})
|
|
109
|
+
|
|
110
|
+
it('should not allow invalid latitude nor longitude', function () {
|
|
111
|
+
var layer = new L.U.Marker(this.map, [10, 20], {
|
|
112
|
+
datalayer: this.datalayer,
|
|
113
|
+
}).addTo(this.datalayer)
|
|
114
|
+
enableEdit()
|
|
115
|
+
layer.edit()
|
|
116
|
+
changeInputValue(qs('form.umap-form input[name="lat"]'), '5443')
|
|
117
|
+
assert.equal(layer._latlng.lat, 10)
|
|
118
|
+
changeInputValue(qs('form.umap-form input[name="lng"]'), '5443')
|
|
119
|
+
assert.equal(layer._latlng.lng, 20)
|
|
120
|
+
})
|
|
121
|
+
})
|
|
122
|
+
})
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
describe('L.Permissions', function () {
|
|
2
|
+
var path = '/map/99/datalayer/edit/62/'
|
|
3
|
+
|
|
4
|
+
before(function () {
|
|
5
|
+
this.server = sinon.fakeServer.create()
|
|
6
|
+
this.server.respondWith(
|
|
7
|
+
/\/datalayer\/62\/\?.*/,
|
|
8
|
+
JSON.stringify(RESPONSES.datalayer62_GET)
|
|
9
|
+
)
|
|
10
|
+
this.map = initMap({ umap_id: 99 })
|
|
11
|
+
this.datalayer = this.map.getDataLayerByUmapId(62)
|
|
12
|
+
this.server.respond()
|
|
13
|
+
enableEdit()
|
|
14
|
+
})
|
|
15
|
+
after(function () {
|
|
16
|
+
clickCancel()
|
|
17
|
+
this.server.restore()
|
|
18
|
+
resetMap()
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
describe('#open()', function () {
|
|
22
|
+
var button
|
|
23
|
+
|
|
24
|
+
it('should exist update permissions link', function () {
|
|
25
|
+
button = qs('a.update-map-permissions')
|
|
26
|
+
expect(button).to.be.ok
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
it('should open table button click', function () {
|
|
30
|
+
happen.click(button)
|
|
31
|
+
expect(qs('.permissions-panel')).to.be.ok
|
|
32
|
+
})
|
|
33
|
+
})
|
|
34
|
+
describe('#anonymous with cookie', function () {
|
|
35
|
+
var button
|
|
36
|
+
|
|
37
|
+
it('should not allow share_status nor owner', function () {
|
|
38
|
+
this.map.permissions.options.anonymous_edit_url = 'http://anonymous.url'
|
|
39
|
+
delete this.map.options.permissions.owner
|
|
40
|
+
button = qs('a.update-map-permissions')
|
|
41
|
+
happen.click(button)
|
|
42
|
+
expect(qs('select[name="share_status"]')).not.to.be.ok
|
|
43
|
+
expect(qs('input.edit-owner')).not.to.be.ok
|
|
44
|
+
})
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
describe('#editor', function () {
|
|
48
|
+
var button
|
|
49
|
+
|
|
50
|
+
it('should only allow editors', function () {
|
|
51
|
+
this.map.options.permissions.owner = { id: 1, url: '/url', name: 'jojo' }
|
|
52
|
+
delete this.map.options.permissions.anonymous_edit_url
|
|
53
|
+
delete this.map.options.user
|
|
54
|
+
button = qs('a.update-map-permissions')
|
|
55
|
+
happen.click(button)
|
|
56
|
+
expect(qs('select[name="share_status"]')).not.to.be.ok
|
|
57
|
+
expect(qs('input.edit-owner')).not.to.be.ok
|
|
58
|
+
expect(qs('input.edit-editors')).to.be.ok
|
|
59
|
+
})
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
describe('#owner', function () {
|
|
63
|
+
var button
|
|
64
|
+
|
|
65
|
+
it('should allow everything', function () {
|
|
66
|
+
this.map.permissions.options.owner = { id: 1, url: '/url', name: 'jojo' }
|
|
67
|
+
this.map.options.user = { id: 1, url: '/url', name: 'jojo' }
|
|
68
|
+
button = qs('a.update-map-permissions')
|
|
69
|
+
happen.click(button)
|
|
70
|
+
expect(qs('input.edit-owner')).to.be.ok
|
|
71
|
+
expect(qs('input.edit-editors')).to.be.ok
|
|
72
|
+
})
|
|
73
|
+
})
|
|
74
|
+
})
|