package com.routeme.model;

import java.util.ArrayList;

import com.google.maps.model.DirectionsRoute;
import com.google.maps.model.DirectionsStep;
import com.google.maps.model.Distance;
import com.google.maps.model.Duration;
import com.routeme.utility.directions.GoogleDirectionsUtility;

public class NonTransitRoute extends Route {

    public NonTransitRoute(DirectionsRoute googleDirectionsRoute) {
        super(googleDirectionsRoute);
        this.setPredictionIoId();
        this.setTransportationModes();
    }

    private void setPredictionIoId() {
        this.predictionIoId = "";
        for (int i = 0; i < steps.length; i++) {
            DirectionsStep currentStep = steps[i];
            this.predictionIoId += getWalkingStepSummary(currentStep.distance, currentStep.duration,
                    currentStep.htmlInstructions);
        }
        this.predictionIoId = "[" + startAddress + "]" + this.predictionIoId;
        this.predictionIoId += "[" + endAddress + "]";
        this.predictionIoId = GoogleDirectionsUtility.replaceUmlaut(this.predictionIoId);
    }

    private String getWalkingStepSummary(Distance distance, Duration duration, String htmlInstructions) {
        String noSpaceBracketedDistance = "(" + distance.humanReadable.replace(" ", "") + ")";
        return htmlInstructions + noSpaceBracketedDistance;
    }

    private void setTransportationModes() {
        final int firstStepIndex = 0;
        transportationModes = new ArrayList<String>();
        transportationModes.add(steps[firstStepIndex].travelMode.name());
    }
}

@@ -704,73 +704,161 @@
     
-this.predictionIoId += getWalkingStepSummary(currentStep.
+String transportationMode = currentStep.travelMode.name();%0A            String htmlInstruction = currentStep.htmlInstructions;%0A            String 
 distance
 , cu
@@ -853,17 +853,18 @@
 distance
-,
+ =
  current
@@ -873,49 +873,81 @@
 ep.d
-uration,%0A                    currentStep.
+istance.humanReadable;%0A            this.predictionIoId += getStepSummary(
 html
@@ -957,17 +957,26 @@
 truction
-s
+, distance
 );%0A     
@@ -1236,15 +1236,8 @@
  get
-Walking
 Step
@@ -1248,46 +1248,8 @@
 ary(
-Distance distance, Duration duration, 
 Stri
@@ -1266,17 +1266,33 @@
 truction
-s
+, String distance
 ) %7B%0A    
@@ -1348,22 +1348,8 @@
 nce.
-humanReadable.
 repl
@@ -1398,17 +1398,16 @@
 truction
-s
  + noSpa

Refactor non-transit steps' summaries