forked from opentripplanner/OpenTripPlanner
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #192 from ibi-group/upstream-merge-2023-11-08
Upstream merge 2023-11-08
- Loading branch information
Showing
66 changed files
with
1,398 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/ext-test/java/org/opentripplanner/ext/emissions/Co2EmissionsDataReaderTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
} |
Oops, something went wrong.