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

Add suport for importing CO₂ emission per trip leg #6614

Open
wants to merge 43 commits into
base: dev-2.x
Choose a base branch
from

Conversation

t2gran
Copy link
Member

@t2gran t2gran commented Apr 11, 2025

Summary

This PR add support for importing emissions on trip leg. The emissions.txt CSV input format looks like this:

trip_id, from_stop_id, from_stop_sequence, co2
MY:ServiceJourney:1, NSR:Quay:300, 1, 150.0
MY:ServiceJourney:1, NSR:Quay:301, 2, 230.0
MY:ServiceJourney:1, NSR:Quay:302, 3, 459.0

The plan is to add support for TripOnServiceDay later. This input format put the entire emission calculation
responsibility on the producer of the input. OTP only decorate itinerary legs by adding the trips "legs" used.

This Transmodel API is NOT updated, this will be done in a separate PR.

Some notes:

  • This PR rename the OTPFature to Emission was (Co2Emissions).
  • All use of emissions (plural) is replaced with emission (singular) in calss, variable and package names following the code convention. A few places is left where the emission variable was indeed more than one Emission (array of Emissions). The user and JavaDoc is updated, but the plural is kept where it is natural.
  • The GTFS API is NOT changed, it has a type and variables called Emissions.
  • The config is changed! The root element is renamed emission, not emissions in build-config.json.
  • I changed the emission lookup of the existing Route approch from using Agency.feed + Route.id.idto use just Route.id. I guess this was a mistake? (DefaultEmissionService line 33)

Issue

I have not tested, but it should fix #6609

Unit tests

✅ The emission module now have close to 100% branch coverage, I have also added unit-tests on the old code - witch had poor and missing test coverage.

Documentation

🟥 I have not added use documentation yet.

Changelog

🟥 This is a Sandbox featue, I will add user doc/changelog in a later PR.

Bumping the serialization version id

✅ The serialization is changed.

t2gran added 30 commits April 11, 2025 13:28
- This need a follow-up commit to make the code compile
@t2gran t2gran added New Feature Sandbox Entur On Entur Roadmap Technical Debt Entur Test This is currently being tested at Entur bump serialization id Add this label if you want the serialization id automatically bumped after merging the PR Skip Changelog Config Change labels Apr 11, 2025
@t2gran t2gran added this to the 2.8 (next release) milestone Apr 11, 2025
@t2gran t2gran requested a review from a team as a code owner April 11, 2025 20:46
@t2gran t2gran force-pushed the add_co2_emissions branch from dc2af3a to ce25780 Compare April 13, 2025 11:17
Copy link

codecov bot commented Apr 13, 2025

Codecov Report

Attention: Patch coverage is 85.21257% with 80 lines in your changes missing coverage. Please review.

Project coverage is 71.15%. Comparing base (95e9d70) to head (9aa0be2).
Report is 4 commits behind head on dev-2.x.

Files with missing lines Patch % Lines
...rg/opentripplanner/graph_builder/GraphBuilder.java 0.00% 19 Missing ⚠️
...planner/graph_builder/GraphBuilderDataSources.java 0.00% 8 Missing ⚠️
...emission/configure/EmissionGraphBuilderModule.java 0.00% 6 Missing ⚠️
.../internal/csvdata/csvparser/AbstractCsvParser.java 87.75% 6 Missing ⚠️
...on/internal/graphbuilder/EmissionGraphBuilder.java 85.29% 3 Missing and 2 partials ⚠️
...ner/standalone/configure/ConstructApplication.java 0.00% 5 Missing ⚠️
.../org/opentripplanner/apis/gtfs/GraphQLScalars.java 0.00% 4 Missing ⚠️
.../emission/internal/csvdata/EmissionDataReader.java 84.21% 1 Missing and 2 partials ⚠️
...va/org/opentripplanner/utils/lang/DoubleRange.java 81.25% 0 Missing and 3 partials ⚠️
...t/emission/configure/EmissionRepositoryModule.java 0.00% 2 Missing ⚠️
... and 13 more
Additional details and impacted files
@@              Coverage Diff              @@
##             dev-2.x    #6614      +/-   ##
=============================================
+ Coverage      71.03%   71.15%   +0.11%     
- Complexity     18296    18436     +140     
=============================================
  Files           2005     2024      +19     
  Lines          75849    76171     +322     
  Branches        7779     7790      +11     
=============================================
+ Hits           53882    54196     +314     
- Misses         19222    19229       +7     
- Partials        2745     2746       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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 Config Change Entur Test This is currently being tested at Entur Entur On Entur Roadmap New Feature Sandbox Skip Changelog Technical Debt
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Exception when using new refactored emissions code
1 participant