| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- // Verify the corrected GIS-aligned CAD/BIM batches and far wrapper provenance.
- import assert from 'node:assert/strict'
- import { readFileSync, existsSync } from 'node:fs'
- import { join, resolve } from 'node:path'
- const root = resolve('tools/city-massing/city/cad-bim')
- const dirs = process.argv.slice(2)
- assert.ok(dirs.length, 'aligned batch directories required')
- const requiredMaterials = ['Door_Walnut', 'Glass_Dark']
- const results = []
- const ids = new Set()
- for (const name of dirs) {
- const dir = resolve(name)
- const manifestPath = join(dir, 'manifest.json')
- const treePath = join(dir, 'tileset.json')
- assert.ok(existsSync(manifestPath), `${name}: manifest missing`)
- const manifest = JSON.parse(readFileSync(manifestPath, 'utf8'))
- const tree = JSON.parse(readFileSync(treePath, 'utf8'))
- assert.equal(manifest.provenance?.gisFootprints, true, `${name}: GIS footprint provenance missing`)
- assert.equal(manifest.provenance?.roadsProcedural, false, `${name}: procedural roads provenance`)
- assert.equal(manifest.provenance?.lod1FootprintOnly, true, `${name}: LOD1 footprint mode missing`)
- assert.equal(manifest.provenance?.facadeDetails, true, `${name}: facade provenance missing`)
- assert.ok(tree.root?.transform?.length === 16, `${name}: root transform missing`)
- assert.ok(tree.root?.children?.length, `${name}: no coarse children`)
- const cellIds = manifest.cells.flatMap((cell) => cell.buildingIds)
- assert.equal(cellIds.length, manifest.count, `${name}: manifest coverage count mismatch`)
- for (const id of cellIds) {
- assert.ok(!ids.has(id), `${name}: duplicate building id ${id}`)
- ids.add(id)
- }
- const lod1Files = manifest.coarseCells.map((record) => record.uri)
- assert.ok(lod1Files.length, `${name}: no coarse records`)
- const materials = new Set()
- for (const uri of lod1Files) {
- const bytes = readFileSync(join(dir, uri))
- const length = bytes.readUInt32LE(12)
- const gltf = JSON.parse(bytes.toString('utf8', 20, 20 + length))
- for (const material of gltf.materials || []) if (material.name) materials.add(material.name)
- }
- for (const material of requiredMaterials) assert.ok(materials.has(material), `${name}: LOD1 lacks ${material}`)
- results.push({ name, buildings: manifest.count, coarseFiles: lod1Files.length,
- lod1Triangles: manifest.totals.lod1.triangles, lod0Triangles: manifest.totals.lod0.triangles,
- materials: [...materials].sort() })
- }
- console.log(JSON.stringify({ passed: true, batches: results, buildings: ids.size }))
|