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.
 
 
 

27 regels
900 B

  1. import {geoProjection as projection} from "d3-geo";
  2. import {mollweideBromleyTheta} from "./mollweide.js";
  3. import {abs, cos, epsilon, pi, quarterPi, sin, sqrt2} from "./math.js";
  4. var k = 2.00276,
  5. w = 1.11072;
  6. export function boggsRaw(lambda, phi) {
  7. var theta = mollweideBromleyTheta(pi, phi);
  8. return [k * lambda / (1 / cos(phi) + w / cos(theta)), (phi + sqrt2 * sin(theta)) / k];
  9. }
  10. boggsRaw.invert = function(x, y) {
  11. var ky = k * y, theta = y < 0 ? -quarterPi : quarterPi, i = 25, delta, phi;
  12. do {
  13. phi = ky - sqrt2 * sin(theta);
  14. theta -= delta = (sin(2 * theta) + 2 * theta - pi * sin(phi)) / (2 * cos(2 * theta) + 2 + pi * cos(phi) * sqrt2 * cos(theta));
  15. } while (abs(delta) > epsilon && --i > 0);
  16. phi = ky - sqrt2 * sin(theta);
  17. return [x * (1 / cos(phi) + w / cos(theta)) / k, phi];
  18. };
  19. export default function() {
  20. return projection(boggsRaw)
  21. .scale(160.857);
  22. }