mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
test json stuff
This commit is contained in:
parent
4883223541
commit
e742231c5f
9 changed files with 357 additions and 13 deletions
|
|
@ -34,6 +34,15 @@ public class JsonConstants {
|
|||
|
||||
public static final String VEHICLE_TYPES = "vehicle_types";
|
||||
|
||||
public static final String META = "meta-info";
|
||||
|
||||
public static class MetaInfo {
|
||||
|
||||
public static final String DISTANCE_UNIT = "distance-unit";
|
||||
|
||||
public static final String TIME_UNIT = "time-unit";
|
||||
}
|
||||
|
||||
public static class Solution {
|
||||
|
||||
public static final String COSTS = "costs";
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@ import jsprit.core.problem.vehicle.VehicleTypeImpl;
|
|||
import jsprit.core.util.Coordinate;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
|
|
@ -69,7 +68,7 @@ public class VrpJsonReader {
|
|||
parse(root);
|
||||
}
|
||||
|
||||
public void parse(JsonNode problemRoot) {
|
||||
private void parse(JsonNode problemRoot) {
|
||||
setFleetSize(problemRoot);
|
||||
parse_and_map_vehicle_types(problemRoot);
|
||||
parse_vehicles(problemRoot);
|
||||
|
|
@ -92,7 +91,7 @@ public class VrpJsonReader {
|
|||
JsonNode node = null;
|
||||
try {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
node = objectMapper.readTree(new FileReader(jsonFile)).path(JsonConstants.PROBLEM);
|
||||
node = objectMapper.readTree(jsonFile).path(JsonConstants.PROBLEM);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
|
|
|
|||
36
jsprit-core/src/main/java/jsprit/core/util/DistanceUnit.java
Normal file
36
jsprit-core/src/main/java/jsprit/core/util/DistanceUnit.java
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (C) 2014 Stefan Schroeder
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
******************************************************************************/
|
||||
|
||||
package jsprit.core.util;
|
||||
|
||||
/**
|
||||
* Created by schroeder on 04.12.14.
|
||||
*/
|
||||
public enum DistanceUnit {
|
||||
|
||||
Meter("m"), Kilometer("km");
|
||||
|
||||
private String abbr;
|
||||
|
||||
DistanceUnit(String abbr) {
|
||||
this.abbr = abbr;
|
||||
}
|
||||
|
||||
public String abbreviation(){
|
||||
return abbr;
|
||||
}
|
||||
}
|
||||
|
|
@ -51,7 +51,7 @@ public class GreatCircleCosts extends AbstractForwardVehicleRoutingTransportCost
|
|||
|
||||
private Locations locations;
|
||||
|
||||
private GreatCircleDistanceCalculator.DistanceUnit distanceUnit = GreatCircleDistanceCalculator.DistanceUnit.Kilometer;
|
||||
private DistanceUnit distanceUnit = DistanceUnit.Kilometer;
|
||||
|
||||
public GreatCircleCosts(Locations locations) {
|
||||
super();
|
||||
|
|
@ -59,7 +59,7 @@ public class GreatCircleCosts extends AbstractForwardVehicleRoutingTransportCost
|
|||
}
|
||||
|
||||
|
||||
public GreatCircleCosts(Locations locations, GreatCircleDistanceCalculator.DistanceUnit distanceUnit) {
|
||||
public GreatCircleCosts(Locations locations, DistanceUnit distanceUnit) {
|
||||
super();
|
||||
this.locations = locations;
|
||||
this.distanceUnit = distanceUnit;
|
||||
|
|
|
|||
|
|
@ -22,12 +22,6 @@ package jsprit.core.util;
|
|||
*/
|
||||
public class GreatCircleDistanceCalculator {
|
||||
|
||||
public enum DistanceUnit {
|
||||
|
||||
Meter, Kilometer
|
||||
|
||||
}
|
||||
|
||||
private static final double R = 6372.8; // km
|
||||
|
||||
/**
|
||||
|
|
|
|||
36
jsprit-core/src/main/java/jsprit/core/util/TimeUnit.java
Normal file
36
jsprit-core/src/main/java/jsprit/core/util/TimeUnit.java
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (C) 2014 Stefan Schroeder
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
******************************************************************************/
|
||||
|
||||
package jsprit.core.util;
|
||||
|
||||
/**
|
||||
* Created by schroeder on 04.12.14.
|
||||
*/
|
||||
public enum TimeUnit {
|
||||
|
||||
SEC("sec"), MIN("min"), HOUR("hour");
|
||||
|
||||
String abbr;
|
||||
|
||||
TimeUnit(String abbr) {
|
||||
this.abbr = abbr;
|
||||
}
|
||||
|
||||
public String abbreviation() {
|
||||
return abbr;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue