MushroomObserver / mushroom-observer

A website for sharing observations of mushrooms.
https://mushroomobserver.org
MIT License
77 stars 25 forks source link

Exclude vague locations from `Mappable::CollapsibleCollectionOfObjects` #2091

Closed nimmolo closed 3 months ago

nimmolo commented 3 months ago

Cleans up maps by getting rid of overly vague location boxes

Currently on the site, we exclude observations whose location is "Earth" on maps, because they mess up the interface. But an observation with a large associated Location like "USA" also obscures more specific observation data on a map, whenever the vague location gets grouped with the more specific locations. (See discussion #2088.)

One way to fix this might be by grouping large locations together so they don't hide the precise ones. But it's hard to control the order of grouping (it would require calculating each location's surface area from lat/lng) and ordering by this derived value. But big boxes would still make underlying boxes difficult to click.

@pellaea proposed just excluding all big locations from mapsets, because

First try: 1º lat/lng max box size

I tried excluding locations whose east-west longitude difference, or north-south latitude difference, was more than 1º either direction, and it immediately improved the legibility of the test map I used for debugging, "observations of name 5066".

Before: mushroomobserver.org/names/5066/map Screen Shot 2024-04-10 at 4 34 54 PM

After: localhost:3000/names/5066/map Screen Shot 2024-04-10 at 4 33 36 PM

However, 1º is not the same everywhere on the globe. Using a "1º rule" obscures some locations closer to the poles that may be considered marginally useful.

For example, observations at Denali National Park and Peace River Area currently appear on the live site:

mushroomobserver.org/names/5066/map Screen Shot 2024-04-10 at 4 39 56 PM

But when limiting areas to "1º" in either direction on this branch, the observations at these locations are not shown:

localhost:3000/names/5066/map Screen Shot 2024-04-10 at 4 38 27 PM

I'm going to search for a better formula for areas of these boxes so we're doing orange-to-orange comparisons of geometric area.

coveralls commented 3 months ago

Coverage Status

coverage: 94.407% (+0.004%) from 94.403% when pulling cb54b4447b4a618bd09820bc68e38801fea2a992 on nimmo-exclude-vague-locations-from-maps into 1902cc4ad06d0faeaa1831f948d98b032c4cc49e on main.

nimmolo commented 3 months ago

Ok - I've updated the PR to calculate a consistent area when trying to determine if a location is small enough to be considered "not vague". It uses the proper formula for the area of a spherical patch, converting degrees to radians.

area = Rˆ2 (Θ1 - Θ2) (sin(ɸ1) - sin(ɸ2))

That's right, Mr. Towell, I remembered that! (Just kidding, no i didn't!)

My arbitrary area cutoff now is 24,000 sq. km. This includes the box around "Peace River Area" but excludes the box around "Denali National Park". (Note that the box around a location may be a much larger area than the location itself.)

localhost:3000/names/5066/map Screen Shot 2024-04-10 at 5 46 46 PM

Doubling the cutoff to 48,000 sq. km would include the box around "Denali", but also probably the box around "Massachusetts" and a bunch of other vague locations. Please feel free to help me decide what the max should be!

I feel like our stance at a certain point has to be, "if you want this observation to appear on maps, then please give a more precise location". There's another discussion about warning people that an observation's location is not precise enough.

JoeCohen commented 3 months ago

Thanks for thinking this through and doing the PR.

nimmolo commented 3 months ago

Added the following message to show obs, under the location, if the location is vague:

This observation will not appear on maps of its taxon because the location is too vague.

If the current user is the observation owner, it also says this:

If you would like it to be included in maps, choose a more precise location.

Also added a test that these messages appear if appropriate.