From c07b77cc9afac36b186b9259c6e2c04a06abb7d9 Mon Sep 17 00:00:00 2001 From: Jeff Frankl Date: Thu, 21 Feb 2019 06:23:49 -0500 Subject: [PATCH] Fix geojson-stream integration (#10) 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. --- bin/geojson-polygon-labels | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/bin/geojson-polygon-labels b/bin/geojson-polygon-labels index f7a401f..0db69f8 100755 --- a/bin/geojson-polygon-labels +++ b/bin/geojson-polygon-labels @@ -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()); } @@ -106,6 +108,7 @@ inputStream function labelFeature(inputFeature) { featureCount++; + let labeledFeatures = []; process.stderr.write('...' + featureCount + "\r"); if (inputFeature.geometry) { @@ -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 @@ -197,6 +199,8 @@ function labelFeature(inputFeature) { } }); } + + return labeledFeatures; } function areaToZoom(area, min, max) {