feat(research): preserve urban geometry pipelines and qualification suites
Preserve offline geometry, marking, replay and evaluation pipelines with source manifests and synthetic tests. Research qualification does not activate these methods as production navigation.
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
"""Form physical paint components once, retaining the exact positive union.
|
||||
|
||||
Overlapping views and primary channels may describe the same paint repeatedly.
|
||||
Union removes that multiplicity before selecting axes. It adds no buffer, hull,
|
||||
closing operation or filled hole. Raw observations remain the scoring evidence;
|
||||
these components only propose axes for the unchanged two-view admission.
|
||||
"""
|
||||
import shapely
|
||||
from shapely.geometry import shape
|
||||
from component_axis import preferred
|
||||
|
||||
|
||||
def collect(records):
|
||||
polygons=[shapely.force_2d(shape(r['geometry'])) for r in records]
|
||||
merged=shapely.union_all(polygons)
|
||||
components=list(shapely.get_parts(merged)) if not merged.is_empty else []
|
||||
components=[p for p in components if p.geom_type=='Polygon' and not p.is_empty]
|
||||
components.sort(key=lambda p:(*p.bounds,p.wkb_hex))
|
||||
seeds=[s for p in components if (s:=preferred(p)) is not None]
|
||||
return seeds,dict(raw_components=len(polygons),physical_components=len(components),axis_seeds=len(seeds),
|
||||
added_geometry=False,positive_area_m2=float(merged.area),selection='exact-positive-union-before-axis-measurement')
|
||||
|
||||
|
||||
def qualify():
|
||||
import numpy as np
|
||||
from shapely.geometry import box,mapping,Polygon
|
||||
def rows(items):return [dict(geometry=mapping(p))for p in items]
|
||||
p=box(0,0,3,.12);q=box(1,0,4,.12);other=box(0,.2,4,.32)
|
||||
seeds,proof=collect(rows([p,p,q,other]))
|
||||
assert proof['raw_components']==4 and proof['physical_components']==2 and len(seeds)==2
|
||||
assert abs(proof['positive_area_m2']-p.union(q).union(other).area)<1e-10
|
||||
reversed_seeds,reversed_proof=collect(rows([other,q,p,p]))
|
||||
assert proof==reversed_proof
|
||||
for a,b in zip(seeds,reversed_seeds):
|
||||
for key in ['origin','axis','length','width']:np.testing.assert_array_equal(a[key],b[key])
|
||||
hole=Polygon([(0,0),(4,0),(4,1),(0,1)],holes=[[(1,.2),(3,.2),(3,.8),(1,.8)]])
|
||||
_,proof=collect(rows([hole,hole]));assert abs(proof['positive_area_m2']-hole.area)<1e-10
|
||||
assert collect([])[0]==[]
|
||||
print('PRIMARY_COMPONENT_CONTRACT_OK',flush=True)
|
||||
Reference in New Issue
Block a user