1

This is a bit of a tricky question. It's not as simple (I don't think) as line intersections.

First of all, I'm given a bunch of map coordinates in order that define a bus route, and I'm drawing it onto my map (MapKit, iOS) with an MKPolyline. It allows several different bus routes to be shown at the same time. The problem is there are several points at which bus routes share the same road and thus follow a very very similar path, though the GPS coordinates are not exact.

My question is how could I best detect when a subsequence of the line segments made from the routes follow the same path so that they don't draw over each other? They have different colors that the user needs to differentiate, but since they are all very similar the colored line segments are being drawn over each other.

And if the mentioned line segments are detected, would there also be a way to get an average run of the line (straight or curved) that they make? That way I could then re-make the coordinates so that they all run next to each other so there's no overlap.

Any help with this is appreciated, I might just need a push in the right direction with a certain algorithm that already exists, since I am sure this type of problem is probably hard.

James Linnell
  • 3,804
  • 1
  • 14
  • 6
  • 1
    [This answer](http://stackoverflow.com/a/12076868/224988) points out a method that can be used to detect bounding rects of your paths and then check if CGRectIntersectsRect or something similar. – Moshe Dec 24 '15 at 23:08
  • As was said in its comments there's a lot of extra space because it's a bounding rectangle. However, that does help; I will also try searching for finding shared edges of polygons, but not necessarily complete overlaps. Instead, slight overlaps. – James Linnell Dec 24 '15 at 23:19

0 Answers0