Revert "Revert "Avoid using float, fix #1741""

This reverts commit 4d500dc97246132f38418ab921cdac8164b850d6.
Revert "Revert "Avoid tiles wrapping with zooming out, see #1741""

This reverts commit 7b674e32483662c820b88137e625fcc405a4e7e8.