(cells: ChallengeCell[])
| 71 | } |
| 72 | |
| 73 | function bounds(cells: ChallengeCell[]) { |
| 74 | if (cells.length === 0) return null; |
| 75 | let minLat = Number.POSITIVE_INFINITY; |
| 76 | let maxLat = Number.NEGATIVE_INFINITY; |
| 77 | let minLng = Number.POSITIVE_INFINITY; |
| 78 | let maxLng = Number.NEGATIVE_INFINITY; |
| 79 | for (const cell of cells) { |
| 80 | for (const [lat, lng] of safeCellBoundary(cell.cell_id)) { |
| 81 | minLat = Math.min(minLat, lat); |
| 82 | maxLat = Math.max(maxLat, lat); |
| 83 | minLng = Math.min(minLng, lng); |
| 84 | maxLng = Math.max(maxLng, lng); |
| 85 | } |
| 86 | } |
| 87 | if (!Number.isFinite(minLat)) return null; |
| 88 | return { minLat, maxLat, minLng, maxLng }; |
| 89 | } |
| 90 | |
| 91 | function safeCellBoundary(cellId: string) { |
| 92 | try { |
no test coverage detected