Closed SymbolixAU closed 5 years ago
PR #126
I think returning 'hovered' points to R session will be tricky. The function to calculate if a point is in range is performed on the GPU, and we can't access this from javascript. I tried writing my own version, but on 57,757 points (mapdeck::roads
) it bogs down
function distance_between_coordinates(lat1, lon1, lat2, lon2) {
var p = 0.017453292519943295; // Math.PI / 180
var c = Math.cos;
var a = 0.5 - c((lat2 - lat1) * p)/2 +
c(lat1 * p) * c(lat2 * p) *
(1 - c((lon2 - lon1) * p))/2;
return 12742 * Math.asin(Math.sqrt(a)); // 2 * R; R = 6371 km
}
function is_point_in_range(point_lat, point_lon, mouse_lat, mouse_lon, range) {
return (distance_between_coordinates(point_lat, point_lon, mouse_lat, mouse_lon) <= range);
}
https://github.com/uber/deck.gl/tree/master/examples/website/brushing/scatterplot-brushing-layer
Similar to Arch Brush #23
TODO
return 'hovered' points to R session (shiny)