combine static method
adds the otherLatLongs to firstWaypath in the correct order. Returns true if successful. Note that firstWaypath may be changed whereas
otherLatLongs is never gonna be changed.
Implementation
static bool combine(Waypath firstWaypath, List<ILatLong> otherLatLongs) {
if (LatLongUtils.isNear(firstWaypath.first, otherLatLongs.last)) {
// add to the start of this list
firstWaypath.removeAt(0);
firstWaypath.insertAll(0, otherLatLongs);
return true;
} else if (LatLongUtils.isNear(firstWaypath.last, otherLatLongs.first)) {
// add to end of this list
firstWaypath.addAll(otherLatLongs.skip(1));
return true;
} else if (LatLongUtils.isNear(firstWaypath.first, otherLatLongs.first)) {
// reversed order, add to start of the list in reversed order
firstWaypath.removeAt(0);
firstWaypath.insertAll(0, otherLatLongs.reversed);
return true;
} else if (LatLongUtils.isNear(firstWaypath.last, otherLatLongs.last)) {
// reversed order, add to end of the list in reversed order
firstWaypath.addAll(otherLatLongs.reversed.skip(1));
return true;
} else {
return false;
}
}