Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/main/java/org/mtransit/parser/DefaultAgencyTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public class DefaultAgencyTools implements GAgencyTools {
private static final int MAX_LOOK_FORWARD_IN_DAYS = 60;

private static final int MIN_CALENDAR_COVERAGE_TOTAL_IN_DAYS = 3; // = 4 days
private static final int MIN_CALENDAR_DATE_COVERAGE_TOTAL_IN_DAYS = 14;
private static final int MIN_CALENDAR_DATE_COVERAGE_TOTAL_IN_DAYS = 10; // = 11 days (not too big to avoid merging 2 different schedule)

// 2024-04-09: 10x -> 3x because merging 2 schedule can create very bad schedule info #GRTbus
private static final long MAX_CALENDAR_DATE_COVERAGE_RATIO = 3;
Expand Down Expand Up @@ -1950,13 +1950,13 @@ && canMergeServiceIds(todayServiceIdInts, previousDayPeriodServiceIdInts)
&& (nextPeriodCoverageInMs <= 0L || previousPeriodCoverageInMs < nextPeriodCoverageInMs)
&& previousToCurrent < MAX_CALENDAR_DATE_COVERAGE_RATIO) {
p.setStartDate(incDateDays(DATE_FORMAT, c, p.getStartDate(), -1)); // start--
MTLog.log("new start date because coverage lower than %s days: %s", MIN_CALENDAR_DATE_COVERAGE_TOTAL_IN_DAYS, p.getStartDate());
MTLog.log("new start date because coverage lower than %s days: %s (ratio: %s x)", MIN_CALENDAR_DATE_COVERAGE_TOTAL_IN_DAYS, p.getStartDate(), previousToCurrent);
} else if (TimeUnit.MILLISECONDS.toDays(currentPeriodCoverageInMs) < MIN_CALENDAR_COVERAGE_TOTAL_IN_DAYS
|| nextToCurrent < MAX_CALENDAR_DATE_COVERAGE_RATIO) {
p.setEndDate(incDateDays(DATE_FORMAT, c, p.getEndDate(), 1)); // end++
MTLog.log("new end date because coverage lower than %s days: %s", MIN_CALENDAR_DATE_COVERAGE_TOTAL_IN_DAYS, p.getEndDate());
MTLog.log("new end date because coverage lower than %s days: %s (ratio: %s x)", MIN_CALENDAR_DATE_COVERAGE_TOTAL_IN_DAYS, p.getEndDate(), nextToCurrent);
Comment thread
mmathieum marked this conversation as resolved.
} else {
MTLog.log("coverage lower than %s days but would add too many days (p: %sx, n: %sx)", MIN_CALENDAR_DATE_COVERAGE_TOTAL_IN_DAYS, nextToCurrent, previousToCurrent);
MTLog.log("coverage lower than %s days but would add too many days (p: %s x, n: %s x)", MIN_CALENDAR_DATE_COVERAGE_TOTAL_IN_DAYS, nextToCurrent, previousToCurrent);
break;
}
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ public void test_parseCalendarDates_Split() { // #KingstonTransit #Should be 2 g
assertEquals(2024_04_06, p.getStartDate().intValue());
assertNotNull(p.getEndDate());
assertEquals(2024_04_25, p.getEndDate().intValue());

// NEXT
p.setTodayStringInt(p.getEndDate() + 1); // current + 1
p.setStartDate(null); // reset
Expand All @@ -273,7 +274,7 @@ public void test_parseCalendarDates_Split() { // #KingstonTransit #Should be 2 g
assertNotNull(p.getStartDate());
assertEquals(2024_04_26, p.getStartDate().intValue());
assertNotNull(p.getEndDate());
assertEquals(2024_05_10, p.getEndDate().intValue());
assertEquals(2024_05_06, p.getEndDate().intValue());
}

@Test
Expand Down Expand Up @@ -372,6 +373,7 @@ public void test_parseCalendarDates_Split_ShouldBeOne() { // #GRT
assertEquals(2024_04_08, p.getStartDate().intValue());
assertNotNull(p.getEndDate());
assertEquals(2024_04_21, p.getEndDate().intValue());

// NEXT
p.setTodayStringInt(p.getEndDate() + 1); // current + 1
p.setStartDate(null); // reset
Expand Down