umap-project 1.4.4__py3-none-any.whl → 1.5.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


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

Files changed (132) hide show
  1. umap/__init__.py +1 -1
  2. umap/locale/br/LC_MESSAGES/django.mo +0 -0
  3. umap/locale/br/LC_MESSAGES/django.po +8 -7
  4. umap/locale/cs_CZ/LC_MESSAGES/django.mo +0 -0
  5. umap/locale/cs_CZ/LC_MESSAGES/django.po +35 -35
  6. umap/locale/en/LC_MESSAGES/django.po +28 -28
  7. umap/migrations/0011_alter_map_edit_status_alter_map_share_status.py +24 -0
  8. umap/models.py +10 -2
  9. umap/settings/base.py +2 -0
  10. umap/static/umap/base.css +4 -4
  11. umap/static/umap/img/16-white.svg +18 -3
  12. umap/static/umap/img/logo_small.svg +14 -0
  13. umap/static/umap/img/source/16-white.svg +19 -5
  14. umap/static/umap/js/umap.controls.js +122 -132
  15. umap/static/umap/js/umap.core.js +12 -5
  16. umap/static/umap/js/umap.features.js +40 -14
  17. umap/static/umap/js/umap.forms.js +55 -5
  18. umap/static/umap/js/umap.js +59 -100
  19. umap/static/umap/js/umap.layer.js +69 -26
  20. umap/static/umap/js/umap.permissions.js +5 -0
  21. umap/static/umap/js/umap.popup.js +3 -6
  22. umap/static/umap/js/umap.xhr.js +2 -1
  23. umap/static/umap/locale/am_ET.js +14 -7
  24. umap/static/umap/locale/am_ET.json +14 -7
  25. umap/static/umap/locale/ar.js +14 -7
  26. umap/static/umap/locale/ar.json +14 -7
  27. umap/static/umap/locale/ast.js +14 -7
  28. umap/static/umap/locale/ast.json +14 -7
  29. umap/static/umap/locale/bg.js +14 -7
  30. umap/static/umap/locale/bg.json +14 -7
  31. umap/static/umap/locale/br.js +29 -22
  32. umap/static/umap/locale/br.json +29 -22
  33. umap/static/umap/locale/ca.js +14 -7
  34. umap/static/umap/locale/ca.json +14 -7
  35. umap/static/umap/locale/cs_CZ.js +42 -35
  36. umap/static/umap/locale/cs_CZ.json +42 -35
  37. umap/static/umap/locale/da.js +14 -7
  38. umap/static/umap/locale/da.json +14 -7
  39. umap/static/umap/locale/de.js +14 -7
  40. umap/static/umap/locale/de.json +14 -7
  41. umap/static/umap/locale/el.js +14 -7
  42. umap/static/umap/locale/el.json +14 -7
  43. umap/static/umap/locale/en.js +14 -7
  44. umap/static/umap/locale/en.json +14 -7
  45. umap/static/umap/locale/en_US.json +14 -7
  46. umap/static/umap/locale/es.js +14 -7
  47. umap/static/umap/locale/es.json +14 -7
  48. umap/static/umap/locale/et.js +14 -7
  49. umap/static/umap/locale/et.json +14 -7
  50. umap/static/umap/locale/eu.js +7 -7
  51. umap/static/umap/locale/eu.json +7 -7
  52. umap/static/umap/locale/fa_IR.js +14 -7
  53. umap/static/umap/locale/fa_IR.json +14 -7
  54. umap/static/umap/locale/fi.js +14 -7
  55. umap/static/umap/locale/fi.json +14 -7
  56. umap/static/umap/locale/fr.js +14 -7
  57. umap/static/umap/locale/fr.json +14 -7
  58. umap/static/umap/locale/gl.js +14 -7
  59. umap/static/umap/locale/gl.json +14 -7
  60. umap/static/umap/locale/he.js +14 -7
  61. umap/static/umap/locale/he.json +14 -7
  62. umap/static/umap/locale/hr.js +14 -7
  63. umap/static/umap/locale/hr.json +14 -7
  64. umap/static/umap/locale/hu.js +14 -7
  65. umap/static/umap/locale/hu.json +14 -7
  66. umap/static/umap/locale/id.js +14 -7
  67. umap/static/umap/locale/id.json +14 -7
  68. umap/static/umap/locale/is.js +14 -7
  69. umap/static/umap/locale/is.json +14 -7
  70. umap/static/umap/locale/it.js +14 -7
  71. umap/static/umap/locale/it.json +14 -7
  72. umap/static/umap/locale/ja.js +14 -7
  73. umap/static/umap/locale/ja.json +14 -7
  74. umap/static/umap/locale/ko.js +14 -7
  75. umap/static/umap/locale/ko.json +14 -7
  76. umap/static/umap/locale/lt.js +14 -7
  77. umap/static/umap/locale/lt.json +14 -7
  78. umap/static/umap/locale/ms.js +14 -7
  79. umap/static/umap/locale/ms.json +14 -7
  80. umap/static/umap/locale/nl.js +14 -7
  81. umap/static/umap/locale/nl.json +14 -7
  82. umap/static/umap/locale/no.js +14 -7
  83. umap/static/umap/locale/no.json +14 -7
  84. umap/static/umap/locale/pl.js +14 -7
  85. umap/static/umap/locale/pl.json +14 -7
  86. umap/static/umap/locale/pl_PL.json +14 -7
  87. umap/static/umap/locale/pt.js +14 -7
  88. umap/static/umap/locale/pt.json +14 -7
  89. umap/static/umap/locale/pt_BR.js +14 -7
  90. umap/static/umap/locale/pt_BR.json +14 -7
  91. umap/static/umap/locale/pt_PT.js +14 -7
  92. umap/static/umap/locale/pt_PT.json +14 -7
  93. umap/static/umap/locale/ro.js +14 -7
  94. umap/static/umap/locale/ro.json +14 -7
  95. umap/static/umap/locale/ru.js +14 -7
  96. umap/static/umap/locale/ru.json +14 -7
  97. umap/static/umap/locale/sk_SK.js +14 -7
  98. umap/static/umap/locale/sk_SK.json +14 -7
  99. umap/static/umap/locale/sl.js +14 -7
  100. umap/static/umap/locale/sl.json +14 -7
  101. umap/static/umap/locale/sr.js +14 -7
  102. umap/static/umap/locale/sr.json +14 -7
  103. umap/static/umap/locale/sv.js +38 -31
  104. umap/static/umap/locale/sv.json +38 -31
  105. umap/static/umap/locale/th_TH.js +14 -7
  106. umap/static/umap/locale/th_TH.json +14 -7
  107. umap/static/umap/locale/tr.js +14 -7
  108. umap/static/umap/locale/tr.json +14 -7
  109. umap/static/umap/locale/uk_UA.js +14 -7
  110. umap/static/umap/locale/uk_UA.json +14 -7
  111. umap/static/umap/locale/vi.js +14 -7
  112. umap/static/umap/locale/vi.json +14 -7
  113. umap/static/umap/locale/vi_VN.json +14 -7
  114. umap/static/umap/locale/zh.js +14 -7
  115. umap/static/umap/locale/zh.json +14 -7
  116. umap/static/umap/locale/zh_CN.json +14 -7
  117. umap/static/umap/locale/zh_TW.Big5.json +14 -7
  118. umap/static/umap/locale/zh_TW.js +14 -7
  119. umap/static/umap/locale/zh_TW.json +14 -7
  120. umap/static/umap/map.css +119 -47
  121. umap/static/umap/test/DataLayer.js +32 -6
  122. umap/static/umap/test/Util.js +7 -7
  123. umap/static/umap/vendors/leaflet/leaflet-src.js +7156 -7156
  124. umap/static/umap/vendors/togeojson/togeojson.js +2 -406
  125. umap/tests/test_map.py +16 -0
  126. umap/tests/test_views.py +18 -0
  127. umap/views.py +3 -1
  128. {umap_project-1.4.4.dist-info → umap_project-1.5.0.dist-info}/METADATA +3 -3
  129. {umap_project-1.4.4.dist-info → umap_project-1.5.0.dist-info}/RECORD +132 -130
  130. {umap_project-1.4.4.dist-info → umap_project-1.5.0.dist-info}/WHEEL +0 -0
  131. {umap_project-1.4.4.dist-info → umap_project-1.5.0.dist-info}/entry_points.txt +0 -0
  132. {umap_project-1.4.4.dist-info → umap_project-1.5.0.dist-info}/licenses/LICENSE +0 -0
@@ -1,406 +1,2 @@
1
- var toGeoJSON = (function() {
2
- 'use strict';
3
-
4
- var removeSpace = /\s*/g,
5
- trimSpace = /^\s*|\s*$/g,
6
- splitSpace = /\s+/;
7
- // generate a short, numeric hash of a string
8
- function okhash(x) {
9
- if (!x || !x.length) return 0;
10
- for (var i = 0, h = 0; i < x.length; i++) {
11
- h = ((h << 5) - h) + x.charCodeAt(i) | 0;
12
- } return h;
13
- }
14
- // all Y children of X
15
- function get(x, y) { return x.getElementsByTagName(y); }
16
- function attr(x, y) { return x.getAttribute(y); }
17
- function attrf(x, y) { return parseFloat(attr(x, y)); }
18
- // one Y child of X, if any, otherwise null
19
- function get1(x, y) { var n = get(x, y); return n.length ? n[0] : null; }
20
- // https://developer.mozilla.org/en-US/docs/Web/API/Node.normalize
21
- function norm(el) { if (el.normalize) { el.normalize(); } return el; }
22
- // cast array x into numbers
23
- function numarray(x) {
24
- for (var j = 0, o = []; j < x.length; j++) { o[j] = parseFloat(x[j]); }
25
- return o;
26
- }
27
- // get the content of a text node, if any
28
- function nodeVal(x) {
29
- if (x) { norm(x); }
30
- return (x && x.textContent) || '';
31
- }
32
- // get the contents of multiple text nodes, if present
33
- function getMulti(x, ys) {
34
- var o = {}, n, k;
35
- for (k = 0; k < ys.length; k++) {
36
- n = get1(x, ys[k]);
37
- if (n) o[ys[k]] = nodeVal(n);
38
- }
39
- return o;
40
- }
41
- // add properties of Y to X, overwriting if present in both
42
- function extend(x, y) { for (var k in y) x[k] = y[k]; }
43
- // get one coordinate from a coordinate array, if any
44
- function coord1(v) { return numarray(v.replace(removeSpace, '').split(',')); }
45
- // get all coordinates from a coordinate array as [[],[]]
46
- function coord(v) {
47
- var coords = v.replace(trimSpace, '').split(splitSpace),
48
- o = [];
49
- for (var i = 0; i < coords.length; i++) {
50
- o.push(coord1(coords[i]));
51
- }
52
- return o;
53
- }
54
- function coordPair(x) {
55
- var ll = [attrf(x, 'lon'), attrf(x, 'lat')],
56
- ele = get1(x, 'ele'),
57
- // handle namespaced attribute in browser
58
- heartRate = get1(x, 'gpxtpx:hr') || get1(x, 'hr'),
59
- time = get1(x, 'time'),
60
- e;
61
- if (ele) {
62
- e = parseFloat(nodeVal(ele));
63
- if (!isNaN(e)) {
64
- ll.push(e);
65
- }
66
- }
67
- return {
68
- coordinates: ll,
69
- time: time ? nodeVal(time) : null,
70
- heartRate: heartRate ? parseFloat(nodeVal(heartRate)) : null
71
- };
72
- }
73
-
74
- // create a new feature collection parent object
75
- function fc() {
76
- return {
77
- type: 'FeatureCollection',
78
- features: []
79
- };
80
- }
81
-
82
- var serializer;
83
- if (typeof XMLSerializer !== 'undefined') {
84
- /* istanbul ignore next */
85
- serializer = new XMLSerializer();
86
- // only require xmldom in a node environment
87
- } else if (typeof exports === 'object' && typeof process === 'object' && !process.browser) {
88
- serializer = new (require('xmldom').XMLSerializer)();
89
- }
90
- function xml2str(str) {
91
- // IE9 will create a new XMLSerializer but it'll crash immediately.
92
- // This line is ignored because we don't run coverage tests in IE9
93
- /* istanbul ignore next */
94
- if (str.xml !== undefined) return str.xml;
95
- return serializer.serializeToString(str);
96
- }
97
-
98
- var t = {
99
- kml: function(doc) {
100
-
101
- var gj = fc(),
102
- // styleindex keeps track of hashed styles in order to match features
103
- styleIndex = {}, styleByHash = {},
104
- // stylemapindex keeps track of style maps to expose in properties
105
- styleMapIndex = {},
106
- // atomic geospatial types supported by KML - MultiGeometry is
107
- // handled separately
108
- geotypes = ['Polygon', 'LineString', 'Point', 'Track', 'gx:Track'],
109
- // all root placemarks in the file
110
- placemarks = get(doc, 'Placemark'),
111
- styles = get(doc, 'Style'),
112
- styleMaps = get(doc, 'StyleMap');
113
-
114
- for (var k = 0; k < styles.length; k++) {
115
- var hash = okhash(xml2str(styles[k])).toString(16);
116
- styleIndex['#' + attr(styles[k], 'id')] = hash;
117
- styleByHash[hash] = styles[k];
118
- }
119
- for (var l = 0; l < styleMaps.length; l++) {
120
- styleIndex['#' + attr(styleMaps[l], 'id')] = okhash(xml2str(styleMaps[l])).toString(16);
121
- var pairs = get(styleMaps[l], 'Pair');
122
- var pairsMap = {};
123
- for (var m = 0; m < pairs.length; m++) {
124
- pairsMap[nodeVal(get1(pairs[m], 'key'))] = nodeVal(get1(pairs[m], 'styleUrl'));
125
- }
126
- styleMapIndex['#' + attr(styleMaps[l], 'id')] = pairsMap;
127
-
128
- }
129
- for (var j = 0; j < placemarks.length; j++) {
130
- gj.features = gj.features.concat(getPlacemark(placemarks[j]));
131
- }
132
- function kmlColor(v) {
133
- var color, opacity;
134
- v = v || '';
135
- if (v.substr(0, 1) === '#') { v = v.substr(1); }
136
- if (v.length === 6 || v.length === 3) { color = v; }
137
- if (v.length === 8) {
138
- opacity = parseInt(v.substr(0, 2), 16) / 255;
139
- color = '#' + v.substr(6, 2) +
140
- v.substr(4, 2) +
141
- v.substr(2, 2);
142
- }
143
- return [color, isNaN(opacity) ? undefined : opacity];
144
- }
145
- function gxCoord(v) { return numarray(v.split(' ')); }
146
- function gxCoords(root) {
147
- var elems = get(root, 'coord', 'gx'), coords = [], times = [];
148
- if (elems.length === 0) elems = get(root, 'gx:coord');
149
- for (var i = 0; i < elems.length; i++) coords.push(gxCoord(nodeVal(elems[i])));
150
- var timeElems = get(root, 'when');
151
- for (var j = 0; j < timeElems.length; j++) times.push(nodeVal(timeElems[j]));
152
- return {
153
- coords: coords,
154
- times: times
155
- };
156
- }
157
- function getGeometry(root) {
158
- var geomNode, geomNodes, i, j, k, geoms = [], coordTimes = [];
159
- if (get1(root, 'MultiGeometry')) { return getGeometry(get1(root, 'MultiGeometry')); }
160
- if (get1(root, 'MultiTrack')) { return getGeometry(get1(root, 'MultiTrack')); }
161
- if (get1(root, 'gx:MultiTrack')) { return getGeometry(get1(root, 'gx:MultiTrack')); }
162
- for (i = 0; i < geotypes.length; i++) {
163
- geomNodes = get(root, geotypes[i]);
164
- if (geomNodes) {
165
- for (j = 0; j < geomNodes.length; j++) {
166
- geomNode = geomNodes[j];
167
- if (geotypes[i] === 'Point') {
168
- geoms.push({
169
- type: 'Point',
170
- coordinates: coord1(nodeVal(get1(geomNode, 'coordinates')))
171
- });
172
- } else if (geotypes[i] === 'LineString') {
173
- geoms.push({
174
- type: 'LineString',
175
- coordinates: coord(nodeVal(get1(geomNode, 'coordinates')))
176
- });
177
- } else if (geotypes[i] === 'Polygon') {
178
- var rings = get(geomNode, 'LinearRing'),
179
- coords = [];
180
- for (k = 0; k < rings.length; k++) {
181
- coords.push(coord(nodeVal(get1(rings[k], 'coordinates'))));
182
- }
183
- geoms.push({
184
- type: 'Polygon',
185
- coordinates: coords
186
- });
187
- } else if (geotypes[i] === 'Track' ||
188
- geotypes[i] === 'gx:Track') {
189
- var track = gxCoords(geomNode);
190
- geoms.push({
191
- type: 'LineString',
192
- coordinates: track.coords
193
- });
194
- if (track.times.length) coordTimes.push(track.times);
195
- }
196
- }
197
- }
198
- }
199
- return {
200
- geoms: geoms,
201
- coordTimes: coordTimes
202
- };
203
- }
204
- function getPlacemark(root) {
205
- var geomsAndTimes = getGeometry(root), i, properties = {},
206
- name = nodeVal(get1(root, 'name')),
207
- styleUrl = nodeVal(get1(root, 'styleUrl')),
208
- description = nodeVal(get1(root, 'description')),
209
- timeSpan = get1(root, 'TimeSpan'),
210
- timeStamp = get1(root, 'TimeStamp'),
211
- extendedData = get1(root, 'ExtendedData'),
212
- lineStyle = get1(root, 'LineStyle'),
213
- polyStyle = get1(root, 'PolyStyle'),
214
- visibility = get1(root, 'visibility');
215
-
216
- if (!geomsAndTimes.geoms.length) return [];
217
- if (name) properties.name = name;
218
- if (styleUrl) {
219
- if (styleUrl[0] !== '#') {
220
- styleUrl = '#' + styleUrl;
221
- }
222
-
223
- properties.styleUrl = styleUrl;
224
- if (styleIndex[styleUrl]) {
225
- properties.styleHash = styleIndex[styleUrl];
226
- }
227
- if (styleMapIndex[styleUrl]) {
228
- properties.styleMapHash = styleMapIndex[styleUrl];
229
- properties.styleHash = styleIndex[styleMapIndex[styleUrl].normal];
230
- }
231
- // Try to populate the lineStyle or polyStyle since we got the style hash
232
- var style = styleByHash[properties.styleHash];
233
- if (style) {
234
- if (!lineStyle) lineStyle = get1(style, 'LineStyle');
235
- if (!polyStyle) polyStyle = get1(style, 'PolyStyle');
236
- }
237
- }
238
- if (description) properties.description = description;
239
- if (timeSpan) {
240
- var begin = nodeVal(get1(timeSpan, 'begin'));
241
- var end = nodeVal(get1(timeSpan, 'end'));
242
- properties.timespan = { begin: begin, end: end };
243
- }
244
- if (timeStamp) {
245
- properties.timestamp = nodeVal(get1(timeStamp, 'when'));
246
- }
247
- if (lineStyle) {
248
- var linestyles = kmlColor(nodeVal(get1(lineStyle, 'color'))),
249
- color = linestyles[0],
250
- opacity = linestyles[1],
251
- width = parseFloat(nodeVal(get1(lineStyle, 'width')));
252
- if (color) properties.stroke = color;
253
- if (!isNaN(opacity)) properties['stroke-opacity'] = opacity;
254
- if (!isNaN(width)) properties['stroke-width'] = width;
255
- }
256
- if (polyStyle) {
257
- var polystyles = kmlColor(nodeVal(get1(polyStyle, 'color'))),
258
- pcolor = polystyles[0],
259
- popacity = polystyles[1],
260
- fill = nodeVal(get1(polyStyle, 'fill')),
261
- outline = nodeVal(get1(polyStyle, 'outline'));
262
- if (pcolor) properties.fill = pcolor;
263
- if (!isNaN(popacity)) properties['fill-opacity'] = popacity;
264
- if (fill) properties['fill-opacity'] = fill === '1' ? properties['fill-opacity'] || 1 : 0;
265
- if (outline) properties['stroke-opacity'] = outline === '1' ? properties['stroke-opacity'] || 1 : 0;
266
- }
267
- if (extendedData) {
268
- var datas = get(extendedData, 'Data'),
269
- simpleDatas = get(extendedData, 'SimpleData');
270
-
271
- for (i = 0; i < datas.length; i++) {
272
- properties[datas[i].getAttribute('name')] = nodeVal(get1(datas[i], 'value'));
273
- }
274
- for (i = 0; i < simpleDatas.length; i++) {
275
- properties[simpleDatas[i].getAttribute('name')] = nodeVal(simpleDatas[i]);
276
- }
277
- }
278
- if (visibility) {
279
- properties.visibility = nodeVal(visibility);
280
- }
281
- if (geomsAndTimes.coordTimes.length) {
282
- properties.coordTimes = (geomsAndTimes.coordTimes.length === 1) ?
283
- geomsAndTimes.coordTimes[0] : geomsAndTimes.coordTimes;
284
- }
285
- var feature = {
286
- type: 'Feature',
287
- geometry: (geomsAndTimes.geoms.length === 1) ? geomsAndTimes.geoms[0] : {
288
- type: 'GeometryCollection',
289
- geometries: geomsAndTimes.geoms
290
- },
291
- properties: properties
292
- };
293
- if (attr(root, 'id')) feature.id = attr(root, 'id');
294
- return [feature];
295
- }
296
- return gj;
297
- },
298
- gpx: function(doc) {
299
- var i,
300
- tracks = get(doc, 'trk'),
301
- routes = get(doc, 'rte'),
302
- waypoints = get(doc, 'wpt'),
303
- // a feature collection
304
- gj = fc(),
305
- feature;
306
- for (i = 0; i < tracks.length; i++) {
307
- feature = getTrack(tracks[i]);
308
- if (feature) gj.features.push(feature);
309
- }
310
- for (i = 0; i < routes.length; i++) {
311
- feature = getRoute(routes[i]);
312
- if (feature) gj.features.push(feature);
313
- }
314
- for (i = 0; i < waypoints.length; i++) {
315
- gj.features.push(getPoint(waypoints[i]));
316
- }
317
- function getPoints(node, pointname) {
318
- var pts = get(node, pointname),
319
- line = [],
320
- times = [],
321
- heartRates = [],
322
- l = pts.length;
323
- if (l < 2) return {}; // Invalid line in GeoJSON
324
- for (var i = 0; i < l; i++) {
325
- var c = coordPair(pts[i]);
326
- line.push(c.coordinates);
327
- if (c.time) times.push(c.time);
328
- if (c.heartRate) heartRates.push(c.heartRate);
329
- }
330
- return {
331
- line: line,
332
- times: times,
333
- heartRates: heartRates
334
- };
335
- }
336
- function getTrack(node) {
337
- var segments = get(node, 'trkseg'),
338
- track = [],
339
- times = [],
340
- heartRates = [],
341
- line;
342
- for (var i = 0; i < segments.length; i++) {
343
- line = getPoints(segments[i], 'trkpt');
344
- if (line) {
345
- if (line.line) track.push(line.line);
346
- if (line.times && line.times.length) times.push(line.times);
347
- if (line.heartRates && line.heartRates.length) heartRates.push(line.heartRates);
348
- }
349
- }
350
- if (track.length === 0) return;
351
- var properties = getProperties(node);
352
- if (times.length) properties.coordTimes = track.length === 1 ? times[0] : times;
353
- if (heartRates.length) properties.heartRates = track.length === 1 ? heartRates[0] : heartRates;
354
- return {
355
- type: 'Feature',
356
- properties: properties,
357
- geometry: {
358
- type: track.length === 1 ? 'LineString' : 'MultiLineString',
359
- coordinates: track.length === 1 ? track[0] : track
360
- }
361
- };
362
- }
363
- function getRoute(node) {
364
- var line = getPoints(node, 'rtept');
365
- if (!line.line) return;
366
- var routeObj = {
367
- type: 'Feature',
368
- properties: getProperties(node),
369
- geometry: {
370
- type: 'LineString',
371
- coordinates: line.line
372
- }
373
- };
374
- return routeObj;
375
- }
376
- function getPoint(node) {
377
- var prop = getProperties(node);
378
- extend(prop, getMulti(node, ['sym', 'type']));
379
- return {
380
- type: 'Feature',
381
- properties: prop,
382
- geometry: {
383
- type: 'Point',
384
- coordinates: coordPair(node).coordinates
385
- }
386
- };
387
- }
388
- function getProperties(node) {
389
- var prop, links;
390
- prop = getMulti(node, ['name', 'cmt', 'desc', 'time', 'keywords']);
391
- links = get(node, 'link');
392
- if (links.length) prop.links = [];
393
- for (var i = 0, link; i < links.length; i++) {
394
- link = { href: attr(links[i], 'href') };
395
- extend(link, getMulti(links[i], ['text', 'type']));
396
- prop.links.push(link);
397
- }
398
- return prop;
399
- }
400
- return gj;
401
- }
402
- };
403
- return t;
404
- })();
405
-
406
- if (typeof module !== 'undefined') module.exports = toGeoJSON;
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).toGeoJSON={})}(this,(function(t){"use strict";function e(t,e){return Array.from(t.getElementsByTagName(e))}function n(t){return"#"===t[0]?t:`#${t}`}function o(t){return t?.normalize(),t&&t.textContent||""}function r(t,e,n){const o=t.getElementsByTagName(e),r=o.length?o[0]:null;return r&&n&&n(r),r}function i(t,e,n){const o={};if(!t)return o;const r=t.getElementsByTagName(e),i=r.length?r[0]:null;return i&&n?n(i,o):o}function s(t,e,n){const i=o(r(t,e));return i&&n&&n(i)||{}}function c(t,e,n){const i=parseFloat(o(r(t,e)));if(!isNaN(i))return i&&n&&n(i)||{}}function a(t,e,n){const i=parseFloat(o(r(t,e)));if(!isNaN(i))return n&&n(i),i}function l(t,e){const n={};for(const o of e)s(t,o,(t=>{n[o]=t}));return n}function u(t){return 1===t?.nodeType}function f(t){return i(t,"line",(t=>Object.assign({},s(t,"color",(t=>({stroke:`#${t}`}))),c(t,"opacity",(t=>({"stroke-opacity":t}))),c(t,"width",(t=>({"stroke-width":96*t/25.4}))))))}function p(t){let e=[];if(null===t)return e;for(const n of Array.from(t.childNodes)){if(!u(n))continue;const t=g(n.nodeName);if("gpxtpx:TrackPointExtension"===t)e=e.concat(p(n));else{const r=o(n);e.push([t,d(r)])}}return e}function g(t){return["heart","gpxtpx:hr","hr"].includes(t)?"heart":t}function d(t){const e=parseFloat(t);return isNaN(e)?t:e}function m(t){const e=[parseFloat(t.getAttribute("lon")||""),parseFloat(t.getAttribute("lat")||"")];if(isNaN(e[0])||isNaN(e[1]))return null;a(t,"ele",(t=>{e.push(t)}));const n=r(t,"time");return{coordinates:e,time:n?o(n):null,extendedValues:p(r(t,"extensions"))}}function h(t){const n=l(t,["name","cmt","desc","type","time","keywords"]),r=Array.from(t.getElementsByTagNameNS("http://www.garmin.com/xmlschemas/GpxExtensions/v3","*"));for(const e of r)e.parentNode?.parentNode===t&&(n[e.tagName.replace(":","_")]=o(e));const i=e(t,"link");return i.length&&(n.links=i.map((t=>Object.assign({href:t.getAttribute("href")},l(t,["text","type"]))))),n}function y(t,n){const o=e(t,n),r=[],i=[],s={};for(let t=0;t<o.length;t++){const e=m(o[t]);if(e){r.push(e.coordinates),e.time&&i.push(e.time);for(const[n,r]of e.extendedValues){const e="heart"===n?n:n.replace("gpxtpx:","")+"s";s[e]||(s[e]=Array(o.length).fill(null)),s[e][t]=r}}}if(!(r.length<2))return{line:r,times:i,extendedValues:s}}function b(t){const e=y(t,"rtept");if(e)return{type:"Feature",properties:Object.assign({_gpxType:"rte"},h(t),f(r(t,"extensions"))),geometry:{type:"LineString",coordinates:e.line}}}function N(t){const n=e(t,"trkseg"),o=[],i=[],s=[];for(const t of n){const e=y(t,"trkpt");e&&(s.push(e),e.times&&e.times.length&&i.push(e.times))}if(0===s.length)return null;const c=s.length>1,a=Object.assign({_gpxType:"trk"},h(t),f(r(t,"extensions")),i.length?{coordinateProperties:{times:c?i:i[0]}}:{});for(const t of s){o.push(t.line),a.coordinateProperties||(a.coordinateProperties={});const e=a.coordinateProperties,n=Object.entries(t.extendedValues);for(let t=0;t<n.length;t++){const[o,r]=n[t];c?(e[o]||(e[o]=s.map((t=>new Array(t.line.length).fill(null)))),e[o][t]=r):e[o]=r}}return{type:"Feature",properties:a,geometry:c?{type:"MultiLineString",coordinates:o}:{type:"LineString",coordinates:o[0]}}}function x(t){const e=Object.assign(h(t),l(t,["sym"])),n=m(t);return n?{type:"Feature",properties:e,geometry:{type:"Point",coordinates:n.coordinates}}:null}function*k(t){for(const n of e(t,"trk")){const t=N(n);t&&(yield t)}for(const n of e(t,"rte")){const t=b(n);t&&(yield t)}for(const n of e(t,"wpt")){const t=x(n);t&&(yield t)}}const A=[["heartRate","heartRates"],["Cadence","cadences"],["Speed","speeds"],["Watts","watts"]],S=[["TotalTimeSeconds","totalTimeSeconds"],["DistanceMeters","distanceMeters"],["MaximumSpeed","maxSpeed"],["AverageHeartRateBpm","avgHeartRate"],["MaximumHeartRateBpm","maxHeartRate"],["AvgSpeed","avgSpeed"],["AvgWatts","avgWatts"],["MaxWatts","maxWatts"]];function v(t,e){const n=[];for(const[i,s]of e){let e=r(t,i);if(!e){const n=t.getElementsByTagNameNS("http://www.garmin.com/xmlschemas/ActivityExtension/v2",i);n.length&&(e=n[0])}const c=parseFloat(o(e));isNaN(c)||n.push([s,c])}return n}function T(t){const e=[a(t,"LongitudeDegrees"),a(t,"LatitudeDegrees")];if(void 0===e[0]||isNaN(e[0])||void 0===e[1]||isNaN(e[1]))return null;const n=r(t,"HeartRateBpm"),i=o(r(t,"Time"));return r(t,"AltitudeMeters",(t=>{const n=parseFloat(o(t));isNaN(n)||e.push(n)})),{coordinates:e,time:i||null,heartRate:n?parseFloat(o(n)):null,extensions:v(t,A)}}function F(t){const n=e(t,"Trackpoint"),o=[],r=[],i=[];if(n.length<2)return null;const s={},c={extendedProperties:s};for(let t=0;t<n.length;t++){const e=T(n[t]);if(null===e)continue;o.push(e.coordinates);const{time:c,heartRate:a,extensions:l}=e;c&&r.push(c),a&&i.push(a);for(const[e,o]of l)s[e]||(s[e]=Array(n.length).fill(null)),s[e][t]=o}return o.length<2?null:Object.assign(c,{line:o,times:r,heartRates:i})}function P(t){const n=e(t,"Track"),r=[],s=[],c=[],a=[];let l;const u=Object.assign(Object.fromEntries(v(t,S)),i(t,"Name",(t=>({name:o(t)}))));for(const t of n)l=F(t),l&&(r.push(l.line),l.times.length&&s.push(l.times),l.heartRates.length&&c.push(l.heartRates),a.push(l.extendedProperties));for(let t=0;t<a.length;t++){const e=a[t];for(const o in e)1===n.length?l&&(u[o]=l.extendedProperties[o]):(u[o]||(u[o]=r.map((t=>Array(t.length).fill(null)))),u[o][t]=e[o])}return 0===r.length?null:((s.length||c.length)&&(u.coordinateProperties=Object.assign(s.length?{times:1===r.length?s[0]:s}:{},c.length?{heart:1===r.length?c[0]:c}:{})),{type:"Feature",properties:u,geometry:1===r.length?{type:"LineString",coordinates:r[0]}:{type:"MultiLineString",coordinates:r}})}function*O(t){for(const n of e(t,"Lap")){const t=P(n);t&&(yield t)}for(const n of e(t,"Courses")){const t=P(n);t&&(yield t)}}function w(t,e){const n={},o="stroke"==e||"fill"===e?e:e+"-color";return"#"===t[0]&&(t=t.substring(1)),6===t.length||3===t.length?n[o]="#"+t:8===t.length&&(n[e+"-opacity"]=parseInt(t.substring(0,2),16)/255,n[o]="#"+t.substring(6,8)+t.substring(4,6)+t.substring(2,4)),n}function M(t,e,n){const o={};return a(t,e,(t=>{o[n]=t})),o}function j(t,e){return i(t,"color",(t=>w(o(t),e)))}function L(t){return i(t,"Icon",((t,e)=>(s(t,"href",(t=>{e.icon=t})),e)))}function G(t){return Object.assign({},function(t){return i(t,"PolyStyle",((t,e)=>Object.assign(e,i(t,"color",(t=>w(o(t),"fill"))),s(t,"fill",(t=>{if("0"===t)return{"fill-opacity":0}})),s(t,"outline",(t=>{if("0"===t)return{"stroke-opacity":0}})))))}(t),function(t){return i(t,"LineStyle",(t=>Object.assign(j(t,"stroke"),M(t,"width","stroke-width"))))}(t),function(t){return i(t,"LabelStyle",(t=>Object.assign(j(t,"label"),M(t,"scale","label-scale"))))}(t),function(t){return i(t,"IconStyle",(t=>Object.assign(j(t,"icon"),M(t,"scale","icon-scale"),M(t,"heading","icon-heading"),i(t,"hotSpot",(t=>{const e=parseFloat(t.getAttribute("x")||""),n=parseFloat(t.getAttribute("y")||""),o=t.getAttribute("xunits")||"",r=t.getAttribute("yunits")||"";return isNaN(e)||isNaN(n)?{}:{"icon-offset":[e,n],"icon-offset-units":[o,r]}})),L(t))))}(t))}const R=t=>Number(t),B={string:t=>t,int:R,uint:R,short:R,ushort:R,float:R,double:R,bool:t=>Boolean(t)};function E(t,n){return i(t,"ExtendedData",((t,i)=>{for(const n of e(t,"Data"))i[n.getAttribute("name")||""]=o(r(n,"value"));for(const r of e(t,"SimpleData")){const t=r.getAttribute("name")||"",e=n[t]||B.string;i[t]=e(o(r))}return i}))}function C(t){const e=r(t,"description");for(const t of Array.from(e?.childNodes||[]))if(4===t.nodeType)return{description:{"@type":"html",value:o(t)}};return{}}function D(t){return i(t,"TimeSpan",(t=>({timespan:{begin:o(r(t,"begin")),end:o(r(t,"end"))}})))}function W(t){return i(t,"TimeStamp",(t=>({timestamp:o(r(t,"when"))})))}function H(t,e){return s(t,"styleUrl",(t=>(t=n(t),e[t]?Object.assign({styleUrl:t},e[t]):{styleUrl:t})))}const _=/\s*/g,I=/^\s*|\s*$/g,U=/\s+/;function V(t){return t.replace(_,"").split(",").map(parseFloat).filter((t=>!isNaN(t))).slice(0,3)}function $(t){return t.replace(I,"").split(U).map(V).filter((t=>t.length>=2))}function q(t){let n=e(t,"coord");var r,i,s;0===n.length&&(r=t,i="coord",s="*",n=Array.from(r.getElementsByTagNameNS(s,i)));const c=n.map((t=>o(t).split(" ").map(parseFloat)));return 0===c.length?null:{geometry:c.length>2?{type:"LineString",coordinates:c}:{type:"Point",coordinates:c[0]},times:e(t,"when").map((t=>o(t)))}}function z(t){if(0===t.length)return t;const e=t[0],n=t[t.length-1];let o=!0;for(let t=0;t<Math.max(e.length,n.length);t++)if(e[t]!==n[t]){o=!1;break}return o?t:t.concat([t[0]])}function J(t){return o(r(t,"coordinates"))}function Q(t){let n=[],o=[];for(let r=0;r<t.childNodes.length;r++){const i=t.childNodes.item(r);if(u(i))switch(i.tagName){case"MultiGeometry":case"MultiTrack":case"gx:MultiTrack":{const t=Q(i);n=n.concat(t.geometries),o=o.concat(t.coordTimes);break}case"Point":{const t=V(J(i));t.length>=2&&n.push({type:"Point",coordinates:t});break}case"LinearRing":case"LineString":{const t=$(J(i));t.length>=2&&n.push({type:"LineString",coordinates:t});break}case"Polygon":{const t=[];for(const n of e(i,"LinearRing")){const e=z($(J(n)));e.length>=4&&t.push(e)}t.length&&n.push({type:"Polygon",coordinates:t});break}case"Track":case"gx:Track":{const t=q(i);if(!t)break;const{times:e,geometry:r}=t;n.push(r),e.length&&o.push(e);break}}}return{geometries:n,coordTimes:o}}function K(t,e,n,o){const{coordTimes:r,geometries:i}=Q(t),s=function(t){return 0===t.length?null:1===t.length?t[0]:{type:"GeometryCollection",geometries:t}}(i);if(!s&&o.skipNullGeometry)return null;const c={type:"Feature",geometry:s,properties:Object.assign(l(t,["name","address","visibility","open","phoneNumber","description"]),C(t),H(t,e),G(t),E(t,n),D(t),W(t),r.length?{coordinateProperties:{times:1===r.length?r[0]:r}}:{})};void 0!==c.properties?.visibility&&(c.properties.visibility="0"!==c.properties.visibility);const a=t.getAttribute("id");return null!==a&&""!==a&&(c.id=a),c}function X(t){if(r(t,"gx:LatLonQuad")){return{geometry:{type:"Polygon",coordinates:[z($(J(t)))]}}}return function(t){const e=r(t,"LatLonBox");if(e){const t=a(e,"north"),n=a(e,"west"),o=a(e,"east"),r=a(e,"south"),i=a(e,"rotation");if("number"==typeof t&&"number"==typeof r&&"number"==typeof n&&"number"==typeof o){const e=[n,r,o,t];let s=[[[n,t],[o,t],[o,r],[n,r],[n,t]]];return"number"==typeof i&&(s=function(t,e,n){const o=[(t[0]+t[2])/2,(t[1]+t[3])/2];return[e[0].map((t=>{const e=t[1]-o[1],r=t[0]-o[0],i=Math.sqrt(Math.pow(e,2)+Math.pow(r,2)),s=Math.atan2(e,r)-n*Y;return[o[0]+Math.cos(s)*i,o[1]+Math.sin(s)*i]}))]}(e,s,i)),{bbox:e,geometry:{type:"Polygon",coordinates:s}}}}return null}(t)}const Y=Math.PI/180;function Z(t,e,n,o){const r=X(t),i=r?.geometry||null;if(!i&&o.skipNullGeometry)return null;const s={type:"Feature",geometry:i,properties:Object.assign({"@geometry-type":"groundoverlay"},l(t,["name","address","visibility","open","phoneNumber","description"]),C(t),H(t,e),G(t),L(t),E(t,n),D(t),W(t))};r?.bbox&&(s.bbox=r.bbox),void 0!==s.properties?.visibility&&(s.properties.visibility="0"!==s.properties.visibility);const c=t.getAttribute("id");return null!==c&&""!==c&&(s.id=c),s}function tt(t){let e=t.getAttribute("id");const o=t.parentNode;return!e&&u(o)&&"CascadingStyle"===o.localName&&(e=o.getAttribute("kml:id")||o.getAttribute("id")),n(e||"")}function et(t){const o={};for(const n of e(t,"Style"))o[tt(n)]=G(n);for(const r of e(t,"StyleMap")){const t=n(r.getAttribute("id")||"");s(r,"styleUrl",(e=>{e=n(e),o[e]&&(o[t]=o[e])}))}return o}function nt(t){const n={};for(const o of e(t,"SimpleField"))n[o.getAttribute("name")||""]=B[o.getAttribute("type")||""]||B.string;return n}const ot=["name","visibility","open","address","description","phoneNumber","visibility"];function*rt(t,n={skipNullGeometry:!1}){const o=et(t),r=nt(t);for(const i of e(t,"Placemark")){const t=K(i,o,r,n);t&&(yield t)}for(const i of e(t,"GroundOverlay")){const t=Z(i,o,r,n);t&&(yield t)}}t.gpx=function(t){return{type:"FeatureCollection",features:Array.from(k(t))}},t.gpxGen=k,t.kml=function(t,e={skipNullGeometry:!1}){return{type:"FeatureCollection",features:Array.from(rt(t,e))}},t.kmlGen=rt,t.kmlWithFolders=function(t,e={skipNullGeometry:!1}){const n=et(t),r=nt(t),i={type:"root",children:[]};return function t(e,i,s){if(u(e))switch(e.tagName){case"GroundOverlay":{const t=Z(e,n,r,s);t&&i.children.push(t);break}case"Placemark":{const t=K(e,n,r,s);t&&i.children.push(t);break}case"Folder":{const t=function(t){const e={};for(const n of Array.from(t.childNodes))u(n)&&ot.includes(n.tagName)&&(e[n.tagName]=o(n));return{type:"folder",meta:e,children:[]}}(e);i.children.push(t),i=t;break}}if(e.childNodes)for(let n=0;n<e.childNodes.length;n++)t(e.childNodes[n],i,s)}(t,i,e),i},t.tcx=function(t){return{type:"FeatureCollection",features:Array.from(O(t))}},t.tcxGen=O,Object.defineProperty(t,"__esModule",{value:!0})}));
2
+ //# sourceMappingURL=togeojson.umd.js.map
umap/tests/test_map.py CHANGED
@@ -106,3 +106,19 @@ def test_publicmanager_should_get_only_public_maps(map, user, licence):
106
106
  assert map in Map.public.all()
107
107
  assert open_map not in Map.public.all()
108
108
  assert private_map not in Map.public.all()
109
+
110
+
111
+ def test_can_change_default_edit_status(user, settings):
112
+ map = MapFactory(owner=user)
113
+ assert map.edit_status == Map.OWNER
114
+ settings.UMAP_DEFAULT_EDIT_STATUS = Map.EDITORS
115
+ map = MapFactory(owner=user)
116
+ assert map.edit_status == Map.EDITORS
117
+
118
+
119
+ def test_can_change_default_share_status(user, settings):
120
+ map = MapFactory(owner=user)
121
+ assert map.share_status == Map.PUBLIC
122
+ settings.UMAP_DEFAULT_SHARE_STATUS = Map.PRIVATE
123
+ map = MapFactory(owner=user)
124
+ assert map.share_status == Map.PRIVATE
umap/tests/test_views.py CHANGED
@@ -261,3 +261,21 @@ def test_user_dashboard_display_user_maps(client, map):
261
261
  assert f"{map.get_absolute_url()}?download" in body
262
262
  assert "Everyone (public)" in body
263
263
  assert "Owner only" in body
264
+
265
+
266
+ @pytest.mark.django_db
267
+ def test_logout_should_return_json_in_ajax(client, user, settings):
268
+ client.login(username=user.username, password="123123")
269
+ response = client.get(
270
+ reverse("logout"), headers={"X_REQUESTED_WITH": "XMLHttpRequest"}
271
+ )
272
+ data = json.loads(response.content.decode())
273
+ assert data["redirect"] == "/"
274
+
275
+
276
+ @pytest.mark.django_db
277
+ def test_logout_should_return_redirect(client, user, settings):
278
+ client.login(username=user.username, password="123123")
279
+ response = client.get(reverse("logout"))
280
+ assert response.status_code == 302
281
+ assert response["Location"] == "/"
umap/views.py CHANGED
@@ -945,7 +945,9 @@ def stats(request):
945
945
 
946
946
  def logout(request):
947
947
  do_logout(request)
948
- return simple_json_response(redirect="/")
948
+ if is_ajax(request):
949
+ return simple_json_response(redirect="/")
950
+ return HttpResponseRedirect("/")
949
951
 
950
952
 
951
953
  class LoginPopupEnd(TemplateView):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: umap-project
3
- Version: 1.4.4
3
+ Version: 1.5.0
4
4
  Summary: Create maps with OpenStreetMap layers in a minute and embed them in your site.
5
5
  Author-email: Yohan Boniface <yb@enix.org>
6
6
  Maintainer-email: David Larlet <david@larlet.fr>
@@ -30,10 +30,10 @@ Requires-Dist: requests==2.30.0
30
30
  Requires-Dist: social-auth-app-django==5.2.0
31
31
  Requires-Dist: social-auth-core==4.4.2
32
32
  Provides-Extra: dev
33
- Requires-Dist: black==21.10b0; extra == 'dev'
33
+ Requires-Dist: black==23.3.0; extra == 'dev'
34
34
  Requires-Dist: djlint==1.31.0; extra == 'dev'
35
35
  Requires-Dist: hatch==1.7.0; extra == 'dev'
36
- Requires-Dist: mkdocs==1.2.3; extra == 'dev'
36
+ Requires-Dist: mkdocs==1.5.2; extra == 'dev'
37
37
  Provides-Extra: docker
38
38
  Requires-Dist: uwsgi==2.0.21; extra == 'docker'
39
39
  Provides-Extra: test