Osrm-backend: Modify opening hours checks to handle inverted date ranges and ignore Holiday syntax

Created on 3 Apr 2018  路  2Comments  路  Source: Project-OSRM/osrm-backend

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

Bug Report

Most helpful comment

@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 https://github.com/Project-OSRM/osrm-backend/blob/8a63ad9b4bc43635cb231fe57b5172709ee0e850/include/util/opening_hours.hpp#L194-L212

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

All 2 comments

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.

@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 https://github.com/Project-OSRM/osrm-backend/blob/8a63ad9b4bc43635cb231fe57b5172709ee0e850/include/util/opening_hours.hpp#L194-L212

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

JamesLawrenceGSI picture JamesLawrenceGSI  路  3Comments

davidbarre picture davidbarre  路  4Comments

Oyabi picture Oyabi  路  5Comments

ltsstar picture ltsstar  路  5Comments

stvno picture stvno  路  3Comments