Skip to content

Commit

Permalink
Batch accessibility map: check request parameter before adding geomet…
Browse files Browse the repository at this point in the history
…ries to csv

Fixes #735
  • Loading branch information
davidmurray authored and tahini committed Oct 31, 2023
1 parent 237e70e commit b0d8a60
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ class BatchAccessibilityMapResultProcessorFile implements BatchAccessibilityMapR
for (let i = 0; i < numberOfPolygons; i++) {
polygonAttributes[`polygon${i}Duration`] = 0;
polygonAttributes[`polygon${i}AreaSqKm`] = 0;
polygonAttributes[`polygon${i}Geojson`] = '';
if (this.parameters.withGeometries) {
polygonAttributes[`polygon${i}Geojson`] = '';
}
}

fileManager.writeFileAbsolute(this.resultsCsvFilePath, '');
Expand Down Expand Up @@ -146,7 +148,9 @@ class BatchAccessibilityMapResultProcessorFile implements BatchAccessibilityMapR
for (let i = 0; i < results.polygons.features.length; i++) {
polygonAttributes[`polygon${i}Duration`] = results.polygons.features[i].properties?.durationMinutes;
polygonAttributes[`polygon${i}AreaSqKm`] = results.polygons.features[i].properties?.areaSqKm;
polygonAttributes[`polygon${i}Geojson`] = JSON.stringify(_omit(results.polygons.features[i], 'properties'));
if (this.parameters.withGeometries) {
polygonAttributes[`polygon${i}Geojson`] = JSON.stringify(_omit(results.polygons.features[i], 'properties'));
}
}
if (this._csvStream) {
this._csvStream.write(unparse([Object.assign(csvResults, polygonAttributes)], { header: false }) + '\n');
Expand Down

0 comments on commit b0d8a60

Please sign in to comment.