Automatic road segment splitting via JOSM?

Is there a way to automate the splitting of highway segments at intersections, either through JOSM or another tool, particularly for a specific area?

When assigning tags based on survey data, I’ve found it more convenient and less error-prone to divide road segments at intersections before applying the necessary tags.

I’m aware that segment splitting results in a loss of history, but I believe that shorter segments contribute to a reduction in tagging errors and the creation of more accurate maps.

Additionally, I plan to provide training for new mappers to add missing tags, as I believe it will significantly streamline their tasks.

I am not sure one way or the other if this is a good idea, but it would be easy to write a JOSM script to do what you are asking. If the community agrees with your approach I can put together some code.

4 Likes

If nothing changed from the time I last checked, scripts are definitely not easy in JOSM. For better or for worse, they expose the internal structure of JOSM Java code.

if the intersections have something like highway=crossing nodes you can select the road, then select all nodes on it (“E”), then go to search and “Find in selection” = “highway=crossing”, then keeping those nodes selected, also select the road and “Split way”.

I have no opinion on whether it is a good idea or not, but this method works road by road. If you want it to repeat you’d have to make a script indeed.

1 Like

I’m against creating changesets just for the purpose of splitting ways to make workflows easier later down the line. What makes your workflow easier makes others’ harder, such as route relations and changing highway classification, etc. I don’t think there’s anything specifically wrong about having the data structured as split ways, but personally I would leave them continuous until the survey data is actually entered in. Like you already mentioned, it messes with the history, and if for example someone wants to add in a surface tag to the whole road, they now have to select every individual segment that was created to do so.

If doing with a script, too, it also has the possibility of breaking route relations. I’ve had to clean up mistakes from myself because I was splitting ways to add in sidewalk tags and without realizing it, the relation membership was not being added to the new ways that were created. So it really seems to me like it should be a manual process to verify relations are maintained.

3 Likes

Depends on how far down the line. Like, if you add semi-finished data at home, then go out with for example StreetComplete to finish it, I don’t see why it’s bad.

I have no particular reason to doubt that OP has some control over the situation and would use common sense to ensure that the outcome truly is an overall improvement, but if two segments turn out to have the same tags they should probably be re-merged later, which is a different kind of workload.

2 Likes

If one uses the “split” function in JOSM I believe that the relations are not broken. In a script one could use the SplitWayCommand class: https://josm.openstreetmap.de/doc/org/openstreetmap/josm/command/SplitWayCommand.html
Which should do the same - but should be tested.