Reverse geocoding gives city of nearest object, not city of current position

Description

Hi,

With some ways which go through multiple cities, reverse geocoding answers the wrong city, as the address given contains the city at the nearest object's centroid, and not the city of the position asked.

A better result could be obtained by mixing the selected objets based on 2 different criterias: ST_Distance to name the nearest object (the name of the road/street) and ST_Distance(ST_Centroid()) to get the details about the city/town of the given location and not using the one of the centroid of the nearest objet which can actually be quite far away.

In order to do this, the SQL query needs to provide both ST_Distance and ST_Distance(ST_Centroid()) in its results (which should be minimal additionnal cost in the query) and have some additionnal post-processing in the php code only when the difference between both distances is significant.

Sorry but it is not as simple as that because currently there are no distances to any address objects calculated. Doing so would add a pretty heavy performance penalty and is simply not worth the trouble.

Sorry but it is not as simple as that because currently there are no distances to any address objects calculated. Doing so would add a pretty heavy performance penalty and is simply not worth the trouble.

Sorry but it is not as simple as that because currently there are no distances to any address objects calculated. Doing so would add a pretty heavy performance penalty and is simply not worth the trouble.

Using the address of the nearest object for the reverse query was a deliberate design decision. Calculating the address involves a lot of voodoo because it has to work world-wide and with different tagging schemas. It would be too expensive to do at each reverse request.

The other thing is that long ways become less and less frequent, the better a region gets mapped. Ways are split for taggings like maxspeed and for route relations and turn restrictions. The moment the way is split, the issue goes away by itself because each part can have a different address. So I wouldn't call it a major issue.