Skip to content

Commit

Permalink
render finally working
Browse files Browse the repository at this point in the history
  • Loading branch information
rveciana committed Aug 29, 2016
1 parent 6f582b3 commit 9cdcb4d
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,3 +1,4 @@
/coses.txt
/node_modules/
/build/
/test/output/
4 changes: 2 additions & 2 deletions test/albersUsa-test.js
Expand Up @@ -24,11 +24,11 @@ tape("geoAlbersUsa.invert(point) returns the expected result", function(test) {
test.inDelta(albersUsa.invert([298.5, 451.0]), [-157.8583, 21.3069], 0.1); // Honolulu, HI
test.end();
});

/*
tape("geoAlbersUsa.getCompositionBorders() returns the expected result", function(test) {
var albersUsa = d3.geoAlbersUsa();
var borders = albersUsa.getCompositionBorders();
test.equal((borders.match(/L/g) || []).length, 6, "Number of border lines must be 6");
test.equal((borders.match(/M/g) || []).length, 2, "Number of borders must be 2");
test.end();
});
});*/
4 changes: 3 additions & 1 deletion test/compare-images
Expand Up @@ -2,5 +2,7 @@

for i in \
albersUsa; do
echo $i
test/render $i \
&& [ "$(compare -metric rmse test/samples/$i.png test/output/$i.png null: 2>&1)" = "0 (0)" ] \
|| echo "✗ test/output/$i.png and test/samples/$i.png differ"
done
1 change: 1 addition & 0 deletions test/data/us-10m.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions test/data/world-50m.json

Large diffs are not rendered by default.

41 changes: 40 additions & 1 deletion test/render 100644 → 100755
Expand Up @@ -10,7 +10,46 @@ if (!/^[a-z0-9]+$/i.test(projectionName)) throw new Error;
var fs = require("fs"),
topojson = require("topojson"),
Canvas = require("canvas"),
d3_geo = require("../");
d3_geo = require("d3-geo"),
d3_composite = require("../");

var canvas = new Canvas(width, height),
context = canvas.getContext("2d");

var world = require("./data/us-10m.json"),
graticule = d3_geo.geoGraticule(),
outline = {type: "Sphere"};

var path = d3_geo.geoPath()
.projection(d3_composite[projectionSymbol]().precision(0.1))
.context(context);

context.fillStyle = "#fff";
context.fillRect(0, 0, width, height);
context.save();

context.beginPath();
path(topojson.feature(world, world.objects.land));
context.fillStyle = "#000";
context.fill();

context.beginPath();
path(graticule());
context.strokeStyle = "rgba(119,119,119,0.5)";
context.stroke();

context.restore();


context.beginPath();
path(outline);
context.strokeStyle = "#00F";
context.stroke();
/*
context.beginPath();
context.strokeStyle = "#F00";
path(d3_composite[projectionSymbol]().getCompositionBorders());
context.stroke();*/

console.warn("↳ test/output/" + projectionName + ".png");
canvas.pngStream().pipe(fs.createWriteStream("test/output/" + projectionName + ".png"));
Binary file added test/samples/albersUsa.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 9cdcb4d

Please sign in to comment.