I would like to create bicycle router which routes more through shade. For that I would like to use OSM. Most routers use OSM xml so my question is:
How to add tags to a street that goes through a forest and write that back to OSM xml? Getting part of a street through forest is easy with POSTGIS. Some intersect operation probably. I can insert OSM to Postgresql with osm2psql but I have found no way to get it back in usable xml again.
My current idea is parsing OSM XML and saving forest polygons somewhere. Then in another pass intersect each road with a forest polygon if bounding boxes intersects. If road is fully in forest tag it as in_forest. If not split road and tag forest part as in forest and other part as is.
I would use python libraries (Shapely) or C++ if Python isn't fast enough. But this would probably take ages. My country is only 350MB unzipped OSM XML.
Is there any better way? I looked into osmosis tag-transform but this is only for regex changes.