Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Our address sorting is bad #6475

Open
pmk01 opened this issue Mar 7, 2024 · 3 comments
Open

Our address sorting is bad #6475

pmk01 opened this issue Mar 7, 2024 · 3 comments

Comments

@pmk01
Copy link
Collaborator

pmk01 commented Mar 7, 2024

image

Addresses which aren't a simple [n] [street name] get pushed to the bottom of the list. This is bad for users, who expect 32A to come between 32 and 33.

@GeoWill GeoWill removed their assignment Mar 7, 2024
@chris48s
Copy link
Member

chris48s commented Mar 7, 2024

Related issues:

The relevant code is

https://github.com/DemocracyClub/uk-geo-utils/blob/master/uk_geo_utils/helpers.py#L277
https://github.com/DemocracyClub/uk-geo-utils/blob/master/uk_geo_utils/tests/test_address_sorter.py

Its not awful, but I think in order to sort all those cases correctly without breaking loads of other stuff, you need to move from a model where address is stored as single string to a model where you keep the addresses broken down into parts, sort them and then concatenate all the bits together for display.

This is further complicated by the fact there are 2 different formats depending on whether it is a PAF address or Local Auth address.

@GeoWill
Copy link
Collaborator

GeoWill commented Mar 7, 2024

Thanks @chris48s

@chris48s
Copy link
Member

Just came across https://github.com/openvenues/libpostal (it has python bindings - https://github.com/openvenues/pypostal and a postgresql extension https://github.com/pramsey/pgsql-postal ) and thought back to this thread.

I suspect it is imperfect, but I wonder if using that to:

  • parse the address into bits
  • sort the bits
  • stick them back together for display

might be a way to improve on my crude attempt to do that without eating the entire elephant of the "proper" solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants