feat: discard route if there's only one point
This commit is contained in:
parent
de5e4cc4d2
commit
1450026270
|
@ -151,8 +151,7 @@ export default function handler(req, res) {
|
||||||
sill(`Requesting ${request_uri}`);
|
sill(`Requesting ${request_uri}`);
|
||||||
const fetch_debug_response = fetch(request_uri).then((response) => {
|
const fetch_debug_response = fetch(request_uri).then((response) => {
|
||||||
return response.json();
|
return response.json();
|
||||||
});
|
}).then((debug_response) => {
|
||||||
fetch_debug_response.then((debug_response) => {
|
|
||||||
// sill(debug_response);
|
// sill(debug_response);
|
||||||
let ps = {};
|
let ps = {};
|
||||||
let ws = {};
|
let ws = {};
|
||||||
|
@ -163,7 +162,8 @@ export default function handler(req, res) {
|
||||||
ws[it.id] = it.nodes;
|
ws[it.id] = it.nodes;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const path_found = shortest_path(ps, ws, pts[0], pts[pts.length - 1]);
|
sill(pts.length);
|
||||||
|
const path_found = pts.length < 2 ? [] : shortest_path(ps, ws, pts[0], pts[pts.length - 1]);
|
||||||
res.status(200).json({
|
res.status(200).json({
|
||||||
log: `Method: click\nArgs: ${pts}\nStatus: requested "${request_uri}", got response ${JSON.stringify(debug_response.elements)}`,
|
log: `Method: click\nArgs: ${pts}\nStatus: requested "${request_uri}", got response ${JSON.stringify(debug_response.elements)}`,
|
||||||
multipolyline: JSON.stringify(path_found),
|
multipolyline: JSON.stringify(path_found),
|
||||||
|
|
Loading…
Reference in New Issue