Skip to content

Commit

Permalink
replace flatMap() and update logic to count all meshes in tile
Browse files Browse the repository at this point in the history
  • Loading branch information
bcamper committed Aug 2, 2020
1 parent 7baed5e commit eebc537
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/labels/main_pass.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ export default async function mainThreadLabelCollisionPass (tiles, view_zoom, hi
// Adaptive collision grid, using a heuristic based on the tile with the most labels
const max_tile_label_count =
Math.max(0, ...Object.values(tiles)
.flatMap(t => Object.values(t.meshes))
.map(m => m[0].labels && Object.keys(m[0].labels).length)
.filter(x => x)
.map(t => Object.values(t.meshes))
.flat()
.map(meshes => Math.max(0, ...meshes.map(mesh => mesh.labels ? Object.keys(mesh.labels).length : 0)))
);

const grid_divs = Math.floor(max_tile_label_count / Geo.tile_size); // heuristic of label density to tile size
Expand Down

0 comments on commit eebc537

Please sign in to comment.