-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgeocoder.test.js
105 lines (99 loc) · 2.48 KB
/
geocoder.test.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
import * as limosa from "./geocoder.js";
test("Geocode sample", async () => {
const run = runs.mainSample;
const photonResult = await limosa.photonLocate(run.input, run.config);
console.log(JSON.stringify(photonResult, null, 2));
const uuids = limosa.extractOsmUuids(photonResult);
console.log(uuids);
const nominatimResult = await limosa.nominatimLookup(
{ osm_ids: uuids },
{
addressdetails: 1,
namedetails: 1,
extratags: 1,
});
console.log(JSON.stringify(nominatimResult, null, 2));
}, 60000);
test("Nominatim lookup", async () => {
const nominatimResult = await limosa.nominatimLookup(
{ osm_ids: ["N9429754917", "N9429754918"] },
{
format: "geojson",
addressdetails: 1,
namedetails: 1,
extratags: 1,
}
);
console.log(JSON.stringify(nominatimResult, null, 2));
});
const runs = {
mainSample: {
input: {
house: "14",
street: "Quai des Saulx",
locality: "Bouillon",
postalCode: "6830",
country: "Belgium",
},
},
exactMatchInCity: {
input: {
street: ["Av. du Vert Chasseur 46"],
postalCode: "1180",
locality: ["Uccle"],
country: ["Belgium"],
},
},
houseNumberUnknown: {
input: {
street: ["60A Grand rue"], // street, first element needs to contain street name
postalCode: "6850",
locality: ["Carlsbourg"], // locality, district, city
country: ["Belgium"], // country
},
},
exactMatchInCountryside: {
input: {
street: ["40 Grand rue"], // street, first element needs to contain street name
postalCode: "6850",
locality: ["Carlsbourg"], // locality, district, city
country: ["Belgium"], // country
},
},
notTheExactCity: {
input: {
street: ["50 Avenue Franklin Roosevelt"],
postalCode: "1050",
country: ["Belgium"],
locality: ["Ixelles"],
},
},
fakeStreet: {
input: {
street: ["Av. des bons légumes"],
postalCode: "1050",
locality: ["Ixelles"],
country: ["Belgium"],
},
},
inAnotherCountryWithoutAStreet: {
input: {
house: ["Swainstown"],
postalCode: "C15 YK80",
locality: ["Kilmessan"],
country: ["Ireland"],
},
config: {
postalCodeLevel: "house",
},
},
// TODO this does not work at the moment see todo
inAnotherProvince: {
input: {
street: ["5 Rue du Moulin"],
postalCode: "5555",
locality: ["Naomé"],
country: ["Belgium"],
},
},
};