-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
update_imagery.js
120 lines (97 loc) · 3.32 KB
/
update_imagery.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
var fs = require('fs');
var sources = require('editor-layer-index/imagery.json');
var imagery = [];
// ignore imagery more than 20 years old..
var cutoffDate = new Date();
cutoffDate.setFullYear(cutoffDate.getFullYear() - 20);
var blacklist = {
"2u": true,
"Hike & Bike": true,
"OpenStreetMap (German Language)": true,
"OpenStreetMap (German Style)": true,
"OpenStreetMap (Sorbian Language)": true,
"OpenStreetMap (Standard Black & White)": true,
"Skobbler": true,
"Public Transport (\u00d6PNV)": true, // https://github.com/osmlab/editor-imagery-index/issues/15
"TIGER 2012 Roads Overlay": true, // https://github.com/openstreetmap/iD/pull/2010,
"Thunderforest OpenCycleMap": true,
"Waymarked Trails: Cycling": true,
"Waymarked Trails: Hiking": true,
"Waymarked Trails: MTB": true,
"Waymarked Trails: Skating": true,
"Waymarked Trails: Winter Sports": true,
"OSM Inspector: Geometry": true,
"OSM Inspector: Highways": true,
"OSM Inspector: Multipolygon": true,
"OSM Inspector: Places": true,
"OSM Inspector: Tagging": true,
"OSM Inspector: Addresses (EU)": true,
"OSM Inspector: Boundaries (EU)": true,
"OSM Inspector: Routing (EU)": true,
"QA No Address": true
};
var whitelist = [
// Add custom sources here if needed.
];
var descriptions = {
'Mapbox Satellite': 'Satellite and aerial imagery.',
'Bing aerial imagery': 'Satellite and aerial imagery.',
'OpenStreetMap (Standard)': 'The default OpenStreetMap layer.'
};
sources.concat(whitelist).forEach(function(source) {
if (source.type !== 'tms' && source.type !== 'bing') return;
if (source.name in blacklist) return;
if (source.end_date) {
var endDate = new Date(source.end_date),
isValid = !isNaN(endDate.getTime());
if (isValid && endDate <= cutoffDate) return;
}
var im = {
name: source.name,
type: source.type
};
var description = source.description || descriptions[im.name];
if (description) im.description = description;
im.template = source.url;
var extent = source.extent || {};
if (extent.min_zoom || extent.max_zoom) {
im.scaleExtent = [
extent.min_zoom || 0,
extent.max_zoom || 20
];
}
if (extent.polygon) {
im.polygon = extent.polygon;
} else if (extent.bbox) {
im.polygon = [[
[extent.bbox.min_lon, extent.bbox.min_lat],
[extent.bbox.min_lon, extent.bbox.max_lat],
[extent.bbox.max_lon, extent.bbox.max_lat],
[extent.bbox.max_lon, extent.bbox.min_lat],
[extent.bbox.min_lon, extent.bbox.min_lat]
]];
}
if (source.name === 'Locator Overlay') {
im.overzoom = false;
}
var attribution = source.attribution || {};
if (attribution.url) {
im.terms_url = attribution.url;
}
if (attribution.text) {
im.terms_text = attribution.text;
}
if (attribution.html) {
im.terms_html = attribution.html;
}
['id', 'default', 'overlay', 'best'].forEach(function(a) {
if (source[a]) {
im[a] = source[a];
}
});
imagery.push(im);
});
imagery.sort(function(a, b) {
return a.name.localeCompare(b.name);
});
fs.writeFileSync('data/imagery.json', JSON.stringify(imagery, null, 4));