forked from shyr1punk/city-visualization
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdiff.js
49 lines (44 loc) · 1.42 KB
/
diff.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
const fs = require('fs');
const geocoder = require('./geocoder');
const readJson = filename => JSON.parse(fs.readFileSync(filename).toString())
const cities = readJson('./cities.json');
const coords = readJson('./coords.json');
let lost = [];
for (i = 1; i < cities.length; i++) {
if (!coords[i] || cities[i][5].includes(' век')) {
// console.log(cities[i])
lost.push(cities[i])
}
}
lost = lost.map(city => {
city[1] = city[1].replace('Оспаривается', '')
city[2] = city[2].replace(' — Югра', '').replace(' АО', '')
// console.log(city[1])
// Кажется тут проблема с определением века
if((city[5].indexOf(' век') !== -1) && (city[5].indexOf(' век') === city[5].length - 4)) {
city[5] = (parseInt(city[5]) - 1) * 100 + 50; // середина века
}
if(city[0] === '396') {
city[5] = -600;
}
if(city[0] === '1014') {
city[5] = -550;
}
if(city[0] === '272') {
city[5] = -497;
}
if(city[0] === '339') {
city[5] = 550;
}
if(city[0] === '722') {
city[5] = 1920;
}
return city;
})
geocoder(lost).then(res => {
// Добавляем новые города к существующим
res.forEach((val, i) => {
coords[val[0] - 1] = val;
})
fs.writeFileSync('./fill_cities_coords.json', JSON.stringify(coords, null, '\t'))
})