Skip to content

Commit

Permalink
Fix EAGAIN.
Browse files Browse the repository at this point in the history
  • Loading branch information
mbostock committed Feb 11, 2016
1 parent e19633e commit 932bf4c
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
5 changes: 3 additions & 2 deletions bin/topojson
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ var argv = optimist
})
.check(function(argv) {
if (argv.help) return;
if (argv.version) return console.log(topojson.version), process.exit(0);
if (argv.version) return process.stdout.write(topojson.version + "\n"), process.exit(0);
if (!argv._.length) argv._ = ["-"];
if (+argv.s && +argv["simplify-proportion"]) throw new Error("--simplify and --simplify-proportion are exclusive");
if (+argv["simplify-proportion"] < 0 || +argv["simplify-proportion"] >= 1) throw new Error("--simplify-proportion must be between 0 and 1");
Expand Down Expand Up @@ -256,7 +256,8 @@ function inputJson(file, callback) {
}

function output(error) {
if (error) return console.trace(error);
if (error) throw error;

var options = {
"verbose": true,
"pre-quantization": +argv.q0,
Expand Down
2 changes: 1 addition & 1 deletion lib/topojson/prune.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ module.exports = function(topology, options) {
pruneGeometry(objects[key]);
}

if (verbose) console.warn("prune: retained " + newArcCount + " / " + oldArcCount + " arcs (" + Math.round(newArcCount / oldArcCount * 100) + "%)");
if (verbose) process.stderr.write("prune: retained " + newArcCount + " / " + oldArcCount + " arcs (" + Math.round(newArcCount / oldArcCount * 100) + "%)\n");

return topology;
};
Expand Down
4 changes: 2 additions & 2 deletions lib/topojson/simplify.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module.exports = function(topology, options) {
});
var n = areas.length;
options["minimum-area"] = minimumArea = n ? areas.sort(function(a, b) { return b - a; })[Math.max(0, Math.ceil((N - 1) * retainProportion + n - N))] : 0;
if (verbose) console.warn("simplification: effective minimum area " + minimumArea.toPrecision(3));
if (verbose) process.stderr.write("simplification: effective minimum area " + minimumArea.toPrecision(3) + "\n");
}

topology.arcs.forEach(topology.transform ? function(arc) {
Expand Down Expand Up @@ -102,7 +102,7 @@ module.exports = function(topology, options) {
M += arc.length = (j || 1) + 1;
});

if (verbose) console.warn("simplification: retained " + M + " / " + N + " points (" + Math.round((M / N) * 100) + "%)");
if (verbose) process.stderr.write("simplification: retained " + M + " / " + N + " points (" + Math.round((M / N) * 100) + "%)\n");

return topology;
};
8 changes: 4 additions & 4 deletions lib/topojson/topology.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ module.exports = function(objects, options) {
}

if (verbose) {
console.warn("bounds: " + bbox.join(" ") + " (" + system.name + ")");
process.stderr.write("bounds: " + bbox.join(" ") + " (" + system.name + ")\n");
}

// Pre-topology quantization.
if (Q0) {
transform = prequantize(objects, bbox, Q0, Q1);
if (verbose) {
console.warn("pre-quantization: " + transform.scale.map(function(k) { return system.formatDistance(k); }).join(" "));
process.stderr.write("pre-quantization: " + transform.scale.map(function(k) { return system.formatDistance(k); }).join(" ") + "\n");
}
}

Expand All @@ -90,15 +90,15 @@ module.exports = function(objects, options) {
if (Q0) topology.transform = transform;
topology.bbox = bbox;
if (verbose) {
console.warn("topology: " + topology.arcs.length + " arcs, " + topology.arcs.reduce(function(p, v) { return p + v.length; }, 0) + " points");
process.stderr.write("topology: " + topology.arcs.length + " arcs, " + topology.arcs.reduce(function(p, v) { return p + v.length; }, 0) + " points\n");
}

// Post-topology quantization.
if (Q1 && Q1 !== Q0) {
postquantize(topology, Q0, Q1);
transform = topology.transform;
if (verbose) {
console.warn("post-quantization: " + transform.scale.map(function(k) { return system.formatDistance(k); }).join(" "));
process.stderr.write("post-quantization: " + transform.scale.map(function(k) { return system.formatDistance(k); }).join(" ") + "\n");
}
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "topojson",
"version": "1.6.23",
"version": "1.6.24",
"description": "An extension to GeoJSON that encodes topology.",
"keywords": [
"topojson",
Expand Down

0 comments on commit 932bf4c

Please sign in to comment.