From fddcfb877df666b5e22cbced53fa627b50629107 Mon Sep 17 00:00:00 2001 From: danesfeder Date: Tue, 3 Apr 2018 17:12:03 -0400 Subject: [PATCH] Finish intersection calculations --- .../v5/routeprogress/RouteStepProgress.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/libandroid-navigation/src/main/java/com/mapbox/services/android/navigation/v5/routeprogress/RouteStepProgress.java b/libandroid-navigation/src/main/java/com/mapbox/services/android/navigation/v5/routeprogress/RouteStepProgress.java index df665086d1c..f4e76e692d9 100644 --- a/libandroid-navigation/src/main/java/com/mapbox/services/android/navigation/v5/routeprogress/RouteStepProgress.java +++ b/libandroid-navigation/src/main/java/com/mapbox/services/android/navigation/v5/routeprogress/RouteStepProgress.java @@ -70,6 +70,8 @@ abstract static class Builder { abstract Builder tunnelIntersections(@NonNull List tunnelIntersections); + abstract List tunnelIntersections(); + abstract Builder tunnelIntersectionDistances(@NonNull List> tunnelIntersectionDistances); RouteStepProgress build() { @@ -83,7 +85,7 @@ RouteStepProgress build() { LegStep nextStep = nextStep(); intersections(createIntersectionsList(step, nextStep)); tunnelIntersections(createTunnelIntersectionsList(step)); - + tunnelIntersectionDistances(createDistancesToTunnelIntersections(step, stepPoints(), tunnelIntersections())); return autoBuild(); } @@ -162,7 +164,7 @@ private List> createDistancesToTunnelIntersections(LegStep LineString stepLineString = LineString.fromLngLats(stepPoints); Point firstStepPoint = stepPoints.get(FIRST_STEP_POINT); - for (int i = 0; i <= tunnels.size(); i++) { + for (int i = 0; i < tunnels.size(); i++) { StepIntersection tunnelIntersection = tunnels.get(i); Point tunnelBeginningPoint = tunnelIntersection.location(); @@ -237,7 +239,18 @@ public static Builder builder() { * The returned list will be empty if not intersections are found. * * @return list of intersections containing a tunnel class - * @since 0.12.0 + * @since 0.13.0 */ public abstract List tunnelIntersections(); + + /** + * Provides a list of pairs containing two distances, in meters, along the route. + *

+ * The first distance in the pair is the tunnel entrance along the step geometry. + * The second distance is the tunnel exit along the step geometry. + * + * @return list of pairs containing tunnnel entrance and exit distances + * @since 0.13.0 + */ + public abstract List> tunnelIntersectionDistances(); } \ No newline at end of file