remove main from IDFMNetworkExtractor

This commit is contained in:
HU helene 2024-04-29 17:35:37 +02:00
parent 8b6c78ca75
commit 541d5a2542

View file

@ -98,142 +98,6 @@ public class IDFMNetworkExtractor {
// Well named constants
private static final double QUARTER_KILOMETER = .25;
/**
* Main entry point for the extractor of IDF mobilité data into a network as
* defined by this application.
*
* @param args the arguments (expected one for the destination file)
*/
public static void main(String[] args) {
if (args.length != 2) {
LOGGER.severe("Invalid command line. Missing target files.");
return;
}
Map<String, TraceEntry> traces = new HashMap<>();
try {
CSVTools.readCSVFromFile(TRACE_FILE_DOWNLOADED_NAME,
(String[] line) -> addLine(line, traces));
} catch (IOException e) {
LOGGER.log(Level.SEVERE, "Error while reading the line paths", e);
}
List<StopEntry> stops = new ArrayList<>(traces.size() * GUESS_STOPS_BY_LINE);
try {
CSVTools.readCSVFromFile(STOPS_FILE_DOWNLOADED_NAME,
(String[] line) -> addStop(line, traces, stops));
} catch (IOException e) {
LOGGER.log(Level.SEVERE, "Error while reading the stops", e);
}
cleanTraces(traces);
Map<String, Transport> transports = new HashMap<>();
CSVStreamProvider provider = new CSVStreamProvider(traces.values().iterator(), transports);
// Write into args[0]
try {
CSVTools.writeCSVToFile(args[0], Stream.iterate(provider.next(),
t -> provider.hasNext(), t -> provider.next()));
} catch (IOException e) {
LOGGER.log(Level.SEVERE, e,
() -> MessageFormat.format("Could not write in file {0}", args[0]));
}
/*CSVStreamSchedulesProvider providerschedules = new CSVStreamSchedulesProvider(traces.values().iterator());
// TraceEntry tmp = traces.values().iterator().next();
// tmp.getTerminus()
// .forEach(m -> LOGGER.log(Level.INFO, m));
// Write into args[1]
try {
CSVTools.writeCSVToFile(args[1], Stream.iterate(providerschedules.next(),
t -> providerschedules.hasNext(), t -> providerschedules.next()));
} catch (IOException e) {
LOGGER.log(Level.SEVERE, e,
() -> MessageFormat.format("Could not write in file {0}", args[1]));
}*/
// System.out.println("****** END ******");
// System.out.println(transports.size());
// System.out.println(transports.get("IDFM:C01371").name);
// System.out.println(transports.get("IDFM:C02060").name);
// Transport ligne_1 = transports.get("IDFM:C01371");
// Transport ligne_7 = transports.get("IDFM:C01377");
// Transport rerd = transports.get("IDFM:C01728");
// Transport b54b = transports.get("IDFM:C00940");
// System.out.println("****** AFFICHAGE LIGNE ******");
// Stop maisonBlanche = ligne_7.stopsMap.get("Maison Blanche");
// System.out.println(maisonBlanche.name);
// for (BifStop nextEntry : maisonBlanche.connected.values()) {
// System.out.println(nextEntry.bifurc+ nextEntry.stop.name);
// }
// System.out.println("****** AFFICHAGE LIGNE ******");
// Stop corientin = ligne_7.stopsMap.get("Corentin Cariou");
// System.out.println(corientin.name);
// for (BifStop nextEntry : corientin.connected.values()) {
// System.out.println(nextEntry.bifurc+ nextEntry.stop.name);
// }
// System.out.println("***************************");
// System.out.println("****** AFFICHAGE Description ******");
// System.out.println(traces.get("IDFM:C01377").descriptions);
// System.out.println("****** AFFICHAGE Description False ******");
// System.out.println(ligne_7.descriptions);
// System.out.println("****************** Build la path ***********************");
// System.out.println(ligne_7.type);
// System.out.println(rerd.type);
// ligne_7.buildBifurcation();
// rerd.buildBifurcation();
// System.out.println("******************Derniere description ***********************");
// System.out.println(ligne_7.descriptions);
// System.out.println("******************Description 54B ************************");
// b54b.buildBifurcation();
// System.out.println(b54b.descriptions);
System.out.println("******************Building bifurcations ************************");
long startTime = System.currentTimeMillis();
for (Transport entry : transports.values()) {
entry.buildBifurcationOptimzed();
}
long endTime = System.currentTimeMillis();
long tempsPasse = endTime - startTime;
long minutes = (tempsPasse / 1000) / 60;
long seconds = (tempsPasse / 1000) % 60;
long milliseconds = tempsPasse % 1000;
System.out.println("Temps écoulé : " + minutes + " minutess, " + seconds + " secndes et " + milliseconds + " millis");
System.out.println("******************Fin Building bifurcations ************************");
CSVSchedulesProvider providerschedules = new CSVSchedulesProvider(transports.values().iterator());
try {
CSVTools.writeCSVToFile(args[1], Stream.iterate(providerschedules.next(),
t -> providerschedules.hasNext(), t -> providerschedules.next()));
} catch (IOException e) {
LOGGER.log(Level.SEVERE, e,
() -> MessageFormat.format("Could not write in file {0}", args[1]));
}
CSVImageProvider providerimage = new CSVImageProvider(transports.values().iterator());
String imageCSV = "image.csv";
try {
CSVTools.writeCSVToFile(imageCSV, Stream.iterate(providerimage.next(),
t -> providerimage.hasNext(), t -> providerimage.next()));
} catch (IOException e) {
LOGGER.log(Level.SEVERE, e,
() -> MessageFormat.format("Could not write in file {0}", imageCSV));
}
}
public static boolean checkFileExistence(String filePath) {
File file = new File(filePath);
if (file.exists()) {