# Accurate Algorithms for Spatial Operations on the Spheroid in a Spatial Database Management System
## 3 Validation of Results
### Tests
#### 3.1.2 Test B  
As explained below, this test provides a linear magnitude of deviation from the intersection point X to both geodesics AB and CD. It has a clear geometric meaning easily interpretable by the user, in contrast to the previous test.  
Assume the calculated intersection point X has some error, then the intersection point would be located at X\({}^{\prime}\) instead of X. If so, there would be some deviation d\({}_{\rm AB}\) (Figure 3), between X\({}^{\prime}\) and X\({}^{\prime\prime}\), greater than zero, where X\({}^{\prime\prime}\) is the projection of X\({}^{\prime}\) on the geodesic AB.  
From a starting point A, an azimuth \(\alpha\)AB and a distance AX\({}^{\prime}\) we can easily calculate X\({}^{\prime\prime}\) through the direct problem of geodesy.  
The distance d\({}_{\rm AB}\) is the distance from the calculated point X\({}^{\prime}\) to the geodesic AB. The same distance can be calculated from the point X\({}^{\prime}\) the other geodesic CD and thus obtain a second deviation distance d\({}_{\rm CD}\). If both distances are zero, the X\({}^{\prime}\) point is the exact intersection of the geodesics AB and CD.  
\begin{table}
\begin{tabular}{c c c c c c} \hline \hline \multirow{2}{*}{**Case**} & \multirow{2}{*}{**Deviation**} & **Oracle and** & **ArcGIS** & **ArcGIS Geodetic** & **PostGIS** \\  & & **Google and** & **Geodetic** & **Density +** & **Geography with** \\  & & **Sphere** & **Density** & **Projection** & **Local Projection** \\ \hline
1 & Test & 0.57991 & 200.47001 & 1.20114 & 1.20015 \\
2 & A & 2.83179 & 23.37880 & 22.83089 & 21.01461 \\
3 & (arcsec) & \(-\)306.75159 & \(-\)0.13274 & \(-\)3.11587 & \(-\)11,408.23193 \\
4 & & 434.55065 & \(-\)0.10260 & \(-\)0.10084 & 187,542.96132 \\
1 & Test & 0.0272 & 6.4566 & 0.03871 & 0.03867 \\
2 & B & 0.3093 & 2.4525 & 2.3951 & 2.20421 \\
3 & (m) & 4887.9260 & 2.8386 & 0.0133 & 1,524,432.6228 \\
4 & & 4148.9669 & 3.0971 & 3.0440 & 2,227,566.4855 \\ \hline \hline \end{tabular}
\end{table}
Table 2: Azimuth and distance deviation (estimation).  
Figure 3: Distance deviation (d\({}_{\rm AB}\)) from the geodesic AB. X exact intersection, X\({}^{\prime}\) intersection point calculated by Oracle, Google, ArcGIS, etc., AX\({}^{\prime}\) = Geodesic distance between A and X\({}^{\prime}\), X\({}^{\prime\prime}\) projection of X\({}^{\prime}\) on the geodesic AB.  
The column deviation of Table 2 shows the value in meters of Test B, Maximum (d\({}_{\text{AB}}\), d\({}_{\text{CD}}\)). The calculation is approximate (although quite accurate as it will be demonstrated in next section) because, obviously, we still do not know where the true point of the intersection is.  
As it can be seen in Table 2, Google Earth Engine and Oracle Spatial show a deviation (test B) of almost 5 km. This is due to the computing with the sphere instead of the ellipsoid. ArcGIS, even in the case of using local projections after applying a densified geodesic, shows deviations of several tens of meters.  
Additionally, PostGIS, with its spatial operators (which internally use local reprojections) shows a deviation of several meters in case 2. Cases 3 and 4 should not count too much, since PostGIS in these cases uses the Web Mercator projection that introduces huge deformations. Hopefully PostGIS will improve the choice of the best projection for these cases, which would limit the deviation to hundreds of meters.  
The most favorable example, case 1, shows a deviation of several centimeters, an amount that, according to the purpose of the spatial analysis, could already be intolerable.