Vitesse des transports adaptée
This commit is contained in:
parent
f77c105ff9
commit
2dd7abcc0c
4 changed files with 40 additions and 7 deletions
|
@ -21,6 +21,8 @@ public class CSVSchedulesProvider {
|
||||||
put("Subway", new int[]{4, 2, 6,3,3,4});
|
put("Subway", new int[]{4, 2, 6,3,3,4});
|
||||||
}};
|
}};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Time between 2 passages for the transports with a new type we don't know yet
|
// Time between 2 passages for the transports with a new type we don't know yet
|
||||||
private static int DEFAULT_TIMING = 6;
|
private static int DEFAULT_TIMING = 6;
|
||||||
private static final NumberFormat MINUTES_SECOND_FORMATTER = NumberFormat
|
private static final NumberFormat MINUTES_SECOND_FORMATTER = NumberFormat
|
||||||
|
|
|
@ -23,6 +23,23 @@ import fr.u_paris.gla.project.utils.GPS;
|
||||||
* CSV Stream Provider class
|
* CSV Stream Provider class
|
||||||
*/
|
*/
|
||||||
public final class CSVStreamProvider {
|
public final class CSVStreamProvider {
|
||||||
|
|
||||||
|
private static final HashMap<String, Double> two_acceleration_distance_by_type = new HashMap<String, Double>(){{
|
||||||
|
put("Bus", 0.1);
|
||||||
|
put("Funicular", 0.1);
|
||||||
|
put("Tram", 0.1);
|
||||||
|
put("Rail", 0.2);
|
||||||
|
put("Subway", 0.1);
|
||||||
|
}};
|
||||||
|
|
||||||
|
private static final HashMap<String, Double> max_speed_by_type = new HashMap<String, Double>(){{
|
||||||
|
put("Bus", 10.0);
|
||||||
|
put("Funicular", 5.0);
|
||||||
|
put("Tram", 20.0);
|
||||||
|
put("Rail", 50.0);
|
||||||
|
put("Subway", 30.0);
|
||||||
|
}};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Formatter from numbers into GPS Coordinates
|
* Formatter from numbers into GPS Coordinates
|
||||||
*/
|
*/
|
||||||
|
@ -201,7 +218,7 @@ public final class CSVStreamProvider {
|
||||||
this.line[NetworkFormat.DISTANCE_INDEX] = NumberFormat.getInstance(Locale.ENGLISH)
|
this.line[NetworkFormat.DISTANCE_INDEX] = NumberFormat.getInstance(Locale.ENGLISH)
|
||||||
.format(distance);
|
.format(distance);
|
||||||
this.line[NetworkFormat.DURATION_INDEX] = formatTime(
|
this.line[NetworkFormat.DURATION_INDEX] = formatTime(
|
||||||
(long) Math.ceil(distanceToTime(distance) * SECONDS_IN_HOURS));
|
(long) Math.ceil(distanceToTime(distance,this.traceType) * SECONDS_IN_HOURS));
|
||||||
int bifurcation = this.lineSegments.get(this.start).size() - 1;
|
int bifurcation = this.lineSegments.get(this.start).size() - 1;
|
||||||
this.line[NetworkFormat.VARIANT_INDEX] = Integer
|
this.line[NetworkFormat.VARIANT_INDEX] = Integer
|
||||||
.toString(bifurcation);
|
.toString(bifurcation);
|
||||||
|
@ -231,6 +248,18 @@ public final class CSVStreamProvider {
|
||||||
MINUTES_SECOND_FORMATTER.format(time / SECONDS_IN_MINUTES), MINUTES_SECOND_FORMATTER.format(time % SECONDS_IN_MINUTES));
|
MINUTES_SECOND_FORMATTER.format(time / SECONDS_IN_MINUTES), MINUTES_SECOND_FORMATTER.format(time % SECONDS_IN_MINUTES));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// /** A tool method to give a delay to go through a certain distance.
|
||||||
|
// * <p>
|
||||||
|
// * This is a model with an linear acceleration and deceleration periods and a
|
||||||
|
// * constant speed in between.
|
||||||
|
// *
|
||||||
|
// * @param distance the distance (in km)
|
||||||
|
// * @return the duration of the trip (in hours) */
|
||||||
|
// private static double distanceToTime(double distance) {
|
||||||
|
// return Math.max(0, distance - TWO_ACCELERATION_DISTANCE) / MAX_SPEED
|
||||||
|
// + Math.pow(Math.min(distance, TWO_ACCELERATION_DISTANCE) / MAX_SPEED, 2);
|
||||||
|
// }
|
||||||
|
|
||||||
/** A tool method to give a delay to go through a certain distance.
|
/** A tool method to give a delay to go through a certain distance.
|
||||||
* <p>
|
* <p>
|
||||||
* This is a model with an linear acceleration and deceleration periods and a
|
* This is a model with an linear acceleration and deceleration periods and a
|
||||||
|
@ -238,9 +267,11 @@ public final class CSVStreamProvider {
|
||||||
*
|
*
|
||||||
* @param distance the distance (in km)
|
* @param distance the distance (in km)
|
||||||
* @return the duration of the trip (in hours) */
|
* @return the duration of the trip (in hours) */
|
||||||
private static double distanceToTime(double distance) {
|
private static double distanceToTime(double distance, String type) {
|
||||||
return Math.max(0, distance - TWO_ACCELERATION_DISTANCE) / MAX_SPEED
|
Double max_speed = max_speed_by_type.get(type);
|
||||||
+ Math.pow(Math.min(distance, TWO_ACCELERATION_DISTANCE) / MAX_SPEED, 2);
|
Double two_acc_distance = two_acceleration_distance_by_type.get(type);
|
||||||
|
return Math.max(0, distance - two_acc_distance) / max_speed
|
||||||
|
+ Math.pow(Math.min(distance, two_acc_distance) / max_speed, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fillTransports(int bif) {
|
private void fillTransports(int bif) {
|
||||||
|
|
|
@ -245,7 +245,7 @@ public class IDFMNetworkExtractor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void builFiles() {
|
public static void buildFiles() {
|
||||||
|
|
||||||
if (checkFileExistence("./"+HOURS_FILE_NAME) && checkFileExistence("./"+TRACE_FILE_NAME)) {
|
if (checkFileExistence("./"+HOURS_FILE_NAME) && checkFileExistence("./"+TRACE_FILE_NAME)) {
|
||||||
LOGGER.severe("Files already exists.");
|
LOGGER.severe("Files already exists.");
|
||||||
|
|
|
@ -209,7 +209,7 @@ public class ItineraryCalculator {
|
||||||
LOGGER.severe("Invalid command line. Target file names are in the main file for now.");
|
LOGGER.severe("Invalid command line. Target file names are in the main file for now.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//IDFMNetworkExtractor.builFiles();
|
IDFMNetworkExtractor.buildFiles();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
HashSet<Stop> nodes = new HashSet<>();
|
HashSet<Stop> nodes = new HashSet<>();
|
||||||
|
@ -244,7 +244,7 @@ public class ItineraryCalculator {
|
||||||
//System.out.println(graph.getConnections(porteivry));
|
//System.out.println(graph.getConnections(porteivry));
|
||||||
Finder finder = new Finder(graph);
|
Finder finder = new Finder(graph);
|
||||||
|
|
||||||
List<Path> res = finder.findPath(porteivry, chatelet, 43200);
|
List<Path> res = finder.findPath(chatelet, garenord, 43200);
|
||||||
for (Path element : res) {
|
for (Path element : res) {
|
||||||
System.out.println(element.getCurrentStop());
|
System.out.println(element.getCurrentStop());
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue