mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
shift from vehicle.getLocation() to vehicle.getStartLocation() and
vehicle.getCoord() to vehicle.getStartLocationCoordinate()
This commit is contained in:
parent
e5dabbdf64
commit
a234bb54c9
36 changed files with 195 additions and 137 deletions
|
|
@ -385,17 +385,27 @@ public class GraphStreamViewer {
|
|||
}
|
||||
|
||||
private void renderVehicle(Graph g, Vehicle vehicle, Label label) {
|
||||
Node n = g.addNode(makeId(vehicle.getId(),vehicle.getLocationId()));
|
||||
if(label.equals(Label.ID)) n.addAttribute("ui.label", "depot");
|
||||
Node vehicleStart = g.addNode(makeId(vehicle.getId(),vehicle.getStartLocationId()));
|
||||
if(label.equals(Label.ID)) vehicleStart.addAttribute("ui.label", "depot");
|
||||
// if(label.equals(Label.ACTIVITY)) n.addAttribute("ui.label", "start");
|
||||
n.addAttribute("x", vehicle.getCoord().getX());
|
||||
n.addAttribute("y", vehicle.getCoord().getY());
|
||||
n.setAttribute("ui.class", "depot");
|
||||
vehicleStart.addAttribute("x", vehicle.getStartLocationCoordinate().getX());
|
||||
vehicleStart.addAttribute("y", vehicle.getStartLocationCoordinate().getY());
|
||||
vehicleStart.setAttribute("ui.class", "depot");
|
||||
|
||||
if(!vehicle.getStartLocationId().equals(vehicle.getEndLocationId())){
|
||||
Node vehicleEnd = g.addNode(makeId(vehicle.getId(),vehicle.getEndLocationId()));
|
||||
if(label.equals(Label.ID)) vehicleEnd.addAttribute("ui.label", "depot");
|
||||
// if(label.equals(Label.ACTIVITY)) n.addAttribute("ui.label", "start");
|
||||
vehicleEnd.addAttribute("x", vehicle.getEndLocationCoordinate().getX());
|
||||
vehicleEnd.addAttribute("y", vehicle.getEndLocationCoordinate().getY());
|
||||
vehicleEnd.setAttribute("ui.class", "depot");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void renderRoute(Graph g, VehicleRoute route, int routeId, long renderDelay_in_ms, Label label) {
|
||||
int vehicle_edgeId = 1;
|
||||
String prevIdentifier = makeId(route.getVehicle().getId(),route.getVehicle().getLocationId());
|
||||
String prevIdentifier = makeId(route.getVehicle().getId(),route.getVehicle().getStartLocationId());
|
||||
if(label.equals(Label.ACTIVITY)){
|
||||
Node n = g.getNode(prevIdentifier);
|
||||
n.addAttribute("ui.label", "start");
|
||||
|
|
@ -414,7 +424,7 @@ public class GraphStreamViewer {
|
|||
sleep(renderDelay_in_ms);
|
||||
}
|
||||
if(route.getVehicle().isReturnToDepot()){
|
||||
String lastIdentifier = makeId(route.getVehicle().getId(),route.getVehicle().getLocationId());
|
||||
String lastIdentifier = makeId(route.getVehicle().getId(),route.getVehicle().getEndLocationId());
|
||||
g.addEdge(makeEdgeId(routeId,vehicle_edgeId), prevIdentifier, lastIdentifier, true);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -404,9 +404,15 @@ public class Plotter {
|
|||
XYSeriesCollection coll = new XYSeriesCollection();
|
||||
XYSeries vehicleSeries = new XYSeries("depot", false, true);
|
||||
for(Vehicle v : vehicles){
|
||||
Coordinate coord = v.getCoord();
|
||||
if(coord == null) throw new NoLocationFoundException();
|
||||
vehicleSeries.add(coord.getX(),coord.getY());
|
||||
Coordinate startCoord = v.getStartLocationCoordinate();
|
||||
if(startCoord == null) throw new NoLocationFoundException();
|
||||
vehicleSeries.add(startCoord.getX(),startCoord.getY());
|
||||
|
||||
if(!v.getStartLocationId().equals(v.getEndLocationId())){
|
||||
Coordinate endCoord = v.getEndLocationCoordinate();
|
||||
if(endCoord == null) throw new NoLocationFoundException();
|
||||
vehicleSeries.add(endCoord.getX(),endCoord.getY());
|
||||
}
|
||||
}
|
||||
coll.addSeries(vehicleSeries);
|
||||
|
||||
|
|
@ -473,11 +479,18 @@ public class Plotter {
|
|||
private Locations retrieveLocations(VehicleRoutingProblem vrp) throws NoLocationFoundException {
|
||||
final Map<String, Coordinate> locs = new HashMap<String, Coordinate>();
|
||||
for(Vehicle v : vrp.getVehicles()){
|
||||
String locationId = v.getLocationId();
|
||||
if(locationId == null) throw new NoLocationFoundException();
|
||||
Coordinate coord = v.getCoord();
|
||||
if(coord == null) throw new NoLocationFoundException();
|
||||
locs.put(locationId, coord);
|
||||
String startLocationId = v.getStartLocationId();
|
||||
if(startLocationId == null) throw new NoLocationFoundException();
|
||||
Coordinate startCoord = v.getStartLocationCoordinate();
|
||||
if(startCoord == null) throw new NoLocationFoundException();
|
||||
locs.put(startLocationId, startCoord);
|
||||
|
||||
String endLocationId = v.getEndLocationId();
|
||||
if(!startLocationId.equals(endLocationId)){
|
||||
Coordinate endCoord = v.getEndLocationCoordinate();
|
||||
if(endCoord == null) throw new NoLocationFoundException();
|
||||
locs.put(endLocationId, endCoord);
|
||||
}
|
||||
}
|
||||
for(Job j : vrp.getJobs().values()){
|
||||
if(j instanceof Service){
|
||||
|
|
|
|||
|
|
@ -75,8 +75,10 @@ public class SolutionPlotter {
|
|||
|
||||
* @param vrp
|
||||
* @param pngFile target path with filename.
|
||||
* @see VehicleRoutingProblem, VehicleRoutingProblemSolution
|
||||
* @see VehicleRoutingProblem, VehicleRoutingProblemSolution
|
||||
* @deprecated use Plotter.java instead (this plotter is not maintained anymore and might plot incorrectly)
|
||||
*/
|
||||
@Deprecated
|
||||
public static void plotVrpAsPNG(VehicleRoutingProblem vrp, String pngFile, String title){
|
||||
String filename = pngFile;
|
||||
if(!pngFile.endsWith(".png")) filename += ".png";
|
||||
|
|
@ -102,7 +104,9 @@ public class SolutionPlotter {
|
|||
* @param pngFile target path with filename.
|
||||
* @param plotTitle
|
||||
* @see VehicleRoute
|
||||
* @deprecated use Plotter.java instead (this plotter is not maintained anymore and might plot incorrectly)
|
||||
*/
|
||||
@Deprecated
|
||||
public static void plotRoutesAsPNG(Collection<VehicleRoute> routes, Locations locations, String pngFile, String title) {
|
||||
String filename = pngFile;
|
||||
if(!pngFile.endsWith(".png")) filename += ".png";
|
||||
|
|
@ -130,8 +134,10 @@ public class SolutionPlotter {
|
|||
* @param vrp
|
||||
* @param solution
|
||||
* @param pngFile target path with filename.
|
||||
* @see VehicleRoutingProblem, VehicleRoutingProblemSolution
|
||||
* @see VehicleRoutingProblem, VehicleRoutingProblemSolution
|
||||
* @deprecated use Plotter.java instead (this plotter is not maintained anymore and might plot incorrectly)
|
||||
*/
|
||||
@Deprecated
|
||||
public static void plotSolutionAsPNG(VehicleRoutingProblem vrp, VehicleRoutingProblemSolution solution, String pngFile, String title){
|
||||
String filename = pngFile;
|
||||
if(!pngFile.endsWith(".png")) filename += ".png";
|
||||
|
|
@ -294,7 +300,7 @@ public class SolutionPlotter {
|
|||
XYSeriesCollection coll = new XYSeriesCollection();
|
||||
XYSeries vehicleSeries = new XYSeries("depot", false, true);
|
||||
for(Vehicle v : vehicles){
|
||||
Coordinate coord = v.getCoord();
|
||||
Coordinate coord = v.getStartLocationCoordinate();
|
||||
if(coord == null) throw new NoLocationFoundException();
|
||||
vehicleSeries.add(coord.getX(),coord.getY());
|
||||
}
|
||||
|
|
@ -353,11 +359,11 @@ public class SolutionPlotter {
|
|||
private static Locations retrieveLocations(VehicleRoutingProblem vrp) throws NoLocationFoundException {
|
||||
final Map<String, Coordinate> locs = new HashMap<String, Coordinate>();
|
||||
for(Vehicle v : vrp.getVehicles()){
|
||||
String locationId = v.getLocationId();
|
||||
if(locationId == null) throw new NoLocationFoundException();
|
||||
Coordinate coord = v.getCoord();
|
||||
String startLocationId = v.getStartLocationId();
|
||||
if(startLocationId == null) throw new NoLocationFoundException();
|
||||
Coordinate coord = v.getStartLocationCoordinate();
|
||||
if(coord == null) throw new NoLocationFoundException();
|
||||
locs.put(locationId, coord);
|
||||
locs.put(startLocationId, coord);
|
||||
}
|
||||
for(Job j : vrp.getJobs().values()){
|
||||
if(j instanceof Service){
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue