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