DCbrain, the company I currently work for, is a
software editor involved in utilities, industry and supply chains
optimisers development. As a relevant and established practice, we
use OSM data and tools to make calculations and mapping plots for
dataviz or dashboarding. Here comes the time to be thankful and share some free code too.
DCbrain, Maxime Beauchene and I now release our own implementation of a pgsql2osm conversion process under GNU GPL v3 licence. pgsql2osm allows to produce osm xml out of postgis geometries, linestrings and points. This
implementation runs sql code to transform geometries to topological
postgresql tables, manage way connections with its own layers and Python
to output actual OSM XML. It is currently used in production to
convert regional areas with ~1M ways and 7M nodes on a 4 CPU/16 GB
server and on a monthly basis. https://github.com/DCbrainOrg/pgsql2osm
It's was way easier for us to do so to feed OSM software with custom postgis data. We provide it as-is without any warranty.
Some improvements will enable to process more data but currently it's mainly for regional processing. It's certainly also possible to rework a bit the sql logic to convert geometries to topological records more quickly.
Feel free to give it a try and let us know about problems you may have on GitHub repository issues.