-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathscratch.js
More file actions
42 lines (39 loc) · 1.28 KB
/
scratch.js
File metadata and controls
42 lines (39 loc) · 1.28 KB
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
import "node-fetch";
const highWayExclude = ["footway", "street_lamp", "steps", "pedestrian", "track", "path"];
const ENDPOINTS = [
"https://overpass-api.de/api/interpreter",
"https://lz4.overpass-api.de/api/interpreter",
"https://z.overpass-api.de/api/interpreter",
"https://overpass.kumi.systems/api/interpreter"
];
async function test() {
const boundingBox = [
{ latitude: 51.5, longitude: -0.1 },
{ latitude: 51.52, longitude: -0.08 }
];
const exclusion = highWayExclude.map(e => `[highway!="${e}"]`).join("");
const query = `
[out:json];(
way[highway]${exclusion}[footway!="*"]
(${boundingBox[0].latitude},${boundingBox[0].longitude},${boundingBox[1].latitude},${boundingBox[1].longitude});
node(w);
);
out skel;`;
for (const endpoint of ENDPOINTS) {
console.log("Testing", endpoint);
try {
const response = await fetch(endpoint, {
method: "POST",
body: query
});
console.log(response.status);
if (response.ok) {
const text = await response.text();
console.log(text.substring(0, 100));
}
} catch (e) {
console.error(e.message);
}
}
}
test();