From 14500262700e6ae3b58775ca21d045077a1ca2f7 Mon Sep 17 00:00:00 2001 From: arielherself Date: Sat, 30 Dec 2023 17:11:16 +0800 Subject: [PATCH] feat: discard route if there's only one point --- api/click.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api/click.js b/api/click.js index dd32828..364ddc1 100644 --- a/api/click.js +++ b/api/click.js @@ -151,8 +151,7 @@ export default function handler(req, res) { sill(`Requesting ${request_uri}`); const fetch_debug_response = fetch(request_uri).then((response) => { return response.json(); - }); - fetch_debug_response.then((debug_response) => { + }).then((debug_response) => { // sill(debug_response); let ps = {}; let ws = {}; @@ -163,7 +162,8 @@ export default function handler(req, res) { 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({ log: `Method: click\nArgs: ${pts}\nStatus: requested "${request_uri}", got response ${JSON.stringify(debug_response.elements)}`, multipolyline: JSON.stringify(path_found),