verify-hybrid-city-tileset.mjs 1.4 KB

1234567891011121314151617181920212223242526272829303132
  1. import assert from 'node:assert/strict'
  2. import { readFileSync, existsSync } from 'node:fs'
  3. import { resolve, join } from 'node:path'
  4. const dir = resolve(process.argv[2] || 'tools/city-massing/city/cad-bim/city-hybrid-v1')
  5. const tree = JSON.parse(readFileSync(join(dir, 'tileset.json'), 'utf8'))
  6. const report = JSON.parse(readFileSync(join(dir, 'manifest.json'), 'utf8'))
  7. assert.equal(report.farCoarseFiles, 74)
  8. assert.equal(report.fineFiles, 3023)
  9. assert.equal(tree.root.children.length, 74)
  10. let coarse = 0, fine = 0, paths = new Set()
  11. function walk(tile, parent = null) {
  12. if (tile.children?.length) assert.equal(tile.refine, 'REPLACE')
  13. if (tile.content?.uri) {
  14. const path = resolve(dir, tile.content.uri)
  15. assert.ok(existsSync(path), path)
  16. assert.ok(!paths.has(path), `duplicate content ${path}`)
  17. paths.add(path)
  18. if (/-lod1\.glb$/.test(tile.content.uri)) coarse++
  19. if (/-lod0\.glb$/.test(tile.content.uri)) {
  20. fine++
  21. assert.equal(tile.geometricError, 0)
  22. assert.ok(parent, 'fine leaf must have coarse parent')
  23. }
  24. }
  25. for (const child of tile.children || []) walk(child, tile)
  26. }
  27. walk(tree.root)
  28. assert.equal(coarse, 74)
  29. assert.equal(fine, 3023)
  30. console.log(JSON.stringify({ passed: true, coarse, fine, content: paths.size,
  31. policy: '74 coarse parents; fine leaves are local children, no global coarse handoff',
  32. traversalValidated: false }))