@param WKBBuffer        $buffer
@param CoordinateSystem $cs

@return Triangle
330490
private function readTriangle(WKBBuffer $buffer, CoordinateSystem $cs) : Triangle
    {
        $numRings = $buffer->readUnsignedLong();

        $rings = [];

        for ($i = 0; $i < $numRings; $i++) {
            $rings[] = $this->readLineString($buffer, $cs);
        }

        return new Triangle($cs, ...$rings);
    }
755213
private function readMultiLineStringText(WKTParser $parser, CoordinateSystem $cs) : MultiLineString
    {
        $lineStrings = $this->readMultiLineString($parser, $cs);

        return new MultiLineString($cs, ...$lineStrings);
    }
208466
public static DZcsd cs_scc(DZcs A)
	{
		int n, i, k, b, nb = 0, top, xi[], pstack[], p[], r[], Ap[], ATp[], rcopy[], Blk[] ;
		DZcs AT ;
		DZcsd D ;
		if (!CS_CSC (A)) return (null) ; 		/* check inputs */
		n = A.n ; Ap = A.p ;
		D = cs_dalloc (n, 0) ;				/* allocate result */
		AT = cs_transpose (A, false) ;			/* AT = A' */
		xi = new int [2*n+1] ;				/* get workspace */
		if (D == null || AT == null || xi == null)
			return (cs_ddone (D, AT, xi, false)) ;
		Blk = xi ; rcopy = xi ;
		int rcopy_offset = n ;
		pstack = xi ;
		int pstack_offset = n ;
		p = D.p ; r = D.r ; ATp = AT.p ;
		top = n ;
		for (i = 0 ; i < n ; i++)			/* first dfs(A) to find finish times (xi) */
		{
			if (!CS_MARKED (Ap, i))
			top = cs_dfs (i, A, top, xi, 0, pstack, pstack_offset, null, 0) ;
		}
		for (i = 0 ; i < n ; i++) CS_MARK (Ap, i) ;	/* restore A; unmark all nodes*/
		top = n ; nb = n ;
		for (k = 0 ; k < n ; k++)			/* dfs(A') to find strongly connnected comp */
		{
			i = xi [k] ;				/* get i in reverse order of finish times */
			if (CS_MARKED (ATp, i)) continue ;	/* skip node i if already ordered */
			r [nb--] = top ;			/* node i is the start of a component in p */
			top = cs_dfs (i, AT, top, p, 0, pstack, pstack_offset, null, 0) ;
		}
		r [nb] = 0 ;					/* first block starts at zero; shift r up */
		for (k = nb ; k <= n ; k++) r [k-nb] = r [k] ;
		D.nb = nb = n - nb ;				/* nb = # of strongly connected components */
		for (b = 0 ; b < nb ; b++)			/* sort each block in natural order */
		{
			for (k = r [b] ; k < r [b+1] ; k++) Blk [p [k]] = b ;
		}
		for (b = 0 ; b <= nb ; b++) rcopy [rcopy_offset + b] = r [b] ;
		for (i = 0 ; i < n ; i++) p [rcopy [rcopy_offset + Blk [i]]++] = i ;
		return (D) ;
	}
571382
private void bfs(int v, int[] cc, int id) {
        cc[v] = id;
        Queue<Integer> queue = new LinkedList<>();
        queue.offer(v);
        while (!queue.isEmpty()) {
            int t = queue.poll();
            for (Edge edge : graph[t]) {
                int i = edge.v2;
                if (!digraph && i == t) {
                    i = edge.v1;
                }

                if (cc[i] == -1) {
                    queue.offer(i);
                    cc[i] = id;
                }
            }
        }
    }
70509
private function readMultiPolygon(WKBBuffer $buffer, CoordinateSystem $cs) : MultiPolygon
    {
        $numPolygons = $buffer->readUnsignedLong();
        $polygons = [];

        for ($i = 0; $i < $numPolygons; $i++) {
            $polygons[] = $this->readGeometry($buffer, $cs->SRID());
        }

        return new MultiPolygon($cs, ...$polygons);
    }
13190
def triangle_unaddress(fx, tr):
    '''
    
    '''
    fx = np.asarray(fx)
    tr = np.asarray(tr)
    # the triangle vectors...
    ab = fx[1] - fx[0]
    ac = fx[2] - fx[0]
    bc = fx[2] - fx[1]
    return np.asarray([ax + tr[1]*(abx + tr[0]*bcx) for (ax, bcx, abx) in zip(fx[0], bc, ab)])
287371
private function readGeometryCollectionText(WKTParser $parser, CoordinateSystem $cs) : GeometryCollection
    {
        $parser->matchOpener();
        $geometries = [];

        do {
            $geometries[] = $this->readGeometry($parser, $cs->SRID());
            $nextToken = $parser->getNextCloserOrComma();
        } while ($nextToken === ',');

        return new GeometryCollection($cs, ...$geometries);
    }
990135
function ImageBufferRendererWebgl(imageCanvas) {

	//////////////////////////////////////////////////////////////
	// ImageBufferRendererWebgl private constants

	// vertices representing entire viewport as two triangles which make up the whole
	// rectangle, in post-projection/clipspace coordinates
	var VIEWPORT_VERTICES = new Float32Array([
			-1.0, -1.0,
			1.0, -1.0,
			-1.0, 1.0,
			-1.0, 1.0,
			1.0, -1.0,
			1.0, 1.0]);
	var NUM_VIEWPORT_VERTICES = VIEWPORT_VERTICES.length / 2;

	// Texture coordinates corresponding to each viewport vertex
	var VERTEX_TEXTURE_COORDS = new Float32Array([
			0.0, 1.0,
			1.0, 1.0,
			0.0, 0.0,
			0.0, 0.0,
			1.0, 1.0,
			1.0, 0.0]);

	//////////////////////////////////////////////////////////////
	// ImageBufferRendererWebgl private properties
	var metadata = this;
	var contextAttributes = { premultipliedAlpha: true, depth: false };
	var glContext = imageCanvas.getContext('webgl', contextAttributes) || imageCanvas.getContext('experimental-webgl', contextAttributes);
	glContext.clearColor(0.0, 0.0, 0.0, 0.0);      // Set clear color to black, fully transparent

	var vertexShader = createShaderFromSource(glContext.VERTEX_SHADER,
			"\
			attribute vec2 aPosition;\
			attribute vec2 aTextureCoord;\
			\
			varying highp vec2 vTextureCoord;\
			\
			void main() {\
					gl_Position = vec4(aPosition, 0, 1);\
					vTextureCoord = aTextureCoord;\
			}");
	var fragmentShader = createShaderFromSource(glContext.FRAGMENT_SHADER,
			"\
			precision mediump float;\
			\
			varying highp vec2 vTextureCoord;\
			\
			uniform sampler2D uSampler;\
			\
			void main() {\
					gl_FragColor = texture2D(uSampler, vTextureCoord);\
			}");
	var program = createProgram([vertexShader, fragmentShader]);
	glContext.useProgram(program);

	var positionAttribute = glContext.getAttribLocation(program, "aPosition");
	glContext.enableVertexAttribArray(positionAttribute);

	var textureCoordAttribute = glContext.getAttribLocation(program, "aTextureCoord");
	glContext.enableVertexAttribArray(textureCoordAttribute);

	// Associate the uniform texture sampler with TEXTURE0 slot
	var textureSamplerUniform = glContext.getUniformLocation(program, "uSampler");
	glContext.uniform1i(textureSamplerUniform, 0);

	// Create a buffer used to represent whole set of viewport vertices
	var vertexBuffer = glContext.createBuffer();
	glContext.bindBuffer(glContext.ARRAY_BUFFER, vertexBuffer);
	glContext.bufferData(glContext.ARRAY_BUFFER, VIEWPORT_VERTICES, glContext.STATIC_DRAW);
	glContext.vertexAttribPointer(positionAttribute, 2, glContext.FLOAT, false, 0, 0);

	// Create a buffer used to represent whole set of vertex texture coordinates
	var textureCoordinateBuffer = glContext.createBuffer();
	glContext.bindBuffer(glContext.ARRAY_BUFFER, textureCoordinateBuffer);
	glContext.bufferData(glContext.ARRAY_BUFFER, VERTEX_TEXTURE_COORDS, glContext.STATIC_DRAW);
	glContext.vertexAttribPointer(textureCoordAttribute, 2, glContext.FLOAT, false, 0, 0);

	// Create a texture to contain images from Kinect server
	// Note: TEXTURE_MIN_FILTER, TEXTURE_WRAP_S and TEXTURE_WRAP_T parameters need to be set
	//       so we can handle textures whose width and height are not a power of 2.
	var texture = glContext.createTexture();
	glContext.bindTexture(glContext.TEXTURE_2D, texture);
	glContext.texParameteri(glContext.TEXTURE_2D, glContext.TEXTURE_MAG_FILTER, glContext.LINEAR);
	glContext.texParameteri(glContext.TEXTURE_2D, glContext.TEXTURE_MIN_FILTER, glContext.LINEAR);
	glContext.texParameteri(glContext.TEXTURE_2D, glContext.TEXTURE_WRAP_S, glContext.CLAMP_TO_EDGE);
	glContext.texParameteri(glContext.TEXTURE_2D, glContext.TEXTURE_WRAP_T, glContext.CLAMP_TO_EDGE);
	glContext.bindTexture(glContext.TEXTURE_2D, null);

	// Since we're only using one single texture, we just make TEXTURE0 the active one
	// at all times
	glContext.activeTexture(glContext.TEXTURE0);

	//////////////////////////////////////////////////////////////
	// ImageBufferRendererWebgl private methods

	// Create a shader of specified type, with the specified source, and compile it.
	//     .createShaderFromSource(shaderType, shaderSource)
	//
	// shaderType: Type of shader to create (fragment or vertex shader)
	// shaderSource: Source for shader to create (string)
	function createShaderFromSource(shaderType, shaderSource) {
			var shader = glContext.createShader(shaderType);
			glContext.shaderSource(shader, shaderSource);
			glContext.compileShader(shader);

			// Check for errors during compilation
			var status = glContext.getShaderParameter(shader, glContext.COMPILE_STATUS);
			if (!status) {
					var infoLog = glContext.getShaderInfoLog(shader);
					console.log("Unable to compile Kinect '" + shaderType + "' shader. Error:" + infoLog);
					glContext.deleteShader(shader);
					return null;
			}

			return shader;
	}

	// Create a WebGL program attached to the specified shaders.
	//     .createProgram(shaderArray)
	//
	// shaderArray: Array of shaders to attach to program
	function createProgram(shaderArray) {
			var newProgram = glContext.createProgram();

			for (var shaderIndex = 0; shaderIndex < shaderArray.length; ++shaderIndex) {
					glContext.attachShader(newProgram, shaderArray[shaderIndex]);
			}
			glContext.linkProgram(newProgram);

			// Check for errors during linking
			var status = glContext.getProgramParameter(newProgram, glContext.LINK_STATUS);
			if (!status) {
					var infoLog = glContext.getProgramInfoLog(newProgram);
					console.log("Unable to link Kinect WebGL program. Error:" + infoLog);
					glContext.deleteProgram(newProgram);
					return null;
			}

			return newProgram;
	}

	//////////////////////////////////////////////////////////////
	// ImageBufferRendererWebgl public properties
	this.isProcessing = false;
	this.canvas = imageCanvas;
	this.width = 0;
	this.height = 0;
	this.gl = glContext;

	//////////////////////////////////////////////////////////////
	// ImageBufferRendererWebgl public functions

	// Draw image data into WebGL canvas context
	//     .processImageData(imageBuffer, width, height)
	//
	// imageBuffer: ArrayBuffer containing image data
	// width: width of image corresponding to imageBuffer data
	// height: height of image corresponding to imageBuffer data
	this.processImageData = function(imageBuffer, width, height) {
			if ((width != metadata.width) || (height != metadata.height)) {
					// Whenever the image width or height changes, update tracked metadata and canvas
					// viewport dimensions.
					this.width = width;
					this.height = height;
					this.canvas.width = width;
					this.canvas.height = height;
					glContext.viewport(0, 0, width, height);
			}
			//Associate the specified image data with a WebGL texture so that shaders can use it
			glContext.bindTexture(glContext.TEXTURE_2D, texture);
			glContext.texImage2D(glContext.TEXTURE_2D, 0, glContext.RGBA, width, height, 0, glContext.RGBA, glContext.UNSIGNED_BYTE, new Uint8Array(imageBuffer));

			//Draw vertices so that shaders get invoked and we can render the texture
			glContext.drawArrays(glContext.TRIANGLES, 0, NUM_VIEWPORT_VERTICES);
			glContext.bindTexture(glContext.TEXTURE_2D, null);
	};

	// Clear all image data from WebGL canvas
	//     .clear()
	this.clear = function() {
			glContext.clear(glContext.COLOR_BUFFER_BIT);
	};
}
92788
public static LinkedBuffer use(byte[] buffer, int start)
    {
        assert start >= 0;
        if (buffer.length - start < MIN_BUFFER_SIZE)
            throw new IllegalArgumentException(MIN_BUFFER_SIZE + " is the minimum buffer size.");

        return new LinkedBuffer(buffer, start, start);
    }
1354936
private function readMultiPolygonText(WKTParser $parser, CoordinateSystem $cs) : MultiPolygon
    {
        $parser->matchOpener();
        $polygons = [];

        do {
            $polygons[] = $this->readPolygonText($parser, $cs);
            $nextToken = $parser->getNextCloserOrComma();
        } while ($nextToken === ',');

        return new MultiPolygon($cs, ...$polygons);
    }
1076649
public static Geometry ringBuffer(Geometry geom, double bufferSize, int numBuffer) throws SQLException {
        return ringBuffer(geom, bufferSize, numBuffer, "endcap=round");
    }
95660
static Object wrapVec3(float x, float y, float z) {
        ByteBuffer temp = ByteBuffer.allocate(3 * 4);
        temp.putFloat(x);
        temp.putFloat(y);
        temp.putFloat(z);
        temp.flip();
        return s_wrapperProvider.wrapVector3f(temp, 0, 3);
    }
351440
function (buffer) {
         JSZip.utils.checkSupport("blob");

         try {
            // Blob constructor
            return new Blob([buffer], { type: "application/zip" });
         }
         catch(e) {}

         try {
            // deprecated, browser only, old way
            var builder = new (window.BlobBuilder || window.WebKitBlobBuilder ||
                               window.MozBlobBuilder || window.MSBlobBuilder)();
            builder.append(buffer);
            return builder.getBlob('application/zip');
         }
         catch(e) {}

         // well, fuck ?!
         throw new Error("Bug : can't construct the Blob.");
      }
1064777
private function readMultiPoint(WKTParser $parser, CoordinateSystem $cs) : array
    {
        $parser->matchOpener();
        $points = [];

        do {
            $points[] = $this->readPoint($parser, $cs);
            $nextToken = $parser->getNextCloserOrComma();
        } while ($nextToken === ',');

        return $points;
    }
610939
private function readMultiPointText(WKTParser $parser, CoordinateSystem $cs) : MultiPoint
    {
        $points = $this->readMultiPoint($parser, $cs);

        return new MultiPoint($cs, ...$points);
    }
959071
public static Dcs cs_transpose(Dcs A, boolean values) {
        int p, q, j, Cp[], Ci[], n, m, Ap[], Ai[], w[];
        double Cx[], Ax[];
        Dcs C;
        if (!Dcs_util.CS_CSC(A))
            return (null); /* check inputs */
        m = A.m;
        n = A.n;
        Ap = A.p;
        Ai = A.i;
        Ax = A.x;
        C = Dcs_util.cs_spalloc(n, m, Ap[n], values && (Ax != null), false); /* allocate result */
        w = new int[m]; /* get workspace */
        Cp = C.p;
        Ci = C.i;
        Cx = C.x;
        for (p = 0; p < Ap[n]; p++)
            w[Ai[p]]++; /* row counts */
        Dcs_cumsum.cs_cumsum(Cp, w, m); /* row pointers */
        for (j = 0; j < n; j++) {
            for (p = Ap[j]; p < Ap[j + 1]; p++) {
                Ci[q = w[Ai[p]]++] = j; /* place A(i,j) as entry C(j,i) */
                if (Cx != null)
                    Cx[q] = Ax[p];
            }
        }
        return C;
    }
342096
private function readPointText(WKTParser $parser, CoordinateSystem $cs) : Point
    {
        $parser->matchOpener();
        $point = $this->readPoint($parser, $cs);
        $parser->matchCloser();

        return $point;
    }