Tile server: how to render overlaping polygons?

I am writing a tile server and I am having issues with polygons and paths that are not enclosed within the tile. I have no idea how it is supposed to be done. The only solution that comes to mind is to enlarge the tile to the size that will encapsulate all objects (points, paths, polygons) that overlap the original tile, render them and then cut it back to the original size.

The issue with this approach is that it will take way more ressources (for example a whole underlying continent area) than I want.

Additionally, I am using OSM data and I haven’t found any tag that could tell me if the object should be displayed for requested zoom level.

So I wonder how is this supposed to be done correctly? So far I haven’t found an article or anything related to this since this is quite niche type of software that not many people write.


The solution was to a) use a polygon clipping and b) divide the data into layers and display them based on the zoom(ie. makes no sense to try and render building on zoom 3).