Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better strategy for determining when to stop tiling depending on tile data #7

Closed
mourner opened this issue Dec 3, 2014 · 2 comments

Comments

@mourner
Copy link
Member

mourner commented Dec 3, 2014

  • each coordinate keeps a switch indicating whether it's from original data or introduced through clipping
  • if a tile contains at least one original point, slice deeper (up to z14)
  • otherwise stop tiling

This solution should reduce the number of tiles significantly while keeping all the necessary precision, is dead simple to implement, and removes the need for any other heuristics (such as based on num. of features, coordinates, simplification etc.).

It assumes we only need precision for areas where we have actual data points — all lines and polygons going "through" tiles don't need as much precision. Does this sound like a good assumption?

@springmeyer
Copy link

This sounds like a great first pass to reduce work. The only small glitch I can think of would be slight mis-alignment between lines at tile edges if:

  • you have a line crossing a tile that - before clipping - does not have any vertices inside the tile. This tile is only rendered at z0
  • the line is very dense with precise coordinates on the adjacent tile and it needs to be rendered at a much higher zoom level: lets say z10
  • the impact of rounding to integers might mean that the z0 line - when overzoomed - does not visually match up with the z10 line.

Hopefully this would not happen in practice however and if we ever encountered it the artifcact would be minor and perhaps easily avoided by enforcing something like a max differential: if one tile needs rendered up to z10 then make sure to render all geometries up to at least z10-N.

@mourner mourner changed the title Stop tiling further if a tile only contains points introduced through clipping Better strategy for determining when to stop tiling depending on tile data Dec 3, 2014
@mourner
Copy link
Member Author

mourner commented Dec 3, 2014

@springmeyer great remark! I thought about the misalignment for a while and it lead me to a super-simple idea that completely solves the problem while reducing the initial work even further: mapbox/mapbox-gl-js#464 (comment)

The basic idea is to tile until the number of coordinates in the tile is low enough on the first GeoJSON preprocessing run, and leave the rest for tiling on demand in case the user zooms in.

@mourner mourner closed this as completed in e645cdf Dec 4, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants