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

Upstream merge 2023-11-08 #192

Merged
merged 83 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
1faf8a0
load co2 data for digitransit
Antiik91 Jun 16, 2023
689d98c
remove sout
Antiik91 Jun 16, 2023
46c479b
calculate co2 emissions
sharhio Jul 5, 2023
9f27798
Merge conflict fix
Antiik91 Jul 19, 2023
b7cd138
updated configuration from placeholder values. Adjusted emissions mod…
Antiik91 Jul 21, 2023
06f7f79
initial documentation
Antiik91 Jul 21, 2023
2df7d32
improved docs
Antiik91 Jul 21, 2023
72c03b1
Fixed typo
Antiik91 Jul 25, 2023
9af1ba5
Fixed typos from tests and docs
Antiik91 Aug 1, 2023
2b0d663
Merge remote-tracking branch 'otp/dev-2.x' into co2
sharhio Aug 1, 2023
a075ffa
Emissions logic refined, more tests + fixes
sharhio Aug 3, 2023
740e0c8
generated documentation fixed
sharhio Aug 3, 2023
4f56079
Implementation using dagger injection
sharhio Aug 31, 2023
af88c7d
Merge remote-tracking branch 'otp/dev-2.x' into co2
sharhio Sep 4, 2023
7207521
test fixed
sharhio Sep 4, 2023
ab6efe8
emissions added to datafetchers
sharhio Sep 4, 2023
571757e
emissions data from gtfs.zip
sharhio Sep 14, 2023
241e784
Merge remote-tracking branch 'otp/dev-2.x' into co2
sharhio Sep 14, 2023
7ec48e4
data should use comma separator
sharhio Sep 14, 2023
bd7285b
documentations fixed, comment removed
sharhio Sep 14, 2023
ccecb7e
also read nonzipped gtfs
sharhio Sep 14, 2023
ab48452
Emissions data simplification
sharhio Sep 21, 2023
b13b7db
Emissions tests and documentation fix
sharhio Sep 21, 2023
b87b7e5
merge dev-2.x
sharhio Oct 3, 2023
d9447e3
Documentation and test fixes
sharhio Oct 3, 2023
1750e15
More tests for emissions, documentation fixed
sharhio Oct 3, 2023
d904701
emissions test fixes, cleanup
sharhio Oct 4, 2023
db30d39
emissions use feedScopedId, use meters instead of km, refactoring
sharhio Oct 4, 2023
72088fe
emissions use double instead of float, better naming
sharhio Oct 4, 2023
bf74026
support decimals in passenger count
sharhio Oct 10, 2023
12c8e21
documentation fixes
sharhio Oct 10, 2023
9c6d5a1
Use emissions data model in build
sharhio Oct 11, 2023
4a00f67
Emissions unit, type, service and package updated
sharhio Oct 18, 2023
c0f4bd8
Update src/main/resources/org/opentripplanner/apis/gtfs/schema.graphqls
sharhio Oct 19, 2023
8afd628
Emissions naming fixed, emissions use record
sharhio Oct 19, 2023
0d2634f
Emissions grams scalar, refactoring, documentation, tests
sharhio Oct 24, 2023
643e545
Update src/ext-test/java/org/opentripplanner/ext/emissions/EmissionsT…
sharhio Oct 26, 2023
5e9bb96
Update src/ext-test/java/org/opentripplanner/ext/emissions/EmissionsT…
sharhio Oct 26, 2023
d380b77
Update src/main/java/org/opentripplanner/api/model/ApiItinerary.java
sharhio Oct 26, 2023
e39fb2a
Update src/main/java/org/opentripplanner/framework/model/Grams.java
sharhio Oct 26, 2023
9d95379
Update src/ext-test/java/org/opentripplanner/ext/emissions/EmissionsT…
sharhio Oct 26, 2023
7116132
Update src/ext-test/java/org/opentripplanner/ext/emissions/EmissionsT…
sharhio Oct 26, 2023
1741481
Update src/ext-test/java/org/opentripplanner/ext/emissions/EmissionsT…
sharhio Oct 26, 2023
d99d903
Update src/ext-test/java/org/opentripplanner/ext/emissions/EmissionsT…
sharhio Oct 26, 2023
5f33345
Update src/ext/java/org/opentripplanner/ext/emissions/EmissionsDataMo…
sharhio Oct 26, 2023
ffb7adf
Update src/ext/java/org/opentripplanner/ext/emissions/EmissionsDataSe…
sharhio Oct 26, 2023
cf1d627
Emissions refactoring, documentations
sharhio Oct 30, 2023
bab72fc
emissions service final field
sharhio Oct 30, 2023
70c8b2a
Merge remote-tracking branch 'otp/dev-2.x' into co2
sharhio Oct 30, 2023
471e0eb
Update src/ext/java/org/opentripplanner/ext/emissions/EmissionsFilter…
sharhio Oct 30, 2023
7dc9b2a
emissions refactoring
sharhio Oct 30, 2023
0b7e414
Emissions refactoring and test fixes
sharhio Oct 30, 2023
f12803e
Emissions file fix
sharhio Oct 31, 2023
502a7ed
orca fares: fix water taxi fare calculation
daniel-heppner-ibigroup Oct 31, 2023
31e04d4
remove unused import
daniel-heppner-ibigroup Oct 31, 2023
8eb34b5
Emissions issssue type and import fixes
sharhio Nov 1, 2023
294ef8e
fix calculation for Whatcom fares
daniel-heppner-ibigroup Nov 1, 2023
3ab8b67
More logging and Merge remote-tracking branch 'otp/dev-2.x' into co2
sharhio Nov 2, 2023
aa5f235
Update src/main/java/org/opentripplanner/model/plan/Itinerary.java
sharhio Nov 2, 2023
291bd79
add test for new Money.half() method
daniel-heppner-ibigroup Nov 2, 2023
304b86d
run formatter, extract constants
daniel-heppner-ibigroup Nov 2, 2023
5ca2c88
format Money.java
daniel-heppner-ibigroup Nov 2, 2023
a9b0151
chore(deps): update dependency org.mockito:mockito-core to v5.7.0
renovate[bot] Nov 3, 2023
35ebd1a
Add logging of siri errors to SiriAzureETUpdater
habrahamsson-skanetrafiken Nov 2, 2023
b563544
chore(deps): update junit5 monorepo to v5.10.1
renovate[bot] Nov 6, 2023
dab69ff
chore(deps): update dependency com.tngtech.archunit:archunit to v1.2.0
renovate[bot] Nov 6, 2023
fb85e6d
Update gbfs-java-model monthly [ci skip]
leonardehrenfried Nov 6, 2023
a842ae8
Use ResultLogger in SiriAzureETUpdater
habrahamsson-skanetrafiken Nov 6, 2023
0f331e9
Emissions model config and doc generation fix
sharhio Nov 6, 2023
95e5532
Merge branch 'co2' of github.com:HSLdevcom/OpenTripPlanner into co2
sharhio Nov 6, 2023
eaf94c3
fix(deps): update dependency org.entur.gbfs:gbfs-java-model to v3.0.13
renovate[bot] Nov 6, 2023
4e6fcba
Merge pull request #5475 from Skanetrafiken/log-azure-siri-errors
Bartosz-Kruba Nov 6, 2023
0ca68ea
fix(deps): update dependency com.google.guava:guava to v32.1.3-jre
renovate[bot] Nov 6, 2023
d009006
chore(deps): update dependency org.apache.maven.plugins:maven-surefir…
renovate[bot] Nov 6, 2023
76e9e27
fix(deps): update dependency com.google.cloud:libraries-bom to v26.26.0
renovate[bot] Nov 7, 2023
aa51f0c
Merge pull request #5479 from opentripplanner/renovate/org.entur.gbfs…
leonardehrenfried Nov 7, 2023
3c0679a
Merge pull request #5486 from opentripplanner/renovate/guava-monorepo
leonardehrenfried Nov 7, 2023
3c33918
Merge pull request #5487 from opentripplanner/renovate/com.google.clo…
leonardehrenfried Nov 7, 2023
08c76e1
Merge pull request #5278 from HSLdevcom/co2
leonardehrenfried Nov 7, 2023
13fe69f
Add changelog entry for #5278 [ci skip]
Nov 7, 2023
70bf18a
Bump serialization version id for #5278
Nov 7, 2023
231f223
Merge pull request #5469 from ibi-group/orca-fixes-pt2
leonardehrenfried Nov 7, 2023
de8bace
Merge remote-tracking branch 'upstream/dev-2.x' into upstream-merge-2…
leonardehrenfried Nov 8, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions doc-templates/Emissions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# CO₂ Emissions calculation

## Contact Info

- Digitransit Team

## Documentation

Graph build import of CO₂ Emissions from GTFS data sets (through custom emissions.txt extension)
and the ability to attach them to itineraries by Digitransit team.
The emissions are represented in grams per kilometer (g/Km) unit.

Emissions data is located in an emissions.txt file within a gtfs package and has the following columns:

`route_id`: route id

`avg_co2_per_vehicle_per_km`: Average carbon dioxide equivalent value for the vehicles used on the route at grams/Km units.

`avg_passenger_count`: Average passenger count for the vehicles on the route.

For example:
```csv
route_id,avg_co2_per_vehicle_per_km,avg_passenger_count
1234,123,20
2345,0,0
3456,12.3,20.0
```

Emissions data is loaded from the gtfs package and embedded into the graph during the build process.


### Configuration
To enable this functionality, you need to enable the "Co2Emissions" feature in the
`otp-config.json` file.

```JSON
//otp-config.json
{
"Co2Emissions": true
}

```
Include the `emissions` object in the
`build-config.json` file. The `emissions` object should contain parameters called
`carAvgCo2PerKm` and `carAvgOccupancy`. The `carAvgCo2PerKm` provides the average emissions value for a car in g/km and
the `carAvgOccupancy` provides the average number of passengers in a car.

<!-- INSERT: config -->

## Changelog

### OTP 2.5

- Initial implementation of the emissions calculation.
7 changes: 6 additions & 1 deletion docs/BuildConfiguration.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ Sections follow that describe particular settings in more depth.
| demDefaults | `object` | Default properties for DEM extracts. | *Optional* | | 2.3 |
|    [elevationUnitMultiplier](#demDefaults_elevationUnitMultiplier) | `double` | Specify a multiplier to convert elevation units from source to meters. | *Optional* | `1.0` | 2.3 |
| [elevationBucket](#elevationBucket) | `object` | Used to download NED elevation tiles from the given AWS S3 bucket. | *Optional* | | na |
| [emissions](sandbox/Emissions.md) | `object` | Emissions configuration. | *Optional* | | na |
| [fares](sandbox/Fares.md) | `object` | Fare configuration. | *Optional* | | 2.0 |
| gtfsDefaults | `object` | The gtfsDefaults section allows you to specify default properties for GTFS files. | *Optional* | | 2.3 |
|    blockBasedInterlining | `boolean` | Whether to create stay-seated transfers in between two trips with the same block id. | *Optional* | `true` | 2.3 |
Expand Down Expand Up @@ -1163,7 +1164,11 @@ case where this is not the case.
"enabled" : true
}
}
]
],
"emissions" : {
"carAvgCo2PerKm" : 170,
"carAvgOccupancy" : 1.3
}
}
```

Expand Down
1 change: 1 addition & 0 deletions docs/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ based on merged pull requests. Search GitHub issues and pull requests for smalle
- Ignore negative travel-times in Raptor [#5443](https://github.com/opentripplanner/OpenTripPlanner/pull/5443)
- Fix sort order bug in optimized transfers [#5446](https://github.com/opentripplanner/OpenTripPlanner/pull/5446)
- Siri file loader [#5460](https://github.com/opentripplanner/OpenTripPlanner/pull/5460)
- Calculate CO₂ emissions of itineraries [#5278](https://github.com/opentripplanner/OpenTripPlanner/pull/5278)
[](AUTOMATIC_CHANGELOG_PLACEHOLDER_DO_NOT_REMOVE)

## 2.4.0 (2023-09-13)
Expand Down
1 change: 1 addition & 0 deletions docs/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ Here is a list of all features which can be toggled on/off and their default val
| `TransferConstraints` | Enforce transfers to happen according to the _transfers.txt_(GTFS) and Interchanges(NeTEx). Turing this _off_ will increase the routing performance a little. | ✓️ | |
| `ActuatorAPI` | Endpoint for actuators (service health status). | | ✓️ |
| `AsyncGraphQLFetchers` | Whether the @async annotation in the GraphQL schema should lead to the fetch being executed asynchronously. This allows batch or alias queries to run in parallel at the cost of consuming extra threads. | | |
| `Co2Emissions` | Enable the emissions sandbox module. | | ✓️ |
| `DataOverlay` | Enable usage of data overlay when calculating costs for the street network. | | ✓️ |
| `FaresV2` | Enable import of GTFS-Fares v2 data. | | ✓️ |
| `FlexRouting` | Enable FLEX routing. | | ✓️ |
Expand Down
79 changes: 79 additions & 0 deletions docs/sandbox/Emissions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# CO₂ Emissions calculation

## Contact Info

- Digitransit Team

## Documentation

Graph build import of CO₂ Emissions from GTFS data sets (through custom emissions.txt extension)
and the ability to attach them to itineraries by Digitransit team.
The emissions are represented in grams per kilometer (g/Km) unit.

Emissions data is located in an emissions.txt file within a gtfs package and has the following columns:

`route_id`: route id

`avg_co2_per_vehicle_per_km`: Average carbon dioxide equivalent value for the vehicles used on the route at grams/Km units.

`avg_passenger_count`: Average passenger count for the vehicles on the route.

For example:
```csv
route_id,avg_co2_per_vehicle_per_km,avg_passenger_count
1234,123,20
2345,0,0
3456,12.3,20.0
```

Emissions data is loaded from the gtfs package and embedded into the graph during the build process.


### Configuration
To enable this functionality, you need to enable the "Co2Emissions" feature in the
`otp-config.json` file.

```JSON
//otp-config.json
{
"Co2Emissions": true
}

```
Include the `emissions` object in the
`build-config.json` file. The `emissions` object should contain parameters called
`carAvgCo2PerKm` and `carAvgOccupancy`. The `carAvgCo2PerKm` provides the average emissions value for a car in g/km and
the `carAvgOccupancy` provides the average number of passengers in a car.

<!-- config BEGIN -->
<!-- NOTE! This section is auto-generated. Do not change, change doc in code instead. -->

### Example configuration

```JSON
// build-config.json
{
"emissions" : {
"carAvgCo2PerKm" : 170,
"carAvgOccupancy" : 1.3
}
}
```
### Overview

| Config Parameter | Type | Summary | Req./Opt. | Default Value | Since |
|------------------|:---------:|------------------------------------------------------------|:----------:|---------------|:-----:|
| carAvgCo2PerKm | `integer` | The average CO₂ emissions of a car in grams per kilometer. | *Optional* | `170` | na |
| carAvgOccupancy | `double` | The average number of passengers in a car. | *Optional* | `1.3` | na |


### Details


<!-- config END -->

## Changelog

### OTP 2.5

- Initial implementation of the emissions calculation.
16 changes: 8 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@


<properties>
<otp.serialization.version.id>123</otp.serialization.version.id>
<otp.serialization.version.id>124</otp.serialization.version.id>
<!-- Lib versions - keep list sorted on property name -->
<geotools.version>30.0</geotools.version>
<google.dagger.version>2.48.1</google.dagger.version>
<jackson.version>2.15.3</jackson.version>
<jersey.version>3.1.3</jersey.version>
<junit.version>5.10.0</junit.version>
<junit.version>5.10.1</junit.version>
<micrometer.version>1.11.5</micrometer.version>
<netcdf4.version>5.5.3</netcdf4.version>
<logback.version>1.4.11</logback.version>
Expand Down Expand Up @@ -247,7 +247,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.2.1</version>
<version>3.2.2</version>
<dependencies>
<dependency>
<groupId>me.fabriciorby</groupId>
Expand Down Expand Up @@ -579,7 +579,7 @@
<!-- This make sure all google libraries are using compatible versions. -->
<groupId>com.google.cloud</groupId>
<artifactId>libraries-bom</artifactId>
<version>26.24.0</version>
<version>26.26.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down Expand Up @@ -721,7 +721,7 @@
<dependency>
<groupId>org.entur.gbfs</groupId>
<artifactId>gbfs-java-model</artifactId>
<version>3.0.11</version>
<version>3.0.13</version>
</dependency>

<!-- TESTING -->
Expand All @@ -740,13 +740,13 @@
<dependency>
<groupId>com.tngtech.archunit</groupId>
<artifactId>archunit</artifactId>
<version>1.1.0</version>
<version>1.2.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>5.6.0</version>
<version>5.7.0</version>
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -772,7 +772,7 @@
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>32.1.2-jre</version>
<version>32.1.3-jre</version>
</dependency>
<!-- Jersey annotation-driven REST web services (JAX-RS implementation) -->
<dependency>
Expand Down
3 changes: 2 additions & 1 deletion renovate.json5
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
"@graphql-codegen/java-resolvers",
"graphql",
"io.micrometer:micrometer-registry-prometheus",
"io.micrometer:micrometer-registry-influx"
"io.micrometer:micrometer-registry-influx",
"org.entur.gbfs:gbfs-java-model"
],
// we don't use the 'monthly' preset because that only fires on the first day of the month
// when there might already other PRs open
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package org.opentripplanner.ext.emissions;

import static org.junit.jupiter.api.Assertions.assertEquals;

import java.io.File;
import org.junit.jupiter.api.Test;
import org.opentripplanner.graph_builder.issue.service.DefaultDataImportIssueStore;
import org.opentripplanner.test.support.ResourceLoader;

public class Co2EmissionsDataReaderTest {

private static final ResourceLoader RES = ResourceLoader.of(Co2EmissionsDataReaderTest.class);
private static final File CO2_GTFS_ZIP = RES.file("emissions-test-gtfs.zip");
private static final File CO2_GTFS = RES.file("emissions-test-gtfs/");
private static final File INVALID_CO2_GTFS = RES.file("emissions-invalid-test-gtfs/");

private Co2EmissionsDataReader co2EmissionsDataReader = new Co2EmissionsDataReader(
new DefaultDataImportIssueStore()
);

@Test
void testCo2EmissionsZipDataReading() {
var emissions = co2EmissionsDataReader.readGtfsZip(CO2_GTFS_ZIP);
assertEquals(6, emissions.size());
}

@Test
void testCo2EmissionsDataReading() {
var emissions = co2EmissionsDataReader.readGtfs(CO2_GTFS);
assertEquals(6, emissions.size());
}

@Test
void testInvalidCo2EmissionsDataReading() {
var emissions = co2EmissionsDataReader.readGtfs(INVALID_CO2_GTFS);
assertEquals(0, emissions.size());
}
}
Loading
Loading