Fixing Chinese Place Name Display Issues in OpenStreetMap with a C++ Batch Script
Posted by lpf452 on 14 September 2025 in English. Last updated on 1 October 2025.As an OpenStreetMap contributor, I’ve always been dedicated to enhancing the detail and usability of local data. Recently, however, I ran into a frustrating problem: in areas I’ve mapped, the Chinese names for many places fail to display correctly in certain applications and services (like OsmAPP, JawgMaps, and MapTiler). Instead, they either fall back to Pinyin or default to the English name (name:en), which looks odd—especially when a primary name tag clearly exists but is simply ignored.
The root of the problem lies in the peculiar rendering rules of these applications, which often prioritize name:[lang] tags that match the user’s language. Even though we add a name tag, the absence of an explicit name:zh or name:zh-Hans tag can leave the renderer confused, causing it to fall back to name:en or just display the Pinyin transliteration.
Manually adding these tags to thousands of elements is obviously out of the question. You can’t just copy and paste your way through it; the sheer monotony would be mind-numbing. So, I decided to automate the process by writing a script.
Tech Stack and Script Logic
When high performance is a priority, C++ is the natural choice. I also leveraged two powerful open-source libraries:
-
pugixml: A lightweight, high-performance C++ XML parser, perfect for rapidly reading and writing large
.osmfiles. -
OpenCC: The community’s go-to library for Simplified and Traditional Chinese conversion, which I used to generate
name:zh-Hanttags.
The core logic of my script is as follows: