Skip to content

Commit

Permalink
Fix for multi-agency import
Browse files Browse the repository at this point in the history
  • Loading branch information
brendannee committed Nov 20, 2020
1 parent ed538ac commit 6c28300
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 7 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.0.1] - 2020-11-19
### Changed
- Better dissolve with polygon-clipping library
### Fixed
- Support for multi agency import

## [2.0.0] - 2020-11-19
### Added
- New export types: envelope, convex, lines, lines-buffer, lines-dissolve, stops, stops-buffer, stops-dissolve, lines-and-stops.
Expand Down
3 changes: 2 additions & 1 deletion lib/formats/lines-dissolved.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ module.exports = async (config, routeId, directionId) => {
const bufferedLines = buffer(lines, config.bufferSizeMeters, { units: 'meters' });

const geometries = [];
geomEach(bufferedLines, (geometry) => {
geomEach(bufferedLines, geometry => {
if (geometry.type === 'MultiPolygon') {
geometries.push(geometry.coordinates);
}

if (geometry.type === 'Polygon') {
geometries.push([geometry.coordinates]);
}
Expand Down
3 changes: 2 additions & 1 deletion lib/formats/stops-dissolved.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ module.exports = async (config, routeId, directionId) => {
const bufferedStops = buffer(stops, config.bufferSizeMeters, { units: 'meters' });

const geometries = [];
geomEach(bufferedStops, (geometry) => {
geomEach(bufferedStops, geometry => {
if (geometry.type === 'MultiPolygon') {
geometries.push(geometry.coordinates);
}

if (geometry.type === 'Polygon') {
geometries.push([geometry.coordinates]);
}
Expand Down
10 changes: 7 additions & 3 deletions lib/gtfs-to-geojson.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,10 @@ module.exports = async initialConfig => {

await gtfs.openDb(config);

await Promise.all(config.agencies.map(async agency => {
config.log(`Started GeoJSON creation for ${config.agencies.length} agencies.`);

/* eslint-disable no-await-in-loop */
for (const agency of config.agencies) {
const timer = new Timer();
timer.start();

Expand All @@ -128,7 +131,7 @@ module.exports = async initialConfig => {
const agencyConfig = clone(omit(config, 'agencies'));
agencyConfig.agencies = [agency];

await gtfs.import(config);
await gtfs.import(agencyConfig);
}

await fs.remove(exportPath);
Expand Down Expand Up @@ -157,5 +160,6 @@ module.exports = async initialConfig => {

timer.stop();
config.log(`GeoJSON generation required ${msToSeconds(timer.time())} seconds`);
}));
}
/* eslint-enable no-await-in-loop */
};
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "gtfs-to-geojson",
"description": "Generate geoJSON of transit route data from a GTFS file",
"version": "2.0.0",
"version": "2.0.1",
"keywords": [
"transit",
"gtfs",
Expand Down

0 comments on commit 6c28300

Please sign in to comment.