ZipCode = GPS => {
const p = [GPS.Longitude, GPS.Latitude];
let nearest = delaunay.find(p[0], p[1]);
let real = nearest;
let type = 0;
if (!inside(p, Contours.features[nearest].geometry.coordinates[0])) {
type = 1;
real = WhichPolygon(p, Array.from(delaunay.neighbors(nearest)));
}
if (real === -1) {
type = 2;
real = WhichPolygon(p, Neighbors2(nearest));
}
if (real === -1) {
real = nearest;
type = 4;
}
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
};
}