# Accurate Algorithms for Spatial Operations on the Spheroid in a Spatial Database Management System
###### Abstract  
Some of the most powerful spatial analysis software solutions (Oracle, Google Earth Engine, PostgreSQL + PostGIS, etc.) are currently performing geometric calculations directly on the ellipsoid (a quadratic surface that models the earth shape), with a double purpose: to attain a high degree of accuracy and to allow the full management of large areas of territory (countries or even continents). It is well known that both objectives are impossible to achieve by means of the traditional approach using local mathematical projections and Cartesian coordinates. This paper demonstrates in a quantitative methodological way that most of the spatial analysis software products make important deviations in calculations regarding to geodesics, being the users unaware of the magnitude of these inaccuracies, which can easily reach meters depending on the distance. This is due to the use of ellipsoid calculations in an approximate way (e.g., using a sphere instead of an ellipsoid). This paper presents the implementation of two algorithms that solve with high accuracy (less than 100 nm) and efficiently (few iterations) two basic geometric calculations on the ellipsoid that are essential to build more complex spatial operators: the intersection of two geodesics and the minimum distance from a point to a geodesic. computational methods; algorithms; ellipsoid; geodesics; geographical information science and systems +
Footnote †: journal: Physics Letters A  
1
Footnote 1: email: _Applied_  
28 May 2021  
Clarke 1866 [4], \(a\) = 6,378,249.145 m and \(f\) = 1/293.465 for Clarke 1880 [5], \(a\) = 6,378,388 m and \(f\) = 1/297 for Hayford [3], \(a\) = 6,378,137 m and \(f\) = 1/298.257222101 for GRS80 [6] and \(a\) = 6,378,137 m and \(f\) = 1/298.257223563 for WGS84 ellipsoid [5], whose minuscule discrepancy with respect to the GRS80 of 0.1 mm in the direction of the minor semiaxes is negligible for all practical purposes. The reference ellipsoid also needs to be assigned a mass and angular velocity, which are conventionally adopted, for it to serve as a dynamic reference. Further, the ellipsoid needs to be conveniently placed with respect to the Earth's center of mass or geocenter, so that a global geodetic reference system is obtained. The realization (or practical implementation) of the reference system is done by means of a set of geodetic benchmarks with coordinates assigned after complex calculations involving different geodetic techniques (Satellite Laser Ranging, Very Long Baseline Interferometry, Global Navigation Satellite Systems and Doppler Orbitography and Radiopositioning Integrated by Satellite [7]). This has eventually resulted in the proposal of the International Terrestrial Reference System (ITRS) and its most recent realization, the International Terrestrial Reference Frame 2014 (ITRF2014 [7]), as the most accurate scientific reference for geospatial analysis [8]. The subsequent realizations of the WGS84 reference system (used by the GPS constellation since its initial deployment), have been increasing aligned with the realizations of the International Terrestrial Reference System so that the latest ones, WGS84(G1762) and ITRF2014, are equivalent in practice (they are consistent at the centimeter level [9; 10; 11]). The practical equivalence of both the WGS84 ellipsoid and the WGS84 reference system with the GRS80 ellipsoid and the ITRS is therefore implied in the rest of the paper. However, solving a geometric problem on the surface of the ellipsoid is not a simple task. Therefore, the auxiliary use of map projections is normally preferred. By means of local projections, the geographic coordinates (on a reference ellipsoid) are converted to flat coordinates and thus all the above calculations can be easily applied.