Given a list of coordinates, I need to generate a (shorter) list of coordinates that, when connected, will create a geographical fence that contains all of the remaining coordinates.
- Find the relative center of all the points
- Sort all points by distance from center, descending. We will call this list
allPoints
. - Create a new empty list called
boundaries
- Iterate through
allPoints
, starting from the greatest distance, following this process: - Check if the point is contained in the geofence defined by
boundaries
. If it is, skip this point. If not, continue. - Insert the coordinate into
boundaries
. - Sort
boundaries
so that each point is the shortest possible distance from its surrounding points (yes, this sort will happen a lot of times) boundaries
is now your geofence defintion, and will contain all coordinates inallPoints