class NavigationHelper {

  @NonNull
  public static List<Pair<StepIntersection, Double>> createDistancesToIntersections(List<Point> stepPoints,
                                                                             List<StepIntersection> intersections) {
    boolean lessThanTwoStepPoints = stepPoints.size() < TWO_POINTS;
    boolean noIntersections = intersections.isEmpty();
    if (lessThanTwoStepPoints || noIntersections) {
      return Collections.emptyList();
    }

    LineString stepLineString = LineString.fromLngLats(stepPoints);
    Point firstStepPoint = stepPoints.get(FIRST_POINT);
    List<Pair<StepIntersection, Double>> distancesToIntersections = new ArrayList<>();

    for (StepIntersection intersection : intersections) {
      Point intersectionPoint = intersection.location();
      if (firstStepPoint.equals(intersectionPoint)) {
        distancesToIntersections.add(new Pair<>(intersection, ZERO_METERS));
      } else {
        LineString beginningLineString = TurfMisc.lineSlice(firstStepPoint, intersectionPoint, stepLineString);
        double distanceToIntersectionInMeters = TurfMeasurement.length(beginningLineString, TurfConstants.UNIT_METERS);
        distancesToIntersections.add(new Pair<>(intersection, distanceToIntersectionInMeters));
      }
    }
    return distancesToIntersections;
  }

  private  NavigationHelper();

}