Skip to content

Road Segmenting

Clerik edited this page May 4, 2018 · 6 revisions

Road segmenting happens when the segment_network function is called by the RoadSegmentViewSet class in views.py.

The segment_network function lies in road_segmenter.py, where an empty list is created. The segmenter loops through a given road network. For each road, the segmenter checks if the road needs to be segmented, meaning the length of the road exceeds the set limit. In that case, it calls "split_segment".

The split_segment function goes through the list of coordinates of the road, and splits it up at the coordinate where the road exceeds the limit. If the new segment after splitting is also exceeding the limit, then the function recursively calls itself on the new segment, but only if the segment has at least 2 GPS points. It checks both the new segments' coordinates list length, and if any of the two segments are too short, it will instead return the unsegmented list.

After segmenting, each segment is appended to the empty list created earlier, and returned.

Clone this wiki locally