Nodes are no longer comparable (confusion with Label comparison). Predefined ArcInspectors easier to get.
This commit is contained in:
parent
723b8ce660
commit
32f99dba49
@ -12,16 +12,9 @@ import org.insa.graphs.model.AccessRestrictions.AccessRestriction;
|
||||
|
||||
public class ArcInspectorFactory {
|
||||
|
||||
/**
|
||||
* @return List of all arc filters in this factory.
|
||||
*/
|
||||
public static List<ArcInspector> getAllFilters() {
|
||||
List<ArcInspector> filters = new ArrayList<>();
|
||||
|
||||
// Common filters:
|
||||
|
||||
// No filter (all arcs allowed):
|
||||
filters.add(new ArcInspector() {
|
||||
static ArcInspector allArcsL = new ArcInspector() {
|
||||
@Override
|
||||
public boolean isAllowed(Arc arc) {
|
||||
return true;
|
||||
@ -48,10 +41,11 @@ public class ArcInspectorFactory {
|
||||
public String toString() {
|
||||
return "Shortest path, all roads allowed";
|
||||
}
|
||||
});
|
||||
} ;
|
||||
|
||||
// Only road allowed for cars and length:
|
||||
filters.add(new ArcInspector() {
|
||||
static ArcInspector forCarsL = new ArcInspector() {
|
||||
|
||||
@Override
|
||||
public boolean isAllowed(Arc arc) {
|
||||
return arc.getRoadInformation().getAccessRestrictions()
|
||||
@ -80,11 +74,11 @@ public class ArcInspectorFactory {
|
||||
public String toString() {
|
||||
return "Shortest path, only roads open for cars";
|
||||
}
|
||||
});
|
||||
} ;
|
||||
|
||||
// Only road allowed for cars and time:
|
||||
static ArcInspector forCarsT = new ArcInspector() {
|
||||
|
||||
filters.add(new ArcInspector() {
|
||||
@Override
|
||||
public boolean isAllowed(Arc arc) {
|
||||
return true;
|
||||
@ -92,7 +86,7 @@ public class ArcInspectorFactory {
|
||||
|
||||
@Override
|
||||
public double getCost(Arc arc) {
|
||||
return arc.getMinimumTravelTime();
|
||||
return arc.getMinimumTravelTime() ;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -104,48 +98,17 @@ public class ArcInspectorFactory {
|
||||
|
||||
@Override
|
||||
public Mode getMode() {
|
||||
return Mode.TIME;
|
||||
return Mode.TIME ;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Fastest path, all roads allowed";
|
||||
}
|
||||
});
|
||||
|
||||
filters.add(new ArcInspector() {
|
||||
@Override
|
||||
public boolean isAllowed(Arc arc) {
|
||||
return arc.getRoadInformation().getAccessRestrictions()
|
||||
.isAllowedForAny(AccessMode.MOTORCAR, EnumSet.complementOf(EnumSet
|
||||
.of(AccessRestriction.FORBIDDEN, AccessRestriction.PRIVATE)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getCost(Arc arc) {
|
||||
return arc.getMinimumTravelTime();
|
||||
}
|
||||
|
||||
/*
|
||||
@Override
|
||||
public int getMaximumSpeed() {
|
||||
return GraphStatistics.NO_MAXIMUM_SPEED;
|
||||
}
|
||||
*/
|
||||
|
||||
@Override
|
||||
public Mode getMode() {
|
||||
return Mode.TIME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Fastest path, only roads open for cars";
|
||||
}
|
||||
});
|
||||
} ;
|
||||
|
||||
// Non-private roads for pedestrian and bicycle:
|
||||
filters.add(new ArcInspector() {
|
||||
static ArcInspector forBicyclesT = new ArcInspector() {
|
||||
|
||||
static final int maxPedestrianSpeed = 5 ;
|
||||
|
||||
@ -178,7 +141,21 @@ public class ArcInspectorFactory {
|
||||
public Mode getMode() {
|
||||
return Mode.TIME;
|
||||
}
|
||||
});
|
||||
} ;
|
||||
|
||||
/**
|
||||
* @return List of all arc filters in this factory.
|
||||
*/
|
||||
public static List<ArcInspector> getAllFilters() {
|
||||
List<ArcInspector> filters = new ArrayList<>();
|
||||
|
||||
// Common filters:
|
||||
|
||||
|
||||
filters.add(allArcsL) ;
|
||||
filters.add(forCarsL) ;
|
||||
filters.add(forCarsT) ;
|
||||
filters.add(forBicyclesT);
|
||||
|
||||
// Add your own filters here (do not forget to implement toString()
|
||||
// to get an understandable output!):
|
||||
|
@ -16,7 +16,7 @@ public class BinaryHeap<E extends Comparable<E>> implements PriorityQueue<E> {
|
||||
// Number of elements in heap.
|
||||
private int currentSize;
|
||||
|
||||
// The heap array.
|
||||
// The heap array, which can be larger than currentSize.
|
||||
protected final ArrayList<E> array;
|
||||
|
||||
/**
|
||||
|
@ -684,7 +684,7 @@ public class BasicDrawing extends JPanel implements Drawing {
|
||||
// Draw arcs only if there are one-way arcs or if origin is lower than
|
||||
// destination, avoid drawing two-ways arc twice.
|
||||
if (arc.getRoadInformation().isOneWay()
|
||||
|| arc.getOrigin().compareTo(arc.getDestination()) < 0) {
|
||||
|| arc.getOrigin().getId() < arc.getDestination().getId()) {
|
||||
drawArc(arc, palette, false);
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ import java.util.List;
|
||||
* </p>
|
||||
*
|
||||
*/
|
||||
public final class Node implements Comparable<Node> {
|
||||
public final class Node { //implements Comparable<Node> {
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@ -144,6 +144,7 @@ public final class Node implements Comparable<Node> {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Do we really need to compare nodes ? Confusion with Label comparisons.
|
||||
/**
|
||||
* Compare the ID of this node with the ID of the given node.
|
||||
*
|
||||
@ -151,9 +152,9 @@ public final class Node implements Comparable<Node> {
|
||||
*
|
||||
* @see java.lang.Comparable#compareTo(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public int compareTo(Node other) {
|
||||
return Integer.compare(getId(), other.getId());
|
||||
}
|
||||
// @Override
|
||||
// public int compareTo(Node other) {
|
||||
// return Integer.compare(getId(), other.getId());
|
||||
// }
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user