Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
project: ([x, y]) => {
// - 1 due to increasing the grid size above
const ll = lonlat.fromPixel(
{
x: x + west - 1,
y: y + north - 1
},
zoom
)
return [ll.lon, ll.lat]
},
// Temporarily disabling interpolation because it causes issues near edges (PR with fix made to
function webMercatorBoundsToGeographic({north, west, width, height, zoom}) {
const nw = lonlat.fromPixel(
{
x: west + 1,
y: north
},
zoom
)
const se = lonlat.fromPixel(
{
x: west + width + 1,
y: north + height
},
zoom
)
return {
east: se.lon,
north: nw.lat,
project([x, y]) {
const {lon, lat} = lonlat.fromPixel(
{
x: x + surface.west,
y: y + surface.north
},
surface.zoom
)
return [lon, lat]
}
})
function webMercatorBoundsToGeographic({north, west, width, height, zoom}) {
const nw = lonlat.fromPixel(
{
x: west + 1,
y: north
},
zoom
)
const se = lonlat.fromPixel(
{
x: west + width + 1,
y: north + height
},
zoom
)
return {
east: se.lon,
north: nw.lat,
south: se.lat,
west: nw.lon
}
}
get (x, y) {
const ll = lonlat.fromPixel({
x: x + surface.west,
y: y + surface.north
}, surface.zoom)
const distMeters = lonlat
.toLeaflet(ll)
.distanceTo(lonlat.toLeaflet(origin))
const timeMinutes = (distMeters / 1000 / speedKmh * 60) | 0
return Array(surface.depth).fill(timeMinutes)
}
}
export const pointToCoordinate = (x, y, zoom) =>
lonlat.fromPixel({ x, y }, zoom)
export default function reproject(ll) {
const p = lonlat.toPixel(ll, Z)
return lonlat.fromPixel(
{
x: Math.round(p.x),
y: Math.round(p.y)
},
Z
)
}