import { TravelTimeClient } from 'traveltime-api'
const { TRAVELTIME_APP_ID: applicationId, TRAVELTIME_API_KEY: apiKey } = process.env
const client = new TravelTimeClient({ applicationId, apiKey })
// The first example: Waterloo and Canary Wharf, both under 45 minutes by public transport
const { results } = await client.h3Fast({
resolution: 9,
properties: ['mean'],
arrival_searches: {
many_to_one: [
{ id: 'Waterloo', coords: { lat: 51.50313, lng: -0.1120801 },
transportation: { type: 'public_transport' },
arrival_time_period: 'weekday_morning', travel_time: 2700 },
{ id: 'Canary Wharf', coords: { lat: 51.5048954, lng: -0.0190006 },
transportation: { type: 'public_transport' },
arrival_time_period: 'weekday_morning', travel_time: 2700 },
],
},
})
// The hexagons both commutes reach
const [first, second] = results.map((result) => new Set(result.cells.map((cell) => cell.id)))
const both = [...first].filter((id) => second.has(id))