findNearestFloorIndex method

int findNearestFloorIndex(
  1. double currentDistance
)

Implementation

int findNearestFloorIndex(double currentDistance) {
  var runningDistance = 0.0;

  for (var i = 1; i < _coordinates.length; i++) {
    runningDistance += turf.distance(get(i - 1), get(i));

    if (runningDistance >= currentDistance) {
      return i - 1;
    }
  }
  return -1;
}