falling-fruit / falling-fruit-api

API (v0.3) for Falling Fruit
https://fallingfruit.org/api/0.3
GNU General Public License v3.0
6 stars 1 forks source link

Add bounding boxes for clusters #30

Open wbazant opened 1 month ago

wbazant commented 1 month ago

Follow-up from https://github.com/falling-fruit/falling-fruit-web/issues/423. Going to isolated clusters could be a nicer experience if we were able to zoom in just into their bounding box.

Implementation idea, without looking at the code: given a list of locations for a cluster and their centre, find max(lat), min(lat), max(lng), min(lng)?

The bounding boxes could be calculated optionally, maybe even with a hardcoded upper bound for a count, since they're most useful for sparsely populated places with a handful of locations.

For example: two locations in Ullapool town centre are visible as a cluster in https://beta.fallingfruit.org/map/@58.1014684,-5.5723643,8z but it takes three clicks to get to them.

ezwelty commented 5 hours ago

It is easy to initially build the clusters with min, max lat, lng, and it is trivial to increment the cluster bounds when a location is added or moved, but it is not at all trivial to decrement the impacted clusters when a location is moved or deleted. In fact, I think it would require recomputing the min, max from scratch, which could be a non-negligible performance hit in areas with lots of locations.