()
| 10771 | } |
| 10772 | |
| 10773 | function ringEnd() { |
| 10774 | pointRing(ring[0][0], ring[0][1]); |
| 10775 | ringSink.lineEnd(); |
| 10776 | |
| 10777 | var clean = ringSink.clean(), |
| 10778 | ringSegments = ringBuffer.result(), |
| 10779 | i, n = ringSegments.length, m, |
| 10780 | segment, |
| 10781 | point; |
| 10782 | |
| 10783 | ring.pop(); |
| 10784 | polygon.push(ring); |
| 10785 | ring = null; |
| 10786 | |
| 10787 | if (!n) return; |
| 10788 | |
| 10789 | // No intersections. |
| 10790 | if (clean & 1) { |
| 10791 | segment = ringSegments[0]; |
| 10792 | if ((m = segment.length - 1) > 0) { |
| 10793 | if (!polygonStarted) sink.polygonStart(), polygonStarted = true; |
| 10794 | sink.lineStart(); |
| 10795 | for (i = 0; i < m; ++i) sink.point((point = segment[i])[0], point[1]); |
| 10796 | sink.lineEnd(); |
| 10797 | } |
| 10798 | return; |
| 10799 | } |
| 10800 | |
| 10801 | // Rejoin connected segments. |
| 10802 | // TODO reuse ringBuffer.rejoin()? |
| 10803 | if (n > 1 && clean & 2) ringSegments.push(ringSegments.pop().concat(ringSegments.shift())); |
| 10804 | |
| 10805 | segments.push(ringSegments.filter(validSegment)); |
| 10806 | } |
| 10807 | |
| 10808 | return clip; |
| 10809 | }; |
nothing calls this directly
no test coverage detected