fix: bound detection QA to inference coverage
This commit is contained in:
@@ -8,6 +8,7 @@ from uuid import UUID
|
||||
from geoalchemy2.shape import to_shape
|
||||
from shapely.geometry import GeometryCollection
|
||||
from shapely.geometry.base import BaseGeometry
|
||||
from shapely.strtree import STRtree
|
||||
from shapely.ops import unary_union
|
||||
from shapely.validation import make_valid
|
||||
from shapely.geometry import shape
|
||||
@@ -160,7 +161,10 @@ class QaService:
|
||||
],
|
||||
)
|
||||
|
||||
unmatched_reference_indices = set(range(len(reference_supported)))
|
||||
reference_tree = STRtree([geometry for _, _, geometry in reference_supported])
|
||||
unmatched_reference_indices = {
|
||||
index for index, (_, _, geometry) in enumerate(reference_supported) if geometry.area > 0
|
||||
}
|
||||
evidence = QaMatchEvidence(warnings=[f"Unsupported geometry types: {unsupported}"] if unsupported else [], unsupported=bool(unsupported))
|
||||
|
||||
for source_index, source_feature, source_geom in source_supported:
|
||||
@@ -172,11 +176,11 @@ class QaService:
|
||||
|
||||
best_iou = 0.0
|
||||
best_index = None
|
||||
for reference_index in list(unmatched_reference_indices):
|
||||
_, _, reference_geom = reference_supported[reference_index]
|
||||
if reference_geom.area <= 0:
|
||||
unmatched_reference_indices.discard(reference_index)
|
||||
candidate_reference_indices = sorted(int(index) for index in reference_tree.query(source_geom))
|
||||
for reference_index in candidate_reference_indices:
|
||||
if reference_index not in unmatched_reference_indices:
|
||||
continue
|
||||
_, _, reference_geom = reference_supported[reference_index]
|
||||
try:
|
||||
intersection = source_geom.intersection(reference_geom)
|
||||
except Exception as exc: # pragma: no cover - robustness path
|
||||
|
||||
Reference in New Issue
Block a user