detailBands.js 1.2 KB

123456789101112131415161718192021
  1. /** Select already nearest-first candidates under the global budget.
  2. * The previous near-band quota rejected close buildings but admitted farther ones.
  3. * Crossing 300m could therefore unload a cached near region and leave permanent coarse blocks.
  4. * LOD refinement belongs to Cesium's tile tree, not to a region eviction quota.
  5. */
  6. export function selectByDistanceBands(candidates, options = {}) {
  7. const list = Array.isArray(candidates) ? candidates.filter(Boolean) : []
  8. const number = (value, fallback) => Number.isFinite(Number(value)) ? Number(value) : fallback
  9. const maxContents = number(options.maxContents, 1200)
  10. const maxBytes = number(options.maxDecodedBytes, 256 * 1024 * 1024)
  11. const maxRegions = number(options.maxRegions, Infinity)
  12. const selected = []
  13. let contents = 0, bytes = 0
  14. for (const region of list) {
  15. if (selected.length >= maxRegions) break
  16. const count = number(region.contentCount, 0), size = number(region.decodedGeometryBytes, 0)
  17. if (contents + count > maxContents || bytes + size > maxBytes) continue
  18. selected.push(region.id); contents += count; bytes += size
  19. }
  20. return selected
  21. }