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

Function extractArcs

docs/tests/v2/es6/js/sanddance.js:80563–80616  ·  view source on GitHub ↗
(topology, object, filter)

Source from the content-addressed store, hash-verified

80561}
80562
80563function extractArcs(topology, object, filter) {
80564 var arcs = [],
80565 geomsByArc = [],
80566 geom;
80567
80568 function extract0(i) {
80569 var j = i < 0 ? ~i : i;
80570 (geomsByArc[j] || (geomsByArc[j] = [])).push({
80571 i: i,
80572 g: geom
80573 });
80574 }
80575
80576 function extract1(arcs) {
80577 arcs.forEach(extract0);
80578 }
80579
80580 function extract2(arcs) {
80581 arcs.forEach(extract1);
80582 }
80583
80584 function extract3(arcs) {
80585 arcs.forEach(extract2);
80586 }
80587
80588 function geometry(o) {
80589 switch (geom = o, o.type) {
80590 case "GeometryCollection":
80591 o.geometries.forEach(geometry);
80592 break;
80593
80594 case "LineString":
80595 extract1(o.arcs);
80596 break;
80597
80598 case "MultiLineString":
80599 case "Polygon":
80600 extract2(o.arcs);
80601 break;
80602
80603 case "MultiPolygon":
80604 extract3(o.arcs);
80605 break;
80606 }
80607 }
80608
80609 geometry(object);
80610 geomsByArc.forEach(filter == null ? function (geoms) {
80611 arcs.push(geoms[0].i);
80612 } : function (geoms) {
80613 if (filter(geoms[0].g, geoms[geoms.length - 1].g)) arcs.push(geoms[0].i);
80614 });
80615 return arcs;
80616}
80617},{"./feature.js":"FNho","./stitch.js":"ycfC"}],"vI6u":[function(require,module,exports) {
80618"use strict";
80619

Callers 1

meshArcsFunction · 0.70

Calls 3

geometryFunction · 0.70
filterFunction · 0.70
forEachMethod · 0.45

Tested by

no test coverage detected