Skip to content

Make graph time zone configurable - #4281

Merged
hannesj merged 12 commits into
opentripplanner:dev-2.xfrom
entur:otp2_configurable_time_zone
Jul 25, 2022
Merged

hannesj merged 12 commits into
opentripplanner:dev-2.xfrom
entur:otp2_configurable_time_zone

Conversation

@hannesj

@hannesj hannesj commented Jul 19, 2022

Copy link
Copy Markdown
Contributor

Summary

Make it possible to configure the time zone when building the graph. Also throw an error, if multiple time zones are detected.

The scheduled times are adjusted to be in the configured time zone. No changes needed for real-time updaters are needed, as they operate on absolute times already.

Unit tests

New unit test for behaviour with multiple timezones is tested. TODO: Add tests for TimeZoneAdjusterModule

Documentation

Added configuration parameter

@hannesj hannesj added !Improvement A functional improvement or micro feature !Technical Debt Improve code quality, no functional changes. +Bump Serialization Id Add this label if you want the serialization id automatically bumped after merging the PR labels Jul 19, 2022
@hannesj hannesj added this to the 2.2 milestone Jul 19, 2022
@codecov-commenter

codecov-commenter commented Jul 19, 2022 •

Copy link
Copy Markdown

Codecov Report

Merging #4281 (887f806) into dev-2.x (8c9aa6c) will increase coverage by 0.00%.
The diff coverage is 78.57%.

@@            Coverage Diff             @@
##             dev-2.x    #4281   +/-   ##
==========================================
  Coverage      57.21%   57.22%           
- Complexity     10767    10774    +7     
==========================================
  Files           1426     1427    +1     
  Lines          57938    57955   +17     
  Branches        6714     6715    +1     
==========================================
+ Hits           33151    33162   +11     
- Misses         22762    22766    +4     
- Partials        2025     2027    +2     
Impacted Files Coverage Δ
.../org/opentripplanner/api/mapping/AgencyMapper.java 0.00% <0.00%> (ø)
...rg/opentripplanner/graph_builder/GraphBuilder.java 0.00% <0.00%> (ø)
.../graph_builder/module/osm/OpenStreetMapModule.java 86.74% <ø> (-0.02%) ⬇️
...ripplanner/model/calendar/CalendarServiceData.java 69.69% <ø> (-5.92%) ⬇️
...anner/model/calendar/impl/CalendarServiceImpl.java 81.81% <ø> (-1.52%) ⬇️
...ipplanner/model/impl/OtpTransitServiceBuilder.java 91.27% <ø> (-0.06%) ⬇️
...opentripplanner/standalone/config/NodeAdapter.java 87.09% <0.00%> (-0.41%) ⬇️
.../opentripplanner/transit/service/TransitModel.java 73.93% <80.95%> (+1.29%) ⬆️
...r/graph_builder/module/TimeZoneAdjusterModule.java 85.71% <85.71%> (ø)
...aphqlapi/datafetchers/LegacyGraphQLAgencyImpl.java 23.91% <100.00%> (ø)
... and 12 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8c9aa6c...887f806. Read the comment docs.

@hannesj
hannesj requested review from optionsome and t2gran July 19, 2022 09:53
@hannesj
hannesj marked this pull request as ready for review July 21, 2022 12:29
@hannesj
hannesj requested a review from a team as a code owner July 21, 2022 12:29

@optionsome optionsome left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Seems reasonable changes. However, I don't understand the wording in the GTFS specification "Timezone where the transit agency is located. If multiple agencies are specified in the dataset, each must have the same agency_timezone.". I have hard time interpreting that in any other way than that the time zone should be the same for each agency in one data set.

Comment thread src/main/java/org/opentripplanner/transit/service/TransitModel.java Outdated
Comment thread src/main/java/org/opentripplanner/standalone/config/BuildConfig.java Outdated
Comment thread docs/BuildConfiguration.md Outdated
Comment thread src/main/java/org/opentripplanner/transit/service/TransitModel.java Outdated
Comment thread src/main/java/org/opentripplanner/transit/service/TransitModel.java Outdated

@t2gran t2gran left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This looks good, a few requested changes. The logic for setting and validating the timezone is probably not the transit models responsibility, but there is not a clear candidate for it, so this is fine for now.

Comment thread src/main/java/org/opentripplanner/transit/service/TransitModel.java Outdated
Comment thread src/test/java/org/opentripplanner/transit/service/TransitModelTest.java Outdated
Comment thread src/main/java/org/opentripplanner/graph_builder/GraphBuilder.java Outdated
Comment thread docs/BuildConfiguration.md Outdated
Co-authored-by: Joel Lappalainen <lappalj8@gmail.com>
public ZoneId asZoneId(String paramName, ZoneId defaultValue) {
return exist(paramName) ? ZoneId.of(param(paramName).asText()) : defaultValue;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is missing a UnitTest, it also throws something else then a OTPApplication exception if the timezone is not found - that might be ok, but most other method do not. If the OTPApplication exception is thrown the application logs the error WITHOUT a stacktrace.

@hannesj

hannesj commented Jul 25, 2022

Copy link
Copy Markdown
Contributor Author

I have hard time interpreting that in any other way than that the time zone should be the same for each agency in one data set.

Currently this is not enforced, and there are no changes related to it. This is to support multiple bundles with different timezones

@optionsome

Copy link
Copy Markdown
Member

Currently this is not enforced, and there are no changes related to it. This is to support multiple bundles with different timezones

I wonder what is the origin of that restriction in the specification. Seems like a really arbitrary limitation.

@hannesj

hannesj commented Jul 25, 2022

Copy link
Copy Markdown
Contributor Author

I wonder what is the origin of that restriction in the specification. Seems like a really arbitrary limitation.

https://groups.google.com/g/gtfs-changes/c/Sh0e4o9o2Gw/m/vd8t58WhW0oJ Here is some context for the decision

@hannesj
hannesj merged commit f84dc1a into opentripplanner:dev-2.x Jul 25, 2022
t2gran pushed a commit that referenced this pull request Jul 25, 2022
@hannesj
hannesj deleted the otp2_configurable_time_zone branch July 25, 2022 14:35
t2gran pushed a commit that referenced this pull request Jul 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

+Bump Serialization Id Add this label if you want the serialization id automatically bumped after merging the PR !Improvement A functional improvement or micro feature !Technical Debt Improve code quality, no functional changes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants