Browse Source

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

master
wangxiang 3 years ago
parent
commit
94471f28b0
  1. 77
      src/components/AMap/src/TaskModal.vue

77
src/components/AMap/src/TaskModal.vue

@ -34,6 +34,7 @@
import { BasicTable, useTable, EditRecordRow, BasicColumn, ActionItem, TableAction } from '/@/components/Table'; import { BasicTable, useTable, EditRecordRow, BasicColumn, ActionItem, TableAction } from '/@/components/Table';
import { formTaskColumns, formSchemeColumns, largeHospitalMapList, smallHospitalMapList, } from './map.data'; import { formTaskColumns, formSchemeColumns, largeHospitalMapList, smallHospitalMapList, } from './map.data';
import { buildUUID } from '/@/utils/uuid'; import { buildUUID } from '/@/utils/uuid';
import { add, divide } from 'lodash-es';
/** 类型规范统一声明定义区域 */ /** 类型规范统一声明定义区域 */
interface WindowState { interface WindowState {
@ -151,46 +152,70 @@
const scheme = []; const scheme = [];
const origin = state.formData.takeSpecimenId; const origin = state.formData.takeSpecimenId;
//
const taskDataSource = getDataSource(); const taskDataSource = getDataSource();
const smallHospitals = Array<any>(); const smallHospitalPositions = Array<any>();
const largeHospitals = Array<any>(); const largeHospitalPositions = Array<any>();
taskDataSource.forEach(item => { taskDataSource.forEach(item => {
// ID
const key = buildUUID(); const key = buildUUID();
smallHospitals.push({ const smallHospital = smallHospitalMapList.find(index => index.id == item.smallHospitalId);
key: key, if(smallHospital) smallHospitalPositions.push([key, new AMap.LngLat(smallHospital.lng, smallHospital.lat)]);
smallHospitalId: item.smallHospitalId, const largeHospital = largeHospitalMapList.find(index => index.id == item.largeHospitalId);
workable: false if(largeHospital) largeHospitalPositions.push([key, new AMap.LngLat(largeHospital.lng, largeHospital.lat)]);
});
largeHospitals.push({
key: key,
largeHospitalId: item.largeHospitalId,
workable: false
});
}); });
// //
const waypoints = Array<any>(); const waypoints = Array<any>();
// //
let destination; let destination;
// ,0
const smallHospitalScheme = Array.from({ length: smallHospitalPositions.length }, () => Array(smallHospitalPositions.length).fill(0));
// for(let i = 0; i < smallHospitalPositions.length; ++i) {
smallHospitals.forEach(small => { // ,
const smallHospital = smallHospitalMapList.find(index => index.id == small.smallHospitalId); const oneDimensionArray = smallHospitalScheme[i];
if(smallHospital) { // ,
small.workable = true; let indexs = Object.keys(smallHospitalPositions);
waypoints.push(new AMap.LngLat(smallHospital.lng, smallHospital.lat)); const reverseIndexs = indexs.slice(0, i);
indexs.splice(0, i);
indexs.push(...reverseIndexs);
//
for(let j = 0; j < indexs.length; ++j) {
const index = indexs[j];
const smallHospitalPosition = smallHospitalPositions[index];
oneDimensionArray[j] = smallHospitalPosition;
} }
largeHospitals.forEach(large => { }
const largeHospital = largeHospitalMapList.find(index => index.id == large.largeHospitalId);
largeHospital
}); //
}) for (let i = 0; i < smallHospitalScheme.length; ++i) {
}
//
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 => {
// ,,
if(waypoints.find(waypoint => waypoint[0] == large.key)){
const largeHospital = largeHospitalMapList.find(index => index.id == large.largeHospitalId);
if(largeHospital) waypoints.push([large.key, new AMap.LngLat(largeHospital.lng, largeHospital.lat)]);
}
});
}
}
} }

Loading…
Cancel
Save