-
Notifications
You must be signed in to change notification settings - Fork 280
add clamp for extreme lats #124
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
base: main
Are you sure you want to change the base?
Changes from 5 commits
0fa52e5
71ae3da
5c5f1e8
4af468c
10dfcfd
2405a96
acba247
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,9 @@ | |
| import simplify from './simplify'; | ||
| import createFeature from './feature'; | ||
|
|
||
| const maxMercatorLatitude = 85.05; | ||
| const minVectorLatitude = -maxMercatorLatitude * 8191/8192; | ||
|
|
||
| // converts GeoJSON feature into an intermediate projected JSON vector format with simplification data | ||
|
|
||
| export default function convert(data, options) { | ||
|
|
@@ -136,7 +139,8 @@ function projectX(x) { | |
| } | ||
|
|
||
| function projectY(y) { | ||
| const sin = Math.sin(y * Math.PI / 180); | ||
| const clampedY = y < minVectorLatitude ? minVectorLatitude : y > maxMercatorLatitude ? maxMercatorLatitude : y; | ||
| const sin = Math.sin(clampedY * Math.PI / 180); | ||
| const y2 = 0.5 - 0.25 * Math.log((1 + sin) / (1 - sin)) / Math.PI; | ||
| return y2 < 0 ? 0 : y2 > 1 ? 1 : y2; | ||
| return y2; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: If we do the
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
@mourner would this clamp features on every tile locally to 8191?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @peterqliu no, since this is a global projection — it projects latitude into 0..1 range (0 is near the north pole, 1 is near the south one). Tile-aware projection happens further down the line |
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why 8191/8192? Probably should add a comment explaining this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 will add comment if we end up going this route. for now, it's explained in the PR text