Skip to content

Commit

Permalink
Add d3.geoQuincuncial. Fixes #80.
Browse files Browse the repository at this point in the history
  • Loading branch information
mbostock committed Nov 2, 2016
1 parent 61d2150 commit aa4f244
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 30 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -816,13 +816,17 @@ Steve Waterman’s butterfly projection.

### Quincuncial Projections

<a href="#geoGringortenQuincuncial" name="geoGringortenQuincuncial">#</a> d3.<b>geoGringortenQuincuncial</b>() [<>](https://github.com/d3/d3-geo-projection/blob/master/src/gringortenQuincuncial.js "Source")
<a href="#geoQuincuncial" name="geoQuincuncial">#</a> d3.<b>geoQuincuncial</b>(<i>project</i>) [<>](https://github.com/d3/d3-geo-projection/blob/master/src/quincuncial/index.js "Source")


<a href="#geoGringortenQuincuncial" name="geoGringortenQuincuncial">#</a> d3.<b>geoGringortenQuincuncial</b>() [<>](https://github.com/d3/d3-geo-projection/blob/master/src/quincuncial/gringorten.js "Source")

<img src="https://raw.githubusercontent.com/d3/d3-geo-projection/master/img/gringortenQuincuncial.png" width="480" height="250">

The Gringorten square equal-area projection.

<a href="#geoPeirceQuincuncial" name="geoPeirceQuincuncial">#</a> d3.<b>geoPeirceQuincuncial</b>() [<>](https://github.com/d3/d3-geo-projection/blob/master/src/peirceQuincuncial.js "Source")
<a href="#geoPeirceQuincuncial" name="geoPeirceQuincuncial">#</a> d3.<b>geoPeirceQuincuncial</b>() [<>](https://github.com/d3/d3-geo-projection/blob/master/src/quincuncial/peirce.js "Source")

[<img src="https://raw.githubusercontent.com/d3/d3-geo-projection/master/img/peirceQuincuncial.png" width="480" height="250">](http://bl.ocks.org/mbostock/4310087)

Expand Down
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export {default as geoProject} from "./src/project/index";
export {default as geoGringortenQuincuncial} from "./src/quincuncial/gringorten.js";
export {default as geoPeirceQuincuncial} from "./src/quincuncial/peirce.js";
export {default as geoPierceQuincuncial} from "./src/quincuncial/peirce.js"; // DEPRECATED misspelling
export {default as geoQuincuncial} from "./src/quincuncial/index.js";
export {default as geoRectangularPolyconic, rectangularPolyconicRaw as geoRectangularPolyconicRaw} from "./src/rectangularPolyconic";
export {default as geoRobinson, robinsonRaw as geoRobinsonRaw} from "./src/robinson";
export {default as geoSatellite, satelliteRaw as geoSatelliteRaw} from "./src/satellite";
Expand Down
9 changes: 3 additions & 6 deletions src/quincuncial/gringorten.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import {geoProjection as projection} from "d3-geo";
import {gringortenRaw} from "../gringorten";
import quincuncialRaw from "./index";
import quincuncial from "./index";

export default function() {
return projection(quincuncialRaw(gringortenRaw))
.scale(176.423)
.rotate([-90, -90, 45])
.clipAngle(180 - 1e-3);
return quincuncial(gringortenRaw)
.scale(176.423);
}
5 changes: 4 additions & 1 deletion src/quincuncial/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {geoProjection as projection} from "d3-geo";
import {abs, halfPi, pi, sign, sqrt1_2} from "../math";

export default function(project) {
Expand Down Expand Up @@ -33,5 +34,7 @@ export default function(project) {
return p;
};

return projectQuincuncial;
return projection(projectQuincuncial)
.rotate([-90, -90, 45])
.clipAngle(180 - 1e-3);
}
9 changes: 3 additions & 6 deletions src/quincuncial/peirce.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import {geoProjection as projection} from "d3-geo";
import {guyouRaw} from "../guyou";
import quincuncialRaw from "./index";
import quincuncial from "./index";

export default function() {
return projection(quincuncialRaw(guyouRaw))
.scale(111.48)
.rotate([-90, -90, 45])
.clipAngle(180 - 1e-3);
return quincuncial(guyouRaw)
.scale(111.48);
}
16 changes: 7 additions & 9 deletions test/compute-scale
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@ var width = 960 - 1,
if (!/^[a-z0-9]+$/i.test(projectionName)) throw new Error;

var topojson = require("topojson"),
d3_format = require("d3-format"),
d3_geo = require("d3-geo"),
d3_geo_projection = require("../");
d3 = Object.assign({}, require("d3-format"), require("d3-geo"), require("../"));

var formatNumber = d3_format.format(".6");
var formatNumber = d3.format(".6");

var projection = d3_geo_projection[projectionSymbol]()
var projection = d3[projectionSymbol]()
.precision(0.01)
.scale(1)
.translate([0, 0])
Expand All @@ -31,7 +29,7 @@ switch (projectionName) {
break;
}
case "littrow": {
land = d3_geo.geoGraticule().extent([[-90, -60], [90, 60]]).outline();
land = d3.geoGraticule().extent([[-90, -60], [90, 60]]).outline();
break;
}
case "modifiedStereographicAlaska": {
Expand All @@ -45,16 +43,16 @@ switch (projectionName) {
break;
}
case "modifiedStereographicGs50": {
land = d3_geo.geoGraticule().extent([[-180, 15], [-50, 75]]).outline();
land = d3.geoGraticule().extent([[-180, 15], [-50, 75]]).outline();
break;
}
case "modifiedStereographicMiller": {
land = d3_geo.geoGraticule().extent([[-40, -40], [80, 80]]).outline();
land = d3.geoGraticule().extent([[-40, -40], [80, 80]]).outline();
break;
}
}

var path = d3_geo.geoPath()
var path = d3.geoPath()
.projection(projection);

var bounds = path.bounds(land),
Expand Down
11 changes: 5 additions & 6 deletions test/render-world
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env node

var width = 960,
height = 500,
height = 960,
projectionName = process.argv[2],
projectionSymbol = "geo" + projectionName[0].toUpperCase() + projectionName.slice(1);

Expand All @@ -10,15 +10,14 @@ 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"),
d3_geo_projection = require("../");
d3 = Object.assign({}, require("d3-geo"), require("../"));

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

var world = require("./data/world-50m.json"),
land = topojson.feature(world, world.objects.land),
graticule = d3_geo.geoGraticule(),
graticule = d3.geoGraticule(),
outline = {type: "Sphere"};

switch (projectionName) {
Expand All @@ -27,8 +26,8 @@ switch (projectionName) {
case "modifiedStereographicMiller": outline = graticule.extent([[-40, -40], [80, 80]]).outline(); break;
}

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

context.fillStyle = "#fff";
Expand Down

0 comments on commit aa4f244

Please sign in to comment.