Meter distance computation in Web Mercator - #10
Conversation
…cator space, add many more tests which uncovered 3 bugs: one padding overflow, one missing contains check for dist computation between segments and boxes, and a nasty error introduced with the deferred OUT event rewrite from 2 weeks ago which skipped deferred OUT events in some cases. also add tests for meter distance computation cases which currently have a large error because we assume that the point from which a segment has the shortest distance to another point is the projected point - this may not be true for segments covering very large lat/lng distance
|
There are now two types of errors left in the meter distance computation (covered now by tests which are for now commented out): 1.) We currently assume that the meter distance between a point A and a line segment S is the distance between the projection of A onto S and A. This is not true for segments spanning large latitude ranges. It can be mitigated a bit by taking min(dist(A, endpointS1), dist(A, endpointS2), dist(A, projectAonS)). |
|
The remaining 2 error sources will be separate PRs. |
The exact meter distance computation has several problems when done in WGS84 space. Most critically, if WGS84 is used directly as a map projection (plate caréé), the distance distortion is not uniform in x and y direction, but only distorted in x direction. This breaks a few assumptions in the search padding function. It would be possible to fix that, but that would add some code duplication. I tried that and it worked correctly, but because several speed-up heuristics are tailored to the web merc space, the direct computation on WGS84 was up to a factor of 4 slower. We also dont really need it, as all call sites of the old meter distance calculation already use web mercator projected geometries.
So this PR replaces all withinMeterDist and meterDist functions with webMercWithinMeterDist and webMercMeterDist functions which work exactly the same. The is also a preparation for updating the meter distance computation in QLever, which should be a simple update of
libspatialjoinwith this PR, requiring no changes in the QLever codebase. As discussed with @ullingerc, I will test this as soon as ad-freiburg/qlever#3199 is merged.Along the way, I added some additional tests which uncovered 3 bugs which are now fixed:
XSortedCollectionwhen the withinDistance threshold was not infinity, but very large. Essentially, all padded x coordinates then collapsed to DBL_MAX, making it impossible to sort them.