feat: shortest path (plain implementation)

This commit is contained in:
arielherself 2023-12-25 00:06:07 +08:00
parent 5eeb2aea42
commit ed568f3572
10 changed files with 12044 additions and 76 deletions

1
.babelrc Normal file
View File

@ -0,0 +1 @@
{ "presets": ["@babel/preset-flow"] }

6
.idea/misc.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaScriptSettings">
<option name="languageLevel" value="ES6" />
</component>
</project>

View File

@ -5,6 +5,13 @@
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="3c7078e7-6f30-4d92-9696-11496f9e6dff" name="Changes" comment=""> <list default="true" id="3c7078e7-6f30-4d92-9696-11496f9e6dff" name="Changes" comment="">
<change afterPath="$PROJECT_DIR$/.babelrc" afterDir="false" />
<change afterPath="$PROJECT_DIR$/comp/ShortestPath.js" afterDir="false" />
<change afterPath="$PROJECT_DIR$/test/test_nearest.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/api/click.js" beforeDir="false" afterPath="$PROJECT_DIR$/api/click.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/package-lock.json" beforeDir="false" afterPath="$PROJECT_DIR$/package-lock.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/package.json" beforeDir="false" afterPath="$PROJECT_DIR$/package.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/UMap.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/UMap.js" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/UMap.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/UMap.js" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
@ -33,23 +40,26 @@
<option name="hideEmptyMiddlePackages" value="true" /> <option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" /> <option name="showLibraryContents" value="true" />
</component> </component>
<component name="PropertiesComponent">{ <component name="PropertiesComponent"><![CDATA[{
&quot;keyToString&quot;: { "keyToString": {
&quot;RunOnceActivity.OpenProjectViewOnStart&quot;: &quot;true&quot;, "Node.js.test.js.executor": "Run",
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;, "RunOnceActivity.OpenProjectViewOnStart": "true",
&quot;WebServerToolWindowFactoryState&quot;: &quot;false&quot;, "RunOnceActivity.ShowReadmeOnStart": "true",
&quot;git-widget-placeholder&quot;: &quot;dev&quot;, "WebServerToolWindowFactoryState": "false",
&quot;last_opened_file_path&quot;: &quot;/home/user/Documents/fd_data-structures/pj/frontend&quot;, "git-widget-placeholder": "dev",
&quot;node.js.detected.package.eslint&quot;: &quot;true&quot;, "last_opened_file_path": "/home/user/Documents/fd_data-structures/pj/frontend",
&quot;node.js.detected.package.tslint&quot;: &quot;true&quot;, "node.js.detected.package.eslint": "true",
&quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;, "node.js.detected.package.tslint": "true",
&quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;, "node.js.selected.package.eslint": "(autodetect)",
&quot;nodejs_interpreter_path&quot;: &quot;/home/user/.nvm/versions/node/v20.10.0/bin/node&quot;, "node.js.selected.package.tslint": "(autodetect)",
&quot;nodejs_package_manager_path&quot;: &quot;npm&quot;, "nodejs_interpreter_path": "/home/user/.nvm/versions/node/v20.10.0/bin/node",
&quot;settings.editor.selected.configurable&quot;: &quot;settings.nodejs&quot;, "nodejs_package_manager_path": "npm",
&quot;vue.rearranger.settings.migration&quot;: &quot;true&quot; "npm.start.executor": "Run",
"settings.editor.selected.configurable": "editor.preferences.fonts.default",
"ts.external.directory.path": "/home/user/.local/share/JetBrains/Toolbox/apps/webstorm/plugins/javascript-impl/jsLanguageServicesImpl/external",
"vue.rearranger.settings.migration": "true"
} }
}</component> }]]></component>
<component name="RunManager"> <component name="RunManager">
<configuration name="start" type="js.build_tools.npm" temporary="true" nameIsGenerated="true"> <configuration name="start" type="js.build_tools.npm" temporary="true" nameIsGenerated="true">
<package-json value="$PROJECT_DIR$/package.json" /> <package-json value="$PROJECT_DIR$/package.json" />
@ -81,6 +91,9 @@
<workItem from="1701004587189" duration="3578000" /> <workItem from="1701004587189" duration="3578000" />
<workItem from="1701042611758" duration="10222000" /> <workItem from="1701042611758" duration="10222000" />
<workItem from="1701056208994" duration="5687000" /> <workItem from="1701056208994" duration="5687000" />
<workItem from="1701847206194" duration="6179000" />
<workItem from="1702448962541" duration="5620000" />
<workItem from="1703419885970" duration="12662000" />
</task> </task>
<servers /> <servers />
</component> </component>

View File

@ -1,19 +1,167 @@
import {post} from "../src/Networking"; import {MinPriorityQueue} from "@datastructures-js/priority-queue";
function haversine_distance(p1,p2) {
const toRadians = (degrees) => {
return degrees * Math.PI / 180;
};
const [lat1, lon1] = p1;
const [lat2, lon2] = p2;
const R = 6371;
const dLat = toRadians(lat2 - lat1);
const dLon = toRadians(lon2 - lon1);
const a = Math.sin(dLat / 2) * Math.sin(dLat / 2) +
Math.cos(toRadians(lat1)) * Math.cos(toRadians(lat2)) *
Math.sin(dLon / 2) * Math.sin(dLon / 2);
const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
if (R * c < 0) console.log("WARNING!!!");
return R * c;
}
function find_nearest_node_id(nodes, point) {
const [lat, lon] = point;
let min_distance = 1e100;
let res = 0;
for (let node_id in nodes) {
const curr_distance = haversine_distance(nodes[node_id], point);
if (curr_distance < min_distance) {
min_distance = curr_distance;
res = node_id;
}
}
return res;
}
function __spa(nodes, ch, u, p) {
console.log(`node count: ${Object.keys(nodes).length}`);
const weight_cache = {};
try {
const get_weight = (n1, n2) => {
const tup = [n1, n2];
if (weight_cache[tup]) {
return weight_cache[[n1, n2]];
}
// console.log("21");
// console.log(`${nodes[n1]} ${nodes[n2]}`);
weight_cache[tup] = haversine_distance(nodes[n1], nodes[n2]);
return weight_cache[tup];
};
const dis = {};
const fa = {};
const vis = new Set();
const pq = new MinPriorityQueue();
// console.log(`nodes: ${JSON.stringify(nodes)}`);
dis[u] = 0;
pq.push([0, u]);
while (!pq.isEmpty()) {
const [d, v] = pq.pop();
if (vis.has(v) || !ch[v]) continue;
vis.add(v);
const t = ch[v].length;
for (let j = 0; j < t; ++j) {
const c = ch[v][j];
if (!nodes[c]) continue;
const w = get_weight(v, c);
if (!dis[c] || d + w < dis[c]) {
dis[c] = d + w;
pq.push([dis[c], c]);
fa[c] = v;
}
}
}
// console.log(`fa = ${JSON.stringify(fa)}`);
let curr = p;
const res = [p];
// console.log(JSON.stringify(p));
vis.clear();
while (fa[curr]) {
// console.log(JSON.stringify(curr));
curr = fa[curr].toString();
if(vis.has(curr)) {
console.log(`Cycle at ${curr}`);
break;
}
vis.add(curr);
res.push(curr);
}
console.log("finished __spa.");
// console.log(JSON.stringify(res));
return res;
} catch (e) {
console.log(e);
}
}
function shortest_path(nodes, ways, start_point, end_point){
try { // console.log(`Calling shortest_path(${nodes},${ways},${start_point},${end_point})`);
const ch_dict = {};
for (const way_id in ways) {
const l = ways[way_id];
const n = l.length;
for (let i = 1; i < n; ++i) {
if (ch_dict[l[i]]) {
ch_dict[l[i]].push(l[i - 1]);
} else {
ch_dict[l[i]] = [l[i - 1]];
}
if (ch_dict[l[i - 1]]) {
ch_dict[l[i - 1]].push(l[i]);
} else {
ch_dict[l[i - 1]] = [l[i]];
}
}
}
// console.log(ch_dict);
const clean_nodes = {};
Object.keys(nodes).forEach((node_id) => {
if (ch_dict[node_id]) clean_nodes[node_id] = nodes[node_id];
});
const actual_start_node_id = find_nearest_node_id(clean_nodes, start_point);
const actual_end_node_id = find_nearest_node_id(clean_nodes, end_point);
console.log("calling __spa...");
const seq = __spa(clean_nodes, ch_dict, actual_start_node_id, actual_end_node_id);
const res = [end_point];
seq.forEach((node_id) => {
if (clean_nodes[node_id]) res.push(clean_nodes[node_id]);
});
res.push(start_point);
return res;
} catch (e) {
console.log(e);
}
}
export default function handler(req,res){ export default function handler(req,res){
const pts=JSON.parse(req.body); const pts=JSON.parse(req.body);
const latRange=pts.map((row)=>row[0]), const latRange=pts.map((row)=>row[0]),
lonRange=pts.map((row)=>row[1]); lonRange=pts.map((row)=>row[1]);
const minlon=Math.min(...lonRange),minlat=Math.min(...latRange), const minlon=Math.min(...lonRange) - 0.01,minlat=Math.min(...latRange) - 0.01,
maxlon=Math.max(...lonRange),maxlat=Math.max(...latRange); maxlon=Math.max(...lonRange) + 0.01,maxlat=Math.max(...latRange) + 0.01;
const request_uri=`https://www.overpass-api.de/api/interpreter?data=[out:json];node[highway](${minlat},${minlon},${maxlat},${maxlon});out;`; // console.log(`1+1`);
const request_uri=`https://www.overpass-api.de/api/interpreter?data=[out:json];way[highway](${minlat},${minlon},${maxlat},${maxlon});(._;>;);out body;`;
console.log(`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();
}); });
fetch_debug_response.then((debug_response)=>{ fetch_debug_response.then((debug_response)=>{
console.log(debug_response);
let ps = {};
let ws = {};
debug_response.elements.forEach((it)=> {
if (it.type === "node") {
ps[it.id] = [it.lat,it.lon];
} else if (it.type === "way") {
ws[it.id] = it.nodes;
}
});
// console.log(`pts[0]: ${pts[0]}`);
const path_found = shortest_path(ps,ws,pts[0],pts[pts.length - 1]);
// const path_found = [];
// console.log(JSON.stringify(path_found));
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(pts), multipolyline: JSON.stringify(path_found),
// __debug_pts: ps
}); });
}).catch(e=>{ }).catch(e=>{
res.status(500); res.status(500);

View File

@ -1,11 +1,8 @@
const __DEBUG__=1, const __DEBUG__=1,
__APP_VERSION__='v0.1.2a', __APP_VERSION__='v0.1.3a',
__APP_INTRO__=` __APP_INTRO__=`
<b>Relocating Support</b> <b>Right way to follow.</b><br>
Can't find where you are from? We now memorize the last location you visited. Tap the "Relocate" button to find your way home.<br> In this update you can find a shortest route for any given start and destination.<br>
<b>Nearby Search</b>
You can first locate a general area and schedule detailed travel plan later. Tap the magnifier/gear icon to toggle between Nearby Search mode and Global Search mode.
<i>This update also includes several stability and UI improvements.</i>
`; `;
export default function handler(req,res){ export default function handler(req,res){

11667
example/interpreter.json Normal file

File diff suppressed because it is too large Load Diff

217
package-lock.json generated
View File

@ -1,13 +1,14 @@
{ {
"name": "nanomap", "name": "nanomap",
"version": "0.1.0", "version": "0.1.1",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "nanomap", "name": "nanomap",
"version": "0.1.0", "version": "0.1.1",
"dependencies": { "dependencies": {
"@datastructures-js/priority-queue": "^6.3.0",
"@emotion/react": "^11.11.1", "@emotion/react": "^11.11.1",
"@emotion/styled": "^11.11.0", "@emotion/styled": "^11.11.0",
"@mui/icons-material": "^5.14.18", "@mui/icons-material": "^5.14.18",
@ -20,7 +21,10 @@
"react-scripts": "5.0.1" "react-scripts": "5.0.1"
}, },
"devDependencies": { "devDependencies": {
"@babel/plugin-proposal-private-property-in-object": "latest" "@babel/cli": "^7.23.4",
"@babel/core": "^7.23.5",
"@babel/plugin-proposal-private-property-in-object": "latest",
"@babel/preset-flow": "^7.23.3"
} }
}, },
"node_modules/@aashutoshrathi/word-wrap": { "node_modules/@aashutoshrathi/word-wrap": {
@ -54,12 +58,90 @@
"node": ">=6.0.0" "node": ">=6.0.0"
} }
}, },
"node_modules/@babel/code-frame": { "node_modules/@babel/cli": {
"version": "7.22.13", "version": "7.23.4",
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.22.13.tgz", "resolved": "https://registry.npmjs.org/@babel/cli/-/cli-7.23.4.tgz",
"integrity": "sha512-XktuhWlJ5g+3TJXc5upd9Ks1HutSArik6jf2eAjYFyIOf4ej3RN+184cZbzDvbPnuTJIUhPKKJE3cIsYTiAT3w==", "integrity": "sha512-j3luA9xGKCXVyCa5R7lJvOMM+Kc2JEnAEIgz2ggtjQ/j5YUVgfsg/WsG95bbsgq7YLHuiCOzMnoSasuY16qiCw==",
"dev": true,
"dependencies": { "dependencies": {
"@babel/highlight": "^7.22.13", "@jridgewell/trace-mapping": "^0.3.17",
"commander": "^4.0.1",
"convert-source-map": "^2.0.0",
"fs-readdir-recursive": "^1.1.0",
"glob": "^7.2.0",
"make-dir": "^2.1.0",
"slash": "^2.0.0"
},
"bin": {
"babel": "bin/babel.js",
"babel-external-helpers": "bin/babel-external-helpers.js"
},
"engines": {
"node": ">=6.9.0"
},
"optionalDependencies": {
"@nicolo-ribaudo/chokidar-2": "2.1.8-no-fsevents.3",
"chokidar": "^3.4.0"
},
"peerDependencies": {
"@babel/core": "^7.0.0-0"
}
},
"node_modules/@babel/cli/node_modules/commander": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/commander/-/commander-4.1.1.tgz",
"integrity": "sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==",
"dev": true,
"engines": {
"node": ">= 6"
}
},
"node_modules/@babel/cli/node_modules/make-dir": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/make-dir/-/make-dir-2.1.0.tgz",
"integrity": "sha512-LS9X+dc8KLxXCb8dni79fLIIUA5VyZoyjSMCwTluaXA0o27cCK0bhXkpgw+sTXVpPy/lSO57ilRixqk0vDmtRA==",
"dev": true,
"dependencies": {
"pify": "^4.0.1",
"semver": "^5.6.0"
},
"engines": {
"node": ">=6"
}
},
"node_modules/@babel/cli/node_modules/pify": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/pify/-/pify-4.0.1.tgz",
"integrity": "sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==",
"dev": true,
"engines": {
"node": ">=6"
}
},
"node_modules/@babel/cli/node_modules/semver": {
"version": "5.7.2",
"resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz",
"integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==",
"dev": true,
"bin": {
"semver": "bin/semver"
}
},
"node_modules/@babel/cli/node_modules/slash": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/slash/-/slash-2.0.0.tgz",
"integrity": "sha512-ZYKh3Wh2z1PpEXWr0MpSBZ0V6mZHAQfYevttO11c51CaWjGTaadiKZ+wVt1PbMlDV5qhMFslpZCemhwOK7C89A==",
"dev": true,
"engines": {
"node": ">=6"
}
},
"node_modules/@babel/code-frame": {
"version": "7.23.5",
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.23.5.tgz",
"integrity": "sha512-CgH3s1a96LipHCmSUmYFPwY7MNx8C3avkq7i4Wl3cfa662ldtUe4VM1TPXX70pfmrlWTb6jLqTYrZyT2ZTJBgA==",
"dependencies": {
"@babel/highlight": "^7.23.4",
"chalk": "^2.4.2" "chalk": "^2.4.2"
}, },
"engines": { "engines": {
@ -75,20 +157,20 @@
} }
}, },
"node_modules/@babel/core": { "node_modules/@babel/core": {
"version": "7.23.3", "version": "7.23.5",
"resolved": "https://registry.npmjs.org/@babel/core/-/core-7.23.3.tgz", "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.23.5.tgz",
"integrity": "sha512-Jg+msLuNuCJDyBvFv5+OKOUjWMZgd85bKjbICd3zWrKAo+bJ49HJufi7CQE0q0uR8NGyO6xkCACScNqyjHSZew==", "integrity": "sha512-Cwc2XjUrG4ilcfOw4wBAK+enbdgwAcAJCfGUItPBKR7Mjw4aEfAFYrLxeRp4jWgtNIKn3n2AlBOfwwafl+42/g==",
"dependencies": { "dependencies": {
"@ampproject/remapping": "^2.2.0", "@ampproject/remapping": "^2.2.0",
"@babel/code-frame": "^7.22.13", "@babel/code-frame": "^7.23.5",
"@babel/generator": "^7.23.3", "@babel/generator": "^7.23.5",
"@babel/helper-compilation-targets": "^7.22.15", "@babel/helper-compilation-targets": "^7.22.15",
"@babel/helper-module-transforms": "^7.23.3", "@babel/helper-module-transforms": "^7.23.3",
"@babel/helpers": "^7.23.2", "@babel/helpers": "^7.23.5",
"@babel/parser": "^7.23.3", "@babel/parser": "^7.23.5",
"@babel/template": "^7.22.15", "@babel/template": "^7.22.15",
"@babel/traverse": "^7.23.3", "@babel/traverse": "^7.23.5",
"@babel/types": "^7.23.3", "@babel/types": "^7.23.5",
"convert-source-map": "^2.0.0", "convert-source-map": "^2.0.0",
"debug": "^4.1.0", "debug": "^4.1.0",
"gensync": "^1.0.0-beta.2", "gensync": "^1.0.0-beta.2",
@ -145,11 +227,11 @@
} }
}, },
"node_modules/@babel/generator": { "node_modules/@babel/generator": {
"version": "7.23.3", "version": "7.23.5",
"resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.23.3.tgz", "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.23.5.tgz",
"integrity": "sha512-keeZWAV4LU3tW0qRi19HRpabC/ilM0HRBBzf9/k8FFiG4KVpiv0FIy4hHfLfFQZNhziCTPTmd59zoyv6DNISzg==", "integrity": "sha512-BPssCHrBD+0YrxviOa3QzpqwhNIXKEtOa2jQrm4FlmkC2apYgRnQcmPWiGZDlGxiNtltnUFolMe8497Esry+jA==",
"dependencies": { "dependencies": {
"@babel/types": "^7.23.3", "@babel/types": "^7.23.5",
"@jridgewell/gen-mapping": "^0.3.2", "@jridgewell/gen-mapping": "^0.3.2",
"@jridgewell/trace-mapping": "^0.3.17", "@jridgewell/trace-mapping": "^0.3.17",
"jsesc": "^2.5.1" "jsesc": "^2.5.1"
@ -428,9 +510,9 @@
} }
}, },
"node_modules/@babel/helper-string-parser": { "node_modules/@babel/helper-string-parser": {
"version": "7.22.5", "version": "7.23.4",
"resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.22.5.tgz", "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.23.4.tgz",
"integrity": "sha512-mM4COjgZox8U+JcXQwPijIZLElkgEpO5rsERVDJTc2qfCDfERyob6k5WegS14SX18IIjv+XD+GrqNumY5JRCDw==", "integrity": "sha512-803gmbQdqwdf4olxrX4AJyFBV/RTr3rSmOj0rKwesmzlfhYNDEs+/iOcznzpNWlJlIlTJC2QfPFcHB6DlzdVLQ==",
"engines": { "engines": {
"node": ">=6.9.0" "node": ">=6.9.0"
} }
@ -465,22 +547,22 @@
} }
}, },
"node_modules/@babel/helpers": { "node_modules/@babel/helpers": {
"version": "7.23.2", "version": "7.23.5",
"resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.23.2.tgz", "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.23.5.tgz",
"integrity": "sha512-lzchcp8SjTSVe/fPmLwtWVBFC7+Tbn8LGHDVfDp9JGxpAY5opSaEFgt8UQvrnECWOTdji2mOWMz1rOhkHscmGQ==", "integrity": "sha512-oO7us8FzTEsG3U6ag9MfdF1iA/7Z6dz+MtFhifZk8C8o453rGJFFWUP1t+ULM9TUIAzC9uxXEiXjOiVMyd7QPg==",
"dependencies": { "dependencies": {
"@babel/template": "^7.22.15", "@babel/template": "^7.22.15",
"@babel/traverse": "^7.23.2", "@babel/traverse": "^7.23.5",
"@babel/types": "^7.23.0" "@babel/types": "^7.23.5"
}, },
"engines": { "engines": {
"node": ">=6.9.0" "node": ">=6.9.0"
} }
}, },
"node_modules/@babel/highlight": { "node_modules/@babel/highlight": {
"version": "7.22.20", "version": "7.23.4",
"resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.22.20.tgz", "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.23.4.tgz",
"integrity": "sha512-dkdMCN3py0+ksCgYmGG8jKeGA/8Tk+gJwSYYlFGxG5lmhfKNoAy004YpLxpS1W2J8m/EK2Ew+yOs9pVRwO89mg==", "integrity": "sha512-acGdbYSfp2WheJoJm/EBBBLh/ID8KDc64ISZ9DYtBmC8/Q204PZJLHyzeB5qMzJ5trcOkybd78M4x2KWsUq++A==",
"dependencies": { "dependencies": {
"@babel/helper-validator-identifier": "^7.22.20", "@babel/helper-validator-identifier": "^7.22.20",
"chalk": "^2.4.2", "chalk": "^2.4.2",
@ -491,9 +573,9 @@
} }
}, },
"node_modules/@babel/parser": { "node_modules/@babel/parser": {
"version": "7.23.3", "version": "7.23.5",
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.23.3.tgz", "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.23.5.tgz",
"integrity": "sha512-uVsWNvlVsIninV2prNz/3lHCb+5CJ+e+IUBfbjToAHODtfGYLfCFuY4AU7TskI+dAKk+njsPiBjq1gKTvZOBaw==", "integrity": "sha512-hOOqoiNXrmGdFbhgCzu6GiURxUgM27Xwd/aPuu8RfHEZPBzL1Z54okAHAQjXfcQNwvrlkAmAp4SlRTZ45vlthQ==",
"bin": { "bin": {
"parser": "bin/babel-parser.js" "parser": "bin/babel-parser.js"
}, },
@ -1899,6 +1981,23 @@
"semver": "bin/semver.js" "semver": "bin/semver.js"
} }
}, },
"node_modules/@babel/preset-flow": {
"version": "7.23.3",
"resolved": "https://registry.npmjs.org/@babel/preset-flow/-/preset-flow-7.23.3.tgz",
"integrity": "sha512-7yn6hl8RIv+KNk6iIrGZ+D06VhVY35wLVf23Cz/mMu1zOr7u4MMP4j0nZ9tLf8+4ZFpnib8cFYgB/oYg9hfswA==",
"dev": true,
"dependencies": {
"@babel/helper-plugin-utils": "^7.22.5",
"@babel/helper-validator-option": "^7.22.15",
"@babel/plugin-transform-flow-strip-types": "^7.23.3"
},
"engines": {
"node": ">=6.9.0"
},
"peerDependencies": {
"@babel/core": "^7.0.0-0"
}
},
"node_modules/@babel/preset-modules": { "node_modules/@babel/preset-modules": {
"version": "0.1.6-no-external-plugins", "version": "0.1.6-no-external-plugins",
"resolved": "https://registry.npmjs.org/@babel/preset-modules/-/preset-modules-0.1.6-no-external-plugins.tgz", "resolved": "https://registry.npmjs.org/@babel/preset-modules/-/preset-modules-0.1.6-no-external-plugins.tgz",
@ -1979,18 +2078,18 @@
} }
}, },
"node_modules/@babel/traverse": { "node_modules/@babel/traverse": {
"version": "7.23.3", "version": "7.23.5",
"resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.23.3.tgz", "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.23.5.tgz",
"integrity": "sha512-+K0yF1/9yR0oHdE0StHuEj3uTPzwwbrLGfNOndVJVV2TqA5+j3oljJUb4nmB954FLGjNem976+B+eDuLIjesiQ==", "integrity": "sha512-czx7Xy5a6sapWWRx61m1Ke1Ra4vczu1mCTtJam5zRTBOonfdJ+S/B6HYmGYu3fJtr8GGET3si6IhgWVBhJ/m8w==",
"dependencies": { "dependencies": {
"@babel/code-frame": "^7.22.13", "@babel/code-frame": "^7.23.5",
"@babel/generator": "^7.23.3", "@babel/generator": "^7.23.5",
"@babel/helper-environment-visitor": "^7.22.20", "@babel/helper-environment-visitor": "^7.22.20",
"@babel/helper-function-name": "^7.23.0", "@babel/helper-function-name": "^7.23.0",
"@babel/helper-hoist-variables": "^7.22.5", "@babel/helper-hoist-variables": "^7.22.5",
"@babel/helper-split-export-declaration": "^7.22.6", "@babel/helper-split-export-declaration": "^7.22.6",
"@babel/parser": "^7.23.3", "@babel/parser": "^7.23.5",
"@babel/types": "^7.23.3", "@babel/types": "^7.23.5",
"debug": "^4.1.0", "debug": "^4.1.0",
"globals": "^11.1.0" "globals": "^11.1.0"
}, },
@ -1999,11 +2098,11 @@
} }
}, },
"node_modules/@babel/types": { "node_modules/@babel/types": {
"version": "7.23.3", "version": "7.23.5",
"resolved": "https://registry.npmjs.org/@babel/types/-/types-7.23.3.tgz", "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.23.5.tgz",
"integrity": "sha512-OZnvoH2l8PK5eUvEcUyCt/sXgr/h+UWpVuBbOljwcrAgUl6lpchoQ++PHGyQy1AtYnVA6CEq3y5xeEI10brpXw==", "integrity": "sha512-ON5kSOJwVO6xXVRTvOI0eOnWe7VdUcIpsovGo9U/Br4Ie4UVFQTboO2cYnDhAGU6Fp+UxSiT+pMft0SMHfuq6w==",
"dependencies": { "dependencies": {
"@babel/helper-string-parser": "^7.22.5", "@babel/helper-string-parser": "^7.23.4",
"@babel/helper-validator-identifier": "^7.22.20", "@babel/helper-validator-identifier": "^7.22.20",
"to-fast-properties": "^2.0.0" "to-fast-properties": "^2.0.0"
}, },
@ -2286,6 +2385,19 @@
"postcss-selector-parser": "^6.0.10" "postcss-selector-parser": "^6.0.10"
} }
}, },
"node_modules/@datastructures-js/heap": {
"version": "4.3.2",
"resolved": "https://registry.npmjs.org/@datastructures-js/heap/-/heap-4.3.2.tgz",
"integrity": "sha512-7/9QSsIZ+wMG3C9++mz9iOjdtTp9C036PISHvNjG3eyFO8nXOBJQFKgeV7M6/+EPl+oXXFRGBb8Ue60LsqTqGw=="
},
"node_modules/@datastructures-js/priority-queue": {
"version": "6.3.0",
"resolved": "https://registry.npmjs.org/@datastructures-js/priority-queue/-/priority-queue-6.3.0.tgz",
"integrity": "sha512-bJkryPys8zVYMCSjyBPYzJlw5V2kMeOYzGHRBXiGkwqTv8vZ/Ux5RO736T8Y6l3cH+ocbQV9UxlsFwA9qI4VhA==",
"dependencies": {
"@datastructures-js/heap": "^4.3.1"
}
},
"node_modules/@emotion/babel-plugin": { "node_modules/@emotion/babel-plugin": {
"version": "11.11.0", "version": "11.11.0",
"resolved": "https://registry.npmjs.org/@emotion/babel-plugin/-/babel-plugin-11.11.0.tgz", "resolved": "https://registry.npmjs.org/@emotion/babel-plugin/-/babel-plugin-11.11.0.tgz",
@ -3620,6 +3732,13 @@
"resolved": "https://registry.npmjs.org/react-is/-/react-is-18.2.0.tgz", "resolved": "https://registry.npmjs.org/react-is/-/react-is-18.2.0.tgz",
"integrity": "sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==" "integrity": "sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w=="
}, },
"node_modules/@nicolo-ribaudo/chokidar-2": {
"version": "2.1.8-no-fsevents.3",
"resolved": "https://registry.npmjs.org/@nicolo-ribaudo/chokidar-2/-/chokidar-2-2.1.8-no-fsevents.3.tgz",
"integrity": "sha512-s88O1aVtXftvp5bCPB7WnmXc5IwOZZ7YPuwNPt+GtOOXpPvad1LfbmjYv+qII7zP6RU2QGnqve27dnLycEnyEQ==",
"dev": true,
"optional": true
},
"node_modules/@nicolo-ribaudo/eslint-scope-5-internals": { "node_modules/@nicolo-ribaudo/eslint-scope-5-internals": {
"version": "5.1.1-v1", "version": "5.1.1-v1",
"resolved": "https://registry.npmjs.org/@nicolo-ribaudo/eslint-scope-5-internals/-/eslint-scope-5-internals-5.1.1-v1.tgz", "resolved": "https://registry.npmjs.org/@nicolo-ribaudo/eslint-scope-5-internals/-/eslint-scope-5-internals-5.1.1-v1.tgz",
@ -8480,6 +8599,12 @@
"resolved": "https://registry.npmjs.org/fs-monkey/-/fs-monkey-1.0.5.tgz", "resolved": "https://registry.npmjs.org/fs-monkey/-/fs-monkey-1.0.5.tgz",
"integrity": "sha512-8uMbBjrhzW76TYgEV27Y5E//W2f/lTFmx78P2w19FZSxarhI/798APGQyuGCwmkNxgwGRhrLfvWyLBvNtuOmew==" "integrity": "sha512-8uMbBjrhzW76TYgEV27Y5E//W2f/lTFmx78P2w19FZSxarhI/798APGQyuGCwmkNxgwGRhrLfvWyLBvNtuOmew=="
}, },
"node_modules/fs-readdir-recursive": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/fs-readdir-recursive/-/fs-readdir-recursive-1.1.0.tgz",
"integrity": "sha512-GNanXlVr2pf02+sPN40XN8HG+ePaNcvM0q5mZBd668Obwb0yD5GiUbZOFgwn8kGMY6I3mdyDJzieUy3PTYyTRA==",
"dev": true
},
"node_modules/fs.realpath": { "node_modules/fs.realpath": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",

View File

@ -3,6 +3,7 @@
"version": "0.1.1", "version": "0.1.1",
"private": true, "private": true,
"dependencies": { "dependencies": {
"@datastructures-js/priority-queue": "^6.3.0",
"@emotion/react": "^11.11.1", "@emotion/react": "^11.11.1",
"@emotion/styled": "^11.11.0", "@emotion/styled": "^11.11.0",
"@mui/icons-material": "^5.14.18", "@mui/icons-material": "^5.14.18",
@ -15,7 +16,10 @@
"react-scripts": "5.0.1" "react-scripts": "5.0.1"
}, },
"devDependencies": { "devDependencies": {
"@babel/plugin-proposal-private-property-in-object": "latest" "@babel/cli": "^7.23.4",
"@babel/core": "^7.23.5",
"@babel/plugin-proposal-private-property-in-object": "latest",
"@babel/preset-flow": "^7.23.3"
}, },
"scripts": { "scripts": {
"start": "react-scripts start", "start": "react-scripts start",

View File

@ -109,13 +109,18 @@ function MapClickHandler({mks,focusUpdater,locator,locker}) {
post('POST', 'click', mks.current.state.markers).then((response) => { post('POST', 'click', mks.current.state.markers).then((response) => {
// TODO: real functionality // TODO: real functionality
const pl = JSON.parse(response.multipolyline); const pl = JSON.parse(response.multipolyline);
mks.current.flushPolylines(pl); // DEBUG
// response.__debug_pts.forEach(({lat,lon})=>{
// mks.current.addCandMarker(lat,lon);
// });
console.log(`pl = ${JSON.stringify(pl)}`);
if (pl.length > 1) mks.current.flushPolylines(pl);
focusUpdater([lat,lng]); focusUpdater([lat,lng]);
locator([lat,lng]); locator([lat,lng]);
locker(true); locker(true);
}).catch((e) => { }).catch((e) => {
console.error(e); console.error(e);
location.reload(); // location.reload();
}); });
}, },
// TODO // TODO

2
test/test_nearest.js Normal file
View File

@ -0,0 +1,2 @@
import shortestPath from "../comp/ShortestPath.js";
console.log('Hello!');