Prefer link endpoints for legacy accident IDs and allow explicit node selection. Read authoritative initial statuses and sources, verify source isolation, and separate direct isolation from newly disconnected supply nodes. Return validation errors as HTTP 422. The node-first lookup misrouted adjacent Fengyang pipes 19025 and 19026 into unrelated regions. Regression cases fail against the previous algorithm and pass after this change.
23 lines
743 B
Python
23 lines
743 B
Python
from typing import Any
|
|
|
|
from app.algorithms.valve_isolation.topology_search import (
|
|
AccidentElementType,
|
|
valve_isolation_analysis,
|
|
)
|
|
from app.native.wndb.gis.network_views import get_valve_isolation_topology
|
|
|
|
|
|
def analyze_valve_isolation(
|
|
network: str,
|
|
accident_element: str | list[str],
|
|
disabled_valves: list[str] | None = None,
|
|
accident_element_type: AccidentElementType = "auto",
|
|
) -> dict[str, Any]:
|
|
link_entries, source_nodes, closed_links = get_valve_isolation_topology(network)
|
|
return valve_isolation_analysis(
|
|
link_entries, accident_element, disabled_valves,
|
|
accident_element_type=accident_element_type,
|
|
water_source_nodes=source_nodes,
|
|
closed_links=closed_links,
|
|
)
|