docs/examples-0.7.x/libs/leaflet-src.js
function (a, b, bounds, useLastCode) {
		var codeA = useLastCode ? this._lastCode : this._getBitCode(a, bounds),
		    codeB = this._getBitCode(b, bounds),

		    codeOut, p, newCode;

		// save 2nd code to avoid calculating it on the next segment
		this._lastCode = codeB;

		while (true) {
			// if a,b is inside the clip window (trivial accept)
			if (!(codeA | codeB)) {
				return [a, b];
			// if a,b is outside the clip window (trivial reject)
			} else if (codeA & codeB) {
				return false;
			// other cases
			} else {
				codeOut = codeA || codeB;
				p = this._getEdgeIntersection(a, b, codeOut, bounds);
				newCode = this._getBitCode(p, bounds);

				if (codeOut === codeA) {
					a = p;
					codeA = newCode;
				} else {
					b = p;
					codeB = newCode;
				}
			}
		}
	}
function (a, b, bounds, useLastCode) {
		var codeA = useLastCode ? this._lastCode : this._getBitCode(a, bounds),
		    codeB = this._getBitCode(b, bounds),

		    codeOut, p, newCode;

		// save 2nd code to avoid calculating it on the next segment
		this._lastCode = codeB;

		while (true) {
			// if a,b is inside the clip window (trivial accept)
			if (!(codeA | codeB)) {
				return [a, b];
			// if a,b is outside the clip window (trivial reject)
			} else if (codeA & codeB) {
				return false;
			// other cases
			} else {
				codeOut = codeA || codeB;
				p = this._getEdgeIntersection(a, b, codeOut, bounds);
				newCode = this._getBitCode(p, bounds);

				if (codeOut === codeA) {
					a = p;
					codeA = newCode;
				} else {
					b = p;
					codeB = newCode;
				}
			}
		}
	}
function ( a , b , bounds , useLastCode ) { var codeA = useLastCode ? this . _lastCode : this . _getBitCode ( a , bounds ) , codeB = this . _getBitCode ( b , bounds ) , codeOut , p , newCode ; // save 2nd code to avoid calculating it on the next segment this . _lastCode = codeB ; while ( true ) { // if a,b is inside the clip window (trivial accept) if ( ! ( codeA | codeB ) ) { return [ a , b ] ; // if a,b is outside the clip window (trivial reject) } else if ( codeA & codeB ) { return false ; // other cases } else { codeOut = codeA || codeB ; p = this . _getEdgeIntersection ( a , b , codeOut , bounds ) ; newCode = this . _getBitCode ( p , bounds ) ; if ( codeOut === codeA ) { a = p ; codeA = newCode ; } else { b = p ; codeB = newCode ; } } } }
Cohen-Sutherland line clipping algorithm. Used to avoid rendering parts of a polyline that are not currently visible.
Cohen - Sutherland line clipping algorithm . Used to avoid rendering parts of a polyline that are not currently visible .