运行图编制 折返数据解析 代码调整

This commit is contained in:
joylink_cuiweidong 2021-03-30 11:26:25 +08:00
parent 770bdff791
commit 0fb623ef59
2 changed files with 118 additions and 110 deletions

View File

@ -7,34 +7,34 @@ const defaultConfig = {
/** 间隔高度*/
multiple: 3,
/** 偏移时间*/
translation: 60 * 60 * 2,
}
translation: 60 * 60 * 2
};
class EqualDistanceParser {
constructor() {
}
constructor() {
}
/** 加载配置*/
load(config = defaultConfig) {
this.config = config;
this.multiple = config.multiple;
this.translation = config.translation;
this.edge = config.edge;
return this;
}
/** 加载配置*/
load(config = defaultConfig) {
this.config = config;
this.multiple = config.multiple;
this.translation = config.translation;
this.edge = config.edge;
return this;
}
/** 解析excel数据转换为Json后台数据*/
importData(sheet, data) {
if (this.config &&
/** 解析excel数据转换为Json后台数据*/
importData(sheet, data) {
if (this.config &&
this.config.importData) {
this.config.importData(sheet, data)
} else {
console.info('no import data function');
}
}
this.config.importData(sheet, data);
} else {
console.info('no import data function');
}
}
/** 将后台数据解析成图表*/
convertDataToModels(data, stations, kmRangeMap, lineStyle) {
/** 将后台数据解析成图表*/
convertDataToModels(data, stations, kmRangeMap, lineStyle) {
var models = [];
if (data && data.serviceNumberDataList && data.serviceNumberDataList.length) {
@ -74,12 +74,16 @@ class EqualDistanceParser {
/** 计算折返点车次坐标点集合*/
if (!train.backup && train.reentry && service.tripNumberDataList[j + 1] && service.tripNumberDataList[j + 1].stationTimeList) {
lastPoint = train.stationTimeList[idx];
nextPoint = service.tripNumberDataList[j + 1].stationTimeList[0];
// ${train.directionCode}
const aa = `${train.tripNumber}`;
opt.data.push([lastPoint.secondTime, this.getCoordYByElem(stations, kmRangeMap, lastPoint, pointdata.directionCode, true), lastPoint.stationCode, aa, '折返轨']);
opt.data.push([nextPoint.secondTime, this.getCoordYByElem(stations, kmRangeMap, lastPoint, pointdata.directionCode, true), lastPoint.stationCode, aa, '折返轨']);
const currentTimeList = service.tripNumberDataList[j].stationTimeList;
const nextTimeList = service.tripNumberDataList[j + 1].stationTimeList;
if (currentTimeList[currentTimeList.length - 1].secondTime != nextTimeList[0].secondTime) {
lastPoint = train.stationTimeList[idx];
nextPoint = service.tripNumberDataList[j + 1].stationTimeList[0];
// ${train.directionCode}
const aa = `${train.tripNumber}`;
opt.data.push([lastPoint.secondTime, this.getCoordYByElem(stations, kmRangeMap, lastPoint, pointdata.directionCode, true), lastPoint.stationCode, aa, '折返轨']);
opt.data.push([nextPoint.secondTime, this.getCoordYByElem(stations, kmRangeMap, lastPoint, pointdata.directionCode, true), lastPoint.stationCode, aa, '折返轨']);
}
}
/** 如果是备用车,按车次添加线*/
@ -232,11 +236,11 @@ class EqualDistanceParser {
/** 根据方向计算y折返偏移量*/
getValueYByDirectionCode(defaultValue, directionCode) {
const sign = this.getReverse() ? -1 : 1;
const sign = this.getReverse() ? -1 : 1;
if (directionCode === '1') {
defaultValue -= sign*this.getEdge() / 2;
defaultValue -= sign * this.getEdge() / 2;
} else if (directionCode === '2') {
defaultValue += sign*this.getEdge() / 2;
defaultValue += sign * this.getEdge() / 2;
}
return defaultValue;
@ -256,33 +260,33 @@ class EqualDistanceParser {
return defaultValue;
}
getMultiple() {
return this.config.multiple;
}
getMultiple() {
return this.config.multiple;
}
getTranslation() {
return this.config.translation
}
getTranslation() {
return this.config.translation;
}
getEdge(){
return this.config.edge;
}
getEdge() {
return this.config.edge;
}
getReverse() {
return this.config.reverse;
}
getReverse() {
return this.config.reverse;
}
__createMartPoint(...args) {
return this.config.reverse ? createMartPointReverse(...args): createMartPoint(...args);
}
__createMartPoint(...args) {
return this.config.reverse ? createMartPointReverse(...args) : createMartPoint(...args);
}
__createSeriesModel(...args) {
return createSeriesModel(...args);
}
__createSeriesModel(...args) {
return createSeriesModel(...args);
}
__createMarkLineModels(...args) {
return createMarkLineModels(...args);
}
__createMarkLineModels(...args) {
return createMarkLineModels(...args);
}
}
export default EqualDistanceParser;

View File

@ -2,40 +2,40 @@ import { createSeriesModel, createMarkLineModels, createMartPoint, createMartPoi
import store from '@/store/index';
const defaultConfig = {
/** 最小时间*/
minTime: 0,
/** 最大时间*/
maxTime: 3600 * 24 - 1,
/** 边缘高度*/
edge: 600,
/** 间隔高度*/
multiple: 1,
/** 偏移时间*/
translation: 0,
}
/** 最小时间*/
minTime: 0,
/** 最大时间*/
maxTime: 3600 * 24 - 1,
/** 边缘高度*/
edge: 600,
/** 间隔高度*/
multiple: 1,
/** 偏移时间*/
translation: 0
};
class EqualRatioParser {
constructor() {
}
constructor() {
}
/** 加载配置*/
load(config = defaultConfig) {
this.config = config;
return this;
}
/** 加载配置*/
load(config = defaultConfig) {
this.config = config;
return this;
}
/** 解析excel数据转换为Json后台数据*/
importData(sheet, data) {
if (this.config &&
/** 解析excel数据转换为Json后台数据*/
importData(sheet, data) {
if (this.config &&
this.config.importData) {
this.config.importData(sheet, data)
} else {
console.info('no import data function');
}
}
this.config.importData(sheet, data);
} else {
console.info('no import data function');
}
}
/** 将后台数据解析成图表*/
convertDataToModels(data, stations, kmRangeMap, lineStyle) {
/** 将后台数据解析成图表*/
convertDataToModels(data, stations, kmRangeMap, lineStyle) {
var models = [];
if (data && data.serviceNumberDataList && data.serviceNumberDataList.length) {
/** 按服务遍历数据*/
@ -74,19 +74,23 @@ class EqualRatioParser {
// if (index == 0 && train.stationTimeList[index].stationCode != train.stationTimeList[index + 1].stationCode ||
// index == train.stationTimeList.length - 2 && train.stationTimeList[index].secondTime != train.stationTimeList[index + 1].secondTime ||
// index > 0 && index < train.stationTimeList.length - 1) {
const aa = `${train.tripNumber}`;
opt.data.push([elem.secondTime, this.getCoordYByElem(stations, kmRangeMap, elem, pointdata.directionCode, false), elem.stationCode, aa]);
const aa = `${train.tripNumber}`;
opt.data.push([elem.secondTime, this.getCoordYByElem(stations, kmRangeMap, elem, pointdata.directionCode, false), elem.stationCode, aa]);
// }
});
/** 计算折返点车次坐标点集合*/
if (!train.backup && train.reentry && service.tripNumberDataList[j + 1] && service.tripNumberDataList[j + 1].stationTimeList) {
lastPoint = train.stationTimeList[train.stationTimeList.length - 1];
nextPoint = service.tripNumberDataList[j + 1].stationTimeList[0];
num = this.computedReentryNumber(train.tripNumber);
const aa = `${train.tripNumber}`;
opt.data.push([lastPoint.secondTime, this.getCoordYByElem(stations, kmRangeMap, lastPoint, pointdata.directionCode, true, num), lastPoint.stationCode, aa]);
opt.data.push([nextPoint.secondTime, this.getCoordYByElem(stations, kmRangeMap, nextPoint, pointdata.directionCode, true, num), nextPoint.stationCode, aa]);
const currentTimeList = service.tripNumberDataList[j].stationTimeList;
const nextTimeList = service.tripNumberDataList[j + 1].stationTimeList;
if (currentTimeList[currentTimeList.length - 1].secondTime != nextTimeList[0].secondTime) {
lastPoint = train.stationTimeList[train.stationTimeList.length - 1];
nextPoint = service.tripNumberDataList[j + 1].stationTimeList[0];
num = this.computedReentryNumber(train.tripNumber);
const aa = `${train.tripNumber}`;
opt.data.push([lastPoint.secondTime, this.getCoordYByElem(stations, kmRangeMap, lastPoint, pointdata.directionCode, true, num), lastPoint.stationCode, aa]);
opt.data.push([nextPoint.secondTime, this.getCoordYByElem(stations, kmRangeMap, nextPoint, pointdata.directionCode, true, num), nextPoint.stationCode, aa]);
}
}
/** 如果是备用车,按车次添加线*/
@ -246,7 +250,7 @@ class EqualRatioParser {
/** 根据方向计算y折返偏移量*/
getValueYByDirectionCode(defaultValue, directionCode, num) {
const sign = this.getReverse() ? -1 : 1;
const sign = this.getReverse() ? -1 : 1;
if (directionCode === '1') {
defaultValue -= sign * this.getEdge() / 2 * num;
} else if (directionCode === '2') {
@ -270,33 +274,33 @@ class EqualRatioParser {
return defaultValue;
}
getMultiple() {
return this.config.multiple;
}
getMultiple() {
return this.config.multiple;
}
getTranslation() {
return this.config.translation
}
getTranslation() {
return this.config.translation;
}
getEdge(){
return this.config.edge;
}
getEdge() {
return this.config.edge;
}
getReverse() {
return this.config.reverse;
}
getReverse() {
return this.config.reverse;
}
__createMartPoint(...args) {
return this.config.reverse ? createMartPointReverse(...args): createMartPoint(...args);
}
__createMartPoint(...args) {
return this.config.reverse ? createMartPointReverse(...args) : createMartPoint(...args);
}
__createSeriesModel(...args) {
return createSeriesModel(...args);
}
__createSeriesModel(...args) {
return createSeriesModel(...args);
}
__createMarkLineModels(...args) {
return createMarkLineModels(...args);
}
__createMarkLineModels(...args) {
return createMarkLineModels(...args);
}
}
export default EqualRatioParser;