pelias / labels

Pelias Label generation
https://pelias.io
MIT License
4 stars 9 forks source link

Add region to default labels if different from city #43

Closed orangejulius closed 3 years ago

orangejulius commented 3 years ago

This adds the region to the default labels, but only if the region name is different from the city name (defined as locality or localadmin name).

The intent is to handle major world cities like Berlin, Sao Paulo, Paris, etc that are contained within an administrative region of the same name, and are so well known that they do not require any additional specifiers.

In the more common case where the region and city names are different, the region abbreviation is preferred, with the region name being returned only if the abbreviation is not available.

orangejulius commented 3 years ago

I think this can serve as a replacement for #41, with a bit of refinement.

It more closely follows our existing logic to use region_a if available, then falling back to region. It also has the logic for skipping the region name (or abbreviation) when it would duplicate the locality name.

missinglink commented 3 years ago

A couple of caveats to this approach, just putting them out there in case they are easy fixes:

Happy to punt those topics, just need to add some Issues for them.

orangejulius commented 3 years ago

Ok, after some testing we definitely needed some basic normalization. I borrowed some code from the API that looks perfect for the task:

https://github.com/pelias/api/blob/0a964c2420dcf2bfc60279916ddbf4fa5d9c4c90/helper/diffPlaces.js#L230-L232

orangejulius commented 3 years ago

Some quick examples of how this looks now: image Here the well known São Paulo does not have a region in the label, but the others do.

Likewise for Berlin. Some other cities with berlin in the name in Berlin Brandenburg have an abbreviation: image I'm not sure this is 100% great, we should check to see what the most common system in Germany is. Looking at Nominatim's list, the region is not included.

missinglink commented 3 years ago

The classic testcase for Germany is that Frankfurt am Main and Frankfurt an der Oder produce different labels.

missinglink commented 3 years ago

I think this is a much better default to have, there may be some improvements to be made on a per-country level but this raises the bar for anything using the generic label generator :+1: