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

Change order of region/macroregion layers when doing search #325

Merged
merged 2 commits into from
Mar 10, 2025

Conversation

SiarheiFedartsou
Copy link
Contributor

👋 I did some awesome work for the Pelias project and would love for everyone to have a look at it and provide feedback.


Here's the reason for this change 🚀

Basically how I bumped into it: we noticed that even though there is WOF data in Azerbaijan for region it is not returned from PIP service in many cases:

Screenshot 2025-03-04 at 17 01 56

I started digging and noticed that order of layers is important, because (as I understand) we are trying to find the lowest one first and then simply use hierarchy to resolve the rest of them. Here since marcoregion goes first in the list of layers + there is macroregions data for Azerbaijan we basically never return region data from this service.

After changing the order it works as expected:
Screenshot 2025-03-04 at 17 01 12

Worth saying that according https://github.com/whosonfirst/whosonfirst-placetypes macroregion indeed should be > region.


Here's what actually got changed 👏

  • Changed order of layers

Here's how others can test the changes 👀

I haven't added any tests, please let me know WDYT first and then I can try come up with some test for it.

@SiarheiFedartsou SiarheiFedartsou marked this pull request as ready for review March 4, 2025 16:07
@SiarheiFedartsou SiarheiFedartsou force-pushed the sf-macroregion-vs-region branch from 8af59b7 to c6075e8 Compare March 4, 2025 16:19
@SiarheiFedartsou SiarheiFedartsou force-pushed the sf-macroregion-vs-region branch from c6075e8 to c89b982 Compare March 4, 2025 16:20
@SiarheiFedartsou
Copy link
Contributor Author

Hey @missinglink @orangejulius WDYT about this? May be I don't get something or it is indeed a bug?

@orangejulius
Copy link
Member

Hmm yeah I think this is a very nice catch :)

The good news is it probably affects very little. There are only 96 active macroregion records in WOF thankfully. Only cases where a direct admin lookup was supposed to go to a region overlapping one of those macroregions should see any difference.

And even then, only if there are no relevant lower layers (neighbourhood, locality, localadmin, county, etc).

For example, for an address record to be missing a region when it should have one, I think it would have to not be contained by any admin area lower than region (for example neighbourhood, localadmin, locality, etc which are all quite common).

I can see how Azerbaijan could be one of those places since it has macroregions and (presumably) a lot of unincorporated land that might not have any lower admin areas.

I was curious and I did some querying, in a recent planet build their are 127k addresses and 383k total records that have a macroregion but no region. Some of those will be legitimate, I'm sure there are places with a macroregion but no region.

Some are wrong though, for example Eizaguirre Auzoa 331, Basque Country, Spain should be parented by both the Gipuzkoa region and Basque Country macroregion within Spain.

We've had lots of issues with macroregion over the years, and it looks like this is a genuine mistake from 8 years ago 😱, so I think we should probably merge this. That said I recall we've had to think carefully about ordered lists of layers in other places in the code. @missinglink can you think of any considerations that are relevant here?

@orangejulius
Copy link
Member

@missinglink this looks good, right?

Copy link
Member

@missinglink missinglink left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@missinglink missinglink merged commit 8fd5eed into pelias:master Mar 10, 2025
3 checks passed
orangejulius added a commit to pelias/openstreetmap that referenced this pull request Mar 10, 2025
Includes a fix for macroregions/region ordering from pelias/wof-admin-lookup#325
orangejulius added a commit to pelias/openstreetmap that referenced this pull request Mar 10, 2025
Includes a fix for macroregions/region ordering from pelias/wof-admin-lookup#325
orangejulius added a commit to pelias/openaddresses that referenced this pull request Mar 10, 2025
Includes a fix for macroregions/region ordering from pelias/wof-admin-lookup#325
orangejulius added a commit to pelias/polylines that referenced this pull request Mar 10, 2025
Includes a fix for macroregions/region ordering from pelias/wof-admin-lookup#325
orangejulius added a commit to pelias/geonames that referenced this pull request Mar 10, 2025
Includes a fix for macroregions/region ordering from pelias/wof-admin-lookup#325
orangejulius added a commit to pelias/transit that referenced this pull request Mar 10, 2025
Includes a fix for macroregions/region ordering from pelias/wof-admin-lookup#325
orangejulius added a commit to pelias/csv-importer that referenced this pull request Mar 10, 2025
Includes a fix for macroregions/region ordering from pelias/wof-admin-lookup#325
orangejulius added a commit to pelias/pip-service that referenced this pull request Mar 10, 2025
Includes a fix for macroregions/region ordering from pelias/wof-admin-lookup#325
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

Successfully merging this pull request may close these issues.

3 participants