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,382 @@
|
|
|
1
|
+
describe('L.U.FeatureMixin', 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.map = initMap({ umap_id: 99 })
|
|
9
|
+
this.datalayer = this.map.getDataLayerByUmapId(62)
|
|
10
|
+
this.server.respond()
|
|
11
|
+
})
|
|
12
|
+
after(function () {
|
|
13
|
+
this.server.restore()
|
|
14
|
+
resetMap()
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
describe('#edit()', function () {
|
|
18
|
+
var link
|
|
19
|
+
|
|
20
|
+
it('should have datalayer features created', function () {
|
|
21
|
+
assert.equal(
|
|
22
|
+
document.querySelectorAll(
|
|
23
|
+
'#map > .leaflet-map-pane > .leaflet-overlay-pane path.leaflet-interactive'
|
|
24
|
+
).length,
|
|
25
|
+
2
|
|
26
|
+
)
|
|
27
|
+
assert.ok(qs('path[fill="none"]')) // Polyline
|
|
28
|
+
assert.ok(qs('path[fill="DarkBlue"]')) // Polygon
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
it('should toggle edit panel on shift-clic', function () {
|
|
32
|
+
enableEdit()
|
|
33
|
+
happen.click(qs('path[fill="DarkBlue"]'), { shiftKey: true })
|
|
34
|
+
assert.ok(qs('form#umap-feature-properties'))
|
|
35
|
+
assert.ok(qs('#map.umap-ui'))
|
|
36
|
+
happen.click(qs('path[fill="DarkBlue"]'), { shiftKey: true })
|
|
37
|
+
assert.notOk(qs('#map.umap-ui'))
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
it('should open datalayer edit panel on ctrl-shift-clic', function () {
|
|
41
|
+
enableEdit()
|
|
42
|
+
happen.click(qs('path[fill="DarkBlue"]'), { shiftKey: true, ctrlKey: true })
|
|
43
|
+
assert.ok(qs('div.umap-layer-properties-container'))
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
it('should take into account styles changes made in the datalayer', function () {
|
|
47
|
+
happen.click(
|
|
48
|
+
qs('#browse_data_toggle_' + L.stamp(this.datalayer) + ' .layer-edit')
|
|
49
|
+
)
|
|
50
|
+
var colorInput = qs('form#datalayer-advanced-properties input[name=color]')
|
|
51
|
+
changeInputValue(colorInput, 'DarkRed')
|
|
52
|
+
assert.ok(qs('path[fill="none"]')) // Polyline fill is unchanged
|
|
53
|
+
assert.notOk(qs('path[fill="DarkBlue"]'))
|
|
54
|
+
assert.ok(qs('path[fill="DarkRed"]'))
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
it('should open a popup toolbar on feature click', function () {
|
|
58
|
+
enableEdit()
|
|
59
|
+
happen.click(qs('path[fill="DarkRed"]'))
|
|
60
|
+
var toolbar = qs('ul.leaflet-inplace-toolbar')
|
|
61
|
+
assert.ok(toolbar)
|
|
62
|
+
link = qs('a.umap-toggle-edit', toolbar)
|
|
63
|
+
assert.ok(link)
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
it('should open a form on popup toolbar toggle edit click', function () {
|
|
67
|
+
happen.click(link)
|
|
68
|
+
var form = qs('form#umap-feature-properties')
|
|
69
|
+
var input = qs('form#umap-feature-properties input[name="name"]')
|
|
70
|
+
assert.ok(form)
|
|
71
|
+
assert.ok(input)
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
it('should not handle _umap_options has normal property', function () {
|
|
75
|
+
assert.notOk(qs('form#umap-feature-properties input[name="_umap_options"]'))
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
it('should give precedence to feature style over datalayer styles', function () {
|
|
79
|
+
var input = qs('#umap-ui-container form input[name="color"]')
|
|
80
|
+
assert.ok(input)
|
|
81
|
+
changeInputValue(input, 'DarkGreen')
|
|
82
|
+
assert.notOk(qs('path[fill="DarkRed"]'))
|
|
83
|
+
assert.notOk(qs('path[fill="DarkBlue"]'))
|
|
84
|
+
assert.ok(qs('path[fill="DarkGreen"]'))
|
|
85
|
+
assert.ok(qs('path[fill="none"]')) // Polyline fill is unchanged
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
it('should remove stroke if set to no', function () {
|
|
89
|
+
assert.notOk(qs('path[stroke="none"]'))
|
|
90
|
+
var defineButton = qs(
|
|
91
|
+
'#umap-feature-shape-properties .formbox:nth-child(4) .define'
|
|
92
|
+
)
|
|
93
|
+
happen.click(defineButton)
|
|
94
|
+
var input = qs('#umap-feature-shape-properties input[name="stroke"]')
|
|
95
|
+
assert.ok(input)
|
|
96
|
+
input.checked = false
|
|
97
|
+
happen.once(input, { type: 'change' })
|
|
98
|
+
assert.ok(qs('path[stroke="none"]'))
|
|
99
|
+
assert.ok(qs('path[fill="none"]')) // Polyline fill is unchanged
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
it('should not override already set style on features', function () {
|
|
103
|
+
happen.click(
|
|
104
|
+
qs('#browse_data_toggle_' + L.stamp(this.datalayer) + ' .layer-edit')
|
|
105
|
+
)
|
|
106
|
+
changeInputValue(qs('#umap-ui-container form input[name=color]'), 'Chocolate')
|
|
107
|
+
assert.notOk(qs('path[fill="DarkBlue"]'))
|
|
108
|
+
assert.notOk(qs('path[fill="DarkRed"]'))
|
|
109
|
+
assert.notOk(qs('path[fill="Chocolate"]'))
|
|
110
|
+
assert.ok(qs('path[fill="DarkGreen"]'))
|
|
111
|
+
assert.ok(qs('path[fill="none"]')) // Polyline fill is unchanged
|
|
112
|
+
})
|
|
113
|
+
|
|
114
|
+
it('should reset style on cancel click', function () {
|
|
115
|
+
clickCancel()
|
|
116
|
+
assert.ok(qs('path[fill="none"]')) // Polyline fill is unchanged
|
|
117
|
+
assert.ok(qs('path[fill="DarkBlue"]'))
|
|
118
|
+
assert.notOk(qs('path[fill="DarkRed"]'))
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
it('should set map.editedFeature on edit', function () {
|
|
122
|
+
enableEdit()
|
|
123
|
+
assert.notOk(this.map.editedFeature)
|
|
124
|
+
happen.click(qs('path[fill="DarkBlue"]'))
|
|
125
|
+
happen.click(qs('ul.leaflet-inplace-toolbar a.umap-toggle-edit'))
|
|
126
|
+
assert.ok(this.map.editedFeature)
|
|
127
|
+
disableEdit()
|
|
128
|
+
})
|
|
129
|
+
|
|
130
|
+
it('should reset map.editedFeature on panel open', function (done) {
|
|
131
|
+
enableEdit()
|
|
132
|
+
assert.notOk(this.map.editedFeature)
|
|
133
|
+
happen.click(qs('path[fill="DarkBlue"]'))
|
|
134
|
+
happen.click(qs('ul.leaflet-inplace-toolbar a.umap-toggle-edit'))
|
|
135
|
+
assert.ok(this.map.editedFeature)
|
|
136
|
+
this.map.displayCaption()
|
|
137
|
+
window.setTimeout(function () {
|
|
138
|
+
assert.notOk(this.map.editedFeature)
|
|
139
|
+
disableEdit()
|
|
140
|
+
done()
|
|
141
|
+
}, 1001) // CSS transition time.
|
|
142
|
+
})
|
|
143
|
+
})
|
|
144
|
+
|
|
145
|
+
describe('#utils()', function () {
|
|
146
|
+
var poly, marker
|
|
147
|
+
function setFeatures(datalayer) {
|
|
148
|
+
datalayer.eachLayer(function (layer) {
|
|
149
|
+
if (!poly && layer instanceof L.Polygon) {
|
|
150
|
+
poly = layer
|
|
151
|
+
}
|
|
152
|
+
if (!marker && layer instanceof L.Marker) {
|
|
153
|
+
marker = layer
|
|
154
|
+
}
|
|
155
|
+
})
|
|
156
|
+
}
|
|
157
|
+
it('should generate a valid geojson', function () {
|
|
158
|
+
setFeatures(this.datalayer)
|
|
159
|
+
assert.ok(poly)
|
|
160
|
+
assert.deepEqual(poly.toGeoJSON().geometry, {
|
|
161
|
+
type: 'Polygon',
|
|
162
|
+
coordinates: [
|
|
163
|
+
[
|
|
164
|
+
[11.25, 53.585984],
|
|
165
|
+
[10.151367, 52.975108],
|
|
166
|
+
[12.689209, 52.167194],
|
|
167
|
+
[14.084473, 53.199452],
|
|
168
|
+
[12.634277, 53.618579],
|
|
169
|
+
[11.25, 53.585984],
|
|
170
|
+
[11.25, 53.585984],
|
|
171
|
+
],
|
|
172
|
+
],
|
|
173
|
+
})
|
|
174
|
+
// Ensure original latlngs has not been modified
|
|
175
|
+
assert.equal(poly.getLatLngs()[0].length, 6)
|
|
176
|
+
})
|
|
177
|
+
|
|
178
|
+
it('should remove empty _umap_options from exported geojson', function () {
|
|
179
|
+
setFeatures(this.datalayer)
|
|
180
|
+
assert.ok(poly)
|
|
181
|
+
assert.deepEqual(poly.toGeoJSON().properties, { name: 'name poly' })
|
|
182
|
+
assert.ok(marker)
|
|
183
|
+
assert.deepEqual(marker.toGeoJSON().properties, {
|
|
184
|
+
_umap_options: { color: 'OliveDrab' },
|
|
185
|
+
name: 'test',
|
|
186
|
+
})
|
|
187
|
+
})
|
|
188
|
+
})
|
|
189
|
+
|
|
190
|
+
describe('#openPopup()', function () {
|
|
191
|
+
let poly
|
|
192
|
+
before(function () {
|
|
193
|
+
this.datalayer.eachLayer(function (layer) {
|
|
194
|
+
if (!poly && layer instanceof L.Polygon) {
|
|
195
|
+
poly = layer
|
|
196
|
+
}
|
|
197
|
+
})
|
|
198
|
+
})
|
|
199
|
+
|
|
200
|
+
it('should open a popup on click', function () {
|
|
201
|
+
assert.notOk(qs('.leaflet-popup-content'))
|
|
202
|
+
happen.click(qs('path[fill="DarkBlue"]'))
|
|
203
|
+
var title = qs('.leaflet-popup-content')
|
|
204
|
+
assert.ok(title)
|
|
205
|
+
assert.include(title.innerHTML, 'name poly')
|
|
206
|
+
happen.click(qs('#map')) // Close popup
|
|
207
|
+
})
|
|
208
|
+
|
|
209
|
+
it('should handle locale parameter inside description', function (done) {
|
|
210
|
+
poly.properties.description =
|
|
211
|
+
'This is a link to [[https://domain.org/?locale={locale}|Wikipedia]]'
|
|
212
|
+
happen.click(qs('path[fill="DarkBlue"]'))
|
|
213
|
+
window.setTimeout(function () {
|
|
214
|
+
let content = qs('.umap-popup-container')
|
|
215
|
+
assert.ok(content)
|
|
216
|
+
assert.include(
|
|
217
|
+
content.innerHTML,
|
|
218
|
+
'<a href="https://domain.org/?locale=en" target="_blank">Wikipedia</a>'
|
|
219
|
+
)
|
|
220
|
+
happen.click(qs('#map')) // Close popup
|
|
221
|
+
done()
|
|
222
|
+
}, 500) // No idea why needed…
|
|
223
|
+
})
|
|
224
|
+
})
|
|
225
|
+
|
|
226
|
+
describe('#highlight()', function () {
|
|
227
|
+
it('should highlight marker on click', function () {
|
|
228
|
+
assert.notOk(qs('.umap-icon-active'))
|
|
229
|
+
happen.click(qs('div.leaflet-marker-icon'))
|
|
230
|
+
assert.ok(qs('.umap-icon-active'))
|
|
231
|
+
happen.click(qs('#map')) // Close popup
|
|
232
|
+
assert.notOk(qs('.umap-icon-active'))
|
|
233
|
+
})
|
|
234
|
+
|
|
235
|
+
it('should still highlight marker after hide() and show()', function () {
|
|
236
|
+
this.datalayer.hide()
|
|
237
|
+
this.datalayer.show()
|
|
238
|
+
happen.click(qs('div.leaflet-marker-icon'))
|
|
239
|
+
assert.ok(qs('.umap-icon-active'))
|
|
240
|
+
})
|
|
241
|
+
|
|
242
|
+
it('should highlight path', function () {
|
|
243
|
+
happen.click(qs('path[stroke-opacity="0.6"]'))
|
|
244
|
+
var path = qs('path[stroke-opacity="1"]')
|
|
245
|
+
assert.ok(path)
|
|
246
|
+
})
|
|
247
|
+
|
|
248
|
+
it('should highlight polygon', function () {
|
|
249
|
+
var path = qs('path[fill="DarkBlue"]')
|
|
250
|
+
happen.click(path)
|
|
251
|
+
assert.isAbove(path.attributes['fill-opacity'].value, 0.5)
|
|
252
|
+
})
|
|
253
|
+
})
|
|
254
|
+
|
|
255
|
+
describe('#tooltip', function () {
|
|
256
|
+
it('should have a tooltip when active and allow variables', function () {
|
|
257
|
+
this.map.options.showLabel = true
|
|
258
|
+
this.map.options.labelKey = 'Foo {name}'
|
|
259
|
+
this.datalayer.redraw()
|
|
260
|
+
assert.equal(
|
|
261
|
+
qs('.leaflet-tooltip-pane .leaflet-tooltip').textContent,
|
|
262
|
+
'Foo name poly'
|
|
263
|
+
)
|
|
264
|
+
})
|
|
265
|
+
})
|
|
266
|
+
|
|
267
|
+
describe('#properties()', function () {
|
|
268
|
+
it('should rename property', function () {
|
|
269
|
+
var poly = this.datalayer._lineToLayer({}, [
|
|
270
|
+
[0, 0],
|
|
271
|
+
[0, 1],
|
|
272
|
+
[0, 2],
|
|
273
|
+
])
|
|
274
|
+
poly.properties.prop1 = 'xxx'
|
|
275
|
+
poly.renameProperty('prop1', 'prop2')
|
|
276
|
+
assert.equal(poly.properties.prop2, 'xxx')
|
|
277
|
+
assert.ok(typeof poly.properties.prop1 === 'undefined')
|
|
278
|
+
})
|
|
279
|
+
|
|
280
|
+
it('should not create property when renaming', function () {
|
|
281
|
+
var poly = this.datalayer._lineToLayer({}, [
|
|
282
|
+
[0, 0],
|
|
283
|
+
[0, 1],
|
|
284
|
+
[0, 2],
|
|
285
|
+
])
|
|
286
|
+
delete poly.properties.prop2 // Make sure it doesn't exist
|
|
287
|
+
poly.renameProperty('prop1', 'prop2')
|
|
288
|
+
assert.ok(typeof poly.properties.prop2 === 'undefined')
|
|
289
|
+
})
|
|
290
|
+
|
|
291
|
+
it('should delete property', function () {
|
|
292
|
+
var poly = this.datalayer._lineToLayer({}, [
|
|
293
|
+
[0, 0],
|
|
294
|
+
[0, 1],
|
|
295
|
+
[0, 2],
|
|
296
|
+
])
|
|
297
|
+
poly.properties.prop = 'xxx'
|
|
298
|
+
assert.equal(poly.properties.prop, 'xxx')
|
|
299
|
+
poly.deleteProperty('prop')
|
|
300
|
+
assert.ok(typeof poly.properties.prop === 'undefined')
|
|
301
|
+
})
|
|
302
|
+
})
|
|
303
|
+
|
|
304
|
+
describe('#matchFilter()', function () {
|
|
305
|
+
var poly
|
|
306
|
+
|
|
307
|
+
it('should filter on properties', function () {
|
|
308
|
+
poly = this.datalayer._lineToLayer({}, [
|
|
309
|
+
[0, 0],
|
|
310
|
+
[0, 1],
|
|
311
|
+
[0, 2],
|
|
312
|
+
])
|
|
313
|
+
poly.properties.name = 'mooring'
|
|
314
|
+
assert.ok(poly.matchFilter('moo', ['name']))
|
|
315
|
+
assert.notOk(poly.matchFilter('foo', ['name']))
|
|
316
|
+
})
|
|
317
|
+
|
|
318
|
+
it('should be case unsensitive', function () {
|
|
319
|
+
assert.ok(poly.matchFilter('Moo', ['name']))
|
|
320
|
+
})
|
|
321
|
+
|
|
322
|
+
it('should match also in the middle of a string', function () {
|
|
323
|
+
assert.ok(poly.matchFilter('oor', ['name']))
|
|
324
|
+
})
|
|
325
|
+
|
|
326
|
+
it('should handle multiproperties', function () {
|
|
327
|
+
poly.properties.city = 'Teulada'
|
|
328
|
+
assert.ok(poly.matchFilter('eul', ['name', 'city', 'foo']))
|
|
329
|
+
})
|
|
330
|
+
})
|
|
331
|
+
|
|
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
|
+
describe('#changeDataLayer()', function () {
|
|
362
|
+
it('should change style on datalayer select change', function () {
|
|
363
|
+
enableEdit()
|
|
364
|
+
happen.click(qs('.manage-datalayers'))
|
|
365
|
+
happen.click(qs('#umap-ui-container .add-datalayer'))
|
|
366
|
+
changeInputValue(qs('form.umap-form input[name="name"]'), 'New layer')
|
|
367
|
+
changeInputValue(
|
|
368
|
+
qs('form#datalayer-advanced-properties input[name=color]'),
|
|
369
|
+
'MediumAquaMarine'
|
|
370
|
+
)
|
|
371
|
+
happen.click(qs('path[fill="DarkBlue"]'))
|
|
372
|
+
happen.click(qs('ul.leaflet-inplace-toolbar a.umap-toggle-edit'))
|
|
373
|
+
var select = qs('select[name=datalayer]')
|
|
374
|
+
select.selectedIndex = 0
|
|
375
|
+
happen.once(select, { type: 'change' })
|
|
376
|
+
assert.ok(qs('path[fill="none"]')) // Polyline fill is unchanged
|
|
377
|
+
assert.notOk(qs('path[fill="DarkBlue"]'))
|
|
378
|
+
assert.ok(qs('path[fill="MediumAquaMarine"]'))
|
|
379
|
+
clickCancel()
|
|
380
|
+
})
|
|
381
|
+
})
|
|
382
|
+
})
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
describe('L.U.Map.Export', 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('#formatters()', function () {
|
|
22
|
+
it('should export to geojson', function () {
|
|
23
|
+
const { content, filetype, filename } = this.map.share.format('geojson')
|
|
24
|
+
assert.equal(filetype, 'application/json')
|
|
25
|
+
assert.equal(filename, 'name_of_the_map.geojson')
|
|
26
|
+
assert.deepEqual(JSON.parse(content), {
|
|
27
|
+
type: 'FeatureCollection',
|
|
28
|
+
features: [
|
|
29
|
+
{
|
|
30
|
+
type: 'Feature',
|
|
31
|
+
properties: {
|
|
32
|
+
name: 'name poly',
|
|
33
|
+
},
|
|
34
|
+
geometry: {
|
|
35
|
+
type: 'Polygon',
|
|
36
|
+
coordinates: [
|
|
37
|
+
[
|
|
38
|
+
[11.25, 53.585984],
|
|
39
|
+
[10.151367, 52.975108],
|
|
40
|
+
[12.689209, 52.167194],
|
|
41
|
+
[14.084473, 53.199452],
|
|
42
|
+
[12.634277, 53.618579],
|
|
43
|
+
[11.25, 53.585984],
|
|
44
|
+
[11.25, 53.585984],
|
|
45
|
+
],
|
|
46
|
+
],
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
type: 'Feature',
|
|
51
|
+
properties: {
|
|
52
|
+
_umap_options: {
|
|
53
|
+
color: 'OliveDrab',
|
|
54
|
+
},
|
|
55
|
+
name: 'test',
|
|
56
|
+
},
|
|
57
|
+
geometry: {
|
|
58
|
+
type: 'Point',
|
|
59
|
+
coordinates: [-0.274658, 52.57635],
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
type: 'Feature',
|
|
64
|
+
properties: {
|
|
65
|
+
_umap_options: {
|
|
66
|
+
fill: false,
|
|
67
|
+
opacity: 0.6,
|
|
68
|
+
},
|
|
69
|
+
name: 'test',
|
|
70
|
+
},
|
|
71
|
+
geometry: {
|
|
72
|
+
type: 'LineString',
|
|
73
|
+
coordinates: [
|
|
74
|
+
[-0.571289, 54.476422],
|
|
75
|
+
[0.439453, 54.610255],
|
|
76
|
+
[1.724854, 53.448807],
|
|
77
|
+
[4.163818, 53.988395],
|
|
78
|
+
[5.306396, 53.533778],
|
|
79
|
+
[6.591797, 53.709714],
|
|
80
|
+
[7.042236, 53.350551],
|
|
81
|
+
],
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
],
|
|
85
|
+
})
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
it('should export to gpx', function () {
|
|
89
|
+
const { content, filetype, filename } = this.map.share.format('gpx')
|
|
90
|
+
assert.equal(filetype, 'application/gpx+xml')
|
|
91
|
+
assert.equal(filename, 'name_of_the_map.gpx')
|
|
92
|
+
const expected =
|
|
93
|
+
'<gpx xmlns="http://www.topografix.com/GPX/1/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd" version="1.1" creator="togpx"><metadata/><wpt lat="52.57635" lon="-0.274658"><name>test</name><desc>name=test</desc></wpt><trk><name>name poly</name><desc>name=name poly</desc><trkseg><trkpt lat="53.585984" lon="11.25"/><trkpt lat="52.975108" lon="10.151367"/><trkpt lat="52.167194" lon="12.689209"/><trkpt lat="53.199452" lon="14.084473"/><trkpt lat="53.618579" lon="12.634277"/><trkpt lat="53.585984" lon="11.25"/><trkpt lat="53.585984" lon="11.25"/></trkseg></trk><trk><name>test</name><desc>name=test</desc><trkseg><trkpt lat="54.476422" lon="-0.571289"/><trkpt lat="54.610255" lon="0.439453"/><trkpt lat="53.448807" lon="1.724854"/><trkpt lat="53.988395" lon="4.163818"/><trkpt lat="53.533778" lon="5.306396"/><trkpt lat="53.709714" lon="6.591797"/><trkpt lat="53.350551" lon="7.042236"/></trkseg></trk></gpx>'
|
|
94
|
+
assert.equal(content, expected)
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
it('should export to kml', function () {
|
|
98
|
+
const { content, filetype, filename } = this.map.share.format('kml')
|
|
99
|
+
assert.equal(filetype, 'application/vnd.google-earth.kml+xml')
|
|
100
|
+
assert.equal(filename, 'name_of_the_map.kml')
|
|
101
|
+
const expected =
|
|
102
|
+
'<?xml version="1.0" encoding="UTF-8"?><kml xmlns="http://www.opengis.net/kml/2.2"><Document><Placemark><name>name poly</name><ExtendedData><Data name="name"><value>name poly</value></Data></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>11.25,53.585984 10.151367,52.975108 12.689209,52.167194 14.084473,53.199452 12.634277,53.618579 11.25,53.585984 11.25,53.585984</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark><name>test</name><ExtendedData><Data name="_umap_options"><value>[object Object]</value></Data><Data name="name"><value>test</value></Data></ExtendedData><Point><coordinates>-0.274658,52.57635</coordinates></Point></Placemark><Placemark><name>test</name><ExtendedData><Data name="_umap_options"><value>[object Object]</value></Data><Data name="name"><value>test</value></Data></ExtendedData><LineString><coordinates>-0.571289,54.476422 0.439453,54.610255 1.724854,53.448807 4.163818,53.988395 5.306396,53.533778 6.591797,53.709714 7.042236,53.350551</coordinates></LineString></Placemark></Document></kml>'
|
|
103
|
+
assert.equal(content, expected)
|
|
104
|
+
})
|
|
105
|
+
})
|
|
106
|
+
})
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
describe('L.U.Map.initialize', function () {
|
|
2
|
+
afterEach(function () {
|
|
3
|
+
resetMap()
|
|
4
|
+
})
|
|
5
|
+
|
|
6
|
+
describe('Controls', function () {
|
|
7
|
+
it('should not show a minimap by default', function () {
|
|
8
|
+
this.map = initMap()
|
|
9
|
+
assert.notOk(qs('.leaflet-control-minimap'))
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
it('should show a minimap', function () {
|
|
13
|
+
this.map = initMap({ miniMap: true })
|
|
14
|
+
assert.ok(qs('.leaflet-control-minimap'))
|
|
15
|
+
})
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
describe('DefaultView', function () {
|
|
19
|
+
it('should set default view in default mode without data', function (done) {
|
|
20
|
+
this.map = initMap({ datalayers: [] })
|
|
21
|
+
// Did not find a better way to wait for tiles to be actually loaded
|
|
22
|
+
window.setTimeout(() => {
|
|
23
|
+
assert.ok(qs('#map .leaflet-tile-pane img.leaflet-tile.leaflet-tile-loaded'))
|
|
24
|
+
done()
|
|
25
|
+
}, 1000)
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
it("should set default view in 'data' mode without data", function (done) {
|
|
29
|
+
this.map = initMap({ datalayers: [], defaultView: 'data' })
|
|
30
|
+
// Did not find a better way to wait for tiles to be actually loaded
|
|
31
|
+
window.setTimeout(() => {
|
|
32
|
+
assert.ok(qs('#map .leaflet-tile-pane img.leaflet-tile.leaflet-tile-loaded'))
|
|
33
|
+
done()
|
|
34
|
+
}, 1000)
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
it("should set default view in 'latest' mode without data", function (done) {
|
|
38
|
+
this.map = initMap({ datalayers: [], defaultView: 'latest' })
|
|
39
|
+
// Did not find a better way to wait for tiles to be actually loaded
|
|
40
|
+
window.setTimeout(() => {
|
|
41
|
+
assert.ok(qs('#map .leaflet-tile-pane img.leaflet-tile.leaflet-tile-loaded'))
|
|
42
|
+
done()
|
|
43
|
+
}, 1000)
|
|
44
|
+
})
|
|
45
|
+
})
|
|
46
|
+
})
|