Commit ca23f165 authored by Volker Krause's avatar Volker Krause Committed by David Faure
Browse files

Convert 24/7 rules to timespan selectors when used in a timespan context

This only covers cases where we even get here due to parser error recovery
though, other variants found in the OSM corpus fail to parse already. But
that's the important part for Osmose's correction suggestions.

BUG: 445962
parent 15a84ba0
Pipeline #105447 passed with stage
in 1 minute and 19 seconds
......@@ -356,6 +356,12 @@ private Q_SLOTS:
T3("Sa-Mo 10:00-23:00, Th 10:00-23:00", "Sa-Mo 10:00-23:00, Th 10:00-23:00", "Sa-Mo,Th 10:00-23:00"); // beginDay > endDay
T3("Sa-Mo 10:00-23:00, Fr 10:00-23:00", "Sa-Mo 10:00-23:00, Fr 10:00-23:00", "Fr-Mo 10:00-23:00"); // beginDay > endDay
T3("Su-Th 10:00-23:00, Fr-Sa 10:00-23:00", "Su-Th 10:00-23:00, Fr-Sa 10:00-23:00", "Mo-Su 10:00-23:00"); // beginDay > endDay
// complex or creative 24/7 use
T("06:00-01:00 open \"Dining in\" || 24/7 \"Drive-through\"");
T2("Friday and Saturday 24/7 Sunday-Thursday 4:00 am to 12:00 am", "Fr,Sa 00:00-24:00; Su-Th 04:00-24:00"); // bug 445962
// 24/7 as standalone small range selector not supported yet
//T2("Apr-Oct: 24/7; Nov-Mar: Mo-Su 06:00-22:00", "Apr-Oct: 00:00-24:00; Nov-Mar: Mo-Su 06:00-22:00");
#undef T
#undef T2
#undef T3
......
......@@ -93,6 +93,15 @@ void OpeningHoursPrivate::autocorrect()
std::swap(*it, *std::prev(it));
it = std::prev(m_rules.erase(it));
}
// previous has no time selector and the current one is a misplaced 24/7 rule:
// convert the 24/7 to a 00:00-24:00 time selector
else if (rule->selectorCount() == 0 && rule->m_seen_24_7 && !prevRule->m_timeSelector) {
prevRule->m_timeSelector.reset(new Timespan);
prevRule->m_timeSelector->begin = { Time::NoEvent, 0, 0 };
prevRule->m_timeSelector->end = { Time::NoEvent, 24, 0 };
it = std::prev(m_rules.erase(it));
}
} else if (rule->m_ruleType == Rule::NormalRule) {
// Previous rule has time and other selectors
// Current rule is only a time selector
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment