This repository has been archived by the owner on Oct 30, 2021. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Distance floor PR
Context
In calculating scoredist, the distratio had a hard-coded minimum value of 0.005. The rationale behind this was that if as distratio approaches zero, the scordist value gets exponentially higher. The cap at 0.05 was hard-coded based on a proximity radius of 200, assuming that 0.05 was the minimum reasonable value (more explanation below).
This value of 0.005 is based on the minimum reasonable value for a proximity radius closer to 200. The problem is that when the proximity radius passed in to coalesce is higher, say 400, there is meaningful differentiation in the values that are less than 0.005.
Alternatively, any distance less than 1 isn't meaningful, since something on the same tile as the proximity point will be 0, and something one tile away will have a distance of >=1.
This PR sets a minimum distance, instead of a minimum distRatio.
Summary of changes
Next steps
More in-depth explanation
zoomTileRadius converts miles into a tile unit value. For zoom 14, it would be
0.8
:proximityRadius for zoom 14, and radius 400 would be
320
(as opposed to160
for radius 200):distRatio for zoom 14, distance 0, score 0, radius 400 would previously have been capped at 0.005:
Previously:
If the feature was 1 tile away from the proximity point, with a radius of 200 (so proximityRadius of 160), the distRatio woud have been
1/160 = 0.00625
. That’s why a minimum of0.005
made sense. If the proximity radius is 400 though, the distRatio for 1/320 would be0.003125
, which is under the 0.005 threshold. This means that there was no distinction in scoredist between a distance of 0 and a distance of 1, so features on the same tile as the proximity point were not getting sorted higher than features 1 tile away.Now:
scoreDist:
Open question:
What are the limits of this for different zoom levels, scores and proximity radius values? Is it still necessary to have another cap to avoid astronomically high scoredists?