Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
I suppose there is something wrong with
With the same array of resolutions in TileCache and Leaflet, Proj4Leaflet works perfectly with portrait bbox, but suffers an offset if bbox is landscape (width>height).
You can find a complete example that demonstrate the problem:
In the above example, I compute resolutions the same way as TileCache (they are printed out as proof)
Using static resolutions/scale array does not solve the problem.
Yes, the bounding box is different, on the left, it's a portrait (width < height), and on the right it's a landscape.
However, only the landscape bbox introduces offsets...
Ok, looking at the code again, I can't really see how the aspect ratio of the bounding box could affect Proj4Leaflet - in fact, it is only the upper left corner of the bbox that is ever sent to Proj4Leaflet (as the origin).
Since Proj4Leaflet never sees the bbox, how could it be affected by its aspect ratio?
I wonder, might it be possible that the bbox coordinates are in fact not really aligned with your tilegrid? When I look at it, it does not look like the height of the bbox (in either one of them!) is a multiple of the tile size 256, which leads me to believe that these bboxes describe underlying data rather than the actual tileset bounds (which becomes greater if you round them up to next tile boundary).
Do you have any other clue as to what might be happening? The use of origin is not very complicated in the code, so I have a bit of a hard time thinking of anything going wrong there, although I might of course be missing some detail.
Thanks a lot for your implication !
Indeed the tilegrid is not aligned between tilecache and leaflet if the bbox height is smaller than width.
I'll investigate more about that rounding, thanks.
BTW in @turban's article, his bbox is 60000 x 60000. (60000 % 256: 96).
For those reading this thread with curiosity (or despair!), I leave here some inspiring resources:
I changed both bboxes to be multiple of 256, and it's not better : http://mathieu-leplatre.info/media/2013-proj4leaflet/
(previous demo is here: http://mathieu-leplatre.info/media/2013-proj4leaflet/index-1.html)
It's not a blocker anyway. I also hard time reading at Leaflet tiling and projections. But can't figure anything out...