Skip to content

Commit

Permalink
more unreachable vertex and failed split fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
abyrd committed Aug 26, 2015
1 parent 3c4722b commit 90900d9
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/main/java/org/opentripplanner/streets/StreetRouter.java
Expand Up @@ -84,8 +84,16 @@ public StreetRouter (StreetLayer streetLayer) {
this.streetLayer = streetLayer;
}

/**
* @param lat Latitude in floating point (not fixed int) degrees.
* @param lon Longitude in flating point (not fixed int) degrees.
*/
public void setOrigin (double lat, double lon) {
Split split = streetLayer.findSplit(lat, lon, 300);
if (split == null) {
LOG.info("No street was found near the specified origin point of {}, {}.", lat, lon);
return;
}
bestStates.clear();
queue.reset();
State startState0 = new State(split.vertex0, -1, null);
Expand Down Expand Up @@ -113,7 +121,7 @@ public void setOrigin (int fromVertex) {
public void route () {

if (bestStates.size() == 0 || queue.size() == 0) {
throw new IllegalStateException("Routing without first setting an origin.");
LOG.warn("Routing without first setting an origin, no search will happen.");
}

PrintStream printStream; // for debug output
Expand Down Expand Up @@ -184,8 +192,11 @@ private int heuristic (State s) {
}

public int getTravelTimeToVertex (int vertexIndex) {
// TODO account for walk speed
return bestStates.get(vertexIndex).weight;
State state = bestStates.get(vertexIndex);
if (state == null) {
return Integer.MAX_VALUE; // Unreachable
}
return state.weight; // TODO true walk speed
}

public static class State implements Cloneable {
Expand Down

0 comments on commit 90900d9

Please sign in to comment.