MCPcopy Create free account
hub / github.com/microsoft/SandDance / graticule

Function graticule

docs/app/js/sanddance-app.js:133269–133386  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

133267 };
133268}
133269function graticule() {
133270 var x1, x0, X1, X0, y1, y0, Y1, Y0, dx = 10, dy = dx, DX = 90, DY = 360, x3, y3, X, Y, precision = 2.5;
133271 function graticule1() {
133272 return {
133273 type: "MultiLineString",
133274 coordinates: lines()
133275 };
133276 }
133277 function lines() {
133278 return (0, _d3Array.range)((0, _mathJs.ceil)(X0 / DX) * DX, X1, DX).map(X).concat((0, _d3Array.range)((0, _mathJs.ceil)(Y0 / DY) * DY, Y1, DY).map(Y)).concat((0, _d3Array.range)((0, _mathJs.ceil)(x0 / dx) * dx, x1, dx).filter(function(x) {
133279 return (0, _mathJs.abs)(x % DX) > (0, _mathJs.epsilon);
133280 }).map(x3)).concat((0, _d3Array.range)((0, _mathJs.ceil)(y0 / dy) * dy, y1, dy).filter(function(y) {
133281 return (0, _mathJs.abs)(y % DY) > (0, _mathJs.epsilon);
133282 }).map(y3));
133283 }
133284 graticule1.lines = function() {
133285 return lines().map(function(coordinates) {
133286 return {
133287 type: "LineString",
133288 coordinates: coordinates
133289 };
133290 });
133291 };
133292 graticule1.outline = function() {
133293 return {
133294 type: "Polygon",
133295 coordinates: [
133296 X(X0).concat(Y(Y1).slice(1), X(X1).reverse().slice(1), Y(Y0).reverse().slice(1))
133297 ]
133298 };
133299 };
133300 graticule1.extent = function(_) {
133301 if (!arguments.length) return graticule1.extentMinor();
133302 return graticule1.extentMajor(_).extentMinor(_);
133303 };
133304 graticule1.extentMajor = function(_) {
133305 if (!arguments.length) return [
133306 [
133307 X0,
133308 Y0
133309 ],
133310 [
133311 X1,
133312 Y1
133313 ]
133314 ];
133315 X0 = +_[0][0], X1 = +_[1][0];
133316 Y0 = +_[0][1], Y1 = +_[1][1];
133317 if (X0 > X1) _ = X0, X0 = X1, X1 = _;
133318 if (Y0 > Y1) _ = Y0, Y0 = Y1, Y1 = _;
133319 return graticule1.precision(precision);
133320 };
133321 graticule1.extentMinor = function(_) {
133322 if (!arguments.length) return [
133323 [
133324 x0,
133325 y0
133326 ],

Callers 1

graticule10Function · 0.70

Calls 3

linesFunction · 0.70
graticuleXFunction · 0.70
graticuleYFunction · 0.70

Tested by

no test coverage detected