0
const destinations = [
{
    id: 0,
    city: "Buenos Aires",
    country: "Argentina",
    codeIATA: "AEP",
    aeroName: "Aeroparque Jorge Newbery",
    coordX: 15,
    coordY: 36,
},
{
    id: 1,
    city: "El Calafate",
    country: "Argentina",
    codeIATA: "FTE",
    aeroName: "Comandante A. Tola",
    coordX: -49,
    coordY: -63,
},

With an array of several objects that constitute cities/airports like the 2 objects above, the user will have to select one object as origin and the other as destination. What I'm trying to find out is how to catch the x and y coordinates of each chosen origin and destination to calculate the distance between the two points and be able to provide distance in km, time and flight cost.

  • https://stackoverflow.com/questions/1602164/shortest-distance-between-points-algorithm – miyav miyav Apr 15 '22 at 14:18
  • when you receive the source point and destination point via canvas/dropdowns etc. You can use the formula to calculate the distance between two points: `const xDes = 0;` `const xSour = -1;` `const yDes = 5;` `const ySour = -2;` `Math.sqrt((xDes - xSour)^2 + (yDes - ySour)^2)` – Mykyta Halchenko Apr 15 '22 at 14:20
  • @Skalpel02 These are geocoordinates, not euler coordinates – Bergi Apr 15 '22 at 14:50
  • Flight time and cost depends on many more things than just distance. – Bergi Apr 15 '22 at 14:51

0 Answers0