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

Use same algorithm in latY #5930

Closed
jingsam opened this issue Jan 2, 2018 · 1 comment
Closed

Use same algorithm in latY #5930

jingsam opened this issue Jan 2, 2018 · 1 comment

Comments

@jingsam
Copy link
Contributor

jingsam commented Jan 2, 2018

We projected latitude to Y in two places:

latY(lat: number) {
const y = 180 / Math.PI * Math.log(Math.tan(Math.PI / 4 + lat * Math.PI / 360));
return (180 - y) * this.worldSize / 360;
}

latY(lat: number, zoom: number) {
const f = clamp(Math.sin(Math.PI / 180 * lat), -0.9999, 0.9999);
const scale = Math.pow(2, zoom) / (2 * Math.PI);
return Math.pow(2, zoom - 1) + 0.5 * Math.log((1 + f) / (1 - f)) * -scale;
}

I notice that the two code varies. Shall we unified with same logic to improve maintenance ?

And in the second:

return Math.pow(2, zoom - 1) + 0.5 * Math.log((1 + f) / (1 - f)) * -scale;

-scale is wired, especially prefix with a *. Should we add a parenthesis?

@vulkd
Copy link

vulkd commented Dec 12, 2019

It looks like this was resolved by #7488 / #7570

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants