How to use the @conveyal/lonlat.toPixel function in @conveyal/lonlat

To help you get started, we’ve selected a few @conveyal/lonlat examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github conveyal / analysis-ui / lib / selectors / destination-travel-time-distribution.js View on Github external
export function createDestinationTravelTimeDistribution(
  destination,
  travelTimeSurface
) {
  if (destination == null || travelTimeSurface == null) return null

  let {x, y} = lonlat.toPixel(destination, travelTimeSurface.zoom)
  // floor them to get top left of cell the point is a part of (TODO correct?)
  x = Math.floor(x - travelTimeSurface.west)
  y = Math.floor(y - travelTimeSurface.north)

  return {
    low: travelTimeSurface.get(x, y, 0),
    iqrLow: travelTimeSurface.get(x, y, 1),
    med: travelTimeSurface.get(x, y, 2),
    iqrHigh: travelTimeSurface.get(x, y, 3),
    high: travelTimeSurface.get(x, y, 4)
  }
}
github conveyal / taui / src / utils / coordinate-to-point.js View on Github external
export default function coordinateToPoint (coordinate, zoom, west, north) {
  const pixel = lonlat.toPixel(coordinate, zoom)

  return {
    x: (pixel.x - west) | 0,
    y: (pixel.y - north) | 0
  }
}
github conveyal / analysis-ui / lib / utils / reproject-coordinates.js View on Github external
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
  )
}