Closed samwillis closed 7 years ago
@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
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,41.2819@2.2x.png?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.
However, if you visit (scale 2.3):
http://localhost:3000/static/10/28.3468,40.8398,29.477,41.2819@2.3x.png?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.
To reproduce the error with Tessera you need to use this branch https://github.com/mojodna/tessera/pull/36 as Tessera currently doesn't allow arbitrary scales in the same way as Studio Classic.
To add the the previous comment, this is the image returned from the second url (scale 2.3) with a patched version of tessera. 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.
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?)