Files
NODEDC_MISSION_CORE/tests/test_whole_infrastructure.py
DCCONSTRUCTIONS f48411f8fe feat(simulation): integrate infrastructure jobs and semantic scene editing
Integrate infrastructure preparation and qualified map delivery with local scenes. Add semantic editing, object provenance, survey caching and operator scene tools.
2026-10-29 09:10:01 +03:00

37 lines
1.9 KiB
Python

"""Whole-scene coverage and overlap ownership, with bounded synthetic geometry."""
import sys
from pathlib import Path
import numpy as np
ROOT=Path(__file__).resolve().parents[1]
sys.path[:0]=[str(ROOT/'simulation/urban-mapping'),str(ROOT/'simulation/urban-mapping/vector'),str(ROOT/'simulation/ai-polygon')]
from whole_scene import plan_tiles
def test_whole_scene_uses_all_bounds_even_beyond_route():
v=np.array([[x,y,0.] for x in range(0,121,2) for y in range(0,21,2)])
f=[]
for x in range(60):
for y in range(10):
i=x*11+y;f.extend([[i,i+1,i+11],[i+1,i+12,i+11]])
request={'source':{},'model':{}}
result=plan_tiles(request,v,np.array(f))
assert len(result['tiles'])==3
assert result['bounds_xy']==[[0.,0.],[120.,20.]]
assert all(t['status']=='pending' for t in result['tiles'])
assert result['tiles'][-1]['core_bounds'][1][0]==120
assert all(t['job']['views'][0]['size']==[1200,1200] for t in result['tiles'])
def test_overlap_owns_polygons_once_and_retains_xyz():
import pytest
pytest.importorskip("shapely")
from whole_vectors import merge
polygon={'id':'crossing','geometry':{'type':'Polygon','coordinates':[[[38,2,3],[42,2,3],[42,6,3],[38,2,3]]]},'properties':{}}
line={'id':'curb','geometry':{'type':'LineString','coordinates':[[30,1,3],[50,1,3]]},'properties':{}}
tiles=[dict(id='left',core_bounds=[[0,0],[40,40]],status='surveyed'),dict(id='right',core_bounds=[[40,0],[80,40]],status='surveyed')]
result=merge({'tiles':tiles,'bounds_xy':[[0,0],[80,40]]},[(t,dict(features=[polygon,line])) for t in tiles],dict(key='a'*64,identity={'provider_sha256':'b'*64},source={}))
assert sum(f['geometry']['type']=='Polygon' for f in result['features'])==1
lines=[f['geometry']['coordinates'] for f in result['features'] if f['geometry']['type']=='LineString']
assert lines==[[[30.,1.,3.],[40.,1.,3.]],[[40.,1.,3.],[50.,1.,3.]]]
assert result['analysis']['tiles_mapped']==2