Browse Source

🔥 高德地图动态计算规划路线算法 todo

master
wangxiang 3 years ago
parent
commit
59cd28b053
  1. 2
      package.json
  2. 70
      src/components/AMap/src/TaskModal.vue

2
package.json

@ -11,7 +11,7 @@
"dev": "vite", "dev": "vite",
"lint:check": "eslint --max-warnings 0 \"src/**/*.{vue,ts,tsx}\"", "lint:check": "eslint --max-warnings 0 \"src/**/*.{vue,ts,tsx}\"",
"lint:eslint": "eslint --cache --max-warnings 0 \"src/**/*.{vue,ts,tsx}\" --fix", "lint:eslint": "eslint --cache --max-warnings 0 \"src/**/*.{vue,ts,tsx}\" --fix",
"build": "yarn lint:check && cross-env NODE_ENV=production vite build && esno ./build/script/postBuild.ts", "build": "cross-env NODE_ENV=production vite build && esno ./build/script/postBuild.ts",
"build:test": "yarn lint:check && vite build --mode test && esno ./build/script/postBuild.ts", "build:test": "yarn lint:check && vite build --mode test && esno ./build/script/postBuild.ts",
"build:no-cache": "yarn delete:cache && yarn build", "build:no-cache": "yarn delete:cache && yarn build",
"preview": "yarn run build && vite preview", "preview": "yarn run build && vite preview",

70
src/components/AMap/src/TaskModal.vue

@ -154,8 +154,8 @@
const origin = state.formData.takeSpecimenId; const origin = state.formData.takeSpecimenId;
// //
const taskDataSource = getDataSource(); const taskDataSource = getDataSource();
const smallHospitalPositions = Array<any>(); const smallHospitalPositions:any[] = [];
const largeHospitalPositions = Array<any>(); const largeHospitalPositions:any[] = [];
taskDataSource.forEach(item => { taskDataSource.forEach(item => {
// ID // ID
const key = buildUUID(); const key = buildUUID();
@ -165,11 +165,13 @@
if(largeHospital) largeHospitalPositions.push([key, new AMap.LngLat(largeHospital.lng, largeHospital.lat)]); if(largeHospital) largeHospitalPositions.push([key, new AMap.LngLat(largeHospital.lng, largeHospital.lat)]);
}); });
// //
const waypoints = Array<any>(); const waypoints:any[] = [];
// //
let destination; let destination;
// ,0 /** 1.计算预测大致的智能规划方案可行性数量 */
//
const smallHospitalScheme = Array.from({ length: smallHospitalPositions.length }, () => Array(smallHospitalPositions.length).fill(0)); const smallHospitalScheme = Array.from({ length: smallHospitalPositions.length }, () => Array(smallHospitalPositions.length).fill(0));
for(let i = 0; i < smallHospitalPositions.length; ++i) { for(let i = 0; i < smallHospitalPositions.length; ++i) {
// , // ,
@ -187,39 +189,45 @@
} }
} }
// //
for (let i = 0; i < smallHospitalScheme.length; ++i) { const composeScheme = mapSchemePermuteUnique([]);
}
}
//
for(let i = 0; i < smallHospitals.length; ++i) {
const composeCycle = add(i,1);
const hospitalCycle = Math.ceil(divide(smallHospitals.length, composeCycle));
for(let j = 0; j < hospitalCycle; ++j) {
for(let k = 0; k < composeCycle; ++k) {
const index = add(j, k);
const small = smallHospitals[index];
const smallHospital = smallHospitalMapList.find(index => index.id == small.smallHospitalId);
if(smallHospital) waypoints.push([small.key, new AMap.LngLat(smallHospital.lng, smallHospital.lat)]);
}
for (let k = 0; k < ; ++k) {
} /** 地图方案组合排列算法,可确保二叉树当存在数组内容相同排列不重复 */
largeHospitals.forEach(large => { function mapSchemePermuteUnique(composeQueue: number[]) {
// ,, const ans: number[][] = [];
if(waypoints.find(waypoint => waypoint[0] == large.key)){ const arr: number[] = [];
const largeHospital = largeHospitalMapList.find(index => index.id == large.largeHospitalId); const used: boolean[] = [];
if(largeHospital) waypoints.push([large.key, new AMap.LngLat(largeHospital.lng, largeHospital.lat)]); function helper() {
} // 退
}); if (arr.length === composeQueue.length) {
ans.push(arr.slice(0));
return;
}
// ,,
let last: unknown = undefined;
for (let i = 0; i < composeQueue.length; i++){
//
if (used[i]) continue;
// ,
if (last == composeQueue[i]) continue;
// 使
last = composeQueue[i];
used[i] = true;
//
arr.push(composeQueue[i]);
//
helper();
//
arr.pop();
used[i] = false;
} }
} }
helper();
return ans;
} }
/** 处理路线预览 */ /** 处理路线预览 */
function handlePathPreview() { function handlePathPreview() {

Loading…
Cancel
Save