From 8b6c78ca75be1c263606c81da9b2fc9220aee916 Mon Sep 17 00:00:00 2001 From: HU helene Date: Mon, 29 Apr 2024 17:31:17 +0200 Subject: [PATCH] remove main from parse --- pom.xml | 2 +- .../{ItineraryCalculator.java => Parse.java} | 45 ++++++------------- 2 files changed, 15 insertions(+), 32 deletions(-) rename src/main/java/fr/u_paris/gla/project/itinerary/{ItineraryCalculator.java => Parse.java} (87%) diff --git a/pom.xml b/pom.xml index da0f1b0..ffe1949 100644 --- a/pom.xml +++ b/pom.xml @@ -62,7 +62,7 @@ true ${project.build.finalName}.lib/ - fr.u_paris.gla.project.itinerary.ItineraryCalculator + fr.u_paris.gla.project.App diff --git a/src/main/java/fr/u_paris/gla/project/itinerary/ItineraryCalculator.java b/src/main/java/fr/u_paris/gla/project/itinerary/Parse.java similarity index 87% rename from src/main/java/fr/u_paris/gla/project/itinerary/ItineraryCalculator.java rename to src/main/java/fr/u_paris/gla/project/itinerary/Parse.java index 666dbf3..1b9f257 100644 --- a/src/main/java/fr/u_paris/gla/project/itinerary/ItineraryCalculator.java +++ b/src/main/java/fr/u_paris/gla/project/itinerary/Parse.java @@ -9,7 +9,7 @@ import java.util.*; import java.util.logging.Level; import java.util.logging.Logger; -public class ItineraryCalculator { +public class Parse { private static final Logger LOGGER = Logger .getLogger(IDFMNetworkExtractor.class.getName()); @@ -44,6 +44,10 @@ public class ItineraryCalculator { //Walking speed in m/s private static final double WALK_SPEED = 1.; + private HashSet nodes = new HashSet<>(); + private HashMap> connections = new HashMap<>(); + private HashMap> tmp = new HashMap<>(); + /** * Returns the coordinates from a String to a double array: * "49.08, 3.07" -> {49.08, 3.07} @@ -204,17 +208,12 @@ public class ItineraryCalculator { } } - public static void main(String[] args){ - if (args.length != 0) { - LOGGER.severe("Invalid command line. Target file names are in the main file for now."); - return; - } + public void parseFiles(){ + IDFMNetworkExtractor.buildFiles(); try { - HashSet nodes = new HashSet<>(); - HashMap> connections = new HashMap<>(); - HashMap> tmp = new HashMap<>(); + CSVTools.readCSVFromFile(TRACE_FILE_NAME, (String[] line) -> addLine(line, nodes, tmp, connections)); @@ -227,32 +226,16 @@ public class ItineraryCalculator { } } - - Stop porteivry = tmp.get("Porte d'Ivry").get(0); - Stop repu = tmp.get("République").get(0); - - Graph graph = new Graph(nodes, connections); - int cpt = 0; - for (Map.Entry> entry : graph.getConnections().entrySet()) { - if (entry.getValue() == null) cpt +=1; - } - Stop garenord = tmp.get("Gare du Nord").get(0); - - Stop chatelet = tmp.get("Châtelet").get(0); - //System.out.println(graph.getConnections(garenord)); - //System.out.println(cpt); - //System.out.println(graph.getConnections(porteivry)); - Finder finder = new Finder(graph); - - List res = finder.findPath(chatelet, garenord, 43200); - for (Path element : res) { - System.out.println(element.getCurrentStop()); - } - } catch (IOException e) { LOGGER.log(Level.SEVERE, "Error while reading the line paths", e); } + } + + public List getItinerary(Stop src, Stop dst, double startTime ){ + Graph graph = new Graph(nodes, connections); + Finder finder = new Finder(graph); + return finder.findPath(src, dst, startTime); } }