更新遗传算法默认参数;更新漏损流量单位为m3/h
This commit is contained in:
@@ -11,6 +11,9 @@ export const AREA_COLORS = [
|
||||
"#be123c",
|
||||
];
|
||||
|
||||
export const DMA_FLOW_DISPLAY_UNIT = "m3/h";
|
||||
const M3H_FACTOR = 3600;
|
||||
|
||||
export const getAreaColor = (areaId: string | number | undefined) => {
|
||||
const text = String(areaId ?? "");
|
||||
let hash = 0;
|
||||
@@ -19,3 +22,17 @@ export const getAreaColor = (areaId: string | number | undefined) => {
|
||||
}
|
||||
return AREA_COLORS[hash % AREA_COLORS.length];
|
||||
};
|
||||
|
||||
export const toM3h = (value: number, sourceUnit: string = "m3/s") => {
|
||||
if (!Number.isFinite(value)) return Number.NaN;
|
||||
const normalizedUnit = sourceUnit.trim().toLowerCase();
|
||||
if (normalizedUnit === "m3/h") return value;
|
||||
return value * M3H_FACTOR;
|
||||
};
|
||||
|
||||
export const toM3s = (value: number, sourceUnit: string = "m3/h") => {
|
||||
if (!Number.isFinite(value)) return Number.NaN;
|
||||
const normalizedUnit = sourceUnit.trim().toLowerCase();
|
||||
if (normalizedUnit === "m3/s") return value;
|
||||
return value / M3H_FACTOR;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user