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,402 @@
|
|
|
1
|
+
describe('L.U.Polyline', function () {
|
|
2
|
+
var p2ll, map
|
|
3
|
+
|
|
4
|
+
before(function () {
|
|
5
|
+
this.map = map = initMap({ umap_id: 99 })
|
|
6
|
+
enableEdit()
|
|
7
|
+
p2ll = function (x, y) {
|
|
8
|
+
return map.containerPointToLatLng([x, y])
|
|
9
|
+
}
|
|
10
|
+
this.datalayer = this.map.createDataLayer()
|
|
11
|
+
this.datalayer.connectToMap()
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
after(function () {
|
|
15
|
+
clickCancel()
|
|
16
|
+
resetMap()
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
afterEach(function () {
|
|
20
|
+
this.datalayer.empty()
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
describe('#isMulti()', function () {
|
|
24
|
+
it('should return false for basic Polyline', function () {
|
|
25
|
+
var layer = new L.U.Polyline(
|
|
26
|
+
this.map,
|
|
27
|
+
[
|
|
28
|
+
[1, 2],
|
|
29
|
+
[3, 4],
|
|
30
|
+
[5, 6],
|
|
31
|
+
],
|
|
32
|
+
{ datalayer: this.datalayer }
|
|
33
|
+
)
|
|
34
|
+
assert.notOk(layer.isMulti())
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
it('should return false for nested basic Polyline', function () {
|
|
38
|
+
var layer = new L.U.Polyline(
|
|
39
|
+
this.map,
|
|
40
|
+
[
|
|
41
|
+
[
|
|
42
|
+
[1, 2],
|
|
43
|
+
[3, 4],
|
|
44
|
+
[5, 6],
|
|
45
|
+
],
|
|
46
|
+
],
|
|
47
|
+
{ datalayer: this.datalayer }
|
|
48
|
+
)
|
|
49
|
+
assert.notOk(layer.isMulti())
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
it('should return true for multi Polyline', function () {
|
|
53
|
+
var latLngs = [
|
|
54
|
+
[
|
|
55
|
+
[
|
|
56
|
+
[1, 2],
|
|
57
|
+
[3, 4],
|
|
58
|
+
[5, 6],
|
|
59
|
+
],
|
|
60
|
+
],
|
|
61
|
+
[
|
|
62
|
+
[
|
|
63
|
+
[7, 8],
|
|
64
|
+
[9, 10],
|
|
65
|
+
[11, 12],
|
|
66
|
+
],
|
|
67
|
+
],
|
|
68
|
+
]
|
|
69
|
+
var layer = new L.U.Polyline(this.map, latLngs, { datalayer: this.datalayer })
|
|
70
|
+
assert.ok(layer.isMulti())
|
|
71
|
+
})
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
describe('#contextmenu', function () {
|
|
75
|
+
afterEach(function () {
|
|
76
|
+
// Make sure contextmenu is hidden.
|
|
77
|
+
happen.once(document, { type: 'keydown', keyCode: 27 })
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
describe('#in edit mode', function () {
|
|
81
|
+
it('should allow to remove shape when multi', function () {
|
|
82
|
+
var latlngs = [
|
|
83
|
+
[p2ll(100, 100), p2ll(100, 200)],
|
|
84
|
+
[p2ll(300, 350), p2ll(350, 400), p2ll(400, 300)],
|
|
85
|
+
],
|
|
86
|
+
layer = new L.U.Polyline(this.map, latlngs, {
|
|
87
|
+
datalayer: this.datalayer,
|
|
88
|
+
}).addTo(this.datalayer)
|
|
89
|
+
happen.once(layer._path, { type: 'contextmenu' })
|
|
90
|
+
assert.equal(qst('Remove shape from the multi'), 1)
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
it('should not allow to remove shape when not multi', function () {
|
|
94
|
+
var latlngs = [[p2ll(100, 100), p2ll(100, 200)]],
|
|
95
|
+
layer = new L.U.Polyline(this.map, latlngs, {
|
|
96
|
+
datalayer: this.datalayer,
|
|
97
|
+
}).addTo(this.datalayer)
|
|
98
|
+
happen.once(layer._path, { type: 'contextmenu' })
|
|
99
|
+
assert.notOk(qst('Remove shape from the multi'))
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
it('should not allow to isolate shape when not multi', function () {
|
|
103
|
+
var latlngs = [[p2ll(100, 100), p2ll(100, 200)]],
|
|
104
|
+
layer = new L.U.Polyline(this.map, latlngs, {
|
|
105
|
+
datalayer: this.datalayer,
|
|
106
|
+
}).addTo(this.datalayer)
|
|
107
|
+
happen.once(layer._path, { type: 'contextmenu' })
|
|
108
|
+
assert.notOk(qst('Extract shape to separate feature'))
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
it('should allow to isolate shape when multi', function () {
|
|
112
|
+
var latlngs = [
|
|
113
|
+
[p2ll(100, 150), p2ll(100, 200)],
|
|
114
|
+
[p2ll(300, 350), p2ll(350, 400), p2ll(400, 300)],
|
|
115
|
+
],
|
|
116
|
+
layer = new L.U.Polyline(this.map, latlngs, {
|
|
117
|
+
datalayer: this.datalayer,
|
|
118
|
+
}).addTo(this.datalayer)
|
|
119
|
+
happen.once(layer._path, { type: 'contextmenu' })
|
|
120
|
+
assert.ok(qst('Extract shape to separate feature'))
|
|
121
|
+
})
|
|
122
|
+
|
|
123
|
+
it('should not allow to transform to polygon when multi', function () {
|
|
124
|
+
var latlngs = [
|
|
125
|
+
[p2ll(100, 150), p2ll(100, 200)],
|
|
126
|
+
[p2ll(300, 350), p2ll(350, 400), p2ll(400, 300)],
|
|
127
|
+
],
|
|
128
|
+
layer = new L.U.Polyline(this.map, latlngs, {
|
|
129
|
+
datalayer: this.datalayer,
|
|
130
|
+
}).addTo(this.datalayer)
|
|
131
|
+
happen.once(layer._path, { type: 'contextmenu' })
|
|
132
|
+
assert.notOk(qst('Transform to polygon'))
|
|
133
|
+
})
|
|
134
|
+
|
|
135
|
+
it('should allow to transform to polygon when not multi', function () {
|
|
136
|
+
var latlngs = [p2ll(100, 150), p2ll(100, 200), p2ll(200, 100)],
|
|
137
|
+
layer = new L.U.Polyline(this.map, latlngs, {
|
|
138
|
+
datalayer: this.datalayer,
|
|
139
|
+
}).addTo(this.datalayer)
|
|
140
|
+
happen.once(layer._path, { type: 'contextmenu' })
|
|
141
|
+
assert.equal(qst('Transform to polygon'), 1)
|
|
142
|
+
})
|
|
143
|
+
|
|
144
|
+
it('should not allow to transfer shape when not editedFeature', function () {
|
|
145
|
+
var layer = new L.U.Polyline(this.map, [p2ll(100, 150), p2ll(100, 200)], {
|
|
146
|
+
datalayer: this.datalayer,
|
|
147
|
+
}).addTo(this.datalayer)
|
|
148
|
+
happen.once(layer._path, { type: 'contextmenu' })
|
|
149
|
+
assert.notOk(qst('Transfer shape to edited feature'))
|
|
150
|
+
})
|
|
151
|
+
|
|
152
|
+
it('should not allow to transfer shape when editedFeature is not a line', function () {
|
|
153
|
+
var layer = new L.U.Polyline(this.map, [p2ll(100, 150), p2ll(100, 200)], {
|
|
154
|
+
datalayer: this.datalayer,
|
|
155
|
+
}).addTo(this.datalayer),
|
|
156
|
+
other = new L.U.Polygon(
|
|
157
|
+
this.map,
|
|
158
|
+
[p2ll(200, 300), p2ll(300, 200), p2ll(200, 100)],
|
|
159
|
+
{ datalayer: this.datalayer }
|
|
160
|
+
).addTo(this.datalayer)
|
|
161
|
+
other.edit()
|
|
162
|
+
happen.once(layer._path, { type: 'contextmenu' })
|
|
163
|
+
assert.notOk(qst('Transfer shape to edited feature'))
|
|
164
|
+
})
|
|
165
|
+
|
|
166
|
+
it('should allow to transfer shape when another line is edited', function () {
|
|
167
|
+
var layer = new L.U.Polyline(
|
|
168
|
+
this.map,
|
|
169
|
+
[p2ll(100, 150), p2ll(100, 200), p2ll(200, 100)],
|
|
170
|
+
{ datalayer: this.datalayer }
|
|
171
|
+
).addTo(this.datalayer),
|
|
172
|
+
other = new L.U.Polyline(this.map, [p2ll(200, 300), p2ll(300, 200)], {
|
|
173
|
+
datalayer: this.datalayer,
|
|
174
|
+
}).addTo(this.datalayer)
|
|
175
|
+
other.edit()
|
|
176
|
+
happen.once(layer._path, { type: 'contextmenu' })
|
|
177
|
+
assert.equal(qst('Transfer shape to edited feature'), 1)
|
|
178
|
+
other.remove()
|
|
179
|
+
layer.remove()
|
|
180
|
+
})
|
|
181
|
+
|
|
182
|
+
it('should allow to merge lines when multi', function () {
|
|
183
|
+
var latlngs = [
|
|
184
|
+
[p2ll(100, 100), p2ll(100, 200)],
|
|
185
|
+
[p2ll(300, 350), p2ll(350, 400), p2ll(400, 300)],
|
|
186
|
+
],
|
|
187
|
+
layer = new L.U.Polyline(this.map, latlngs, {
|
|
188
|
+
datalayer: this.datalayer,
|
|
189
|
+
}).addTo(this.datalayer)
|
|
190
|
+
happen.once(layer._path, { type: 'contextmenu' })
|
|
191
|
+
assert.equal(qst('Merge lines'), 1)
|
|
192
|
+
})
|
|
193
|
+
|
|
194
|
+
it('should not allow to merge lines when not multi', function () {
|
|
195
|
+
var latlngs = [[p2ll(100, 100), p2ll(100, 200)]],
|
|
196
|
+
layer = new L.U.Polyline(this.map, latlngs, {
|
|
197
|
+
datalayer: this.datalayer,
|
|
198
|
+
}).addTo(this.datalayer)
|
|
199
|
+
happen.once(layer._path, { type: 'contextmenu' })
|
|
200
|
+
assert.notOk(qst('Merge lines'))
|
|
201
|
+
})
|
|
202
|
+
|
|
203
|
+
it('should allow to split lines when clicking on vertex', function () {
|
|
204
|
+
var latlngs = [[p2ll(300, 350), p2ll(350, 400), p2ll(400, 300)]],
|
|
205
|
+
layer = new L.U.Polyline(this.map, latlngs, {
|
|
206
|
+
datalayer: this.datalayer,
|
|
207
|
+
}).addTo(this.datalayer)
|
|
208
|
+
layer.enableEdit()
|
|
209
|
+
happen.at('contextmenu', 350, 400)
|
|
210
|
+
assert.equal(qst('Split line'), 1)
|
|
211
|
+
})
|
|
212
|
+
|
|
213
|
+
it('should not allow to split lines when clicking on first vertex', function () {
|
|
214
|
+
var latlngs = [[p2ll(300, 350), p2ll(350, 400), p2ll(400, 300)]],
|
|
215
|
+
layer = new L.U.Polyline(this.map, latlngs, {
|
|
216
|
+
datalayer: this.datalayer,
|
|
217
|
+
}).addTo(this.datalayer)
|
|
218
|
+
layer.enableEdit()
|
|
219
|
+
happen.at('contextmenu', 300, 350)
|
|
220
|
+
assert.equal(qst('Delete this feature'), 1) // Make sure we have clicked on the vertex.
|
|
221
|
+
assert.notOk(qst('Split line'))
|
|
222
|
+
})
|
|
223
|
+
|
|
224
|
+
it('should not allow to split lines when clicking on last vertex', function () {
|
|
225
|
+
var latlngs = [[p2ll(300, 350), p2ll(350, 400), p2ll(400, 300)]],
|
|
226
|
+
layer = new L.U.Polyline(this.map, latlngs, {
|
|
227
|
+
datalayer: this.datalayer,
|
|
228
|
+
}).addTo(this.datalayer)
|
|
229
|
+
layer.enableEdit()
|
|
230
|
+
happen.at('contextmenu', 400, 300)
|
|
231
|
+
assert.equal(qst('Delete this feature'), 1) // Make sure we have clicked on the vertex.
|
|
232
|
+
assert.notOk(qst('Split line'))
|
|
233
|
+
})
|
|
234
|
+
})
|
|
235
|
+
})
|
|
236
|
+
|
|
237
|
+
describe('#addShape', function () {
|
|
238
|
+
it('"add shape" control should not be visible by default', function () {
|
|
239
|
+
assert.notOk(qs('.umap-draw-polyline-multi'))
|
|
240
|
+
})
|
|
241
|
+
|
|
242
|
+
it('"add shape" control should be visible when editing a Polyline', function () {
|
|
243
|
+
var layer = new L.U.Polyline(this.map, [p2ll(100, 100), p2ll(100, 200)], {
|
|
244
|
+
datalayer: this.datalayer,
|
|
245
|
+
}).addTo(this.datalayer)
|
|
246
|
+
layer.edit()
|
|
247
|
+
assert.ok(qs('.umap-draw-polyline-multi'))
|
|
248
|
+
})
|
|
249
|
+
|
|
250
|
+
it('"add shape" control should extend the same multi', function () {
|
|
251
|
+
var layer = new L.U.Polyline(this.map, [p2ll(100, 100), p2ll(100, 200)], {
|
|
252
|
+
datalayer: this.datalayer,
|
|
253
|
+
}).addTo(this.datalayer)
|
|
254
|
+
layer.edit()
|
|
255
|
+
assert.notOk(layer.isMulti())
|
|
256
|
+
happen.click(qs('.umap-draw-polyline-multi'))
|
|
257
|
+
happen.at('mousemove', 300, 300)
|
|
258
|
+
happen.at('click', 300, 300)
|
|
259
|
+
happen.at('mousemove', 350, 300)
|
|
260
|
+
happen.at('click', 350, 300)
|
|
261
|
+
happen.at('click', 350, 300)
|
|
262
|
+
assert.ok(layer.isMulti())
|
|
263
|
+
assert.equal(this.datalayer._index.length, 1)
|
|
264
|
+
})
|
|
265
|
+
})
|
|
266
|
+
|
|
267
|
+
describe('#transferShape', function () {
|
|
268
|
+
it('should transfer simple line shape to another line', function () {
|
|
269
|
+
var latlngs = [p2ll(100, 150), p2ll(100, 200), p2ll(200, 100)],
|
|
270
|
+
layer = new L.U.Polyline(this.map, latlngs, {
|
|
271
|
+
datalayer: this.datalayer,
|
|
272
|
+
}).addTo(this.datalayer),
|
|
273
|
+
other = new L.U.Polyline(this.map, [p2ll(200, 300), p2ll(300, 200)], {
|
|
274
|
+
datalayer: this.datalayer,
|
|
275
|
+
}).addTo(this.datalayer)
|
|
276
|
+
assert.ok(this.map.hasLayer(layer))
|
|
277
|
+
layer.transferShape(p2ll(150, 150), other)
|
|
278
|
+
assert.equal(other._latlngs.length, 2)
|
|
279
|
+
assert.deepEqual(other._latlngs[1], latlngs)
|
|
280
|
+
assert.notOk(this.map.hasLayer(layer))
|
|
281
|
+
})
|
|
282
|
+
|
|
283
|
+
it('should transfer multi line shape to another line', function () {
|
|
284
|
+
var latlngs = [
|
|
285
|
+
[p2ll(100, 150), p2ll(100, 200), p2ll(200, 100)],
|
|
286
|
+
[p2ll(200, 300), p2ll(300, 200)],
|
|
287
|
+
],
|
|
288
|
+
layer = new L.U.Polyline(this.map, latlngs, {
|
|
289
|
+
datalayer: this.datalayer,
|
|
290
|
+
}).addTo(this.datalayer),
|
|
291
|
+
other = new L.U.Polyline(this.map, [p2ll(250, 300), p2ll(350, 200)], {
|
|
292
|
+
datalayer: this.datalayer,
|
|
293
|
+
}).addTo(this.datalayer)
|
|
294
|
+
assert.ok(this.map.hasLayer(layer))
|
|
295
|
+
layer.transferShape(p2ll(150, 150), other)
|
|
296
|
+
assert.equal(other._latlngs.length, 2)
|
|
297
|
+
assert.deepEqual(other._latlngs[1], latlngs[0])
|
|
298
|
+
assert.ok(this.map.hasLayer(layer))
|
|
299
|
+
assert.equal(layer._latlngs.length, 1)
|
|
300
|
+
})
|
|
301
|
+
})
|
|
302
|
+
|
|
303
|
+
describe('#mergeShapes', function () {
|
|
304
|
+
it('should remove duplicated join point when merging', function () {
|
|
305
|
+
var latlngs = [
|
|
306
|
+
[
|
|
307
|
+
[0, 0],
|
|
308
|
+
[0, 1],
|
|
309
|
+
],
|
|
310
|
+
[
|
|
311
|
+
[0, 1],
|
|
312
|
+
[0, 2],
|
|
313
|
+
],
|
|
314
|
+
],
|
|
315
|
+
layer = new L.U.Polyline(this.map, latlngs, {
|
|
316
|
+
datalayer: this.datalayer,
|
|
317
|
+
}).addTo(this.datalayer)
|
|
318
|
+
layer.mergeShapes()
|
|
319
|
+
layer.disableEdit() // Remove vertex from latlngs to compare them.
|
|
320
|
+
assert.deepEqual(layer.getLatLngs(), [
|
|
321
|
+
L.latLng([0, 0]),
|
|
322
|
+
L.latLng([0, 1]),
|
|
323
|
+
L.latLng([0, 2]),
|
|
324
|
+
])
|
|
325
|
+
assert(this.map.isDirty)
|
|
326
|
+
})
|
|
327
|
+
|
|
328
|
+
it('should revert candidate if first point is closer', function () {
|
|
329
|
+
var latlngs = [
|
|
330
|
+
[
|
|
331
|
+
[0, 0],
|
|
332
|
+
[0, 1],
|
|
333
|
+
],
|
|
334
|
+
[
|
|
335
|
+
[0, 2],
|
|
336
|
+
[0, 1],
|
|
337
|
+
],
|
|
338
|
+
],
|
|
339
|
+
layer = new L.U.Polyline(this.map, latlngs, {
|
|
340
|
+
datalayer: this.datalayer,
|
|
341
|
+
}).addTo(this.datalayer)
|
|
342
|
+
layer.mergeShapes()
|
|
343
|
+
layer.disableEdit()
|
|
344
|
+
assert.deepEqual(layer.getLatLngs(), [
|
|
345
|
+
L.latLng([0, 0]),
|
|
346
|
+
L.latLng([0, 1]),
|
|
347
|
+
L.latLng([0, 2]),
|
|
348
|
+
])
|
|
349
|
+
})
|
|
350
|
+
})
|
|
351
|
+
|
|
352
|
+
describe('#isolateShape', function () {
|
|
353
|
+
it('should not allow to isolate simple line', function () {
|
|
354
|
+
var latlngs = [p2ll(100, 150), p2ll(100, 200), p2ll(200, 100)],
|
|
355
|
+
layer = new L.U.Polyline(this.map, latlngs, {
|
|
356
|
+
datalayer: this.datalayer,
|
|
357
|
+
}).addTo(this.datalayer)
|
|
358
|
+
assert.equal(this.datalayer._index.length, 1)
|
|
359
|
+
assert.ok(this.map.hasLayer(layer))
|
|
360
|
+
layer.isolateShape(p2ll(150, 150))
|
|
361
|
+
assert.equal(layer._latlngs.length, 3)
|
|
362
|
+
assert.equal(this.datalayer._index.length, 1)
|
|
363
|
+
})
|
|
364
|
+
|
|
365
|
+
it('should isolate multipolyline shape', function () {
|
|
366
|
+
var latlngs = [
|
|
367
|
+
[p2ll(100, 150), p2ll(100, 200), p2ll(200, 100)],
|
|
368
|
+
[[p2ll(200, 300), p2ll(300, 200)]],
|
|
369
|
+
],
|
|
370
|
+
layer = new L.U.Polyline(this.map, latlngs, {
|
|
371
|
+
datalayer: this.datalayer,
|
|
372
|
+
}).addTo(this.datalayer)
|
|
373
|
+
assert.equal(this.datalayer._index.length, 1)
|
|
374
|
+
assert.ok(this.map.hasLayer(layer))
|
|
375
|
+
var other = layer.isolateShape(p2ll(150, 150))
|
|
376
|
+
assert.equal(this.datalayer._index.length, 2)
|
|
377
|
+
assert.equal(other._latlngs.length, 3)
|
|
378
|
+
assert.deepEqual(other._latlngs, latlngs[0])
|
|
379
|
+
assert.ok(this.map.hasLayer(layer))
|
|
380
|
+
assert.ok(this.map.hasLayer(other))
|
|
381
|
+
assert.equal(layer._latlngs.length, 1)
|
|
382
|
+
other.remove()
|
|
383
|
+
})
|
|
384
|
+
})
|
|
385
|
+
|
|
386
|
+
describe('#clone', function () {
|
|
387
|
+
it('should clone polyline', function () {
|
|
388
|
+
var latlngs = [p2ll(100, 150), p2ll(100, 200), p2ll(200, 100)],
|
|
389
|
+
layer = new L.U.Polyline(this.map, latlngs, {
|
|
390
|
+
datalayer: this.datalayer,
|
|
391
|
+
}).addTo(this.datalayer)
|
|
392
|
+
assert.equal(this.datalayer._index.length, 1)
|
|
393
|
+
other = layer.clone()
|
|
394
|
+
assert.ok(this.map.hasLayer(other))
|
|
395
|
+
assert.equal(this.datalayer._index.length, 2)
|
|
396
|
+
// Must not be the same reference
|
|
397
|
+
assert.notEqual(layer._latlngs, other._latlngs)
|
|
398
|
+
assert.equal(L.Util.formatNum(layer._latlngs[0].lat), other._latlngs[0].lat)
|
|
399
|
+
assert.equal(L.Util.formatNum(layer._latlngs[0].lng), other._latlngs[0].lng)
|
|
400
|
+
})
|
|
401
|
+
})
|
|
402
|
+
})
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
describe('L.TableEditor', 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 table click on edit mode', function () {
|
|
25
|
+
button = qs(
|
|
26
|
+
'#browse_data_toggle_' + L.stamp(this.datalayer) + ' .layer-table-edit'
|
|
27
|
+
)
|
|
28
|
+
expect(button).to.be.ok
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
it('should open table button click', function () {
|
|
32
|
+
happen.click(button)
|
|
33
|
+
expect(qs('#umap-ui-container div.table')).to.be.ok
|
|
34
|
+
expect(qsa('#umap-ui-container div.table form').length).to.eql(3) // One per feature.
|
|
35
|
+
expect(qsa('#umap-ui-container div.table input').length).to.eql(3) // One per feature and per property.
|
|
36
|
+
})
|
|
37
|
+
})
|
|
38
|
+
describe('#properties()', function () {
|
|
39
|
+
var feature
|
|
40
|
+
|
|
41
|
+
before(function () {
|
|
42
|
+
var firstIndex = this.datalayer._index[0]
|
|
43
|
+
feature = this.datalayer._layers[firstIndex]
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
it('should create new property column', function () {
|
|
47
|
+
var newPrompt = function () {
|
|
48
|
+
return 'newprop'
|
|
49
|
+
}
|
|
50
|
+
var oldPrompt = window.prompt
|
|
51
|
+
window.prompt = newPrompt
|
|
52
|
+
var button = qs('#umap-ui-container .add-property')
|
|
53
|
+
expect(button).to.be.ok
|
|
54
|
+
happen.click(button)
|
|
55
|
+
expect(qsa('#umap-ui-container div.table input').length).to.eql(6) // One per feature and per property.
|
|
56
|
+
window.prompt = oldPrompt
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
it('should populate feature property on fill', function () {
|
|
60
|
+
var input = qs(
|
|
61
|
+
'form#umap-feature-properties_' + L.stamp(feature) + ' input[name=newprop]'
|
|
62
|
+
)
|
|
63
|
+
changeInputValue(input, 'the value')
|
|
64
|
+
expect(feature.properties.newprop).to.eql('the value')
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
it('should update property name on update click', function () {
|
|
68
|
+
var newPrompt = function () {
|
|
69
|
+
return 'newname'
|
|
70
|
+
}
|
|
71
|
+
var oldPrompt = window.prompt
|
|
72
|
+
window.prompt = newPrompt
|
|
73
|
+
var button = qs('#umap-ui-container div.thead div.tcell:last-of-type .umap-edit')
|
|
74
|
+
expect(button).to.be.ok
|
|
75
|
+
happen.click(button)
|
|
76
|
+
expect(qsa('#umap-ui-container div.table input').length).to.eql(6)
|
|
77
|
+
expect(feature.properties.newprop).to.be.undefined
|
|
78
|
+
expect(feature.properties.newname).to.eql('the value')
|
|
79
|
+
window.prompt = oldPrompt
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
it('should update property on delete click', function () {
|
|
83
|
+
var oldConfirm,
|
|
84
|
+
newConfirm = function () {
|
|
85
|
+
return true
|
|
86
|
+
}
|
|
87
|
+
oldConfirm = window.confirm
|
|
88
|
+
window.confirm = newConfirm
|
|
89
|
+
var button = qs(
|
|
90
|
+
'#umap-ui-container div.thead div.tcell:last-of-type .umap-delete'
|
|
91
|
+
)
|
|
92
|
+
expect(button).to.be.ok
|
|
93
|
+
happen.click(button)
|
|
94
|
+
FEATURE = feature
|
|
95
|
+
expect(qsa('#umap-ui-container div.table input').length).to.eql(3)
|
|
96
|
+
expect(feature.properties.newname).to.be.undefined
|
|
97
|
+
window.confirm = oldConfirm
|
|
98
|
+
})
|
|
99
|
+
})
|
|
100
|
+
})
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import URLs from '../js/modules/urls.js'
|
|
2
|
+
|
|
3
|
+
describe('URLs', () => {
|
|
4
|
+
// Mock server URLs that will be used for testing
|
|
5
|
+
const mockServerUrls = {
|
|
6
|
+
map_create: '/maps/create',
|
|
7
|
+
map_update: '/maps/{map_id}/update',
|
|
8
|
+
datalayer_create: '/maps/{map_id}/datalayers/create',
|
|
9
|
+
datalayer_update: '/maps/{map_id}/datalayers/{pk}/update',
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
let urls = new URLs(mockServerUrls)
|
|
13
|
+
|
|
14
|
+
describe('get()', () => {
|
|
15
|
+
it('should throw an error if the urlName does not exist', () => {
|
|
16
|
+
expect(() => urls.get('non_existent')).to.throw()
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
it('should return the correct templated URL for known urlNames', () => {
|
|
20
|
+
expect(urls.get('map_create')).to.be.equal('/maps/create')
|
|
21
|
+
expect(urls.get('map_update', { map_id: '123' })).to.be.equal('/maps/123/update')
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
it('should return the correct templated URL when provided with parameters', () => {
|
|
25
|
+
expect(urls.get('datalayer_update', { map_id: '123', pk: '456' })).to.be.equal(
|
|
26
|
+
'/maps/123/datalayers/456/update'
|
|
27
|
+
)
|
|
28
|
+
})
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
describe('map_save()', () => {
|
|
32
|
+
it('should return the create URL if no map_id is provided', () => {
|
|
33
|
+
expect(urls.map_save({})).to.be.equal('/maps/create')
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
it('should return the update URL if a map_id is provided', () => {
|
|
37
|
+
expect(urls.map_save({ map_id: '123' })).to.be.equal('/maps/123/update')
|
|
38
|
+
})
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
describe('datalayer_save()', () => {
|
|
42
|
+
it('should return the create URL if no pk is provided', () => {
|
|
43
|
+
expect(urls.datalayer_save({ map_id: '123' })).to.be.equal(
|
|
44
|
+
'/maps/123/datalayers/create'
|
|
45
|
+
)
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
it('should return the update URL if a pk is provided', () => {
|
|
49
|
+
expect(urls.datalayer_save({ map_id: '123', pk: '456' })).to.be.equal(
|
|
50
|
+
'/maps/123/datalayers/456/update'
|
|
51
|
+
)
|
|
52
|
+
})
|
|
53
|
+
})
|
|
54
|
+
})
|