1

Using Swift and apple mapKit I would like to calculate the concave hull from gps coordinates. I have an array of CLLocation (latitude, longitude) defining a Polyline. For a route geofencing I calculated for each 2d point in the polyline all possible latitudes and longitudes with a distance of n meters. At this point I would like to calculate the concave hull of this set of points. I can not find any information about how to calculate concave hull from gps coordinates. Can anyone suggest me a tutorial?

masterWN
  • 85
  • 1
  • 9

2 Answers2

2

This paper should be useful for you. I used algorithm from this paper to implement my hull.js library.

Also you can triangulate your shape via Delaunay triangulation and then remove boundary edges like here.

AndriiHeonia
  • 162
  • 6
1

I had never heard the term concave hulls until I read your question, so I googled it. I found references to several algorithms for concave hulls.

It seems there is not a single solution. You have to decide whether you want a smoother hull or one with the least internal area, or somewhere in between.

If all the points you are working with are within 100 km of each other or so, you can simplify the problem and convert your lat/longs to cartesian coordinates. All you have to do to do that is figure out the distance between degrees of longitude at the current latitude.

Once you've converted your points to cartesian coordinates it becomes a straightforward concave hull problem.

If you're dealing with large regions and want to allow for the curvature of the earth you have a much more complex problem.

Duncan C
  • 128,072
  • 22
  • 173
  • 272