mapbox / sphericalmercator

Spherical Mercator math in Javascript
BSD 3-Clause "New" or "Revised" License
270 stars 46 forks source link

bbox does not respect tile size #39

Open samdelacruz opened 4 years ago

samdelacruz commented 4 years ago

Despite initialising SphericalMercator with a different tile size, .bbox returns identical latitude and longitude coordinates for the same inputs, which suggests that tile size is not being taken into account.

Example:

const SM = require("@mapbox/sphericalmercator")
const sm1 = new SM({ size: 256 });
sm1.bbox(8298, 5450, 14);
// [ 2.3291015625, 51.467696956223364, 2.35107421875, 51.481382896100975 ]
const sm2 = new SM({ size: 512 });
sm2.bbox(8298, 5450, 14);
// [ 2.3291015625, 51.467696956223364, 2.35107421875, 51.481382896100975 ]
samdelacruz commented 4 years ago

Unless I'm mistaken, what I think this means is that for sizes other than 256, the returned bounding box will be incorrect.