Distance calculation: what algorithm/formula is used?

Options

The Utility Functions : Distance Calculation is used to calculate the distance between 2 points (with lat/lng).
But it didn't use the Google Map API or tools like that, so which algorithm/formula is used to calculate the distance ? Vincenty ? Haversine ?

It has an important stake in precision, that’s why it interests me

Thanks in advance

Best Answer

  • arturosanz
    arturosanz Member ✭✭
    edited September 2023 Answer ✓
    Options

    @Kat I guess Xano uses neither Haversine nor Vicenty, though it's very close to Haversine. Maybe Xano is using the Haversine formula but rounding off a few decimals at some point.

    It is easy to test by comparing the results with online calculators. For example, let's calculate the distance between the following two points.

    (48.857461 N, 2.291029 W) and (48.857461 N, 2.304698 W)

    Xano: 999.9595481786212

    Haversine: 1000

    Vicenty (GRS80 or WGS84): 1003.036

    Vicenty (ANS): 1003.04

    Vicenty (International 1924): 1003.084

    Here are the online calculators I have used:

    https://www.vcalc.com/wiki/vcalc/haversine-distance

    https://geodesyapps.ga.gov.au/vincenty-inverse

Answers

  • Kat
    Kat Member
    Options
  • Ray Deck
    Ray Deck Trusted Xano Expert ✭✭✭
    Options

    hey Kat this is a xano product question and they are an American company on holiday for a long weekend (Labor Day). Be patient and they will get back to this in the coming week! I’m curious about the answer too!

  • Kat
    Kat Member
    edited September 2023
    Options

    Hello Xano Team, do you have an answer to my question please :) ?

  • Kat
    Kat Member
    Options

    thanks @arturosanz

    Do you have an alternative to formulas.

    A free Google map distance calculation or something like this just to have more precision. I know mapbox api let you a large number of requests before paying.

    The difference between formula and api service is they do not take into account the roads, obstacle …


    I know there is more complexe formulas they took the rounding of the earth, … I’m just asking :&

  • arturosanz
    arturosanz Member ✭✭
    Options

    What is your use case in particular @Kat? What do you need the distance calculation for?

  • Lefteris - blupry.com
    Options

    Hello @Kat

    You can have a FREE distance calculation between 2 points (with lat/lng) using here.com API

    They offer a number of free calls.

    We have already implemented the here.com API on Xano and created a snippet