AtB-AS / tavla

:bus: A customizable departure board for public transport in Trøndelag
https://tavla.dev.mittatb.no
Other
2 stars 0 forks source link

Sortere bysykler ut i fra avstand i forhold til din lokasjon. Fra nærmest til lengst unna. #21

Closed Martinbmoller closed 4 years ago

rosvik commented 4 years ago

The stations prop in BikeTile has coordinates, but not distance.

{
  "id": "YTR:VehicleSharingParkingArea:109",
  "name": "Torvet II",
  "networks": [
    "Trondheim bysykkel"
  ],
  "bikesAvailable": 13,
  "spacesAvailable": 5,
  "longitude": 10.393931418657303,
  "latitude": 63.430470910132236
}

From Entur SDK:

/**
 * Bike rental
 */

export interface BikeRentalStation {
    id: string
    name: string
    bikesAvailable?: number
    spacesAvailable?: number
    longitude: number
    latitude: number
    networks: Array<string>
}

https://sdk.entur.org/bikes/getBikeRentalStationsByPosition

Distance can be calculated if current position in known.

rosvik commented 4 years ago

nearestPlaces in /src/logic/useNearestPlaces.ts has distance to position as part of object

{
  "distance": 231,
  "id": "YTR:VehicleSharingParkingArea:175",
  "type": "BikeRentalStation",
  "latitude": 63.43051170410531,
  "longitude": 10.392764550201036
}