umap-project 2.0.0a0__py3-none-any.whl → 2.0.0a1__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/storage.py +2 -0
- umap/templates/umap/js.html +0 -1
- {umap_project-2.0.0a0.dist-info → umap_project-2.0.0a1.dist-info}/METADATA +1 -1
- {umap_project-2.0.0a0.dist-info → umap_project-2.0.0a1.dist-info}/RECORD +8 -17
- umap/static/umap/vendors/contextmenu/leaflet.contextmenu.css +0 -54
- umap/static/umap/vendors/contextmenu/leaflet.contextmenu.js +0 -586
- umap/static/umap/vendors/csv2geojson/index.js +0 -259
- umap/static/umap/vendors/dompurify/purify.js +0 -1633
- umap/static/umap/vendors/locatecontrol/L.Control.Locate.css +0 -63
- umap/static/umap/vendors/locatecontrol/L.Control.Locate.js +0 -950
- umap/static/umap/vendors/minimap/Control.MiniMap.css +0 -88
- umap/static/umap/vendors/minimap/Control.MiniMap.js +0 -352
- umap/static/umap/vendors/togeojson/togeojson.js +0 -2
- {umap_project-2.0.0a0.dist-info → umap_project-2.0.0a1.dist-info}/WHEEL +0 -0
- {umap_project-2.0.0a0.dist-info → umap_project-2.0.0a1.dist-info}/entry_points.txt +0 -0
- {umap_project-2.0.0a0.dist-info → umap_project-2.0.0a1.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,259 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var dsv = require('d3-dsv'),
|
|
4
|
-
sexagesimal = require('@mapbox/sexagesimal');
|
|
5
|
-
|
|
6
|
-
var latRegex = /(Lat)(itude)?/gi,
|
|
7
|
-
lonRegex = /(L)(on|ng)(gitude)?/i;
|
|
8
|
-
|
|
9
|
-
function guessHeader(row, regexp) {
|
|
10
|
-
var name, match, score;
|
|
11
|
-
for (var f in row) {
|
|
12
|
-
match = f.match(regexp);
|
|
13
|
-
if (match && (!name || match[0].length / f.length > score)) {
|
|
14
|
-
score = match[0].length / f.length;
|
|
15
|
-
name = f;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
return name;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function guessLatHeader(row) { return guessHeader(row, latRegex); }
|
|
22
|
-
function guessLonHeader(row) { return guessHeader(row, lonRegex); }
|
|
23
|
-
|
|
24
|
-
function isLat(f) { return !!f.match(latRegex); }
|
|
25
|
-
function isLon(f) { return !!f.match(lonRegex); }
|
|
26
|
-
|
|
27
|
-
function keyCount(o) {
|
|
28
|
-
return (typeof o == 'object') ? Object.keys(o).length : 0;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function autoDelimiter(x) {
|
|
32
|
-
var delimiters = [',', ';', '\t', '|'];
|
|
33
|
-
var results = [];
|
|
34
|
-
|
|
35
|
-
delimiters.forEach(function (delimiter) {
|
|
36
|
-
var res = dsv.dsvFormat(delimiter).parse(x);
|
|
37
|
-
if (res.length >= 1) {
|
|
38
|
-
var count = keyCount(res[0]);
|
|
39
|
-
for (var i = 0; i < res.length; i++) {
|
|
40
|
-
if (keyCount(res[i]) !== count) return;
|
|
41
|
-
}
|
|
42
|
-
results.push({
|
|
43
|
-
delimiter: delimiter,
|
|
44
|
-
arity: Object.keys(res[0]).length,
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
if (results.length) {
|
|
50
|
-
return results.sort(function (a, b) {
|
|
51
|
-
return b.arity - a.arity;
|
|
52
|
-
})[0].delimiter;
|
|
53
|
-
} else {
|
|
54
|
-
return null;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Silly stopgap for dsv to d3-dsv upgrade
|
|
60
|
-
*
|
|
61
|
-
* @param {Array} x dsv output
|
|
62
|
-
* @returns {Array} array without columns member
|
|
63
|
-
*/
|
|
64
|
-
function deleteColumns(x) {
|
|
65
|
-
delete x.columns;
|
|
66
|
-
return x;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function auto(x) {
|
|
70
|
-
var delimiter = autoDelimiter(x);
|
|
71
|
-
if (!delimiter) return null;
|
|
72
|
-
return deleteColumns(dsv.dsvFormat(delimiter).parse(x));
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
function csv2geojson(x, options, callback) {
|
|
76
|
-
|
|
77
|
-
if (!callback) {
|
|
78
|
-
callback = options;
|
|
79
|
-
options = {};
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
options.delimiter = options.delimiter || ',';
|
|
83
|
-
|
|
84
|
-
var latfield = options.latfield || '',
|
|
85
|
-
lonfield = options.lonfield || '',
|
|
86
|
-
crs = options.crs || '';
|
|
87
|
-
|
|
88
|
-
var features = [],
|
|
89
|
-
featurecollection = {type: 'FeatureCollection', features: features};
|
|
90
|
-
|
|
91
|
-
if (crs !== '') {
|
|
92
|
-
featurecollection.crs = {type: 'name', properties: {name: crs}};
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
if (options.delimiter === 'auto' && typeof x == 'string') {
|
|
96
|
-
options.delimiter = autoDelimiter(x);
|
|
97
|
-
if (!options.delimiter) {
|
|
98
|
-
callback({
|
|
99
|
-
type: 'Error',
|
|
100
|
-
message: 'Could not autodetect delimiter'
|
|
101
|
-
});
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
var numericFields = options.numericFields ? options.numericFields.split(',') : null;
|
|
107
|
-
|
|
108
|
-
var parsed = (typeof x == 'string') ?
|
|
109
|
-
dsv.dsvFormat(options.delimiter).parse(x, function (d) {
|
|
110
|
-
if (numericFields) {
|
|
111
|
-
for (var key in d) {
|
|
112
|
-
if (numericFields.includes(key)) {
|
|
113
|
-
d[key] = +d[key];
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
return d;
|
|
118
|
-
}) : x;
|
|
119
|
-
|
|
120
|
-
if (!parsed.length) {
|
|
121
|
-
callback(null, featurecollection);
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
var errors = [];
|
|
126
|
-
var i;
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
if (!latfield) latfield = guessLatHeader(parsed[0]);
|
|
130
|
-
if (!lonfield) lonfield = guessLonHeader(parsed[0]);
|
|
131
|
-
var noGeometry = (!latfield || !lonfield);
|
|
132
|
-
|
|
133
|
-
if (noGeometry) {
|
|
134
|
-
for (i = 0; i < parsed.length; i++) {
|
|
135
|
-
features.push({
|
|
136
|
-
type: 'Feature',
|
|
137
|
-
properties: parsed[i],
|
|
138
|
-
geometry: null
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
callback(errors.length ? errors : null, featurecollection);
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
for (i = 0; i < parsed.length; i++) {
|
|
146
|
-
if (parsed[i][lonfield] !== undefined &&
|
|
147
|
-
parsed[i][latfield] !== undefined) {
|
|
148
|
-
|
|
149
|
-
var lonk = parsed[i][lonfield],
|
|
150
|
-
latk = parsed[i][latfield],
|
|
151
|
-
lonf, latf,
|
|
152
|
-
a;
|
|
153
|
-
|
|
154
|
-
a = sexagesimal(lonk, 'EW');
|
|
155
|
-
if (a) lonk = a;
|
|
156
|
-
a = sexagesimal(latk, 'NS');
|
|
157
|
-
if (a) latk = a;
|
|
158
|
-
|
|
159
|
-
lonf = parseFloat(lonk);
|
|
160
|
-
latf = parseFloat(latk);
|
|
161
|
-
|
|
162
|
-
if (isNaN(lonf) ||
|
|
163
|
-
isNaN(latf)) {
|
|
164
|
-
errors.push({
|
|
165
|
-
message: 'A row contained an invalid value for latitude or longitude',
|
|
166
|
-
row: parsed[i],
|
|
167
|
-
index: i
|
|
168
|
-
});
|
|
169
|
-
} else {
|
|
170
|
-
if (!options.includeLatLon) {
|
|
171
|
-
delete parsed[i][lonfield];
|
|
172
|
-
delete parsed[i][latfield];
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
features.push({
|
|
176
|
-
type: 'Feature',
|
|
177
|
-
properties: parsed[i],
|
|
178
|
-
geometry: {
|
|
179
|
-
type: 'Point',
|
|
180
|
-
coordinates: [
|
|
181
|
-
parseFloat(lonf),
|
|
182
|
-
parseFloat(latf)
|
|
183
|
-
]
|
|
184
|
-
}
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
callback(errors.length ? errors : null, featurecollection);
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
function toLine(gj) {
|
|
194
|
-
var features = gj.features;
|
|
195
|
-
var line = {
|
|
196
|
-
type: 'Feature',
|
|
197
|
-
geometry: {
|
|
198
|
-
type: 'LineString',
|
|
199
|
-
coordinates: []
|
|
200
|
-
}
|
|
201
|
-
};
|
|
202
|
-
for (var i = 0; i < features.length; i++) {
|
|
203
|
-
line.geometry.coordinates.push(features[i].geometry.coordinates);
|
|
204
|
-
}
|
|
205
|
-
line.properties = features.reduce(function (aggregatedProperties, newFeature) {
|
|
206
|
-
for (var key in newFeature.properties) {
|
|
207
|
-
if (!aggregatedProperties[key]) {
|
|
208
|
-
aggregatedProperties[key] = [];
|
|
209
|
-
}
|
|
210
|
-
aggregatedProperties[key].push(newFeature.properties[key]);
|
|
211
|
-
}
|
|
212
|
-
return aggregatedProperties;
|
|
213
|
-
}, {});
|
|
214
|
-
return {
|
|
215
|
-
type: 'FeatureCollection',
|
|
216
|
-
features: [line]
|
|
217
|
-
};
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
function toPolygon(gj) {
|
|
221
|
-
var features = gj.features;
|
|
222
|
-
var poly = {
|
|
223
|
-
type: 'Feature',
|
|
224
|
-
geometry: {
|
|
225
|
-
type: 'Polygon',
|
|
226
|
-
coordinates: [[]]
|
|
227
|
-
}
|
|
228
|
-
};
|
|
229
|
-
for (var i = 0; i < features.length; i++) {
|
|
230
|
-
poly.geometry.coordinates[0].push(features[i].geometry.coordinates);
|
|
231
|
-
}
|
|
232
|
-
poly.properties = features.reduce(function (aggregatedProperties, newFeature) {
|
|
233
|
-
for (var key in newFeature.properties) {
|
|
234
|
-
if (!aggregatedProperties[key]) {
|
|
235
|
-
aggregatedProperties[key] = [];
|
|
236
|
-
}
|
|
237
|
-
aggregatedProperties[key].push(newFeature.properties[key]);
|
|
238
|
-
}
|
|
239
|
-
return aggregatedProperties;
|
|
240
|
-
}, {});
|
|
241
|
-
return {
|
|
242
|
-
type: 'FeatureCollection',
|
|
243
|
-
features: [poly]
|
|
244
|
-
};
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
module.exports = {
|
|
248
|
-
isLon: isLon,
|
|
249
|
-
isLat: isLat,
|
|
250
|
-
guessLatHeader: guessLatHeader,
|
|
251
|
-
guessLonHeader: guessLonHeader,
|
|
252
|
-
csv: dsv.csvParse,
|
|
253
|
-
tsv: dsv.tsvParse,
|
|
254
|
-
dsv: dsv,
|
|
255
|
-
auto: auto,
|
|
256
|
-
csv2geojson: csv2geojson,
|
|
257
|
-
toLine: toLine,
|
|
258
|
-
toPolygon: toPolygon
|
|
259
|
-
};
|