Published
Edited
Jul 4, 2020
1 fork
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
ZipCode = GPS => {
const p = [GPS.Longitude, GPS.Latitude];
let nearest = delaunay.find(p[0], p[1]);
let real = nearest;
let type = 0; // = nearest
if (!inside(p, Contours.features[nearest].geometry.coordinates[0])) {
type = 1; // =un des neighbours
real = WhichPolygon(p, Array.from(delaunay.neighbors(nearest)));
}
if (real === -1) {
type = 2; // pas trouvé on essaye les voisins de niveau 2
real = WhichPolygon(p, Neighbors2(nearest));
}
/*
if (real === -1) {
type = 3; // pas trouvé on essaye les voisins de niveau 3
real = WhichPolygon(p, Neighbors3(nearest));
} //Pas trouvé de cas où cela se produit
*/
if (real === -1) {
real = nearest;
type = 4; // pas trouvé
}
const f = Contours.features[real];
return {
insee: f.properties.insee_com,
code_postal: f.properties.postal_code,
Longitude: GPS.Longitude,
Latitude: GPS.Latitude,
name: f.properties.nom_comm,
type: type
};
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more