You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

35 lines
844 B

  1. import {geoProjectionMutator as projectionMutator} from "d3-geo";
  2. import {atan2, cos, halfPi, sin, sqrt} from "./math.js";
  3. export function bottomleyRaw(sinPsi) {
  4. function forward(lambda, phi) {
  5. var rho = halfPi - phi,
  6. eta = rho ? lambda * sinPsi * sin(rho) / rho : rho;
  7. return [rho * sin(eta) / sinPsi, halfPi - rho * cos(eta)];
  8. }
  9. forward.invert = function(x, y) {
  10. var x1 = x * sinPsi,
  11. y1 = halfPi - y,
  12. rho = sqrt(x1 * x1 + y1 * y1),
  13. eta = atan2(x1, y1);
  14. return [(rho ? rho / sin(rho) : 1) * eta / sinPsi, halfPi - rho];
  15. };
  16. return forward;
  17. }
  18. export default function() {
  19. var sinPsi = 0.5,
  20. m = projectionMutator(bottomleyRaw),
  21. p = m(sinPsi);
  22. p.fraction = function(_) {
  23. return arguments.length ? m(sinPsi = +_) : sinPsi;
  24. };
  25. return p
  26. .scale(158.837);
  27. }