|
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:
957 bytes
|
| Line | |
|---|
| 1 | import {abs, asin, atan2, cos, epsilon, pi, sign, sin, sqrt} from "../math.js";
|
|---|
| 2 | import {conicProjection} from "./conic.js";
|
|---|
| 3 | import {cylindricalEqualAreaRaw} from "./cylindricalEqualArea.js";
|
|---|
| 4 |
|
|---|
| 5 | export function conicEqualAreaRaw(y0, y1) {
|
|---|
| 6 | var sy0 = sin(y0), n = (sy0 + sin(y1)) / 2;
|
|---|
| 7 |
|
|---|
| 8 | // Are the parallels symmetrical around the Equator?
|
|---|
| 9 | if (abs(n) < epsilon) return cylindricalEqualAreaRaw(y0);
|
|---|
| 10 |
|
|---|
| 11 | var c = 1 + sy0 * (2 * n - sy0), r0 = sqrt(c) / n;
|
|---|
| 12 |
|
|---|
| 13 | function project(x, y) {
|
|---|
| 14 | var r = sqrt(c - 2 * n * sin(y)) / n;
|
|---|
| 15 | return [r * sin(x *= n), r0 - r * cos(x)];
|
|---|
| 16 | }
|
|---|
| 17 |
|
|---|
| 18 | project.invert = function(x, y) {
|
|---|
| 19 | var r0y = r0 - y,
|
|---|
| 20 | l = atan2(x, abs(r0y)) * sign(r0y);
|
|---|
| 21 | if (r0y * n < 0)
|
|---|
| 22 | l -= pi * sign(x) * sign(r0y);
|
|---|
| 23 | return [l / n, asin((c - (x * x + r0y * r0y) * n * n) / (2 * n))];
|
|---|
| 24 | };
|
|---|
| 25 |
|
|---|
| 26 | return project;
|
|---|
| 27 | }
|
|---|
| 28 |
|
|---|
| 29 | export default function() {
|
|---|
| 30 | return conicProjection(conicEqualAreaRaw)
|
|---|
| 31 | .scale(155.424)
|
|---|
| 32 | .center([0, 33.6442]);
|
|---|
| 33 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.