Search in sources :

Example 6 with Transfer

use of im.tny.segvault.subway.Transfer in project underlx by underlx.

the class Path method manualExtendEnd.

public void manualExtendEnd(Stop vertex) {
    // start by reverting to the path with the end without user-made extensions
    int edgesToRemove = 0;
    while (manualEntry.get(manualEntry.size() - 1)) {
        manualEntry.remove(manualEntry.size() - 1);
        times.remove(times.size() - 1);
        edgesToRemove++;
    }
    for (int i = 0; i < edgesToRemove; i++) {
        edgeList.remove(edgeList.size() - 1);
    }
    if (edgeList.size() > 0) {
        endVertex = edgeList.get(edgeList.size() - 1).getTarget();
    }
    // now go from the program-made end
    Date time = times.get(times.size() - 1).second;
    List<Connection> cs = Route.getShortestPath(graph, endVertex, vertex, new LeastHopsWeighter()).getEdgeList();
    int size = cs.size();
    for (int i = 0; i < size; i++) {
        // the same line)
        if (i == size - 1 && cs.get(i) instanceof Transfer) {
            this.endVertex = cs.get(i).getSource();
            return;
        }
        times.add(new Pair<Date, Date>(time, time));
        manualEntry.add(true);
        edgeList.add(cs.get(i));
    }
    this.endVertex = vertex;
    for (OnPathChangedListener l : listeners) {
        l.onPathChanged(this);
    }
}
Also used : Connection(im.tny.segvault.subway.Connection) Transfer(im.tny.segvault.subway.Transfer) LeastHopsWeighter(im.tny.segvault.s2ls.routing.LeastHopsWeighter) Date(java.util.Date)

Aggregations

Transfer (im.tny.segvault.subway.Transfer)6 Connection (im.tny.segvault.subway.Connection)5 Date (java.util.Date)3 LeastHopsWeighter (im.tny.segvault.s2ls.routing.LeastHopsWeighter)2 Line (im.tny.segvault.subway.Line)2 Station (im.tny.segvault.subway.Station)2 Intent (android.content.Intent)1 View (android.view.View)1 FrameLayout (android.widget.FrameLayout)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 CacheException (im.tny.segvault.disturbances.exception.CacheException)1 StationActivity (im.tny.segvault.disturbances.ui.activity.StationActivity)1 BSSID (im.tny.segvault.s2ls.wifi.BSSID)1 Lobby (im.tny.segvault.subway.Lobby)1 Network (im.tny.segvault.subway.Network)1 POI (im.tny.segvault.subway.POI)1 Schedule (im.tny.segvault.subway.Schedule)1 Stop (im.tny.segvault.subway.Stop)1 WorldPath (im.tny.segvault.subway.WorldPath)1