-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
133 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,30 @@ | ||
const earthRadius = 6378137 | ||
|
||
const tile2lon = (x, z) => (x / Math.pow(2, z)) * 360 - 180 | ||
|
||
const tile2lat = (y, z) => { | ||
const n = Math.PI - (2 * Math.PI * y) / Math.pow(2, z) | ||
return (180 / Math.PI) * Math.atan(0.5 * (Math.exp(n) - Math.exp(-n))) | ||
} | ||
|
||
// Returns resolution in meters at zoom | ||
export const getZoomResolution = zoom => | ||
(2 * Math.PI * earthRadius) / 256 / Math.pow(2, zoom) | ||
|
||
// Returns lng/lat bounds for a tile | ||
export const getTileBBox = (x, y, z) => { | ||
var e = tile2lon(x + 1, z) | ||
var w = tile2lon(x, z) | ||
var s = tile2lat(y + 1, z) | ||
var n = tile2lat(y, z) | ||
const e = tile2lon(x + 1, z) | ||
const w = tile2lon(x, z) | ||
const s = tile2lat(y + 1, z) | ||
const n = tile2lat(y, z) | ||
return [w, s, e, n].join(',') | ||
} | ||
|
||
const tile2lon = (x, z) => (x / Math.pow(2, z)) * 360 - 180 | ||
|
||
const tile2lat = (y, z) => { | ||
const n = Math.PI - (2 * Math.PI * y) / Math.pow(2, z) | ||
return (180 / Math.PI) * Math.atan(0.5 * (Math.exp(n) - Math.exp(-n))) | ||
} | ||
// Returns true if two bbox'es intersects | ||
export const bboxIntersect = (bbox1, bbox2) => | ||
!( | ||
bbox1[0] > bbox2[2] || | ||
bbox1[2] < bbox2[0] || | ||
bbox1[3] < bbox2[1] || | ||
bbox1[1] > bbox2[3] | ||
) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters