Skip to content

Conversation

@optionsome
Copy link
Member

Summary

Add openingHours and feeHours to vehicle parkings and use openingHours for routing.

Issue

relates to #3432

Unit tests

Added tests but they might have to be changed based on the final implementation.

Code style

Have you followed the suggested code style?
yes

Documentation

TODO

Changelog

From title

@optionsome
Copy link
Member Author

Opened this pr as a draft to get comments on what should be changed. We have discussed this topic before in developer meetings and there have already been on suggestions on what should be done (at least at some point in the future).

Some things I will change for sure:

  • Remove lombok use
  • Add more javadoc/comments
  • Implement openingHours/feeHours for the updaters and tile layer

Some things to discuss:

  • Should the use of LocalDateTime be replaced with some time-zone aware format
  • Should we only store opening hours that cover a limited time span (based on transitServiceStart and transitServiceEnd end maybe?) in some static format instead of evaluating if the parking is open or not based on some rules at routing time
  • Are public holidays somehow taken into account already and should they be?

@t2gran t2gran added this to the 2.1 milestone Jan 11, 2022
@t2gran
Copy link
Member

t2gran commented Jan 28, 2022

Should we only store opening hours that cover a limited time span (based on transitServiceStart and transitServiceEnd end maybe?) in some static format instead of evaluating if the parking is open or not based on some rules at routing time.

It is hard to say what would lead to the best performance. A pre-calculated structure may take up more memory space and end up being slower due to fetching data. I think maybe going for the simplest solution now, and then optimize later is a ok strategy. @leonardehrenfried might have some input on how often we encounter this and if it have any performance impact at all.

Comment on lines +109 to +126
while (iterations < MAX_TIME_RESTRICTION_ITERATIONS) {
for (final TimeRestrictionWithOffset timeRestriction : timeRestrictions) {
var offsetFromArrival = timeRestriction.getOffsetInSecondsFromStartOfSearch() - durationInSeconds;
var timeAtRestriction = time.plusSeconds(offsetFromArrival);
var traversableAt = timeRestriction.getTimeRestriction()
.latestArrivalTime(timeAtRestriction);

if (traversableAt.isEmpty()) {
break DATETIME_SEARCH;
}

var alternateTime = traversableAt.get();
if (!alternateTime.equals(timeAtRestriction)) {
time = alternateTime.minusSeconds(offsetFromArrival);
iterations++;
continue DATETIME_SEARCH;
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To me it is not obvious that this loop is safe - do not enter an infinite loop with poor data. If the !alternateTime.equals(timeAtRestriction) is false every time, this loop never exit. Can this be refactored so we by reading the code are sure it is safe?

Comment on lines +693 to +697
<dependency>
<groupId>io.leonard</groupId>
<artifactId>opening-hours-evaluator</artifactId>
<version>1.2.1</version>
</dependency>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if we should have this dependency - I know it is @leonardehrenfried and @flaktack who maintain it, but I am skeptical to use a library that is just 2 classes and a thin wrapper around another lib - it is poetically creating problems in the future, while maintaining the needed logic inside OTP seem like a better option. Also the ch.poole.openinghoursparser lib is used in this PR directly, so we should include the dependency to it as well, and not relay on a transitive dependency. Another problem is the license - am not an expert, but we at least need to include it if we use the lib.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will keep using this as a depedency but we will add ch.poole.openinghoursparser to pom as an separate depedency as well.

@t2gran
Copy link
Member

t2gran commented Feb 4, 2022

I started on an Opening Hours Calendar. Take a look at the API, see unit test in #3866. I am unsure what the simplest way to create it are. Is the query design ok?

See unit test

@t2gran t2gran modified the milestones: 2.1, 2.2 Feb 25, 2022
@t2gran t2gran modified the milestones: 2.2, 2.3 Nov 1, 2022
@t2gran t2gran modified the milestones: 2.3, 2.4 Apr 24, 2023
@t2gran t2gran modified the milestones: 2.4, 2.5 (next release) Sep 13, 2023
@t2gran t2gran modified the milestones: 2.5, 2.6 (next release) Mar 13, 2024
@optionsome optionsome modified the milestones: 2.6 (next release), Parked Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants