In mkgmap [1] this calculation is done to allow address search. It handles several special cases like roads building city boundaries,
roads crossing city boundaries and places where the name in addr:street doesn’t match the name of the highway=* way.

If you don’t care about these special cases it should be rather easy to use mkgmap to create a list of highway=* ways and a city name
that is likely to be correct. If you are interested I can give you details.

Gerd
[1] http://www.mkgmap.org.uk/