Skip to content

Commit

Permalink
Fix geojson-stream integration (#10)
Browse files Browse the repository at this point in the history
When determining labels, push each label to an empty array, which gets passed back to the through function. This allows us to use  multiple times when there are multiple labels returned from a single feature.
  • Loading branch information
Jeff Frankl authored and andrewharvey committed Feb 21, 2019
1 parent 6d6ee0b commit c07b77c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions bin/geojson-polygon-labels
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ if (includeMinzoom && typeof includeMinzoom === "string" && includeMinzoom.split
function polylabelStream() {
return Combiner(geojsonStream.parse(),
through(function (feature, callback) {
this.queue(labelFeature(feature));
labelFeature(feature).forEach((feature) => {
this.queue(feature);
})
}),
geojsonStream.stringify());
}
Expand All @@ -106,6 +108,7 @@ inputStream

function labelFeature(inputFeature) {
featureCount++;
let labeledFeatures = [];
process.stderr.write('...' + featureCount + "\r");

if (inputFeature.geometry) {
Expand Down Expand Up @@ -183,8 +186,7 @@ function labelFeature(inputFeature) {
if (tippecanoeProperties) {
labelFeature.tippecanoe = tippecanoeProperties;
}
console.log(labelFeature)
return labelFeature;
labeledFeatures.push(labelFeature);
}else{
if (feature.geometry) {
// warn the users that non Polygon features are ignored
Expand All @@ -197,6 +199,8 @@ function labelFeature(inputFeature) {
}
});
}

return labeledFeatures;
}

function areaToZoom(area, min, max) {
Expand Down

0 comments on commit c07b77c

Please sign in to comment.