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

Fix bug where there are white lines between tiles when scale*256 isn't whole number #19

Merged
merged 2 commits into from
Oct 26, 2016

Conversation

samwillis
Copy link
Contributor

When (scale*256)%1 > 0.5 there are white lines between tiles, rounding down when calculating tileSize fixes the issue.

I don't understand the code completely but I believe that this results in the tiles packing together towards the middle of the image. Therefore a few extra pixels of map are shown from the edge tiles and so the edge tiles may be a little out of alignment from the expected coods. I think this is an OK tradeoff as its only vary slight and not having the white lines is obviously more important.

The alignment between the tiles does not seem to be affected at all, there is no missing slice of map between them.

(I wander if somewhere during the tile generation process the tile size is rounded down, could be the source of the error?)

Fix bug where there are white lines between tiles when scale*256 isn't
whole number.
It happens when (scale*256)%256 > 0.5.
Rounding down when calculating tileSize fixes the issue.
@springmeyer
Copy link

@samwillis - thanks for the contribution and for looking into this. Can you post some images describing the problem in more detail? As it stands right now I'm hesitant to accept this without a stronger case of the problem and what it solves exactly. /cc @camilleanne

@samwillis
Copy link
Contributor Author

Hi Dane,

The easiest way for you to reproduce the problem is with Mapbox Studio Classic (I am also experiencing it with Tessera - https://github.com/mojodna/tessera). When running Studio Classic if you visit the url (scale 2.2):

http://localhost:3000/static/10/28.3468,40.8398,29.477,[email protected]?id=tmpstyle:///Applications/Mapbox%20Studio.app/Contents/Resources/app/node_modules/mapbox-machine-styles/node_modules/mapbox-studio-wheatpaste

there are no white line between the tiles and 256*2.2 = 563.2, therefore currently tileSize is rounded down.

wheatpaste-z10_28 3468_40 8398_29 477_41 2819_2 scale 2 2

However, if you visit (scale 2.3):

http://localhost:3000/static/10/28.3468,40.8398,29.477,[email protected]?id=tmpstyle:///Applications/Mapbox%20Studio.app/Contents/Resources/app/node_modules/mapbox-machine-styles/node_modules/mapbox-studio-wheatpaste

there is a single pixel white line between all the tiles and 256*2.3 = 588.8, therefore currently tileSize is rounded up. It seems that rounding up is causing the white lines to appear, I think abaculus thinks it is using tiles one pixel bigger than are being drawn.

wheatpaste-z10_28 3468_40 8398_29 477_41 2819_2 scale 2 3

To reproduce the error with Tessera you need to use this branch mojodna/tessera#36 as Tessera currently doesn't allow arbitrary scales in the same way as Studio Classic.

@samwillis
Copy link
Contributor Author

To add the the previous comment, this is the image returned from the second url (scale 2.3) with a patched version of tessera.
wheatpaste-z10_28 3468_40 8398_29 477_41 2819_2 7
As you can see the while lines are gone.

If you open all three images in separate tabs and tab between them you can see that the first two are showing exactly the same area, with the second one showing the white lines. The third images (with the white lines fixed) seems to pull the tiles from the second image together towards the centre of the image, this results in the image showing a couple of extra pixels of map around the outside.

I don't understand the complete process well enough to know why this is the case. However if it was a choice between one bug or the other, not having the white lines seems to be preferable.

@flippmoke flippmoke merged commit 65ce36b into mapbox:master Oct 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants