# HG changeset patch # User jbe # Date 1474720942 -7200 # Node ID bdbec73dc8fff92205566f625021d0c28ef17b5a # Parent 868220477afb262621fc774208b98fed14f3f5a5 Improved accuracy for distance calculation to paths/polygons/outlines diff -r 868220477afb -r bdbec73dc8ff latlon-v0007.c --- a/latlon-v0007.c Sat Sep 24 01:23:11 2016 +0200 +++ b/latlon-v0007.c Sat Sep 24 14:42:22 2016 +0200 @@ -820,10 +820,15 @@ double min_dist = INFINITY; /* minimum distance */ /* distance is zero if point is contained in cluster */ if (pgl_point_in_cluster(point, cluster, false)) return 0; - /* calculate (approximate) square compression of meridians */ - /* TODO: use more exact formula based on WGS-84 */ + /* calculate approximate square compression of meridians */ comp = cos((lat0 / 180.0) * M_PI); comp *= comp; + /* calculate exact square compression of meridians */ + comp *= ( + (1.0 - PGL_EPS2 * (1.0-comp)) * + (1.0 - PGL_EPS2 * (1.0-comp)) / + (PGL_SUBEPS2 * PGL_SUBEPS2) + ); /* iterate over all entries */ for (i=0; inentries; i++) { /* get properties of entry */