Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Map in a cube #86

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export {default as geoPolyconic, polyconicRaw as geoPolyconicRaw} from "./src/po
export {default as geoPolyhedral} from "./src/polyhedral/index.js";
export {default as geoPolyhedralButterfly} from "./src/polyhedral/butterfly.js";
export {default as geoPolyhedralCollignon} from "./src/polyhedral/collignon.js";
export {default as geoPolyhedralReichard} from "./src/polyhedral/reichard.js";
export {default as geoPolyhedralWaterman} from "./src/polyhedral/waterman.js";
export {default as geoProject} from "./src/project/index";
export {default as geoGringortenQuincuncial} from "./src/quincuncial/gringorten.js";
Expand Down
33 changes: 33 additions & 0 deletions src/polyhedral/reichard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import {geoCentroid as centroid, geoGnomonic as gnomonic} from "d3-geo";
import {pi, atan, sqrt1_2, degrees} from "../math";
import polyhedral from "./index";
import cube from "./cube";

var phi1 = atan(sqrt1_2);

export default function (faceProjection) {
faceProjection = faceProjection || function (face) {
var c = centroid({type: 'MultiPoint', coordinates: face});
return gnomonic().scale(1).translate([0, 0]).rotate([-c[0], -c[1]]);
};

var faces = cube.map(function (face) {
return {face: face, project: faceProjection(face)};
});

[-1, 4, 5, 2, 0, 1].forEach(function (d, i) {
var node = faces[d];
node && (node.children || (node.children = [])).push(faces[i]);
});

return polyhedral(faces[0], function (lambda, phi) {
return faces[
phi >= phi1 ? 0 : phi <= -phi1 ? 5 :
lambda <= -pi / 2 ? 3 :
lambda <= 0 ? 4 :
lambda <= pi / 2 ? 1 : 2
];
})
.scale(63.4368)
.center([45, -45]);
}
1 change: 1 addition & 0 deletions test/render-world
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ switch (projectionName) {
case "modifiedStereographicGs50":
case "modifiedStereographicMiller":
case "polyhedralButterfly":
case "polyhedralReichard":
case "polyhedralWaterman":
case "polyhedralCollignon": {
context.beginPath();
Expand Down