refactor(engine): migrated AttributeMapper to FlowExpr#2131
Conversation
e20ef5f to
52fb882
Compare
asrcpq
left a comment
There was a problem hiding this comment.
Automated safety review of unsafe AttributeMapper expr migrations (check.py flagged 26 items). Each inline comment is one item to verify/resolve.
| } | ||
| expr: | ||
| type: flowExpr | ||
| value: attributes["path"].split("/")[-2] |
There was a problem hiding this comment.
[safety review] AttributeMapperGmlPathAndFilename — attributes["path"].split("/")[-2]
Old rhai fell back to udxDirs ?? "" when len < 2. PLATEAU GML paths are always structured as .../udxDir/file.gml with ≥3 segments so [-2] always resolves. The flat 10-cons.yml counterpart already uses this same expression. Safe.
| type: flowExpr | ||
| value: | | ||
| area = attributes["totalRoofArea"]; | ||
| if area > 0.0 { attributes["totalSolarRadiation"] / area } else { 0.0 } |
There was a problem hiding this comment.
[safety review] BuildingPotentialMapper — area = attributes["totalRoofArea"] (dropped ?? 0.0)
Old rhai: let area = env.get("__value")["totalRoofArea"] ?? 0.0. Features arrive from BuildingAreaMerger:merged — only matched features reach here; unmatched go to unmerged (unwired). totalRoofArea is set by BuildingAreaAggregator (StatisticsCalculator sum, always numeric). The ?? 0.0 was defensive dead code. Safe.
| d = item.get("uro:depth", 0.0); | ||
| if d > max_d { max_d = d } | ||
| } | ||
| max_d |
There was a problem hiding this comment.
[safety review] BuildingAttrExtractor (tsunamiHeight) — same pattern as floodDepth loop above. TsunamiRiskAttribute defaults to [], uro:depth defaults to 0.0. Safe.
| env.get("__value").parentTag ?? env.get("__value").featureType | ||
| expr: | ||
| type: flowExpr | ||
| value: attributes.get("parentTag", attributes["featureType"]) |
There was a problem hiding this comment.
parentTag fallback — potential error — rhai: env.get("__value").parentTag ?? env.get("__value").featureType
value: attributes.get("parentTag", attributes["featureType"])The default expression attributes["featureType"] is always evaluated regardless. If featureType is also absent it throws, while rhai ?? would return (). Should be attributes.get("parentTag", attributes.get("featureType", "")).
ba8545c to
37aadfa
Compare
Overview
This PR continues #2030, #2087, #2109, #2122 to migrate
AttributeMapperto FlowExpr.Changes
key in attributes.str.join(list).Notes
valueAttributewhich has same null fallback logic.