How to use the @conveyal/lonlat.toLatFirstString 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 / utils / get-route-polyline.js View on Github external
export default async function getRoutePolyline (start: LonLatC, end: LonLatC) {
  const startPoint = lonlat.toLatFirstString(start)
  const endPoint = lonlat.toLatFirstString(end)
  const response = await fetch(`${GRAPHHOPPER_API_URL}?key=${process.env.GRAPHHOPPER_API_KEY || ''}&point=${startPoint}&point=${endPoint}&instructions=false`)
  const json = await response.json()

  return decodePolyline(json.paths[0].points).map(c => ([c[1], c[0]])) // [lat,lon] -> [lon,lat]
}
github conveyal / analysis-ui / lib / utils / get-route-polyline.js View on Github external
export default async function getRoutePolyline (start: LonLatC, end: LonLatC) {
  const startPoint = lonlat.toLatFirstString(start)
  const endPoint = lonlat.toLatFirstString(end)
  const response = await fetch(`${GRAPHHOPPER_API_URL}?key=${process.env.GRAPHHOPPER_API_KEY || ''}&point=${startPoint}&point=${endPoint}&instructions=false`)
  const json = await response.json()

  return decodePolyline(json.paths[0].points).map(c => ([c[1], c[0]])) // [lat,lon] -> [lon,lat]
}
github conveyal / analysis-ui / lib / utils / __tests__ / get-route-polyline.js View on Github external
.reply(200, (uri, body) => {
        expect(uri.indexOf(lonlat.toLatFirstString(start)) > -1).toBeTruthy()
        expect(uri.indexOf(lonlat.toLatFirstString(end)) > -1).toBeTruthy()
        return mockResponse
      })
github conveyal / analysis-ui / lib / utils / __tests__ / get-route-polyline.js View on Github external
.reply(200, (uri, body) => {
        expect(uri.indexOf(lonlat.toLatFirstString(start)) > -1).toBeTruthy()
        expect(uri.indexOf(lonlat.toLatFirstString(end)) > -1).toBeTruthy()
        return mockResponse
      })