Browse Source

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

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

75
src/components/AMap/src/TaskModal.vue

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

Loading…
Cancel
Save