UNPKG

s2maps-gpu

Version:

S2 Maps GPU - An open source, high-performance, and GPU-accelerated map engine for rendering large-scale, interactive maps.

29 lines (28 loc) 799 B
// 32bit: 4,294,967,295 --- 24bit: 16,777,216 --- 22bit: 4,194,304 --- 16bit: 65,535 --- 7bit: 128 export const ID_MAX_SIZE = 1 << 22; /** Id Generator to ensure features don't overlap. Used by vector workers. */ export class IDGen { workerID; num; startNum; incrSize; maxNum = ID_MAX_SIZE; /** * @param id - the thread id * @param totalWorkers - the total number of threads */ constructor(id, totalWorkers) { this.workerID = id; this.num = id + 1; this.startNum = id + 1; this.incrSize = totalWorkers; } /** @returns the next id */ getNum() { const res = this.num; this.num += this.incrSize; if (this.num >= this.maxNum) this.num = this.startNum; return res; } }