Preserve offline geometry, marking, replay and evaluation pipelines with source manifests and synthetic tests. Research qualification does not activate these methods as production navigation.
25 lines
1.3 KiB
Python
25 lines
1.3 KiB
Python
"""Whole measured stroke ownership; retain positive paint during replacement."""
|
|
import numpy as np
|
|
import shapely
|
|
from shapely.geometry import shape
|
|
from marking_rules import plan_replacement,validate_removed,isolated_addition,POLICY
|
|
|
|
|
|
def replacement(candidate,current,readers):
|
|
p=candidate['polygons'][0]
|
|
proposal={**candidate,'domain':p.buffer(POLICY['max_join_gap_m'])}
|
|
plan=plan_replacement(proposal,current)
|
|
if plan is None:return None,dict(reason='incompatible-ownership')
|
|
ids,polygons=plan
|
|
old=shapely.union_all([shapely.force_2d(shape(current[i]['geometry']))for i in ids])
|
|
removed=old.difference(p.buffer(POLICY['retained_paint_tolerance_m']))
|
|
if not removed.is_empty:
|
|
axis=candidate['axis'];normal=np.array([-axis[1],axis[0]])
|
|
transverse=(shapely.get_coordinates(removed)-candidate['origin'])@normal
|
|
if np.max(abs(transverse))>.7:return None,dict(reason='removed-paint-outside-measurement')
|
|
okay,evidence=validate_removed(old,p,candidate,readers)
|
|
if not okay:return None,dict(reason='positive-or-unobserved-removed-paint',views=evidence)
|
|
rest={i:f for i,f in current.items()if i not in ids}
|
|
if not isolated_addition(p,rest):return None,dict(reason='unresolved-neighbor-seam')
|
|
return ids,dict(reason='retained-or-two-view-dark',views=evidence)
|