1
0
Fork 0
mirror of https://github.com/graphhopper/jsprit.git synced 2020-01-24 07:45:05 +01:00

allow coordinate switch

This commit is contained in:
oblonski 2015-04-28 05:55:53 +02:00
parent 62e1057518
commit 92df247132

View file

@ -39,6 +39,11 @@ public class TSPLIB95Reader {
private VehicleRoutingProblem.Builder vrpBuilder;
private boolean switchCoordinates = false;
public void setSwitchCoordinates(boolean switchCoordinates) {
this.switchCoordinates = switchCoordinates;
}
public TSPLIB95Reader(VehicleRoutingProblem.Builder vrpBuilder) {
this.vrpBuilder = vrpBuilder;
@ -128,7 +133,10 @@ public class TSPLIB95Reader {
if(coords == null) throw new IllegalStateException("DIMENSION tag missing");
String[] tokens = line.trim().split("\\s+");
Integer id = Integer.parseInt(tokens[0]);
coords[coordIndex] = Coordinate.newInstance(Double.parseDouble(tokens[1]), Double.parseDouble(tokens[2]));
if(switchCoordinates){
coords[coordIndex] = Coordinate.newInstance(Double.parseDouble(tokens[2]), Double.parseDouble(tokens[1]));
}
else coords[coordIndex] = Coordinate.newInstance(Double.parseDouble(tokens[1]), Double.parseDouble(tokens[2]));
indexMap.put(id,coordIndex);
coordIndex++;
continue;