Get all Sections overlapping the specified region.
({height, width, x, y}: SizeAndPositionInfo)
| 50 | |
| 51 | /** Get all Sections overlapping the specified region. */ |
| 52 | getSections({height, width, x, y}: SizeAndPositionInfo): Array<Section> { |
| 53 | const sectionXStart = Math.floor(x / this._sectionSize); |
| 54 | const sectionXStop = Math.floor((x + width - 1) / this._sectionSize); |
| 55 | const sectionYStart = Math.floor(y / this._sectionSize); |
| 56 | const sectionYStop = Math.floor((y + height - 1) / this._sectionSize); |
| 57 | |
| 58 | const sections = []; |
| 59 | |
| 60 | for (let sectionX = sectionXStart; sectionX <= sectionXStop; sectionX++) { |
| 61 | for (let sectionY = sectionYStart; sectionY <= sectionYStop; sectionY++) { |
| 62 | const key = `${sectionX}.${sectionY}`; |
| 63 | |
| 64 | if (!this._sections[key]) { |
| 65 | this._sections[key] = new Section({ |
| 66 | height: this._sectionSize, |
| 67 | width: this._sectionSize, |
| 68 | x: sectionX * this._sectionSize, |
| 69 | y: sectionY * this._sectionSize, |
| 70 | }); |
| 71 | } |
| 72 | |
| 73 | sections.push(this._sections[key]); |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | return sections; |
| 78 | } |
| 79 | |
| 80 | /** Total number of Sections based on the currently registered cells. */ |
| 81 | getTotalSectionCount() { |
no outgoing calls
no test coverage detected