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

Offsets with landscape bbox #37

Closed
leplatrem opened this issue Aug 23, 2013 · 7 comments

Comments

@leplatrem
Copy link
Contributor

@leplatrem leplatrem commented Aug 23, 2013

I suppose there is something wrong with origin usage for landscape bounding boxes.

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:
http://mathieu-leplatre.info/media/2013-proj4leaflet/

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.

@perliedman

This comment has been minimized.

Copy link
Contributor

@perliedman perliedman commented Aug 26, 2013

Maybe I am missing your point, but from looking at your example, the third parameter of the bbox is different in the two examples (985649 compared to 985849). Isn't that what's causing the offset?

@leplatrem

This comment has been minimized.

Copy link
Contributor Author

@leplatrem leplatrem commented Aug 26, 2013

Yes, the bounding box is different, on the left, it's a portrait (width < height), and on the right it's a landscape.

  • In both cases I use the bbox (and that only) as input to intialize Proj4Leaflet (and Tilecache).
  • In both cases the resolutions array computed automatically matches Tilecache resolutions.

However, only the landscape bbox introduces offsets...

@perliedman

This comment has been minimized.

Copy link
Contributor

@perliedman perliedman commented Aug 26, 2013

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.

@leplatrem

This comment has been minimized.

Copy link
Contributor Author

@leplatrem leplatrem commented Aug 28, 2013

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.
I will try to define an horizontal bbox for which tiling perfectly fits tiles boundaries.
AFAIU it does not have to be multiple of 256 though :

cellsize = width / 256
fits_grid = (height % cellsize === 0)

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:

@leplatrem

This comment has been minimized.

Copy link
Contributor Author

@leplatrem leplatrem commented Aug 30, 2013

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...

@pthorin

This comment has been minimized.

Copy link

@pthorin pthorin commented Jan 26, 2017

Is this still an issue?

@perliedman

This comment has been minimized.

Copy link
Contributor

@perliedman perliedman commented Nov 12, 2017

Closing as we don't have any information to act on here, and the issue is really old.

Happy to re-open if this is still an issue and we can get example code for recent versions.

@perliedman perliedman closed this Nov 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.