Bugs resolved
This commit is contained in:
parent
ce8a801322
commit
06d80926e0
6 changed files with 51 additions and 29 deletions
|
@ -105,12 +105,14 @@ public class CSVSchedulesProvider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String[][] next() {
|
public String[] next() {
|
||||||
if (!hasNext()) {
|
if (!hasNext()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
skipToNext();
|
skipToNext();
|
||||||
return new String[][]{Arrays.copyOf(this.line, this.line.length)};
|
return Arrays.copyOf(this.line, this.line.length);
|
||||||
|
|
||||||
|
// return new String[][]{Arrays.copyOf(this.line, this.line.length)};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -130,7 +130,7 @@ public final class CSVStreamProvider {
|
||||||
} while (currentSegmentStart == null);
|
} while (currentSegmentStart == null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String[][] next() {
|
public String[] next() {
|
||||||
if (!this.onNext) {
|
if (!this.onNext) {
|
||||||
skipToNext();
|
skipToNext();
|
||||||
}
|
}
|
||||||
|
@ -148,7 +148,9 @@ public final class CSVStreamProvider {
|
||||||
this.line[NetworkFormat.VARIANT_INDEX] = Integer
|
this.line[NetworkFormat.VARIANT_INDEX] = Integer
|
||||||
.toString(bifurcation);
|
.toString(bifurcation);
|
||||||
fillTransports(bifurcation);
|
fillTransports(bifurcation);
|
||||||
return new String[][]{Arrays.copyOf(this.line, this.line.length)};
|
return Arrays.copyOf(this.line, this.line.length);
|
||||||
|
// return new String[][]{Arrays.copyOf(this.line, this.line.length)};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @param stop1
|
/** @param stop1
|
||||||
|
@ -182,21 +184,24 @@ public final class CSVStreamProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fillTransports(int bif) {
|
private void fillTransports(int bif) {
|
||||||
String nameTransport = this.line[NetworkFormat.LINE_INDEX];
|
if(transports != null){
|
||||||
String start_p = this.line[NetworkFormat.START_INDEX];
|
String nameTransport = this.line[NetworkFormat.LINE_INDEX];
|
||||||
String end_p = this.line[NetworkFormat.STOP_INDEX];
|
String start_p = this.line[NetworkFormat.START_INDEX];
|
||||||
// String bifurcation = this.line[NetworkFormat.VARIANT_INDEX];
|
String end_p = this.line[NetworkFormat.STOP_INDEX];
|
||||||
Transport transp = null;
|
// String bifurcation = this.line[NetworkFormat.VARIANT_INDEX];
|
||||||
if(!transports.containsKey(traceId)){
|
Transport transp = null;
|
||||||
transp = new Transport(nameTransport,traceType);
|
if(!transports.containsKey(traceId)){
|
||||||
transports.put(traceId, transp);
|
transp = new Transport(nameTransport,traceType);
|
||||||
}else{
|
transports.put(traceId, transp);
|
||||||
transp = transports.get(traceId);
|
}else{
|
||||||
}
|
transp = transports.get(traceId);
|
||||||
transp.addStop(start_p, end_p, bif);
|
}
|
||||||
if(transp.descriptions.isEmpty()){
|
transp.addStop(start_p, end_p, bif);
|
||||||
transp.addDescriptions(descriptions);
|
if(transp.descriptions.isEmpty()){
|
||||||
|
transp.addDescriptions(descriptions);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -69,13 +69,28 @@ public final class CSVTools {
|
||||||
* @throws IOException if we can't write the data into the file
|
* @throws IOException if we can't write the data into the file
|
||||||
*/
|
*/
|
||||||
public static void writeCSVToFile(String filename,
|
public static void writeCSVToFile(String filename,
|
||||||
Stream<String[][]> contentLinesConsumer) throws IOException {
|
Stream<String[]> contentLinesConsumer) throws IOException {
|
||||||
try (FileWriter writer = new FileWriter(filename, StandardCharsets.UTF_8)) {
|
try (FileWriter writer = new FileWriter(filename, StandardCharsets.UTF_8)) {
|
||||||
CSVWriterBuilder wBuilder = new CSVWriterBuilder(writer).withSeparator(';');
|
CSVWriterBuilder wBuilder = new CSVWriterBuilder(writer).withSeparator(';');
|
||||||
try (ICSVWriter csv = wBuilder.build()) {
|
try (ICSVWriter csv = wBuilder.build()) {
|
||||||
contentLinesConsumer.forEachOrdered(line -> Arrays.stream(line).forEach(csv::writeNext));
|
contentLinesConsumer.forEachOrdered(csv::writeNext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// /** Save our current CSV variable's data into an actual file
|
||||||
|
// * @param filename the saved file's name and path
|
||||||
|
// * @param contentLineConsumer our data variable
|
||||||
|
// * @throws IOException if we can't write the data into the file
|
||||||
|
// */
|
||||||
|
// public static void writeCSVToFile(String filename,
|
||||||
|
// Stream<String[][]> contentLinesConsumer) throws IOException {
|
||||||
|
// try (FileWriter writer = new FileWriter(filename, StandardCharsets.UTF_8)) {
|
||||||
|
// CSVWriterBuilder wBuilder = new CSVWriterBuilder(writer).withSeparator(';');
|
||||||
|
// try (ICSVWriter csv = wBuilder.build()) {
|
||||||
|
// contentLinesConsumer.forEachOrdered(line -> Arrays.stream(line).forEach(csv::writeNext));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ public class CSVStreamProviderTest {
|
||||||
@Test
|
@Test
|
||||||
public void testHasNext() {
|
public void testHasNext() {
|
||||||
// Scénario sans Trace
|
// Scénario sans Trace
|
||||||
CSVStreamProvider providerWithoutTrace = new CSVStreamProvider(Collections.emptyIterator());
|
CSVStreamProvider providerWithoutTrace = new CSVStreamProvider(Collections.emptyIterator(),null);
|
||||||
assertFalse(providerWithoutTrace.hasNext(), "hasNext should return false when no traces are provided");
|
assertFalse(providerWithoutTrace.hasNext(), "hasNext should return false when no traces are provided");
|
||||||
|
|
||||||
// Scénario avec Trace
|
// Scénario avec Trace
|
||||||
|
@ -29,10 +29,10 @@ public class CSVStreamProviderTest {
|
||||||
StopEntry stop2 = new StopEntry("Stop2", 2.295, 48.8738);
|
StopEntry stop2 = new StopEntry("Stop2", 2.295, 48.8738);
|
||||||
List<StopEntry> path = Arrays.asList(stop1, stop2);
|
List<StopEntry> path = Arrays.asList(stop1, stop2);
|
||||||
|
|
||||||
TraceEntry trace = new TraceEntry("Ligne1");
|
TraceEntry trace = new TraceEntry("Ligne1","IDFM:03434","Bus");
|
||||||
trace.addPath(path);
|
trace.addPath(path);
|
||||||
|
|
||||||
CSVStreamProvider providerWithTrace = new CSVStreamProvider(Arrays.asList(trace).iterator());
|
CSVStreamProvider providerWithTrace = new CSVStreamProvider(Arrays.asList(trace).iterator(),null);
|
||||||
assertTrue(providerWithTrace.hasNext(), "hasNext should return true when traces are provided");
|
assertTrue(providerWithTrace.hasNext(), "hasNext should return true when traces are provided");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,10 +45,10 @@ public class CSVStreamProviderTest {
|
||||||
StopEntry start = new StopEntry("Début", 2.3522, 48.8566); // Paris
|
StopEntry start = new StopEntry("Début", 2.3522, 48.8566); // Paris
|
||||||
StopEntry end = new StopEntry("Fin", 2.295, 48.8738); // Proche de Paris
|
StopEntry end = new StopEntry("Fin", 2.295, 48.8738); // Proche de Paris
|
||||||
|
|
||||||
TraceEntry traceEntry = new TraceEntry("Ligne1");
|
TraceEntry traceEntry = new TraceEntry("Ligne1","IDFM:03434","Bus");
|
||||||
traceEntry.addPath(Arrays.asList(start, end)); // Ajout d'un chemin à la trace
|
traceEntry.addPath(Arrays.asList(start, end)); // Ajout d'un chemin à la trace
|
||||||
|
|
||||||
CSVStreamProvider provider = new CSVStreamProvider(Collections.singletonList(traceEntry).iterator());
|
CSVStreamProvider provider = new CSVStreamProvider(Collections.singletonList(traceEntry).iterator(),null);
|
||||||
|
|
||||||
assertTrue(provider.hasNext(), "Doit avoir un prochain élément");
|
assertTrue(provider.hasNext(), "Doit avoir un prochain élément");
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ class IDFMNetworkExtractorTest {
|
||||||
public void testAddCandidate() throws Exception {
|
public void testAddCandidate() throws Exception {
|
||||||
UnidentifiedStopEntry unidentifiedStop = new UnidentifiedStopEntry(2.3522, 48.8566); // Coordonnées pour Paris
|
UnidentifiedStopEntry unidentifiedStop = new UnidentifiedStopEntry(2.3522, 48.8566); // Coordonnées pour Paris
|
||||||
List<StopEntry> path = new ArrayList<>(Arrays.asList(unidentifiedStop));
|
List<StopEntry> path = new ArrayList<>(Arrays.asList(unidentifiedStop));
|
||||||
TraceEntry trace = new TraceEntry("Ligne1");
|
TraceEntry trace = new TraceEntry("Ligne1","IDFM:03434","Bus");
|
||||||
trace.addPath(path);
|
trace.addPath(path);
|
||||||
|
|
||||||
StopEntry candidate = new StopEntry("Proche Candidat", 2.3523, 48.8567); // Coordonnées proches
|
StopEntry candidate = new StopEntry("Proche Candidat", 2.3523, 48.8567); // Coordonnées proches
|
||||||
|
|
|
@ -9,7 +9,7 @@ public class TraceEntryTest {
|
||||||
//addTerminus
|
//addTerminus
|
||||||
@Test
|
@Test
|
||||||
public void testAddTerminus() {
|
public void testAddTerminus() {
|
||||||
TraceEntry traceEntry = new TraceEntry("Ligne 1");
|
TraceEntry traceEntry = new TraceEntry("Ligne 1","IDFM:03434","Bus");
|
||||||
String terminus1 = "Terminus A";
|
String terminus1 = "Terminus A";
|
||||||
String terminus2 = "Terminus B";
|
String terminus2 = "Terminus B";
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ public class TraceEntryTest {
|
||||||
//addPath
|
//addPath
|
||||||
@Test
|
@Test
|
||||||
public void testAddPath() {
|
public void testAddPath() {
|
||||||
TraceEntry traceEntry = new TraceEntry("Ligne 1");
|
TraceEntry traceEntry = new TraceEntry("Ligne 1","IDFM:03434","Bus");
|
||||||
StopEntry stop1 = new StopEntry("Station 1", 2.300, 48.850);
|
StopEntry stop1 = new StopEntry("Station 1", 2.300, 48.850);
|
||||||
StopEntry stop2 = new StopEntry("Station 2", 2.310, 48.855);
|
StopEntry stop2 = new StopEntry("Station 2", 2.310, 48.855);
|
||||||
List<StopEntry> path = Arrays.asList(stop1, stop2);
|
List<StopEntry> path = Arrays.asList(stop1, stop2);
|
||||||
|
@ -42,7 +42,7 @@ public class TraceEntryTest {
|
||||||
//Verfier si le nom de la ligne lname est correctement initialiser
|
//Verfier si le nom de la ligne lname est correctement initialiser
|
||||||
@Test
|
@Test
|
||||||
public void testTraceEntryName() {
|
public void testTraceEntryName() {
|
||||||
TraceEntry traceEntry = new TraceEntry("Ligne 1");
|
TraceEntry traceEntry = new TraceEntry("Ligne 1","IDFM:03434","Bus");
|
||||||
assertEquals("Ligne 1", traceEntry.lname, "Le nom de la ligne doit être 'Ligne 1'.");
|
assertEquals("Ligne 1", traceEntry.lname, "Le nom de la ligne doit être 'Ligne 1'.");
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in a new issue