MySQL Forums
Forum List  »  GIS

Re: New openGIS functionality in MySQL available for testing
Posted by: Daniel Zburivsky
Date: April 04, 2008 11:29AM

Hi,
I'm testing new GIS functionality and would like to know how the DISTANCE function is currently implemented. Particularly, does it calculate distance on the Earth's surface?

As an example I used the following:

Coordinates of Ottawa are: Lat:45.424, Long:-75.695, coordinates of Los Angeles: Lat:34.051, Long:-118.254.

To calculate distance I've used a calculator found here:http://www.movable-type.co.uk/scripts/latlong.html . It uses Haversine formula. The result is 3802 km, which seems to be true.

Now let's calculate the same distance using MySQL function:


SELECT DISTANCE(GeomFromText('POINT(-75.695 45.424)'), GeomFromText('POINT(-118.254 34.051)'));
+-----------------------------------------------------------------------------------------+
| DISTANCE(GeomFromText('POINT(-75.695 45.424)'), GeomFromText('POINT(-118.254 34.051)')) |
+-----------------------------------------------------------------------------------------+
| 44.052396189084 |
+-----------------------------------------------------------------------------------------+

This gives us quite strange result. Which even doesn't correspond to the result of a simple math formula calculating geometrical distance between two points sqrt((x2-x1)^2+(y2-y1)^2), which gives the number of 194.

Thanks in advance!

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.