This work presents the mathematical definition and programming considerations of an efficient geometric algorithm used to add roofs to polyhedral 3D building models obtained from OpenStreetMap. The algorithm covers numerous roof shapes, including some well-defined shapes that lack an explicit reconstruction theory. These shapes include gabled, hipped, pyramidal, skillion, half-hipped, gambrel, and mansard. The input data for the developed code consist of latitude and longitude coordinates defining the target area. Geospatial data necessary for the algorithm are obtained through a request to the overpass-turbo service. The findings showcase outstanding performance for buildings with straightforward footprints, but they have limitations for the ones with intricate footprints. In future work, further refinement is necessary to solve the mentioned limitation.