How can I calculate distance between to coordinates in Delphi

To calculate the distance between two coordinates (points) in Delphi, you can use the Haversine formula, which is a method used to calculate the great-circle distance between two points on a sphere based on their longitudes and latitudes.

Here is a function that you can use to calculate the distance between two coordinates in Delphi:

This function takes in four parameters:

  • lat1: The latitude of the first coordinate
  • lon1: The longitude of the first coordinate
  • lat2: The latitude of the second coordinate
  • lon2: The longitude of the second coordinate

It returns the distance between the two coordinates, in kilometers.

To use this function, you would call it like this:

This would calculate the distance between the coordinates for the Statue of Liberty in New York (40.689247, -74.044502) and the London Eye in London (51.508530, -0.076132). The function would return the distance between the two points in kilometers.


Posted

in

by

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *