source: node_modules/d3-geo/src/projection/naturalEarth1.js@ a762898

Last change on this file since a762898 was e4c61dd, checked in by istevanoska <ilinastevanoska@…>, 6 months ago

Prototype 1.1

  • Property mode set to 100644
File size: 1.0 KB
Line 
1import projection from "./index.js";
2import {abs, epsilon} from "../math.js";
3
4export function naturalEarth1Raw(lambda, phi) {
5 var phi2 = phi * phi, phi4 = phi2 * phi2;
6 return [
7 lambda * (0.8707 - 0.131979 * phi2 + phi4 * (-0.013791 + phi4 * (0.003971 * phi2 - 0.001529 * phi4))),
8 phi * (1.007226 + phi2 * (0.015085 + phi4 * (-0.044475 + 0.028874 * phi2 - 0.005916 * phi4)))
9 ];
10}
11
12naturalEarth1Raw.invert = function(x, y) {
13 var phi = y, i = 25, delta;
14 do {
15 var phi2 = phi * phi, phi4 = phi2 * phi2;
16 phi -= delta = (phi * (1.007226 + phi2 * (0.015085 + phi4 * (-0.044475 + 0.028874 * phi2 - 0.005916 * phi4))) - y) /
17 (1.007226 + phi2 * (0.015085 * 3 + phi4 * (-0.044475 * 7 + 0.028874 * 9 * phi2 - 0.005916 * 11 * phi4)));
18 } while (abs(delta) > epsilon && --i > 0);
19 return [
20 x / (0.8707 + (phi2 = phi * phi) * (-0.131979 + phi2 * (-0.013791 + phi2 * phi2 * phi2 * (0.003971 - 0.001529 * phi2)))),
21 phi
22 ];
23};
24
25export default function() {
26 return projection(naturalEarth1Raw)
27 .scale(175.295);
28}
Note: See TracBrowser for help on using the repository browser.