make-cad-bim-dedup-batch.mjs 1.0 KB

123456789101112
  1. // Produce a deduplicated seated batch: keep the pilot's unique buildings, then remove all pilot ids
  2. // from the overlapping urban batch before re-exporting it.
  3. import { readFileSync, writeFileSync } from 'node:fs'
  4. const root = 'tools/city-massing/city/cad-bim/'
  5. const seated = JSON.parse(readFileSync(root + 'seated-plan.json', 'utf8'))
  6. const pilot = JSON.parse(readFileSync(root + 'lod-pilot/manifest.json', 'utf8'))
  7. const oldBatch = JSON.parse(readFileSync(root + 'seated-batch-urban8000.json', 'utf8'))
  8. const pilotIds = new Set(pilot.cells.flatMap((cell) => cell.buildingIds))
  9. const buildings = oldBatch.buildings.filter((building) => !pilotIds.has(building.id))
  10. const out = { ...oldBatch, buildings, batch: { ...(oldBatch.batch || {}), deduplicatedAgainst: 'lod-pilot', selected: buildings.length } }
  11. writeFileSync(root + 'seated-batch-urban8000-dedup.json', JSON.stringify(out, null, 2))
  12. console.log(JSON.stringify({ pilot: pilotIds.size, before: oldBatch.buildings.length, after: buildings.length, removed: oldBatch.buildings.length - buildings.length }))