# Accurate Algorithms for Spatial Operations on the Spheroid in a Spatial Database Management System
## 2 Experiments  
Our hypothesis states that some of the most powerful geospatial software products provide only approximate results in the calculations of operations D and E on the ellipsoid, despite that, some software companies claim that these calculations are accurate. We start with operation D, first describing the methodology used by each software and then demonstrating how the results of the calculations are in all cases approximate. Operation E is discussed in Section 4.3. For all the examples the ellipsoid WGS84 is used. First, we will solve a simple intersection of two geodesics defined by four points. Given points A, B, C and D on the ellipsoid (Figure 1) we calculate the intersection (denoted by X) of geodesics AB and CD with different software products. In Table 1 four cases are distinguished for short, medium, long and very long lines, depending on the coordinates given for A(\(\varphi_{A}\),\(\lambda_{A}\)), B(\(\varphi_{B}\),\(\lambda_{B}\)), C(\(\varphi_{C}\),\(\lambda_{C}\)) and D(\(\varphi_{D}\),\(\lambda_{D}\)): Case 1 A(54.0\({}^{\circ}\),14.5\({}^{\circ}\)), B(54.2\({}^{\circ}\),14.6\({}^{\circ}\)), C(54.1\({}^{\circ}\),14.4\({}^{\circ}\)), D(54.0\({}^{\circ}\),14.7\({}^{\circ}\)), distances AX and CX are 6.6 and 9.6 km; Case 2 A(52\({}^{\circ}\),5\({}^{\circ}\)), B(51.4\({}^{\circ}\),6\({}^{\circ}\)), C(51.5\({}^{\circ}\),4.5\({}^{\circ}\)), D(52\({}^{\circ}\),5.5\({}^{\circ}\)), distances AX and CX are 21.6 and 64.7 km; Case 3 A(42\({}^{\circ}\),29\({}^{\circ}\)), B(39\({}^{\circ}\),\(-77^{\circ}\)), C(6\({}^{\circ}\),0), D(64\({}^{\circ}\),\(-22^{\circ}\)), distances AX and CX are 345 and 556 km; Case 4 A(35\({}^{\circ}\),\(-92^{\circ}\)), B(40\({}^{\circ}\),52\({}^{\circ}\)), C(\(-8^{\circ}\),20\({}^{\circ}\)), D(49\({}^{\circ}\),\(-95^{\circ}\)), distances AX and CX are 2003 and 11,347 km. In the first example, the distance (average of AX and CX) is 8 km. For the second, third and fourth examples, the distances are 43, 450 and 6675 km, respectively. For each of the three geospatial software groups, namely geographic information systems (GIS), spatial database management systems (SDBMS) and geospatial libraries (APIs), we chose one of the most powerful solutions. Representing  
Figure 1: Intersection of geodesics AB and CD. the first group, we will test ArcGIS by ESRI [19], which is a very well-known and powerful GIS Desktop solution, spread all over the world and used by many public governments. It is worth noting that none of the open-source GIS desktops (QGIS, GRASS, gvSIG, uDIG, etc.) implement operations D or E on the ellipsoid. The best known and most advanced open-source Spatial DBMS is, definitely, PostGIS [20] but it is discarded because it does not implement the D or E operations on the ellipsoid. We will use instead one of the most powerful spatial DBMS commercial solutions: the Oracle Spatial extension [21], which allows us to solve operations D and E on the ellipsoid. Regarding geospatial libraries using the ellipsoid in their algorithms we can find Google Earth Engine [22], which is one of the most powerful Geospatial API solutions, with many new features in recent years. The last row of Table 1 shows the geocentric coordinates from the result of intersecting the two great circles AB-CD using a sphere. Solving the intersection is trivial if we consider a sphere instead of an ellipsoid. In that case, the minimum distance between two points on the surface of the sphere is not a geodesic of complicated geometry but a simple great circle (orthodrome). The intersection of two great circles using some spherical trigonometry math is solved by a very straightforward formula [23] but at the cost of possibly having huge discrepancies with respect to the true intersection on the ellipsoid. In this section we will prove that some spatial software are using great circles and not geodesics on the ellipsoid. In Section 3, we design two tests to assess the errors of the different software solutions.