itowns
itowns copied to clipboard
[PROPOSAL] Error as value instead of throwing during picking
Your Environment
- Version used: commit 9fa4cde79b138548c5b897ea78bd2a88d0946029
- Browser Name and version: Firefox 123.0 (64-bit)
- Operating System and version (desktop or mobile): Ubuntu 22.04.4 LTS x86_64
Context
Datasets should ideally be clean of artifacts, but that's rarely the case so failing an entire picking call for a single artifact encounter is ineffective. This happens for example when picking certain NaN-ed out points in point cloud datasets while using proj4.
Expected Behavior
The picking routine should catch the errors and return them as values along with the valid results.
Actual Behavior
The picking routine pickPointsAt
in src/Core/Picking.js
does not catch errors and instead passes them along, leading to a discard of possibly valid and unrelated results when Coordinates::spatialEuclideanDistanceTo
throws an error.
Possible Cause/Fix/Solution
Catching thrown errors per-point and transforming them into error values to push into the result
array. This should not incur additional runtime costs at least on the V8 engine.
It just hit me that this would be even better handled by making the function a generator and keeping the current throw mechanism.