MCPcopy Create free account
hub / github.com/idank/explainshell / d3_geo_clip

Function d3_geo_clip

explainshell/web/static/js/d3.v3.js:2350–2438  ·  view source on GitHub ↗
(pointVisible, clipLine, interpolate)

Source from the content-addressed store, hash-verified

2348 b.prev = a;
2349 }
2350 function d3_geo_clip(pointVisible, clipLine, interpolate) {
2351 return function(listener) {
2352 var line = clipLine(listener);
2353 var clip = {
2354 point: point,
2355 lineStart: lineStart,
2356 lineEnd: lineEnd,
2357 polygonStart: function() {
2358 clip.point = pointRing;
2359 clip.lineStart = ringStart;
2360 clip.lineEnd = ringEnd;
2361 invisible = false;
2362 invisibleArea = visibleArea = 0;
2363 segments = [];
2364 listener.polygonStart();
2365 },
2366 polygonEnd: function() {
2367 clip.point = point;
2368 clip.lineStart = lineStart;
2369 clip.lineEnd = lineEnd;
2370 segments = d3.merge(segments);
2371 if (segments.length) {
2372 d3_geo_clipPolygon(segments, d3_geo_clipSort, null, interpolate, listener);
2373 } else if (visibleArea < -ε || invisible && invisibleArea < -ε) {
2374 listener.lineStart();
2375 interpolate(null, null, 1, listener);
2376 listener.lineEnd();
2377 }
2378 listener.polygonEnd();
2379 segments = null;
2380 },
2381 sphere: function() {
2382 listener.polygonStart();
2383 listener.lineStart();
2384 interpolate(null, null, 1, listener);
2385 listener.lineEnd();
2386 listener.polygonEnd();
2387 }
2388 };
2389 function point(λ, φ) {
2390 if (pointVisible(λ, φ)) listener.point(λ, φ);
2391 }
2392 function pointLine(λ, φ) {
2393 line.point(λ, φ);
2394 }
2395 function lineStart() {
2396 clip.point = pointLine;
2397 line.lineStart();
2398 }
2399 function lineEnd() {
2400 clip.point = point;
2401 line.lineEnd();
2402 }
2403 var segments, visibleArea, invisibleArea, invisible;
2404 var buffer = d3_geo_clipBufferListener(), ringListener = clipLine(buffer), ring;
2405 function pointRing(λ, φ) {
2406 ringListener.point(λ, φ);
2407 ring.push([ λ, φ ]);

Callers 2

d3.v3.jsFile · 0.85
d3_geo_clipCircleFunction · 0.85

Calls 4

clipLineFunction · 0.85
d3_geo_clipPolygonFunction · 0.85
interpolateFunction · 0.85

Tested by

no test coverage detected