Multiple location distance calculation

Hi so i am working with a logistics company that want to pass multiple locations into a system where it will then calculate the distance between those locations.

Here is what the page could look like: (blurred out parts are the locations)

Now here is my problem. I know that there is a distance between column in glide and I know that I can have multiple of these and then just calculate them all together with a formula.

Do any of you know of a better way to do this. I am also a little bit experienced with api calls.

I haven’t tried it yet myself, but I believe that the Radar Integration can do this.

Are you saying that I can add more than 2 destination into the radar column.

As I only see origin and destination.

ah, I see.

So you’re basically looking to calculate the total distance in a single step. And I guess the challenge might be that there could be an indeterminant number of intermediate stops, yes?

I think my approach to this would be to use a Helper Table to arrange the route stops into rows, use a single column to calculate the distance between each stop (1st to 2nd row, 2nd to 3rd row, etc), and then use a rollup to calculate the total.

That was my approach before posting in the community. I am wondering if its possible to send these locations as an array into airtable where I can run a script to calculate the distances.

But I see the webhook is unable to take an array

What about a delimited list of locations, and then you split that into an array later on when it gets to Airtable?

What do you mean by delimited list? Sorry I am pretty new to this.

I mean passing something like “Location A,Location B,Location C” and then you do your magic on the Airtable side. Would that work?

Oh yes, that what i was working on. But I would have preferred if I could do it in glide as doing things in airtable is really slow. I wish we could pass arrays into the js column

Would passing the list above works for the JS column, then you use a split function to split that into an array?

That can work. I really think glide should spend more time with the JS column. Limited Inputs and no popup code editor.

So this is what I cam up with.

The locations are set as an array and then the JS looks for the first and last entries in the array that sets them as Origin and Destination, with the rest being set as Waypoints.

  var origin = locationsArray[0];
  var destination = locationsArray[locationsArray.length - 1];
  var waypoints = [];
  for (var i = 1; i < locationsArray.length - 1; i++) {
    waypoints.push({location: locationsArray[i]});
  }

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.