pgLatLon
changeset 30:bdbec73dc8ff
Improved accuracy for distance calculation to paths/polygons/outlines
author | jbe |
---|---|
date | Sat Sep 24 14:42:22 2016 +0200 (2016-09-24) |
parents | 868220477afb |
children | 42d0e73f7d58 |
files | latlon-v0007.c |
line diff
1.1 --- a/latlon-v0007.c Sat Sep 24 01:23:11 2016 +0200 1.2 +++ b/latlon-v0007.c Sat Sep 24 14:42:22 2016 +0200 1.3 @@ -820,10 +820,15 @@ 1.4 double min_dist = INFINITY; /* minimum distance */ 1.5 /* distance is zero if point is contained in cluster */ 1.6 if (pgl_point_in_cluster(point, cluster, false)) return 0; 1.7 - /* calculate (approximate) square compression of meridians */ 1.8 - /* TODO: use more exact formula based on WGS-84 */ 1.9 + /* calculate approximate square compression of meridians */ 1.10 comp = cos((lat0 / 180.0) * M_PI); 1.11 comp *= comp; 1.12 + /* calculate exact square compression of meridians */ 1.13 + comp *= ( 1.14 + (1.0 - PGL_EPS2 * (1.0-comp)) * 1.15 + (1.0 - PGL_EPS2 * (1.0-comp)) / 1.16 + (PGL_SUBEPS2 * PGL_SUBEPS2) 1.17 + ); 1.18 /* iterate over all entries */ 1.19 for (i=0; i<cluster->nentries; i++) { 1.20 /* get properties of entry */