I have a situation where I get routes from drivers and store them in a PostGIS database. What I want is to get a GeoJSON from the whole network covered, without overlaps of road segments. In other words, I would like a "cleared" network (see image) of the driven roads.
At first, I thought of creating a trigger for checking if there are any overlaps before inserting a new route. However, a new route could have overlaps itself, so this approach is declined.
Another thought was to split the routes into the minimum, smallest line segments and then delete the ones that are equal to others. However, I think that storing all these segments as different records could be an overkill for the database (correct me If I am wrong).
Ideally, I am searching for a query that would return all network without duplicates (overlaps). Any ideas?
