MCPcopy Index your code
hub / github.com/microsoft/SandDance / mercatorProjection

Function mercatorProjection

docs/app/js/sanddance-app.js:134503–134561  ·  view source on GitHub ↗
(project)

Source from the content-addressed store, hash-verified

134501 return mercatorProjection(mercatorRaw).scale(961 / (0, _mathJs.tau));
134502};
134503function mercatorProjection(project) {
134504 var m = (0, _indexJsDefault.default)(project), center = m.center, scale = m.scale, translate = m.translate, clipExtent = m.clipExtent, x0 = null, y0, x1, y1; // clip extent
134505 m.scale = function(_) {
134506 return arguments.length ? (scale(_), reclip()) : scale();
134507 };
134508 m.translate = function(_) {
134509 return arguments.length ? (translate(_), reclip()) : translate();
134510 };
134511 m.center = function(_) {
134512 return arguments.length ? (center(_), reclip()) : center();
134513 };
134514 m.clipExtent = function(_) {
134515 return arguments.length ? (_ == null ? x0 = y0 = x1 = y1 = null : (x0 = +_[0][0], y0 = +_[0][1], x1 = +_[1][0], y1 = +_[1][1]), reclip()) : x0 == null ? null : [
134516 [
134517 x0,
134518 y0
134519 ],
134520 [
134521 x1,
134522 y1
134523 ]
134524 ];
134525 };
134526 function reclip() {
134527 var k = (0, _mathJs.pi) * scale(), t = m((0, _rotationJsDefault.default)(m.rotate()).invert([
134528 0,
134529 0
134530 ]));
134531 return clipExtent(x0 == null ? [
134532 [
134533 t[0] - k,
134534 t[1] - k
134535 ],
134536 [
134537 t[0] + k,
134538 t[1] + k
134539 ]
134540 ] : project === mercatorRaw ? [
134541 [
134542 Math.max(t[0] - k, x0),
134543 y0
134544 ],
134545 [
134546 Math.min(t[0] + k, x1),
134547 y1
134548 ]
134549 ] : [
134550 [
134551 x0,
134552 Math.max(t[1] - k, y0)
134553 ],
134554 [
134555 x1,
134556 Math.min(t[1] + k, y1)
134557 ]
134558 ]);
134559 }
134560 return reclip();

Callers 1

sanddance-app.jsFile · 0.70

Calls 4

scaleFunction · 0.70
reclipFunction · 0.70
translateFunction · 0.70
centerFunction · 0.70

Tested by

no test coverage detected