I want to use the open world map data in an app that I develop. The app generates chunks around the player. Each chunk draws the information provided in a .osm file that has the same name as the chunk. The problem is that the polygons and relations sometimes go over the map border and are drawn multiple times because of that. This costs performance. Is there any program or online-service that clips the polygons and relations that go over the border of the exported map? If not, I'll need to write a script that does this. I tried to split a big .osm file into several small ones with osmosis but didn't got the intended result with it.

I developed a text based application to solve my issue. It can cut any polygon and line from osm street map so the polygon or line is only existent and visible inside the bounds and not outside of them. The application adds points to the edges and corners of the exported map if nessessary.