Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify opening hours checks to handle inverted date ranges and ignore Holiday syntax #4992

Closed
oxidase opened this issue Apr 3, 2018 · 2 comments
Assignees

Comments

@oxidase
Copy link
Contributor

oxidase commented Apr 3, 2018

Inverted date ranges

Implement support of date ranges that wraparound a year, e.g. winter closure, Nov 1 - Mar 1.

Unit test to add to unit_tests/util/opening_hours_parsing.cpp

BOOST_AUTO_TEST_CASE(check_opening_hours_inverted_date_range)
{
    const auto &opening_hours = ParseOpeningHours("Aug 15-Jun 15: Mo-Fr 07:30-09:30,13:30-15:30");
    BOOST_CHECK_EQUAL(CheckOpeningHours(opening_hours, time("Tue, 03 Jul 2018 07:00:00")), false);
    BOOST_CHECK_EQUAL(CheckOpeningHours(opening_hours, time("Tue, 03 Jul 2018 09:00:00")), false);
    BOOST_CHECK_EQUAL(CheckOpeningHours(opening_hours, time("Tue, 03 Apr 2018 09:00:00")), true);
    BOOST_CHECK_EQUAL(CheckOpeningHours(opening_hours, time("Mon, 03 Sep 2018 14:00:00")), true);
}

Holiday syntax in opening hours

SH/PH syntax, from osm wiki: "School Holiday, can be used to indicate different opening hours during school holidays (e.g., Mo-Fr 08:00-09:00,14:00-15:00; SH off)"

The following unit tests to add into unit_tests/util/opening_hours_parsing.cpp

BOOST_AUTO_TEST_CASE(check_opening_hours_school_hours)
{
    const auto &opening_hours = ParseOpeningHours("Mo-Fr 07:00-08:30,14:30-15:30; SH off");
    BOOST_CHECK_EQUAL(CheckOpeningHours(opening_hours, time("Tue, 03 Jul 2018 06:00:00")), false);
    BOOST_CHECK_EQUAL(CheckOpeningHours(opening_hours, time("Tue, 03 Jul 2018 09:00:00")), false);
    BOOST_CHECK_EQUAL(CheckOpeningHours(opening_hours, time("Tue, 03 Apr 2018 08:00:00")), true);
    BOOST_CHECK_EQUAL(CheckOpeningHours(opening_hours, time("Mon, 03 Sep 2018 15:00:00")), true);
    BOOST_CHECK_EQUAL(CheckOpeningHours(opening_hours, time("Sun, 02 Sep 2018 15:00:00")), false);
}

/cc @srividyacb

@daniel-j-h
Copy link
Member

I don't understand how we can support the SH syntax. Doesn't it depend on the specific school? What about schools which are open on Saturday? What about school holidays?

Looking around for PH and SH I found:

School holidays are not even standardized across states in Germany.

@oxidase oxidase changed the title School hours support in opening hours checking Ignore school hours rules in opening hours checking Apr 3, 2018
@oxidase oxidase changed the title Ignore school hours rules in opening hours checking Ignore school holidays rules in opening hours checking Apr 3, 2018
@oxidase
Copy link
Contributor Author

oxidase commented Apr 3, 2018

@daniel-j-h I have updated the title to reduce the scope just to a bug fix. The problem is in SH off rule that has empty times, weekdays and monthdays ranges at

&& (weekdays.empty() ||
std::any_of(weekdays.begin(),
weekdays.end(),
[&time, use_curr_day, use_next_day](const auto &x) {
return x.IsInRange(time, use_curr_day, use_next_day);
}))
// .. and if month-day ranges are not specified or is in any month-day range
&& (monthdays.empty() ||
std::any_of(monthdays.begin(),
monthdays.end(),
[&time, use_curr_day, use_next_day](const auto &x) {
return x.IsInRange(time, use_curr_day, use_next_day);
}));
}
std::vector<TimeSpan> times;
std::vector<WeekdayRange> weekdays;
std::vector<MonthdayRange> monthdays;
Modifier modifier;

So the rule is active with the off modifier and disables turn restrictions unconditionally.

@oxidase oxidase self-assigned this Apr 3, 2018
@karenzshea karenzshea changed the title Ignore school holidays rules in opening hours checking Modify opening hours checks to handle inverted date ranges and ignore Holiday syntax Apr 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants