Don't apply unimplemented SH and PH conditions
This commit is contained in:
parent
5693ffd2cf
commit
bc120776f0
@ -5,6 +5,7 @@
|
|||||||
- FIXED: Use smaller range for U-turn angles in map-matching [#4920](https://github.com/Project-OSRM/osrm-backend/pull/4920)
|
- FIXED: Use smaller range for U-turn angles in map-matching [#4920](https://github.com/Project-OSRM/osrm-backend/pull/4920)
|
||||||
- FIXED: Remove the last short annotation segment in `trimShortSegments` [#4946](https://github.com/Project-OSRM/osrm-backend/pull/4946)
|
- FIXED: Remove the last short annotation segment in `trimShortSegments` [#4946](https://github.com/Project-OSRM/osrm-backend/pull/4946)
|
||||||
- FIXED: Properly calculate annotations for speeds, durations and distances when waypoints are used with mapmatching [#4949](https://github.com/Project-OSRM/osrm-backend/pull/4949)
|
- FIXED: Properly calculate annotations for speeds, durations and distances when waypoints are used with mapmatching [#4949](https://github.com/Project-OSRM/osrm-backend/pull/4949)
|
||||||
|
- FIXED: Don't apply unimplemented SH and PH conditions in OpeningHours and add inversed date ranges [#4992](https://github.com/Project-OSRM/osrm-backend/issues/4992)
|
||||||
- Profile:
|
- Profile:
|
||||||
- CHANGED: Handle oneways in get_forward_backward_by_key [#4929](https://github.com/Project-OSRM/osrm-backend/pull/4929)
|
- CHANGED: Handle oneways in get_forward_backward_by_key [#4929](https://github.com/Project-OSRM/osrm-backend/pull/4929)
|
||||||
- FIXED: Do not route against oneway road if there is a cycleway in the wrong direction; also review bike profile [#4943](https://github.com/Project-OSRM/osrm-backend/issues/4943)
|
- FIXED: Do not route against oneway road if there is a cycleway in the wrong direction; also review bike profile [#4943](https://github.com/Project-OSRM/osrm-backend/issues/4943)
|
||||||
|
@ -166,12 +166,18 @@ struct OpeningHours
|
|||||||
date_to = date_from;
|
date_to = date_from;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const bool inverse = (from.year == 0) && (to.year == 0) && (date_from > date_to);
|
||||||
|
if (inverse)
|
||||||
|
{
|
||||||
|
std::swap(date_from, date_to);
|
||||||
|
}
|
||||||
|
|
||||||
if (!use_curr_day)
|
if (!use_curr_day)
|
||||||
date_from += date_duration(1);
|
date_from += date_duration(1);
|
||||||
if (use_next_day && date_to != date(boost::gregorian::max_date_time))
|
if (use_next_day && date_to != date(boost::gregorian::max_date_time))
|
||||||
date_to += date_duration(1);
|
date_to += date_duration(1);
|
||||||
|
|
||||||
return date_from <= date_current && date_current <= date_to;
|
return (date_from <= date_current && date_current <= date_to) ^ inverse;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -181,11 +187,12 @@ struct OpeningHours
|
|||||||
{
|
{
|
||||||
bool use_curr_day = true; // the first matching time uses the current day
|
bool use_curr_day = true; // the first matching time uses the current day
|
||||||
bool use_next_day = false; // the first matching time uses the next day
|
bool use_next_day = false; // the first matching time uses the next day
|
||||||
return
|
return (!times.empty() || !weekdays.empty() || !monthdays.empty())
|
||||||
// the value is in range if time is not specified or is in any time range
|
// the value is in range if time is not specified or is in any time range
|
||||||
// (also modifies use_curr_day and use_next_day flags to handle overnight day ranges,
|
// (also modifies use_curr_day and use_next_day flags to handle overnight day ranges,
|
||||||
// e.g. for 22:00-03:00 and 2am -> use_curr_day = false and use_next_day = true)
|
// e.g. for 22:00-03:00 and 2am -> use_curr_day = false and use_next_day = true)
|
||||||
(times.empty() || std::any_of(times.begin(),
|
&& (times.empty() ||
|
||||||
|
std::any_of(times.begin(),
|
||||||
times.end(),
|
times.end(),
|
||||||
[&time, &use_curr_day, &use_next_day](const auto &x) {
|
[&time, &use_curr_day, &use_next_day](const auto &x) {
|
||||||
return x.IsInRange(time, use_curr_day, use_next_day);
|
return x.IsInRange(time, use_curr_day, use_next_day);
|
||||||
|
@ -303,7 +303,7 @@ struct opening_hours_grammar : qi::grammar<Iterator, Skipper, std::vector<Openin
|
|||||||
|
|
||||||
daynum
|
daynum
|
||||||
= uint2_p[_pass = bind([](unsigned x) { return 01 <= x && x <= 31; }, _1), _val = _1]
|
= uint2_p[_pass = bind([](unsigned x) { return 01 <= x && x <= 31; }, _1), _val = _1]
|
||||||
>> (&~lit(':') | eoi)
|
>> !qi::no_skip[lit(':') >> uint2_p] // distinguish "daynum:.." from "hour:minute"
|
||||||
;
|
;
|
||||||
|
|
||||||
weeknum = uint2_p[_pass = bind([](unsigned x) { return 01 <= x && x <= 53; }, _1), _val = _1];
|
weeknum = uint2_p[_pass = bind([](unsigned x) { return 01 <= x && x <= 53; }, _1), _val = _1];
|
||||||
|
@ -49,8 +49,10 @@ BOOST_AUTO_TEST_CASE(check_opening_hours_grammar)
|
|||||||
"2016 Feb-2017 Dec",
|
"2016 Feb-2017 Dec",
|
||||||
"2016-2017",
|
"2016-2017",
|
||||||
"Mo,Tu,Th,Fr 12:00-18:00;Sa 12:00-17:00; Th[3] off; Th[-1] off",
|
"Mo,Tu,Th,Fr 12:00-18:00;Sa 12:00-17:00; Th[3] off; Th[-1] off",
|
||||||
"Sep 15+Sa-Oct Su[1]; Oct 01-03" // Oktoberfest
|
"Sep 15+Sa-Oct Su[1]; Oct 01-03", // Oktoberfest
|
||||||
};
|
"Aug 15-Jun 15: Mo-Fr 07:30-09:30,13:30-15:30",
|
||||||
|
"Mo-Fr 07:00-08:30,14:30-15:30; SH off",
|
||||||
|
"Jun 07: 08:30"};
|
||||||
|
|
||||||
for (auto &input : opening_hours)
|
for (auto &input : opening_hours)
|
||||||
{
|
{
|
||||||
@ -78,7 +80,8 @@ BOOST_AUTO_TEST_CASE(check_opening_hours_grammar_incorrect_correct)
|
|||||||
"Fr-Sa 20:00-04:00",
|
"Fr-Sa 20:00-04:00",
|
||||||
"Tu-Th 20:00-03:00 open \"Club and bar\"; Fr-Sa 20:00-04:00 open \"Club and bar\" || "
|
"Tu-Th 20:00-03:00 open \"Club and bar\"; Fr-Sa 20:00-04:00 open \"Club and bar\" || "
|
||||||
"Su-Mo 18:00-02:00 open \"bar\" || Tu-Th 18:00-03:00 open \"bar\" || Fr-Sa 18:00-04:00 "
|
"Su-Mo 18:00-02:00 open \"bar\" || Tu-Th 18:00-03:00 open \"bar\" || Fr-Sa 18:00-04:00 "
|
||||||
"open \"bar\""}};
|
"open \"bar\""},
|
||||||
|
{"Jun 07:08:30", "Jun 07:08"}};
|
||||||
|
|
||||||
for (auto &input : opening_hours)
|
for (auto &input : opening_hours)
|
||||||
{
|
{
|
||||||
@ -290,4 +293,25 @@ BOOST_AUTO_TEST_CASE(check_opening_hours_extended_hours_nonoverlapping)
|
|||||||
BOOST_CHECK_EQUAL(CheckOpeningHours(opening_hours, time("Thu, 22 Dec 2016 20:00:00")), false);
|
BOOST_CHECK_EQUAL(CheckOpeningHours(opening_hours, time("Thu, 22 Dec 2016 20:00:00")), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
BOOST_CHECK_EQUAL(CheckOpeningHours(opening_hours, time("Fri, 13 Jun 2018 09:00:00")), true);
|
||||||
|
BOOST_CHECK_EQUAL(CheckOpeningHours(opening_hours, time("Mon, 16 Jun 2018 09:00:00")), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
Loading…
Reference in New Issue
Block a user