Why compute a surveyor with lat / lon instead of caching Cartesian points?

When researching how to make the classic "get POI in range" problem, I found that the most used algorithms are Haversine, and if you need real accuracy, then the Vincenty formula. I went first because high accuracy was not a problem. However, it made me think of something that struck me as strange, why didn't I find Cartesean coordinate cache references in the database instead of using the haversine formula with lat / lon?

The problem here, of course, is performance. The haversine formula requires tons of cos / sin function calls, but isnโ€™t it easier to save the projected X / Y and Z lat / lon points in the database and directly apply the dot product? This will require one call to arccos, if I'm not mistaken.

+4
source share
3 answers

Since any given Cartesian projection will give only the correct answer for certain points - a projection that gives the correct distance between two points on one particular circle around the sphere will distort the distances along another specific circle.

Formulas such as Haversin are independent of the relative locations of various points on the sphere; they return the correct distance regardless.

+3
source

No, you are not mistaken. However, two things. First, itโ€™s obvious that your performance benefits will depend on the nature of your application. If you need to use the same points in your calculations, you will improve productivity by doing what you offer.

Secondly, the formula you use is not a problem here. If you precompile and save sin and cos for lat / lon and use haversine, you will get the same performance improvement.

0
source

Calculating the distance between the two coordinates X, Y, Z will give you a rectilinear distance (as the arrow flies). The Haversin formula gives the shortest path on the surface of curved earth (spherical distance). Most geographic software applications must calculate the distance over the earth's surface, which is why Haversine algorithms or similar spherical trigonometry are used.

0
source

Source: https://habr.com/ru/post/1313963/


All Articles