/**
   * Sets the Agent up to proceed along an Edge
   *
   * @param edge the GeomPlanarGraphEdge to traverse next
   */
  void setupEdge(GeomPlanarGraphEdge edge) {

    // clean up on old edge
    if (currentEdge != null) {
      ArrayList<AgentCopy> traffic = world.edgeTraffic.get(currentEdge);
      traffic.remove(this);
    }
    currentEdge = edge;

    // update new edge traffic
    if (world.edgeTraffic.get(currentEdge) == null) {
      world.edgeTraffic.put(currentEdge, new ArrayList<AgentCopy>());
    }
    world.edgeTraffic.get(currentEdge).add(this);

    // set up the new segment and index info
    LineString line = edge.getLine();
    segment = new LengthIndexedLine(line);
    startIndex = segment.getStartIndex();
    endIndex = segment.getEndIndex();
    linkDirection = 1;

    // check to ensure that Agent is moving in the right direction
    double distanceToStart = line.getStartPoint().distance(location.geometry),
        distanceToEnd = line.getEndPoint().distance(location.geometry);
    if (distanceToStart <= distanceToEnd) { // closer to start
      currentIndex = startIndex;
      linkDirection = 1;
    } else if (distanceToEnd < distanceToStart) { // closer to end
      currentIndex = endIndex;
      linkDirection = -1;
    }
  }
 double progress(double val) {
   double edgeLength = currentEdge.getLine().getLength();
   double traffic = world.edgeTraffic.get(currentEdge).size();
   double factor = 1000 * edgeLength / (traffic * 5);
   factor = Math.min(1, factor);
   return val * linkDirection * factor;
 }