mushroom-observer icon indicating copy to clipboard operation
mushroom-observer copied to clipboard

Location name suggestions

Open pellaea opened this issue 3 years ago • 51 comments

Improves observation form's handling of locations.

  1. Officially changes policy concerning including counties back to what it was at the beginning: counties are now encouraged again.

  2. When lat/long is updated (pin dropped or dragged, gps taken from image header, user enters it by hand), it uses google to reverse geolocate, and it sends the resulting info to the observer controller: country, state, county, city. (It makes the submit buttons wait for google to respond.)

  3. "Earth" is no longer considered acceptable. It will complain "please enter at least country!" and force the user to approve "Earth" before accepting it. If geolocation data is available, it will suggest existing locations which contain the lat/long, or which match google's reverse geolocation, or if nothing matches it will suggest a fairly reasonable name for a new location based on google's reverse geolocation. This latter will require some editing in some cases, but it will at least be better than nothing.

  4. If the lat/long is way outside of the bounding box for the chosen location, it will complain, and it will suggest some alternative existing locations which contain the lat/long.

  5. If a smaller location contains the lat/long it will suggest this location.

  6. If the location name entered does not match an existing location, it will go to some rather extreme efforts to correct a number of common mistakes, including but not limited to correcting spelling mistakes, filling in omitted country, state, county, unabbreviating states. It will use info from google's reverse geolocation in some cases to fill in missing terms. But importantly, this process will only ever suggest existing locations. All the usual mistakes are still going to happen when creating new locations.

  7. If any of the above cause MO to suggest one or more alternative location names, it will reload the form and display the suggestions as a set of radio boxes, along with at least some explanation of why we're suggesting the alternative locations. The user can then click any of the radio boxes and re-submit. Or the user can simply resubmit the form to "approve" whatever data they already have entered.

All tests are passing, but I feel like a good deal more testing is required before merging this. Also, two of the primary location name correction methods (in app/models/location/suggestions.rb) violate ABC complexity and should probably be refactored a bit. I will take a look at this later when I'm fresher to see if any clever ideas arise.

Meanwhile, this is a working draft.

pellaea avatar Dec 02 '20 08:12 pellaea