转换实际需水量单位为 m³/h,优化数据展示
This commit is contained in:
@@ -33,6 +33,7 @@ import { Icon, Style } from "ol/style.js";
|
||||
import { FeatureLike } from "ol/Feature";
|
||||
import { Point } from "ol/geom";
|
||||
import { ContourLayer } from "deck.gl";
|
||||
import { toM3h } from "@utils/units";
|
||||
|
||||
interface MapComponentProps {
|
||||
children?: React.ReactNode;
|
||||
@@ -151,7 +152,12 @@ const MapComponent: React.FC<MapComponentProps> = ({ children }) => {
|
||||
const nodeMap = new Map(currentJunctionCalData.map((r: any) => [r.ID, r]));
|
||||
return junctionData.map((j) => {
|
||||
const record = nodeMap.get(j.id);
|
||||
return record ? { ...j, [junctionText]: record.value } : j;
|
||||
let val = record ? record.value : undefined;
|
||||
// 在这合并时将实际需水量从 LPS 转换为大写表示
|
||||
if (val !== undefined && junctionText === "actualdemand") {
|
||||
val = toM3h(val, "lps");
|
||||
}
|
||||
return record ? { ...j, [junctionText]: val } : j;
|
||||
});
|
||||
}, [junctionData, currentJunctionCalData, junctionText]);
|
||||
|
||||
@@ -161,9 +167,13 @@ const MapComponent: React.FC<MapComponentProps> = ({ children }) => {
|
||||
const record = linkMap.get(p.id);
|
||||
if (!record) return p;
|
||||
const isFlow = pipeText === "flow";
|
||||
let val = record.value;
|
||||
if (val !== undefined && isFlow) {
|
||||
val = toM3h(val, "lps");
|
||||
}
|
||||
return {
|
||||
...p,
|
||||
[pipeText]: isFlow ? Math.abs(record.value) : record.value,
|
||||
[pipeText]: isFlow ? Math.abs(val) : val,
|
||||
flowFlag: isFlow && record.value < 0 ? -1 : 1,
|
||||
path: isFlow && record.value < 0 ? [...p.path].reverse() : p.path,
|
||||
};
|
||||
@@ -790,15 +800,7 @@ const MapComponent: React.FC<MapComponentProps> = ({ children }) => {
|
||||
let propPart = "";
|
||||
if (showJunctionTextLayer && d[junctionText] !== undefined) {
|
||||
const value = (d[junctionText] as number).toFixed(3);
|
||||
// 根据属性类型添加符号前缀
|
||||
const prefix =
|
||||
{
|
||||
pressure: "P:",
|
||||
head: "H:",
|
||||
quality: "Q:",
|
||||
actualdemand: "D:",
|
||||
}[junctionText] || "";
|
||||
propPart = `${prefix}${value}`;
|
||||
propPart = `${value}`;
|
||||
}
|
||||
if (idPart && propPart) return `${idPart} - ${propPart}`;
|
||||
return idPart || propPart;
|
||||
@@ -850,17 +852,7 @@ const MapComponent: React.FC<MapComponentProps> = ({ children }) => {
|
||||
} else {
|
||||
value = Math.abs(d[pipeText] as number).toFixed(3);
|
||||
}
|
||||
// 根据属性类型添加符号前缀
|
||||
const prefix =
|
||||
{
|
||||
flow: "F:",
|
||||
velocity: "V:",
|
||||
headloss: "HL:",
|
||||
unit_headloss: "UHL:",
|
||||
diameter: "D:",
|
||||
friction: "FR:",
|
||||
}[pipeText] || "";
|
||||
propPart = `${prefix}${value}`;
|
||||
propPart = `${value}`;
|
||||
}
|
||||
if (idPart && propPart) return `${idPart} - ${propPart}`;
|
||||
return idPart || propPart;
|
||||
|
||||
Reference in New Issue
Block a user