repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
brick/geo
src/CurvePolygon.php
CurvePolygon.interiorRingN
public function interiorRingN(int $n) : Curve { if ($n === 0 || ! isset($this->rings[$n])) { throw new NoSuchGeometryException('There is no interior ring in this CurvePolygon at index ' . $n); } return $this->rings[$n]; }
php
public function interiorRingN(int $n) : Curve { if ($n === 0 || ! isset($this->rings[$n])) { throw new NoSuchGeometryException('There is no interior ring in this CurvePolygon at index ' . $n); } return $this->rings[$n]; }
[ "public", "function", "interiorRingN", "(", "int", "$", "n", ")", ":", "Curve", "{", "if", "(", "$", "n", "===", "0", "||", "!", "isset", "(", "$", "this", "->", "rings", "[", "$", "n", "]", ")", ")", "{", "throw", "new", "NoSuchGeometryException",...
Returns the specified interior ring N in this CurvePolygon. @param int $n The ring number, 1-based. @return Curve @throws NoSuchGeometryException If there is no interior ring at this index.
[ "Returns", "the", "specified", "interior", "ring", "N", "in", "this", "CurvePolygon", "." ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/CurvePolygon.php#L108-L115
brick/geo
src/CurvePolygon.php
CurvePolygon.toArray
public function toArray() : array { $result = []; foreach ($this->rings as $ring) { $result[] = $ring->toArray(); } return $result; }
php
public function toArray() : array { $result = []; foreach ($this->rings as $ring) { $result[] = $ring->toArray(); } return $result; }
[ "public", "function", "toArray", "(", ")", ":", "array", "{", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "rings", "as", "$", "ring", ")", "{", "$", "result", "[", "]", "=", "$", "ring", "->", "toArray", "(", ")", ";",...
{@inheritdoc}
[ "{" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/CurvePolygon.php#L150-L159
brick/geo
src/IO/AbstractWKBWriter.php
AbstractWKBWriter.setByteOrder
public function setByteOrder(int $byteOrder) : void { WKBTools::checkByteOrder($byteOrder); $this->byteOrder = $byteOrder; }
php
public function setByteOrder(int $byteOrder) : void { WKBTools::checkByteOrder($byteOrder); $this->byteOrder = $byteOrder; }
[ "public", "function", "setByteOrder", "(", "int", "$", "byteOrder", ")", ":", "void", "{", "WKBTools", "::", "checkByteOrder", "(", "$", "byteOrder", ")", ";", "$", "this", "->", "byteOrder", "=", "$", "byteOrder", ";", "}" ]
@param int $byteOrder The byte order, one of the WKBTools::BIG_ENDIAN or WKBTools::LITTLE_ENDIAN constants. @return void @throws \InvalidArgumentException If the byte order is invalid.
[ "@param", "int", "$byteOrder", "The", "byte", "order", "one", "of", "the", "WKBTools", "::", "BIG_ENDIAN", "or", "WKBTools", "::", "LITTLE_ENDIAN", "constants", "." ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/AbstractWKBWriter.php#L51-L55
brick/geo
src/IO/AbstractWKBWriter.php
AbstractWKBWriter.doWrite
protected function doWrite(Geometry $geometry, bool $outer) : string { if ($geometry instanceof Point) { return $this->writePoint($geometry, $outer); } if ($geometry instanceof LineString) { return $this->writeCurve($geometry, $outer); } if ($geometry instanceof CircularString) { return $this->writeCurve($geometry, $outer); } if ($geometry instanceof Polygon) { return $this->writePolygon($geometry, $outer); } if ($geometry instanceof CompoundCurve) { return $this->writeComposedGeometry($geometry, $outer); } if ($geometry instanceof CurvePolygon) { return $this->writeComposedGeometry($geometry, $outer); } if ($geometry instanceof GeometryCollection) { return $this->writeComposedGeometry($geometry, $outer); } if ($geometry instanceof PolyhedralSurface) { return $this->writeComposedGeometry($geometry, $outer); } throw GeometryIOException::unsupportedGeometryType($geometry->geometryType()); }
php
protected function doWrite(Geometry $geometry, bool $outer) : string { if ($geometry instanceof Point) { return $this->writePoint($geometry, $outer); } if ($geometry instanceof LineString) { return $this->writeCurve($geometry, $outer); } if ($geometry instanceof CircularString) { return $this->writeCurve($geometry, $outer); } if ($geometry instanceof Polygon) { return $this->writePolygon($geometry, $outer); } if ($geometry instanceof CompoundCurve) { return $this->writeComposedGeometry($geometry, $outer); } if ($geometry instanceof CurvePolygon) { return $this->writeComposedGeometry($geometry, $outer); } if ($geometry instanceof GeometryCollection) { return $this->writeComposedGeometry($geometry, $outer); } if ($geometry instanceof PolyhedralSurface) { return $this->writeComposedGeometry($geometry, $outer); } throw GeometryIOException::unsupportedGeometryType($geometry->geometryType()); }
[ "protected", "function", "doWrite", "(", "Geometry", "$", "geometry", ",", "bool", "$", "outer", ")", ":", "string", "{", "if", "(", "$", "geometry", "instanceof", "Point", ")", "{", "return", "$", "this", "->", "writePoint", "(", "$", "geometry", ",", ...
@param Geometry $geometry The geometry export as WKB write. @param bool $outer False if the geometry is nested in another geometry, true otherwise. @return string The WKB representation of the given geometry. @throws GeometryIOException If the given geometry cannot be exported as WKT.
[ "@param", "Geometry", "$geometry", "The", "geometry", "export", "as", "WKB", "write", ".", "@param", "bool", "$outer", "False", "if", "the", "geometry", "is", "nested", "in", "another", "geometry", "true", "otherwise", "." ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/AbstractWKBWriter.php#L77-L112
brick/geo
src/IO/AbstractWKBWriter.php
AbstractWKBWriter.packUnsignedInteger
protected function packUnsignedInteger(int $uint) : string { return pack($this->byteOrder === WKBTools::BIG_ENDIAN ? 'N' : 'V', $uint); }
php
protected function packUnsignedInteger(int $uint) : string { return pack($this->byteOrder === WKBTools::BIG_ENDIAN ? 'N' : 'V', $uint); }
[ "protected", "function", "packUnsignedInteger", "(", "int", "$", "uint", ")", ":", "string", "{", "return", "pack", "(", "$", "this", "->", "byteOrder", "===", "WKBTools", "::", "BIG_ENDIAN", "?", "'N'", ":", "'V'", ",", "$", "uint", ")", ";", "}" ]
@param int $uint @return string
[ "@param", "int", "$uint" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/AbstractWKBWriter.php#L127-L130
brick/geo
src/IO/AbstractWKBWriter.php
AbstractWKBWriter.packDouble
private function packDouble(float $double) : string { $binary = pack('d', $double); if ($this->byteOrder !== $this->machineByteOrder) { return strrev($binary); } return $binary; }
php
private function packDouble(float $double) : string { $binary = pack('d', $double); if ($this->byteOrder !== $this->machineByteOrder) { return strrev($binary); } return $binary; }
[ "private", "function", "packDouble", "(", "float", "$", "double", ")", ":", "string", "{", "$", "binary", "=", "pack", "(", "'d'", ",", "$", "double", ")", ";", "if", "(", "$", "this", "->", "byteOrder", "!==", "$", "this", "->", "machineByteOrder", ...
@param float $double @return string
[ "@param", "float", "$double" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/AbstractWKBWriter.php#L137-L146
brick/geo
src/IO/AbstractWKBWriter.php
AbstractWKBWriter.packPoint
private function packPoint(Point $point) : string { if ($point->isEmpty()) { throw new GeometryIOException('Empty points have no WKB representation.'); } $binary = $this->packDouble($point->x()) . $this->packDouble($point->y()); if (null !== $z = $point->z()) { $binary .= $this->packDouble($z); } if (null !== $m = $point->m()) { $binary .= $this->packDouble($m); } return $binary; }
php
private function packPoint(Point $point) : string { if ($point->isEmpty()) { throw new GeometryIOException('Empty points have no WKB representation.'); } $binary = $this->packDouble($point->x()) . $this->packDouble($point->y()); if (null !== $z = $point->z()) { $binary .= $this->packDouble($z); } if (null !== $m = $point->m()) { $binary .= $this->packDouble($m); } return $binary; }
[ "private", "function", "packPoint", "(", "Point", "$", "point", ")", ":", "string", "{", "if", "(", "$", "point", "->", "isEmpty", "(", ")", ")", "{", "throw", "new", "GeometryIOException", "(", "'Empty points have no WKB representation.'", ")", ";", "}", "$...
@param Point $point @return string @throws GeometryIOException
[ "@param", "Point", "$point" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/AbstractWKBWriter.php#L155-L171
brick/geo
src/IO/AbstractWKBWriter.php
AbstractWKBWriter.packCurve
private function packCurve(Curve $curve) : string { $wkb = $this->packUnsignedInteger($curve->count()); foreach ($curve as $point) { $wkb .= $this->packPoint($point); } return $wkb; }
php
private function packCurve(Curve $curve) : string { $wkb = $this->packUnsignedInteger($curve->count()); foreach ($curve as $point) { $wkb .= $this->packPoint($point); } return $wkb; }
[ "private", "function", "packCurve", "(", "Curve", "$", "curve", ")", ":", "string", "{", "$", "wkb", "=", "$", "this", "->", "packUnsignedInteger", "(", "$", "curve", "->", "count", "(", ")", ")", ";", "foreach", "(", "$", "curve", "as", "$", "point"...
@param Curve $curve @return string
[ "@param", "Curve", "$curve" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/AbstractWKBWriter.php#L178-L187
brick/geo
src/IO/AbstractWKBWriter.php
AbstractWKBWriter.writePoint
private function writePoint(Point $point, bool $outer) : string { $wkb = $this->packByteOrder(); $wkb.= $this->packHeader($point, $outer); $wkb.= $this->packPoint($point); return $wkb; }
php
private function writePoint(Point $point, bool $outer) : string { $wkb = $this->packByteOrder(); $wkb.= $this->packHeader($point, $outer); $wkb.= $this->packPoint($point); return $wkb; }
[ "private", "function", "writePoint", "(", "Point", "$", "point", ",", "bool", "$", "outer", ")", ":", "string", "{", "$", "wkb", "=", "$", "this", "->", "packByteOrder", "(", ")", ";", "$", "wkb", ".=", "$", "this", "->", "packHeader", "(", "$", "p...
@param Point $point @param bool $outer @return string
[ "@param", "Point", "$point", "@param", "bool", "$outer" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/AbstractWKBWriter.php#L195-L202
brick/geo
src/IO/AbstractWKBWriter.php
AbstractWKBWriter.writeCurve
private function writeCurve(Curve $curve, bool $outer) : string { $wkb = $this->packByteOrder(); $wkb.= $this->packHeader($curve, $outer); $wkb.= $this->packCurve($curve); return $wkb; }
php
private function writeCurve(Curve $curve, bool $outer) : string { $wkb = $this->packByteOrder(); $wkb.= $this->packHeader($curve, $outer); $wkb.= $this->packCurve($curve); return $wkb; }
[ "private", "function", "writeCurve", "(", "Curve", "$", "curve", ",", "bool", "$", "outer", ")", ":", "string", "{", "$", "wkb", "=", "$", "this", "->", "packByteOrder", "(", ")", ";", "$", "wkb", ".=", "$", "this", "->", "packHeader", "(", "$", "c...
@param Curve $curve @param bool $outer @return string
[ "@param", "Curve", "$curve", "@param", "bool", "$outer" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/AbstractWKBWriter.php#L210-L217
brick/geo
src/IO/AbstractWKBWriter.php
AbstractWKBWriter.writePolygon
private function writePolygon(Polygon $polygon, bool $outer) : string { $wkb = $this->packByteOrder(); $wkb.= $this->packHeader($polygon, $outer); $wkb.= $this->packUnsignedInteger($polygon->count()); foreach ($polygon as $ring) { $wkb .= $this->packCurve($ring); } return $wkb; }
php
private function writePolygon(Polygon $polygon, bool $outer) : string { $wkb = $this->packByteOrder(); $wkb.= $this->packHeader($polygon, $outer); $wkb.= $this->packUnsignedInteger($polygon->count()); foreach ($polygon as $ring) { $wkb .= $this->packCurve($ring); } return $wkb; }
[ "private", "function", "writePolygon", "(", "Polygon", "$", "polygon", ",", "bool", "$", "outer", ")", ":", "string", "{", "$", "wkb", "=", "$", "this", "->", "packByteOrder", "(", ")", ";", "$", "wkb", ".=", "$", "this", "->", "packHeader", "(", "$"...
@param Polygon $polygon @param bool $outer @return string
[ "@param", "Polygon", "$polygon", "@param", "bool", "$outer" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/AbstractWKBWriter.php#L225-L236
brick/geo
src/IO/AbstractWKBWriter.php
AbstractWKBWriter.writeComposedGeometry
private function writeComposedGeometry(Geometry $collection, bool $outer) : string { $wkb = $this->packByteOrder(); $wkb.= $this->packHeader($collection, $outer); $wkb.= $this->packUnsignedInteger($collection->count()); foreach ($collection as $geometry) { $wkb .= $this->doWrite($geometry, false); } return $wkb; }
php
private function writeComposedGeometry(Geometry $collection, bool $outer) : string { $wkb = $this->packByteOrder(); $wkb.= $this->packHeader($collection, $outer); $wkb.= $this->packUnsignedInteger($collection->count()); foreach ($collection as $geometry) { $wkb .= $this->doWrite($geometry, false); } return $wkb; }
[ "private", "function", "writeComposedGeometry", "(", "Geometry", "$", "collection", ",", "bool", "$", "outer", ")", ":", "string", "{", "$", "wkb", "=", "$", "this", "->", "packByteOrder", "(", ")", ";", "$", "wkb", ".=", "$", "this", "->", "packHeader",...
@param Geometry $collection @param bool $outer @return string
[ "@param", "Geometry", "$collection", "@param", "bool", "$outer" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/AbstractWKBWriter.php#L244-L255
brick/geo
src/Proxy/PolyhedralSurfaceProxy.php
PolyhedralSurfaceProxy.numPatches
public function numPatches() : int { if ($this->proxyGeometry === null) { $this->load(); } return $this->proxyGeometry->numPatches(); }
php
public function numPatches() : int { if ($this->proxyGeometry === null) { $this->load(); } return $this->proxyGeometry->numPatches(); }
[ "public", "function", "numPatches", "(", ")", ":", "int", "{", "if", "(", "$", "this", "->", "proxyGeometry", "===", "null", ")", "{", "$", "this", "->", "load", "(", ")", ";", "}", "return", "$", "this", "->", "proxyGeometry", "->", "numPatches", "(...
{@inheritdoc}
[ "{" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Proxy/PolyhedralSurfaceProxy.php#L157-L164
brick/geo
src/Proxy/PolyhedralSurfaceProxy.php
PolyhedralSurfaceProxy.patchN
public function patchN(int $n) : \Brick\Geo\Polygon { if ($this->proxyGeometry === null) { $this->load(); } return $this->proxyGeometry->patchN($n); }
php
public function patchN(int $n) : \Brick\Geo\Polygon { if ($this->proxyGeometry === null) { $this->load(); } return $this->proxyGeometry->patchN($n); }
[ "public", "function", "patchN", "(", "int", "$", "n", ")", ":", "\\", "Brick", "\\", "Geo", "\\", "Polygon", "{", "if", "(", "$", "this", "->", "proxyGeometry", "===", "null", ")", "{", "$", "this", "->", "load", "(", ")", ";", "}", "return", "$"...
{@inheritdoc}
[ "{" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Proxy/PolyhedralSurfaceProxy.php#L169-L176
brick/geo
src/CompoundCurve.php
CompoundCurve.of
public static function of(Curve $curve1, Curve ...$curveN) : CompoundCurve { return new CompoundCurve($curve1->coordinateSystem(), $curve1, ...$curveN); }
php
public static function of(Curve $curve1, Curve ...$curveN) : CompoundCurve { return new CompoundCurve($curve1->coordinateSystem(), $curve1, ...$curveN); }
[ "public", "static", "function", "of", "(", "Curve", "$", "curve1", ",", "Curve", "...", "$", "curveN", ")", ":", "CompoundCurve", "{", "return", "new", "CompoundCurve", "(", "$", "curve1", "->", "coordinateSystem", "(", ")", ",", "$", "curve1", ",", "......
Creates a non-empty CompoundCurve composed of the given curves. @param Curve $curve1 The first curve. @param Curve ...$curveN The subsequent curves, if any. @return CompoundCurve @throws EmptyGeometryException If any of the input curves is empty. @throws InvalidGeometryException If the compound curve is not continuous. @throws CoordinateSystemException If the curves use different coordinate systems.
[ "Creates", "a", "non", "-", "empty", "CompoundCurve", "composed", "of", "the", "given", "curves", "." ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/CompoundCurve.php#L79-L82
brick/geo
src/CompoundCurve.php
CompoundCurve.endPoint
public function endPoint() : Point { if ($this->isEmpty) { throw new EmptyGeometryException('The CompoundCurve is empty and has no end point.'); } $count = count($this->curves); return $this->curves[$count - 1]->endPoint(); }
php
public function endPoint() : Point { if ($this->isEmpty) { throw new EmptyGeometryException('The CompoundCurve is empty and has no end point.'); } $count = count($this->curves); return $this->curves[$count - 1]->endPoint(); }
[ "public", "function", "endPoint", "(", ")", ":", "Point", "{", "if", "(", "$", "this", "->", "isEmpty", ")", "{", "throw", "new", "EmptyGeometryException", "(", "'The CompoundCurve is empty and has no end point.'", ")", ";", "}", "$", "count", "=", "count", "(...
{@inheritdoc}
[ "{" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/CompoundCurve.php#L99-L108
brick/geo
src/CompoundCurve.php
CompoundCurve.curveN
public function curveN(int $n) : Curve { if (! isset($this->curves[$n - 1])) { throw new NoSuchGeometryException('There is no Curve in this CompoundCurve at index ' . $n); } return $this->curves[$n - 1]; }
php
public function curveN(int $n) : Curve { if (! isset($this->curves[$n - 1])) { throw new NoSuchGeometryException('There is no Curve in this CompoundCurve at index ' . $n); } return $this->curves[$n - 1]; }
[ "public", "function", "curveN", "(", "int", "$", "n", ")", ":", "Curve", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "curves", "[", "$", "n", "-", "1", "]", ")", ")", "{", "throw", "new", "NoSuchGeometryException", "(", "'There is no Curve ...
Returns the specified Curve N in this CompoundCurve. @param int $n The curve number, 1-based. @return Curve @throws NoSuchGeometryException If there is no Curve at this index.
[ "Returns", "the", "specified", "Curve", "N", "in", "this", "CompoundCurve", "." ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/CompoundCurve.php#L129-L136
brick/geo
src/CompoundCurve.php
CompoundCurve.toArray
public function toArray() : array { $result = []; foreach ($this->curves as $curve) { $result[] = $curve->toArray(); } return $result; }
php
public function toArray() : array { $result = []; foreach ($this->curves as $curve) { $result[] = $curve->toArray(); } return $result; }
[ "public", "function", "toArray", "(", ")", ":", "array", "{", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "curves", "as", "$", "curve", ")", "{", "$", "result", "[", "]", "=", "$", "curve", "->", "toArray", "(", ")", "...
{@inheritdoc}
[ "{" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/CompoundCurve.php#L171-L180
brick/geo
src/IO/AbstractWKTWriter.php
AbstractWKTWriter.doWrite
protected function doWrite(Geometry $geometry) : string { $type = strtoupper($geometry->geometryType()); $cs = $geometry->coordinateSystem(); $hasZ = $cs->hasZ(); $hasM = $cs->hasM(); $dimensionality = ''; if ($hasZ || $hasM) { $dimensionality .= ' '; if ($hasZ) { $dimensionality .= 'Z'; } if ($hasM) { $dimensionality .= 'M'; } } if ($geometry instanceof GeometryCollection) { $isEmpty = ($geometry->numGeometries() === 0); } else { $isEmpty = $geometry->isEmpty(); } if ($isEmpty) { return $type . $dimensionality . ' EMPTY'; } if ($geometry instanceof Point) { $data = $this->writePoint($geometry); } elseif ($geometry instanceof LineString) { $data = $this->writeLineString($geometry); } elseif ($geometry instanceof CircularString) { $data = $this->writeCircularString($geometry); } elseif ($geometry instanceof CompoundCurve) { $data = $this->writeCompoundCurve($geometry); } elseif ($geometry instanceof Triangle) { $data = $this->writePolygon($geometry); } elseif ($geometry instanceof Polygon) { $data = $this->writePolygon($geometry); } elseif ($geometry instanceof CurvePolygon) { $data = $this->writeCurvePolygon($geometry); } elseif ($geometry instanceof MultiPoint) { $data = $this->writeMultiPoint($geometry); } elseif ($geometry instanceof MultiLineString) { $data = $this->writeMultiLineString($geometry); } elseif ($geometry instanceof MultiPolygon) { $data = $this->writeMultiPolygon($geometry); } elseif ($geometry instanceof GeometryCollection) { $data = $this->writeGeometryCollection($geometry); } elseif ($geometry instanceof TIN) { $data = $this->writePolyhedralSurface($geometry); } elseif ($geometry instanceof PolyhedralSurface) { $data = $this->writePolyhedralSurface($geometry); } else { throw GeometryIOException::unsupportedGeometryType($geometry->geometryType()); } return $type . $dimensionality . $this->prettyPrintSpace . '(' . $data . ')'; }
php
protected function doWrite(Geometry $geometry) : string { $type = strtoupper($geometry->geometryType()); $cs = $geometry->coordinateSystem(); $hasZ = $cs->hasZ(); $hasM = $cs->hasM(); $dimensionality = ''; if ($hasZ || $hasM) { $dimensionality .= ' '; if ($hasZ) { $dimensionality .= 'Z'; } if ($hasM) { $dimensionality .= 'M'; } } if ($geometry instanceof GeometryCollection) { $isEmpty = ($geometry->numGeometries() === 0); } else { $isEmpty = $geometry->isEmpty(); } if ($isEmpty) { return $type . $dimensionality . ' EMPTY'; } if ($geometry instanceof Point) { $data = $this->writePoint($geometry); } elseif ($geometry instanceof LineString) { $data = $this->writeLineString($geometry); } elseif ($geometry instanceof CircularString) { $data = $this->writeCircularString($geometry); } elseif ($geometry instanceof CompoundCurve) { $data = $this->writeCompoundCurve($geometry); } elseif ($geometry instanceof Triangle) { $data = $this->writePolygon($geometry); } elseif ($geometry instanceof Polygon) { $data = $this->writePolygon($geometry); } elseif ($geometry instanceof CurvePolygon) { $data = $this->writeCurvePolygon($geometry); } elseif ($geometry instanceof MultiPoint) { $data = $this->writeMultiPoint($geometry); } elseif ($geometry instanceof MultiLineString) { $data = $this->writeMultiLineString($geometry); } elseif ($geometry instanceof MultiPolygon) { $data = $this->writeMultiPolygon($geometry); } elseif ($geometry instanceof GeometryCollection) { $data = $this->writeGeometryCollection($geometry); } elseif ($geometry instanceof TIN) { $data = $this->writePolyhedralSurface($geometry); } elseif ($geometry instanceof PolyhedralSurface) { $data = $this->writePolyhedralSurface($geometry); } else { throw GeometryIOException::unsupportedGeometryType($geometry->geometryType()); } return $type . $dimensionality . $this->prettyPrintSpace . '(' . $data . ')'; }
[ "protected", "function", "doWrite", "(", "Geometry", "$", "geometry", ")", ":", "string", "{", "$", "type", "=", "strtoupper", "(", "$", "geometry", "->", "geometryType", "(", ")", ")", ";", "$", "cs", "=", "$", "geometry", "->", "coordinateSystem", "(",...
@param Geometry $geometry The geometry to export as WKT. @return string The WKT representation of the given geometry. @throws GeometryIOException If the given geometry cannot be exported as WKT.
[ "@param", "Geometry", "$geometry", "The", "geometry", "to", "export", "as", "WKT", "." ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/AbstractWKTWriter.php#L61-L124
brick/geo
src/IO/AbstractWKTWriter.php
AbstractWKTWriter.writePoint
private function writePoint(Point $point) : string { $result = $point->x() . ' ' . $point->y(); if (null !== $z = $point->z()) { $result .= ' ' . $z; } if (null !== $m = $point->m()) { $result .= ' ' . $m; } return $result; }
php
private function writePoint(Point $point) : string { $result = $point->x() . ' ' . $point->y(); if (null !== $z = $point->z()) { $result .= ' ' . $z; } if (null !== $m = $point->m()) { $result .= ' ' . $m; } return $result; }
[ "private", "function", "writePoint", "(", "Point", "$", "point", ")", ":", "string", "{", "$", "result", "=", "$", "point", "->", "x", "(", ")", ".", "' '", ".", "$", "point", "->", "y", "(", ")", ";", "if", "(", "null", "!==", "$", "z", "=", ...
@param Point $point @return string
[ "@param", "Point", "$point" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/AbstractWKTWriter.php#L131-L144
brick/geo
src/IO/AbstractWKTWriter.php
AbstractWKTWriter.writeLineString
private function writeLineString(LineString $lineString) : string { $result = []; foreach ($lineString as $point) { $result[] = $this->writePoint($point); } return implode(',' . $this->prettyPrintSpace, $result); }
php
private function writeLineString(LineString $lineString) : string { $result = []; foreach ($lineString as $point) { $result[] = $this->writePoint($point); } return implode(',' . $this->prettyPrintSpace, $result); }
[ "private", "function", "writeLineString", "(", "LineString", "$", "lineString", ")", ":", "string", "{", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "lineString", "as", "$", "point", ")", "{", "$", "result", "[", "]", "=", "$", "this", "-...
@param LineString $lineString @return string
[ "@param", "LineString", "$lineString" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/AbstractWKTWriter.php#L151-L160
brick/geo
src/IO/AbstractWKTWriter.php
AbstractWKTWriter.writeCircularString
private function writeCircularString(CircularString $circularString) : string { $result = []; foreach ($circularString as $point) { $result[] = $this->writePoint($point); } return implode(',' . $this->prettyPrintSpace, $result); }
php
private function writeCircularString(CircularString $circularString) : string { $result = []; foreach ($circularString as $point) { $result[] = $this->writePoint($point); } return implode(',' . $this->prettyPrintSpace, $result); }
[ "private", "function", "writeCircularString", "(", "CircularString", "$", "circularString", ")", ":", "string", "{", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "circularString", "as", "$", "point", ")", "{", "$", "result", "[", "]", "=", "$"...
@param CircularString $circularString @return string
[ "@param", "CircularString", "$circularString" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/AbstractWKTWriter.php#L167-L176
brick/geo
src/IO/AbstractWKTWriter.php
AbstractWKTWriter.writeCompoundCurve
private function writeCompoundCurve(CompoundCurve $compoundCurve) : string { $result = []; foreach ($compoundCurve as $curve) { if ($curve instanceof LineString) { $result[] = '(' . $this->writeLineString($curve). ')'; } elseif ($curve instanceof CircularString) { $result[] = $this->doWrite($curve); } else { throw new GeometryIOException('Only LineString and CircularString are allowed in CompoundCurve WKT.'); } } return implode(',' . $this->prettyPrintSpace, $result); }
php
private function writeCompoundCurve(CompoundCurve $compoundCurve) : string { $result = []; foreach ($compoundCurve as $curve) { if ($curve instanceof LineString) { $result[] = '(' . $this->writeLineString($curve). ')'; } elseif ($curve instanceof CircularString) { $result[] = $this->doWrite($curve); } else { throw new GeometryIOException('Only LineString and CircularString are allowed in CompoundCurve WKT.'); } } return implode(',' . $this->prettyPrintSpace, $result); }
[ "private", "function", "writeCompoundCurve", "(", "CompoundCurve", "$", "compoundCurve", ")", ":", "string", "{", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "compoundCurve", "as", "$", "curve", ")", "{", "if", "(", "$", "curve", "instanceof", ...
@param CompoundCurve $compoundCurve @return string @throws GeometryIOException
[ "@param", "CompoundCurve", "$compoundCurve" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/AbstractWKTWriter.php#L185-L200
brick/geo
src/IO/AbstractWKTWriter.php
AbstractWKTWriter.writePolygon
private function writePolygon(Polygon $polygon) : string { $result = []; foreach ($polygon as $ring) { $result[] = '(' . $this->writeLineString($ring) . ')'; } return implode(',' . $this->prettyPrintSpace, $result); }
php
private function writePolygon(Polygon $polygon) : string { $result = []; foreach ($polygon as $ring) { $result[] = '(' . $this->writeLineString($ring) . ')'; } return implode(',' . $this->prettyPrintSpace, $result); }
[ "private", "function", "writePolygon", "(", "Polygon", "$", "polygon", ")", ":", "string", "{", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "polygon", "as", "$", "ring", ")", "{", "$", "result", "[", "]", "=", "'('", ".", "$", "this", ...
@param Polygon $polygon @return string
[ "@param", "Polygon", "$polygon" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/AbstractWKTWriter.php#L207-L216
brick/geo
src/IO/AbstractWKTWriter.php
AbstractWKTWriter.writeCurvePolygon
private function writeCurvePolygon(CurvePolygon $curvePolygon) : string { $result = []; foreach ($curvePolygon as $ring) { if ($ring instanceof LineString) { $result[] = '(' . $this->writeLineString($ring) . ')'; } else { $result[] = $this->doWrite($ring); } } return implode(',' . $this->prettyPrintSpace, $result); }
php
private function writeCurvePolygon(CurvePolygon $curvePolygon) : string { $result = []; foreach ($curvePolygon as $ring) { if ($ring instanceof LineString) { $result[] = '(' . $this->writeLineString($ring) . ')'; } else { $result[] = $this->doWrite($ring); } } return implode(',' . $this->prettyPrintSpace, $result); }
[ "private", "function", "writeCurvePolygon", "(", "CurvePolygon", "$", "curvePolygon", ")", ":", "string", "{", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "curvePolygon", "as", "$", "ring", ")", "{", "if", "(", "$", "ring", "instanceof", "Lin...
@param CurvePolygon $curvePolygon @return string
[ "@param", "CurvePolygon", "$curvePolygon" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/AbstractWKTWriter.php#L223-L236
brick/geo
src/IO/AbstractWKTWriter.php
AbstractWKTWriter.writeMultiPoint
private function writeMultiPoint(MultiPoint $multiPoint) : string { $result = []; foreach ($multiPoint as $point) { $result[] = $this->writePoint($point); } return implode(',' . $this->prettyPrintSpace, $result); }
php
private function writeMultiPoint(MultiPoint $multiPoint) : string { $result = []; foreach ($multiPoint as $point) { $result[] = $this->writePoint($point); } return implode(',' . $this->prettyPrintSpace, $result); }
[ "private", "function", "writeMultiPoint", "(", "MultiPoint", "$", "multiPoint", ")", ":", "string", "{", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "multiPoint", "as", "$", "point", ")", "{", "$", "result", "[", "]", "=", "$", "this", "-...
@param MultiPoint $multiPoint @return string
[ "@param", "MultiPoint", "$multiPoint" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/AbstractWKTWriter.php#L243-L252
brick/geo
src/IO/AbstractWKTWriter.php
AbstractWKTWriter.writeMultiLineString
private function writeMultiLineString(MultiLineString $multiLineString) : string { $result = []; foreach ($multiLineString as $lineString) { $result[] = '(' . $this->writeLineString($lineString) . ')'; } return implode(',' . $this->prettyPrintSpace, $result); }
php
private function writeMultiLineString(MultiLineString $multiLineString) : string { $result = []; foreach ($multiLineString as $lineString) { $result[] = '(' . $this->writeLineString($lineString) . ')'; } return implode(',' . $this->prettyPrintSpace, $result); }
[ "private", "function", "writeMultiLineString", "(", "MultiLineString", "$", "multiLineString", ")", ":", "string", "{", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "multiLineString", "as", "$", "lineString", ")", "{", "$", "result", "[", "]", "...
@param MultiLineString $multiLineString @return string
[ "@param", "MultiLineString", "$multiLineString" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/AbstractWKTWriter.php#L259-L268
brick/geo
src/IO/AbstractWKTWriter.php
AbstractWKTWriter.writeMultiPolygon
private function writeMultiPolygon(MultiPolygon $multiPolygon) : string { $result = []; foreach ($multiPolygon as $polygon) { $result[] = '(' . $this->writePolygon($polygon) . ')'; } return implode(',' . $this->prettyPrintSpace, $result); }
php
private function writeMultiPolygon(MultiPolygon $multiPolygon) : string { $result = []; foreach ($multiPolygon as $polygon) { $result[] = '(' . $this->writePolygon($polygon) . ')'; } return implode(',' . $this->prettyPrintSpace, $result); }
[ "private", "function", "writeMultiPolygon", "(", "MultiPolygon", "$", "multiPolygon", ")", ":", "string", "{", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "multiPolygon", "as", "$", "polygon", ")", "{", "$", "result", "[", "]", "=", "'('", ...
@param MultiPolygon $multiPolygon @return string
[ "@param", "MultiPolygon", "$multiPolygon" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/AbstractWKTWriter.php#L275-L284
brick/geo
src/IO/AbstractWKTWriter.php
AbstractWKTWriter.writeGeometryCollection
private function writeGeometryCollection(GeometryCollection $collection) : string { $result = []; foreach ($collection as $geometry) { $result[] = $this->doWrite($geometry); } return implode(',' . $this->prettyPrintSpace, $result); }
php
private function writeGeometryCollection(GeometryCollection $collection) : string { $result = []; foreach ($collection as $geometry) { $result[] = $this->doWrite($geometry); } return implode(',' . $this->prettyPrintSpace, $result); }
[ "private", "function", "writeGeometryCollection", "(", "GeometryCollection", "$", "collection", ")", ":", "string", "{", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "collection", "as", "$", "geometry", ")", "{", "$", "result", "[", "]", "=", ...
@param GeometryCollection $collection @return string
[ "@param", "GeometryCollection", "$collection" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/AbstractWKTWriter.php#L291-L300
brick/geo
src/IO/AbstractWKTWriter.php
AbstractWKTWriter.writePolyhedralSurface
private function writePolyhedralSurface(PolyhedralSurface $polyhedralSurface) : string { $result = []; foreach ($polyhedralSurface as $patch) { $result[] = '(' . $this->writePolygon($patch) . ')'; } return implode(',' . $this->prettyPrintSpace, $result); }
php
private function writePolyhedralSurface(PolyhedralSurface $polyhedralSurface) : string { $result = []; foreach ($polyhedralSurface as $patch) { $result[] = '(' . $this->writePolygon($patch) . ')'; } return implode(',' . $this->prettyPrintSpace, $result); }
[ "private", "function", "writePolyhedralSurface", "(", "PolyhedralSurface", "$", "polyhedralSurface", ")", ":", "string", "{", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "polyhedralSurface", "as", "$", "patch", ")", "{", "$", "result", "[", "]", ...
@param PolyhedralSurface $polyhedralSurface @return string
[ "@param", "PolyhedralSurface", "$polyhedralSurface" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/AbstractWKTWriter.php#L307-L316
brick/geo
src/Point.php
Point.xy
public static function xy(float $x, float $y, int $srid = 0) : Point { return new Point(CoordinateSystem::xy($srid), $x, $y); }
php
public static function xy(float $x, float $y, int $srid = 0) : Point { return new Point(CoordinateSystem::xy($srid), $x, $y); }
[ "public", "static", "function", "xy", "(", "float", "$", "x", ",", "float", "$", "y", ",", "int", "$", "srid", "=", "0", ")", ":", "Point", "{", "return", "new", "Point", "(", "CoordinateSystem", "::", "xy", "(", "$", "srid", ")", ",", "$", "x", ...
Creates a point with X and Y coordinates. @param float $x The X coordinate. @param float $y The Y coordinate. @param int $srid An optional SRID. @return Point
[ "Creates", "a", "point", "with", "X", "and", "Y", "coordinates", "." ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Point.php#L92-L95
brick/geo
src/Point.php
Point.xyz
public static function xyz(float $x, float $y, float $z, int $srid = 0) : Point { return new Point(CoordinateSystem::xyz($srid), $x, $y, $z); }
php
public static function xyz(float $x, float $y, float $z, int $srid = 0) : Point { return new Point(CoordinateSystem::xyz($srid), $x, $y, $z); }
[ "public", "static", "function", "xyz", "(", "float", "$", "x", ",", "float", "$", "y", ",", "float", "$", "z", ",", "int", "$", "srid", "=", "0", ")", ":", "Point", "{", "return", "new", "Point", "(", "CoordinateSystem", "::", "xyz", "(", "$", "s...
Creates a point with X, Y and Z coordinates. @param float $x The X coordinate. @param float $y The Y coordinate. @param float $z The Z coordinate. @param int $srid An optional SRID. @return Point
[ "Creates", "a", "point", "with", "X", "Y", "and", "Z", "coordinates", "." ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Point.php#L107-L110
brick/geo
src/Point.php
Point.xym
public static function xym(float $x, float $y, float $m, int $srid = 0) : Point { return new Point(CoordinateSystem::xym($srid), $x, $y, $m); }
php
public static function xym(float $x, float $y, float $m, int $srid = 0) : Point { return new Point(CoordinateSystem::xym($srid), $x, $y, $m); }
[ "public", "static", "function", "xym", "(", "float", "$", "x", ",", "float", "$", "y", ",", "float", "$", "m", ",", "int", "$", "srid", "=", "0", ")", ":", "Point", "{", "return", "new", "Point", "(", "CoordinateSystem", "::", "xym", "(", "$", "s...
Creates a point with X, Y and M coordinates. @param float $x The X coordinate. @param float $y The Y coordinate. @param float $m The M coordinate. @param int $srid An optional SRID. @return Point
[ "Creates", "a", "point", "with", "X", "Y", "and", "M", "coordinates", "." ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Point.php#L122-L125
brick/geo
src/Point.php
Point.xyzm
public static function xyzm(float $x, float $y, float $z, float $m, int $srid = 0) : Point { return new Point(CoordinateSystem::xyzm($srid), $x, $y, $z, $m); }
php
public static function xyzm(float $x, float $y, float $z, float $m, int $srid = 0) : Point { return new Point(CoordinateSystem::xyzm($srid), $x, $y, $z, $m); }
[ "public", "static", "function", "xyzm", "(", "float", "$", "x", ",", "float", "$", "y", ",", "float", "$", "z", ",", "float", "$", "m", ",", "int", "$", "srid", "=", "0", ")", ":", "Point", "{", "return", "new", "Point", "(", "CoordinateSystem", ...
Creates a point with X, Y, Z and M coordinates. @param float $x The X coordinate. @param float $y The Y coordinate. @param float $z The Z coordinate. @param float $m The M coordinate. @param int $srid An optional SRID. @return Point
[ "Creates", "a", "point", "with", "X", "Y", "Z", "and", "M", "coordinates", "." ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Point.php#L138-L141
brick/geo
src/Point.php
Point.toArray
public function toArray() : array { if ($this->isEmpty) { return []; } $result = [$this->x, $this->y]; if ($this->z !== null) { $result[] = $this->z; } if ($this->m !== null) { $result[] = $this->m; } return $result; }
php
public function toArray() : array { if ($this->isEmpty) { return []; } $result = [$this->x, $this->y]; if ($this->z !== null) { $result[] = $this->z; } if ($this->m !== null) { $result[] = $this->m; } return $result; }
[ "public", "function", "toArray", "(", ")", ":", "array", "{", "if", "(", "$", "this", "->", "isEmpty", ")", "{", "return", "[", "]", ";", "}", "$", "result", "=", "[", "$", "this", "->", "x", ",", "$", "this", "->", "y", "]", ";", "if", "(", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Point.php#L272-L289
brick/geo
src/IO/EWKBReader.php
EWKBReader.read
public function read(string $ewkb) : Geometry { $buffer = new WKBBuffer($ewkb); $geometry = $this->readGeometry($buffer, 0); if (! $buffer->isEndOfStream()) { throw GeometryIOException::invalidWKB('unexpected data at end of stream'); } return $geometry; }
php
public function read(string $ewkb) : Geometry { $buffer = new WKBBuffer($ewkb); $geometry = $this->readGeometry($buffer, 0); if (! $buffer->isEndOfStream()) { throw GeometryIOException::invalidWKB('unexpected data at end of stream'); } return $geometry; }
[ "public", "function", "read", "(", "string", "$", "ewkb", ")", ":", "Geometry", "{", "$", "buffer", "=", "new", "WKBBuffer", "(", "$", "ewkb", ")", ";", "$", "geometry", "=", "$", "this", "->", "readGeometry", "(", "$", "buffer", ",", "0", ")", ";"...
@param string $ewkb The EWKB to read. @return Geometry @throws GeometryIOException
[ "@param", "string", "$ewkb", "The", "EWKB", "to", "read", "." ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/EWKBReader.php#L22-L32
brick/geo
src/IO/EWKBReader.php
EWKBReader.readGeometryHeader
protected function readGeometryHeader(WKBBuffer $buffer, & $geometryType, & $hasZ, & $hasM, & $srid) : void { $header = $buffer->readUnsignedLong(); if ($header >= 0 && $header < 4000) { $geometryType = $header % 1000; $dimension = ($header - $geometryType) / 1000; $hasZ = ($dimension === 1 || $dimension === 3); $hasM = ($dimension === 2 || $dimension === 3); } else { $geometryType = $header & 0xFFF; $hasZ = (($header & EWKBTools::Z) !== 0); $hasM = (($header & EWKBTools::M) !== 0); $hasSRID = (($header & EWKBTools::S) !== 0); if ($hasSRID) { $srid = $buffer->readUnsignedLong(); } } }
php
protected function readGeometryHeader(WKBBuffer $buffer, & $geometryType, & $hasZ, & $hasM, & $srid) : void { $header = $buffer->readUnsignedLong(); if ($header >= 0 && $header < 4000) { $geometryType = $header % 1000; $dimension = ($header - $geometryType) / 1000; $hasZ = ($dimension === 1 || $dimension === 3); $hasM = ($dimension === 2 || $dimension === 3); } else { $geometryType = $header & 0xFFF; $hasZ = (($header & EWKBTools::Z) !== 0); $hasM = (($header & EWKBTools::M) !== 0); $hasSRID = (($header & EWKBTools::S) !== 0); if ($hasSRID) { $srid = $buffer->readUnsignedLong(); } } }
[ "protected", "function", "readGeometryHeader", "(", "WKBBuffer", "$", "buffer", ",", "&", "$", "geometryType", ",", "&", "$", "hasZ", ",", "&", "$", "hasM", ",", "&", "$", "srid", ")", ":", "void", "{", "$", "header", "=", "$", "buffer", "->", "readU...
{@inheritdoc}
[ "{" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/EWKBReader.php#L37-L58
brick/geo
src/Proxy/PolygonProxy.php
PolygonProxy.load
private function load() : void { $this->proxyGeometry = $this->proxyIsBinary ? \Brick\Geo\Polygon::fromBinary($this->proxyData, $this->proxySRID) : \Brick\Geo\Polygon::fromText($this->proxyData, $this->proxySRID); }
php
private function load() : void { $this->proxyGeometry = $this->proxyIsBinary ? \Brick\Geo\Polygon::fromBinary($this->proxyData, $this->proxySRID) : \Brick\Geo\Polygon::fromText($this->proxyData, $this->proxySRID); }
[ "private", "function", "load", "(", ")", ":", "void", "{", "$", "this", "->", "proxyGeometry", "=", "$", "this", "->", "proxyIsBinary", "?", "\\", "Brick", "\\", "Geo", "\\", "Polygon", "::", "fromBinary", "(", "$", "this", "->", "proxyData", ",", "$",...
Loads the underlying geometry. @return void @throws GeometryIOException If the proxy data is not valid. @throws CoordinateSystemException If the resulting geometry contains mixed coordinate systems. @throws InvalidGeometryException If the resulting geometry is not valid. @throws UnexpectedGeometryException If the resulting geometry is not an instance of the proxied class.
[ "Loads", "the", "underlying", "geometry", "." ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Proxy/PolygonProxy.php#L70-L75
brick/geo
src/Proxy/PolygonProxy.php
PolygonProxy.exteriorRing
public function exteriorRing() : \Brick\Geo\LineString { if ($this->proxyGeometry === null) { $this->load(); } return $this->proxyGeometry->exteriorRing(); }
php
public function exteriorRing() : \Brick\Geo\LineString { if ($this->proxyGeometry === null) { $this->load(); } return $this->proxyGeometry->exteriorRing(); }
[ "public", "function", "exteriorRing", "(", ")", ":", "\\", "Brick", "\\", "Geo", "\\", "LineString", "{", "if", "(", "$", "this", "->", "proxyGeometry", "===", "null", ")", "{", "$", "this", "->", "load", "(", ")", ";", "}", "return", "$", "this", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Proxy/PolygonProxy.php#L157-L164
brick/geo
src/Polygon.php
Polygon.of
public static function of(LineString $exteriorRing, LineString ...$interiorRings) : Polygon { return new static($exteriorRing->coordinateSystem(), $exteriorRing, ...$interiorRings); }
php
public static function of(LineString $exteriorRing, LineString ...$interiorRings) : Polygon { return new static($exteriorRing->coordinateSystem(), $exteriorRing, ...$interiorRings); }
[ "public", "static", "function", "of", "(", "LineString", "$", "exteriorRing", ",", "LineString", "...", "$", "interiorRings", ")", ":", "Polygon", "{", "return", "new", "static", "(", "$", "exteriorRing", "->", "coordinateSystem", "(", ")", ",", "$", "exteri...
Creates a non-empty Polygon composed of the given rings. @param LineString $exteriorRing The exterior ring. @param LineString ...$interiorRings The interior rings, if any. @return Polygon @throws InvalidGeometryException If the resulting geometry is not valid for a sub-type of Polygon. @throws CoordinateSystemException If the rings use different coordinate systems.
[ "Creates", "a", "non", "-", "empty", "Polygon", "composed", "of", "the", "given", "rings", "." ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Polygon.php#L84-L87
brick/geo
src/Polygon.php
Polygon.interiorRingN
public function interiorRingN(int $n) : LineString { if ($n === 0 || ! isset($this->rings[$n])) { throw new NoSuchGeometryException('There is no interior ring in this Polygon at index ' . $n); } return $this->rings[$n]; }
php
public function interiorRingN(int $n) : LineString { if ($n === 0 || ! isset($this->rings[$n])) { throw new NoSuchGeometryException('There is no interior ring in this Polygon at index ' . $n); } return $this->rings[$n]; }
[ "public", "function", "interiorRingN", "(", "int", "$", "n", ")", ":", "LineString", "{", "if", "(", "$", "n", "===", "0", "||", "!", "isset", "(", "$", "this", "->", "rings", "[", "$", "n", "]", ")", ")", "{", "throw", "new", "NoSuchGeometryExcept...
Returns the specified interior ring N in this Polygon. @param int $n The ring number, 1-based. @return LineString @throws NoSuchGeometryException If there is no interior ring at this index.
[ "Returns", "the", "specified", "interior", "ring", "N", "in", "this", "Polygon", "." ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Polygon.php#L128-L135
brick/geo
src/Engine/PDOEngine.php
PDOEngine.executeQuery
protected function executeQuery(string $query, array $parameters) : array { $errMode = $this->pdo->getAttribute(\PDO::ATTR_ERRMODE); $this->pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); try { if (! isset($this->statements[$query])) { $this->statements[$query] = $this->pdo->prepare($query); } $statement = $this->statements[$query]; $index = 1; foreach ($parameters as $parameter) { if ($parameter instanceof Geometry) { if ($parameter->isEmpty()) { $statement->bindValue($index++, $parameter->asText(), \PDO::PARAM_STR); $statement->bindValue($index++, $parameter->SRID(), \PDO::PARAM_INT); } else { $statement->bindValue($index++, $parameter->asBinary(), \PDO::PARAM_LOB); $statement->bindValue($index++, $parameter->SRID(), \PDO::PARAM_INT); } } else { $statement->bindValue($index++, $parameter); } } $statement->execute(); $result = $statement->fetch(\PDO::FETCH_NUM); } catch (\PDOException $e) { $errorClass = substr($e->getCode(), 0, 2); // 42XXX = syntax error or access rule violation; reported on undefined function. // 22XXX = data exception; reported by MySQL 5.7 on unsupported geometry. if ($errorClass === '42' || $errorClass === '22') { throw GeometryEngineException::operationNotSupportedByEngine($e); } throw $e; } $this->pdo->setAttribute(\PDO::ATTR_ERRMODE, $errMode); return $result; }
php
protected function executeQuery(string $query, array $parameters) : array { $errMode = $this->pdo->getAttribute(\PDO::ATTR_ERRMODE); $this->pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); try { if (! isset($this->statements[$query])) { $this->statements[$query] = $this->pdo->prepare($query); } $statement = $this->statements[$query]; $index = 1; foreach ($parameters as $parameter) { if ($parameter instanceof Geometry) { if ($parameter->isEmpty()) { $statement->bindValue($index++, $parameter->asText(), \PDO::PARAM_STR); $statement->bindValue($index++, $parameter->SRID(), \PDO::PARAM_INT); } else { $statement->bindValue($index++, $parameter->asBinary(), \PDO::PARAM_LOB); $statement->bindValue($index++, $parameter->SRID(), \PDO::PARAM_INT); } } else { $statement->bindValue($index++, $parameter); } } $statement->execute(); $result = $statement->fetch(\PDO::FETCH_NUM); } catch (\PDOException $e) { $errorClass = substr($e->getCode(), 0, 2); // 42XXX = syntax error or access rule violation; reported on undefined function. // 22XXX = data exception; reported by MySQL 5.7 on unsupported geometry. if ($errorClass === '42' || $errorClass === '22') { throw GeometryEngineException::operationNotSupportedByEngine($e); } throw $e; } $this->pdo->setAttribute(\PDO::ATTR_ERRMODE, $errMode); return $result; }
[ "protected", "function", "executeQuery", "(", "string", "$", "query", ",", "array", "$", "parameters", ")", ":", "array", "{", "$", "errMode", "=", "$", "this", "->", "pdo", "->", "getAttribute", "(", "\\", "PDO", "::", "ATTR_ERRMODE", ")", ";", "$", "...
{@inheritdoc}
[ "{" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Engine/PDOEngine.php#L52-L98
brick/geo
src/Engine/GEOSEngine.php
GEOSEngine.toGEOS
private function toGEOS(Geometry $geometry) : \GEOSGeometry { if ($geometry->isEmpty()) { $geosGeometry = $this->wktReader->read($geometry->asText()); $geosGeometry->setSRID($geometry->SRID()); return $geosGeometry; } if ($this->hasBinaryReadWrite) { return $this->wkbReader->read($this->ewkbWriter->write($geometry)); } return $this->wkbReader->readHEX(bin2hex($this->ewkbWriter->write($geometry))); }
php
private function toGEOS(Geometry $geometry) : \GEOSGeometry { if ($geometry->isEmpty()) { $geosGeometry = $this->wktReader->read($geometry->asText()); $geosGeometry->setSRID($geometry->SRID()); return $geosGeometry; } if ($this->hasBinaryReadWrite) { return $this->wkbReader->read($this->ewkbWriter->write($geometry)); } return $this->wkbReader->readHEX(bin2hex($this->ewkbWriter->write($geometry))); }
[ "private", "function", "toGEOS", "(", "Geometry", "$", "geometry", ")", ":", "\\", "GEOSGeometry", "{", "if", "(", "$", "geometry", "->", "isEmpty", "(", ")", ")", "{", "$", "geosGeometry", "=", "$", "this", "->", "wktReader", "->", "read", "(", "$", ...
@param Geometry $geometry @return \GEOSGeometry
[ "@param", "Geometry", "$geometry" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Engine/GEOSEngine.php#L80-L94
brick/geo
src/Engine/GEOSEngine.php
GEOSEngine.fromGEOS
private function fromGEOS(\GEOSGeometry $geometry) : Geometry { if ($geometry->isEmpty()) { return Geometry::fromText($this->wktWriter->write($geometry), $geometry->getSRID()); } if ($this->hasBinaryReadWrite) { return $this->ewkbReader->read($this->wkbWriter->write($geometry)); } return $this->ewkbReader->read(hex2bin($this->wkbWriter->writeHEX($geometry))); }
php
private function fromGEOS(\GEOSGeometry $geometry) : Geometry { if ($geometry->isEmpty()) { return Geometry::fromText($this->wktWriter->write($geometry), $geometry->getSRID()); } if ($this->hasBinaryReadWrite) { return $this->ewkbReader->read($this->wkbWriter->write($geometry)); } return $this->ewkbReader->read(hex2bin($this->wkbWriter->writeHEX($geometry))); }
[ "private", "function", "fromGEOS", "(", "\\", "GEOSGeometry", "$", "geometry", ")", ":", "Geometry", "{", "if", "(", "$", "geometry", "->", "isEmpty", "(", ")", ")", "{", "return", "Geometry", "::", "fromText", "(", "$", "this", "->", "wktWriter", "->", ...
@param \GEOSGeometry $geometry @return Geometry
[ "@param", "\\", "GEOSGeometry", "$geometry" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Engine/GEOSEngine.php#L101-L112
brick/geo
src/Engine/GEOSEngine.php
GEOSEngine.length
public function length(Geometry $g) : float { try { return $this->toGEOS($g)->length(); } catch (\Exception $e) { throw GeometryEngineException::operationNotSupportedByEngine($e); } }
php
public function length(Geometry $g) : float { try { return $this->toGEOS($g)->length(); } catch (\Exception $e) { throw GeometryEngineException::operationNotSupportedByEngine($e); } }
[ "public", "function", "length", "(", "Geometry", "$", "g", ")", ":", "float", "{", "try", "{", "return", "$", "this", "->", "toGEOS", "(", "$", "g", ")", "->", "length", "(", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "...
{@inheritdoc}
[ "{" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Engine/GEOSEngine.php#L153-L160
brick/geo
src/Engine/GEOSEngine.php
GEOSEngine.isValid
public function isValid(Geometry $g) : bool { try { return $this->toGEOS($g)->checkValidity()['valid']; } catch (\Exception $e) { throw GeometryEngineException::operationNotSupportedByEngine($e); } }
php
public function isValid(Geometry $g) : bool { try { return $this->toGEOS($g)->checkValidity()['valid']; } catch (\Exception $e) { throw GeometryEngineException::operationNotSupportedByEngine($e); } }
[ "public", "function", "isValid", "(", "Geometry", "$", "g", ")", ":", "bool", "{", "try", "{", "return", "$", "this", "->", "toGEOS", "(", "$", "g", ")", "->", "checkValidity", "(", ")", "[", "'valid'", "]", ";", "}", "catch", "(", "\\", "Exception...
{@inheritdoc}
[ "{" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Engine/GEOSEngine.php#L213-L220
brick/geo
src/Engine/GEOSEngine.php
GEOSEngine.isClosed
public function isClosed(Geometry $g) : bool { try { return $this->toGEOS($g)->isClosed(); } catch (\Exception $e) { throw GeometryEngineException::operationNotSupportedByEngine($e); } }
php
public function isClosed(Geometry $g) : bool { try { return $this->toGEOS($g)->isClosed(); } catch (\Exception $e) { throw GeometryEngineException::operationNotSupportedByEngine($e); } }
[ "public", "function", "isClosed", "(", "Geometry", "$", "g", ")", ":", "bool", "{", "try", "{", "return", "$", "this", "->", "toGEOS", "(", "$", "g", ")", "->", "isClosed", "(", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Engine/GEOSEngine.php#L225-L232
brick/geo
src/Engine/GEOSEngine.php
GEOSEngine.contains
public function contains(Geometry $a, Geometry $b) : bool { try { return $this->toGEOS($a)->contains($this->toGEOS($b)); } catch (\Exception $e) { throw GeometryEngineException::operationNotSupportedByEngine($e); } }
php
public function contains(Geometry $a, Geometry $b) : bool { try { return $this->toGEOS($a)->contains($this->toGEOS($b)); } catch (\Exception $e) { throw GeometryEngineException::operationNotSupportedByEngine($e); } }
[ "public", "function", "contains", "(", "Geometry", "$", "a", ",", "Geometry", "$", "b", ")", ":", "bool", "{", "try", "{", "return", "$", "this", "->", "toGEOS", "(", "$", "a", ")", "->", "contains", "(", "$", "this", "->", "toGEOS", "(", "$", "b...
{@inheritdoc}
[ "{" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Engine/GEOSEngine.php#L321-L328
brick/geo
src/Engine/GEOSEngine.php
GEOSEngine.relate
public function relate(Geometry $a, Geometry $b, string $matrix) : bool { try { return $this->toGEOS($a)->relate($this->toGEOS($b), $matrix); } catch (\Exception $e) { throw GeometryEngineException::operationNotSupportedByEngine($e); } }
php
public function relate(Geometry $a, Geometry $b, string $matrix) : bool { try { return $this->toGEOS($a)->relate($this->toGEOS($b), $matrix); } catch (\Exception $e) { throw GeometryEngineException::operationNotSupportedByEngine($e); } }
[ "public", "function", "relate", "(", "Geometry", "$", "a", ",", "Geometry", "$", "b", ",", "string", "$", "matrix", ")", ":", "bool", "{", "try", "{", "return", "$", "this", "->", "toGEOS", "(", "$", "a", ")", "->", "relate", "(", "$", "this", "-...
{@inheritdoc}
[ "{" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Engine/GEOSEngine.php#L345-L352
brick/geo
src/Engine/GEOSEngine.php
GEOSEngine.locateBetween
public function locateBetween(Geometry $g, float $mStart, float $mEnd) : Geometry { throw GeometryEngineException::unimplementedMethod(__METHOD__); }
php
public function locateBetween(Geometry $g, float $mStart, float $mEnd) : Geometry { throw GeometryEngineException::unimplementedMethod(__METHOD__); }
[ "public", "function", "locateBetween", "(", "Geometry", "$", "g", ",", "float", "$", "mStart", ",", "float", "$", "mEnd", ")", ":", "Geometry", "{", "throw", "GeometryEngineException", "::", "unimplementedMethod", "(", "__METHOD__", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Engine/GEOSEngine.php#L365-L368
brick/geo
src/Engine/GEOSEngine.php
GEOSEngine.distance
public function distance(Geometry $a, Geometry $b) : float { try { return $this->toGEOS($a)->distance($this->toGEOS($b)); } catch (\Exception $e) { throw GeometryEngineException::operationNotSupportedByEngine($e); } }
php
public function distance(Geometry $a, Geometry $b) : float { try { return $this->toGEOS($a)->distance($this->toGEOS($b)); } catch (\Exception $e) { throw GeometryEngineException::operationNotSupportedByEngine($e); } }
[ "public", "function", "distance", "(", "Geometry", "$", "a", ",", "Geometry", "$", "b", ")", ":", "float", "{", "try", "{", "return", "$", "this", "->", "toGEOS", "(", "$", "a", ")", "->", "distance", "(", "$", "this", "->", "toGEOS", "(", "$", "...
{@inheritdoc}
[ "{" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Engine/GEOSEngine.php#L373-L380
brick/geo
src/Engine/GEOSEngine.php
GEOSEngine.buffer
public function buffer(Geometry $g, float $distance) : Geometry { try { return $this->fromGEOS($this->toGEOS($g)->buffer($distance)); } catch (\Exception $e) { throw GeometryEngineException::operationNotSupportedByEngine($e); } }
php
public function buffer(Geometry $g, float $distance) : Geometry { try { return $this->fromGEOS($this->toGEOS($g)->buffer($distance)); } catch (\Exception $e) { throw GeometryEngineException::operationNotSupportedByEngine($e); } }
[ "public", "function", "buffer", "(", "Geometry", "$", "g", ",", "float", "$", "distance", ")", ":", "Geometry", "{", "try", "{", "return", "$", "this", "->", "fromGEOS", "(", "$", "this", "->", "toGEOS", "(", "$", "g", ")", "->", "buffer", "(", "$"...
{@inheritdoc}
[ "{" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Engine/GEOSEngine.php#L385-L392
brick/geo
src/Engine/GEOSEngine.php
GEOSEngine.convexHull
public function convexHull(Geometry $g) : Geometry { try { return $this->fromGEOS($this->toGEOS($g)->convexHull()); } catch (\Exception $e) { throw GeometryEngineException::operationNotSupportedByEngine($e); } }
php
public function convexHull(Geometry $g) : Geometry { try { return $this->fromGEOS($this->toGEOS($g)->convexHull()); } catch (\Exception $e) { throw GeometryEngineException::operationNotSupportedByEngine($e); } }
[ "public", "function", "convexHull", "(", "Geometry", "$", "g", ")", ":", "Geometry", "{", "try", "{", "return", "$", "this", "->", "fromGEOS", "(", "$", "this", "->", "toGEOS", "(", "$", "g", ")", "->", "convexHull", "(", ")", ")", ";", "}", "catch...
{@inheritdoc}
[ "{" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Engine/GEOSEngine.php#L397-L404
brick/geo
src/Engine/GEOSEngine.php
GEOSEngine.intersection
public function intersection(Geometry $a, Geometry $b) : Geometry { try { return $this->fromGEOS($this->toGEOS($a)->intersection($this->toGEOS($b))); } catch (\Exception $e) { throw GeometryEngineException::operationNotSupportedByEngine($e); } }
php
public function intersection(Geometry $a, Geometry $b) : Geometry { try { return $this->fromGEOS($this->toGEOS($a)->intersection($this->toGEOS($b))); } catch (\Exception $e) { throw GeometryEngineException::operationNotSupportedByEngine($e); } }
[ "public", "function", "intersection", "(", "Geometry", "$", "a", ",", "Geometry", "$", "b", ")", ":", "Geometry", "{", "try", "{", "return", "$", "this", "->", "fromGEOS", "(", "$", "this", "->", "toGEOS", "(", "$", "a", ")", "->", "intersection", "(...
{@inheritdoc}
[ "{" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Engine/GEOSEngine.php#L409-L416
brick/geo
src/Engine/GEOSEngine.php
GEOSEngine.simplify
public function simplify(Geometry $g, float $tolerance) : Geometry { try { return $this->fromGEOS($this->toGEOS($g)->simplify($tolerance)); } catch (\Exception $e) { throw GeometryEngineException::operationNotSupportedByEngine($e); } }
php
public function simplify(Geometry $g, float $tolerance) : Geometry { try { return $this->fromGEOS($this->toGEOS($g)->simplify($tolerance)); } catch (\Exception $e) { throw GeometryEngineException::operationNotSupportedByEngine($e); } }
[ "public", "function", "simplify", "(", "Geometry", "$", "g", ",", "float", "$", "tolerance", ")", ":", "Geometry", "{", "try", "{", "return", "$", "this", "->", "fromGEOS", "(", "$", "this", "->", "toGEOS", "(", "$", "g", ")", "->", "simplify", "(", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Engine/GEOSEngine.php#L441-L448
brick/geo
src/IO/WKBWriter.php
WKBWriter.packHeader
protected function packHeader(Geometry $geometry, bool $outer) : string { $geometryType = $geometry->geometryTypeBinary(); $cs = $geometry->coordinateSystem(); if ($cs->hasZ()) { $geometryType += 1000; } if ($cs->hasM()) { $geometryType += 2000; } return $this->packUnsignedInteger($geometryType); }
php
protected function packHeader(Geometry $geometry, bool $outer) : string { $geometryType = $geometry->geometryTypeBinary(); $cs = $geometry->coordinateSystem(); if ($cs->hasZ()) { $geometryType += 1000; } if ($cs->hasM()) { $geometryType += 2000; } return $this->packUnsignedInteger($geometryType); }
[ "protected", "function", "packHeader", "(", "Geometry", "$", "geometry", ",", "bool", "$", "outer", ")", ":", "string", "{", "$", "geometryType", "=", "$", "geometry", "->", "geometryTypeBinary", "(", ")", ";", "$", "cs", "=", "$", "geometry", "->", "coo...
{@inheritdoc}
[ "{" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/WKBWriter.php#L17-L32
brick/geo
src/Doctrine/Functions/AbstractFunction.php
AbstractFunction.getSql
public function getSql(SqlWalker $sqlWalker) { $sql = $this->getSqlFunctionName() . '('; foreach ($this->args as $key => $arg) { if ($key !== 0) { $sql .= ', '; } $sql .= $arg->dispatch($sqlWalker); } $sql .= ')'; return $sql; }
php
public function getSql(SqlWalker $sqlWalker) { $sql = $this->getSqlFunctionName() . '('; foreach ($this->args as $key => $arg) { if ($key !== 0) { $sql .= ', '; } $sql .= $arg->dispatch($sqlWalker); } $sql .= ')'; return $sql; }
[ "public", "function", "getSql", "(", "SqlWalker", "$", "sqlWalker", ")", "{", "$", "sql", "=", "$", "this", "->", "getSqlFunctionName", "(", ")", ".", "'('", ";", "foreach", "(", "$", "this", "->", "args", "as", "$", "key", "=>", "$", "arg", ")", "...
{@inheritdoc}
[ "{" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Doctrine/Functions/AbstractFunction.php#L35-L50
brick/geo
src/Doctrine/Functions/AbstractFunction.php
AbstractFunction.parse
public function parse(Parser $parser) { $this->args = []; $parser->match(Lexer::T_IDENTIFIER); $parser->match(Lexer::T_OPEN_PARENTHESIS); $parameterCount = $this->getParameterCount(); for ($i = 0; $i < $parameterCount; $i++) { if ($i !== 0) { $parser->match(Lexer::T_COMMA); } $this->args[] = $parser->ArithmeticPrimary(); } $parser->match(Lexer::T_CLOSE_PARENTHESIS); }
php
public function parse(Parser $parser) { $this->args = []; $parser->match(Lexer::T_IDENTIFIER); $parser->match(Lexer::T_OPEN_PARENTHESIS); $parameterCount = $this->getParameterCount(); for ($i = 0; $i < $parameterCount; $i++) { if ($i !== 0) { $parser->match(Lexer::T_COMMA); } $this->args[] = $parser->ArithmeticPrimary(); } $parser->match(Lexer::T_CLOSE_PARENTHESIS); }
[ "public", "function", "parse", "(", "Parser", "$", "parser", ")", "{", "$", "this", "->", "args", "=", "[", "]", ";", "$", "parser", "->", "match", "(", "Lexer", "::", "T_IDENTIFIER", ")", ";", "$", "parser", "->", "match", "(", "Lexer", "::", "T_O...
{@inheritdoc}
[ "{" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Doctrine/Functions/AbstractFunction.php#L55-L73
brick/geo
src/Engine/DatabaseEngine.php
DatabaseEngine.query
private function query(string $function, array $parameters, bool $returnsGeometry) : array { $queryParameters = []; foreach ($parameters as $parameter) { if ($parameter instanceof Geometry) { if ($parameter->isEmpty()) { $queryParameters[] = 'ST_GeomFromText(?, ?)'; } else { $queryParameters[] = 'ST_GeomFromWKB(?, ?)'; } } else { $queryParameters[] = '?'; } } $query = sprintf('SELECT %s(%s)', $function, implode(', ', $queryParameters)); if ($returnsGeometry) { $query = sprintf(' SELECT CASE WHEN ST_IsEmpty(g) THEN ST_AsText(g) ELSE NULL END, CASE WHEN ST_IsEmpty(g) THEN NULL ELSE ST_AsBinary(g) END, ST_GeometryType(g), ST_SRID(g) FROM (%s AS g) AS q ', $query); } return $this->executeQuery($query, $parameters); }
php
private function query(string $function, array $parameters, bool $returnsGeometry) : array { $queryParameters = []; foreach ($parameters as $parameter) { if ($parameter instanceof Geometry) { if ($parameter->isEmpty()) { $queryParameters[] = 'ST_GeomFromText(?, ?)'; } else { $queryParameters[] = 'ST_GeomFromWKB(?, ?)'; } } else { $queryParameters[] = '?'; } } $query = sprintf('SELECT %s(%s)', $function, implode(', ', $queryParameters)); if ($returnsGeometry) { $query = sprintf(' SELECT CASE WHEN ST_IsEmpty(g) THEN ST_AsText(g) ELSE NULL END, CASE WHEN ST_IsEmpty(g) THEN NULL ELSE ST_AsBinary(g) END, ST_GeometryType(g), ST_SRID(g) FROM (%s AS g) AS q ', $query); } return $this->executeQuery($query, $parameters); }
[ "private", "function", "query", "(", "string", "$", "function", ",", "array", "$", "parameters", ",", "bool", "$", "returnsGeometry", ")", ":", "array", "{", "$", "queryParameters", "=", "[", "]", ";", "foreach", "(", "$", "parameters", "as", "$", "param...
Builds and executes a SQL query for a GIS function. @param string $function The SQL GIS function to execute. @param array $parameters The Geometry objects or scalar values to pass as parameters. @param bool $returnsGeometry Whether the GIS function returns a Geometry. @return array A numeric result array. @throws GeometryEngineException
[ "Builds", "and", "executes", "a", "SQL", "query", "for", "a", "GIS", "function", "." ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Engine/DatabaseEngine.php#L46-L76
brick/geo
src/Engine/DatabaseEngine.php
DatabaseEngine.queryBoolean
private function queryBoolean(string $function, ...$parameters) : bool { [$result] = $this->query($function, $parameters, false); if ($result === null || $result === -1) { // SQLite3 returns -1 when calling a boolean GIS function on a NULL result. throw GeometryEngineException::operationYieldedNoResult(); } return (bool) $result; }
php
private function queryBoolean(string $function, ...$parameters) : bool { [$result] = $this->query($function, $parameters, false); if ($result === null || $result === -1) { // SQLite3 returns -1 when calling a boolean GIS function on a NULL result. throw GeometryEngineException::operationYieldedNoResult(); } return (bool) $result; }
[ "private", "function", "queryBoolean", "(", "string", "$", "function", ",", "...", "$", "parameters", ")", ":", "bool", "{", "[", "$", "result", "]", "=", "$", "this", "->", "query", "(", "$", "function", ",", "$", "parameters", ",", "false", ")", ";...
Queries a GIS function returning a boolean value. @param string $function The SQL GIS function to execute. @param mixed ...$parameters The Geometry objects or scalar values to pass as parameters. @return bool @throws GeometryEngineException
[ "Queries", "a", "GIS", "function", "returning", "a", "boolean", "value", "." ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Engine/DatabaseEngine.php#L88-L97
brick/geo
src/Engine/DatabaseEngine.php
DatabaseEngine.queryFloat
private function queryFloat(string $function, ...$parameters) : float { [$result] = $this->query($function, $parameters, false); if ($result === null) { throw GeometryEngineException::operationYieldedNoResult(); } return (float) $result; }
php
private function queryFloat(string $function, ...$parameters) : float { [$result] = $this->query($function, $parameters, false); if ($result === null) { throw GeometryEngineException::operationYieldedNoResult(); } return (float) $result; }
[ "private", "function", "queryFloat", "(", "string", "$", "function", ",", "...", "$", "parameters", ")", ":", "float", "{", "[", "$", "result", "]", "=", "$", "this", "->", "query", "(", "$", "function", ",", "$", "parameters", ",", "false", ")", ";"...
Queries a GIS function returning a floating point value. @param string $function The SQL GIS function to execute. @param mixed ...$parameters The Geometry objects or scalar values to pass as parameters. @return float @throws GeometryEngineException
[ "Queries", "a", "GIS", "function", "returning", "a", "floating", "point", "value", "." ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Engine/DatabaseEngine.php#L109-L118
brick/geo
src/Engine/DatabaseEngine.php
DatabaseEngine.queryGeometry
private function queryGeometry(string $function, ...$parameters) : Geometry { [$wkt, $wkb, $geometryType, $srid] = $this->query($function, $parameters, true); $srid = (int) $srid; if ($wkt !== null) { if ($this->useProxy) { $proxyClassName = $this->getProxyClassName($geometryType); return new $proxyClassName($wkt, false, $srid); } return Geometry::fromText($wkt, $srid); } if ($wkb !== null) { if (is_resource($wkb)) { $wkb = stream_get_contents($wkb); } if ($this->useProxy) { $proxyClassName = $this->getProxyClassName($geometryType); return new $proxyClassName($wkb, true, $srid); } return Geometry::fromBinary($wkb, $srid); } throw GeometryEngineException::operationYieldedNoResult(); }
php
private function queryGeometry(string $function, ...$parameters) : Geometry { [$wkt, $wkb, $geometryType, $srid] = $this->query($function, $parameters, true); $srid = (int) $srid; if ($wkt !== null) { if ($this->useProxy) { $proxyClassName = $this->getProxyClassName($geometryType); return new $proxyClassName($wkt, false, $srid); } return Geometry::fromText($wkt, $srid); } if ($wkb !== null) { if (is_resource($wkb)) { $wkb = stream_get_contents($wkb); } if ($this->useProxy) { $proxyClassName = $this->getProxyClassName($geometryType); return new $proxyClassName($wkb, true, $srid); } return Geometry::fromBinary($wkb, $srid); } throw GeometryEngineException::operationYieldedNoResult(); }
[ "private", "function", "queryGeometry", "(", "string", "$", "function", ",", "...", "$", "parameters", ")", ":", "Geometry", "{", "[", "$", "wkt", ",", "$", "wkb", ",", "$", "geometryType", ",", "$", "srid", "]", "=", "$", "this", "->", "query", "(",...
Queries a GIS function returning a Geometry object. @param string $function The SQL GIS function to execute. @param mixed ...$parameters The Geometry objects or scalar values to pass as parameters. @return Geometry @throws GeometryEngineException
[ "Queries", "a", "GIS", "function", "returning", "a", "Geometry", "object", "." ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Engine/DatabaseEngine.php#L130-L161
brick/geo
src/Engine/DatabaseEngine.php
DatabaseEngine.getProxyClassName
private function getProxyClassName(string $geometryType) : string { $proxyClasses = [ 'CIRCULARSTRING' => Proxy\CircularStringProxy::class, 'COMPOUNDCURVE' => Proxy\CompoundCurveProxy::class, 'CURVE' => Proxy\CurveProxy::class, 'CURVEPOLYGON' => Proxy\CurvePolygonProxy::class, 'GEOMETRY' => Proxy\GeometryProxy::class, 'GEOMETRYCOLLECTION' => Proxy\GeometryCollectionProxy::class, 'LINESTRING' => Proxy\LineStringProxy::class, 'MULTICURVE' => Proxy\MultiCurveProxy::class, 'MULTILINESTRING' => Proxy\MultiLineStringProxy::class, 'MULTIPOINT' => Proxy\MultiPointProxy::class, 'MULTIPOLYGON' => Proxy\MultiPolygonProxy::class, 'MULTISURFACE' => Proxy\MultiSurfaceProxy::class, 'POINT' => Proxy\PointProxy::class, 'POLYGON' => Proxy\PolygonProxy::class, 'POLYHEDRALSURFACE' => Proxy\PolyhedralSurfaceProxy::class, 'SURFACE' => Proxy\SurfaceProxy::class, 'TIN' => Proxy\TINProxy::class, 'TRIANGLE' => Proxy\TriangleProxy::class ]; $geometryType = strtoupper($geometryType); $geometryType = preg_replace('/^ST_/', '', $geometryType); $geometryType = preg_replace('/ .*/', '', $geometryType); if (! isset($proxyClasses[$geometryType])) { throw new GeometryEngineException('Unknown geometry type: ' . $geometryType); } return $proxyClasses[$geometryType]; }
php
private function getProxyClassName(string $geometryType) : string { $proxyClasses = [ 'CIRCULARSTRING' => Proxy\CircularStringProxy::class, 'COMPOUNDCURVE' => Proxy\CompoundCurveProxy::class, 'CURVE' => Proxy\CurveProxy::class, 'CURVEPOLYGON' => Proxy\CurvePolygonProxy::class, 'GEOMETRY' => Proxy\GeometryProxy::class, 'GEOMETRYCOLLECTION' => Proxy\GeometryCollectionProxy::class, 'LINESTRING' => Proxy\LineStringProxy::class, 'MULTICURVE' => Proxy\MultiCurveProxy::class, 'MULTILINESTRING' => Proxy\MultiLineStringProxy::class, 'MULTIPOINT' => Proxy\MultiPointProxy::class, 'MULTIPOLYGON' => Proxy\MultiPolygonProxy::class, 'MULTISURFACE' => Proxy\MultiSurfaceProxy::class, 'POINT' => Proxy\PointProxy::class, 'POLYGON' => Proxy\PolygonProxy::class, 'POLYHEDRALSURFACE' => Proxy\PolyhedralSurfaceProxy::class, 'SURFACE' => Proxy\SurfaceProxy::class, 'TIN' => Proxy\TINProxy::class, 'TRIANGLE' => Proxy\TriangleProxy::class ]; $geometryType = strtoupper($geometryType); $geometryType = preg_replace('/^ST_/', '', $geometryType); $geometryType = preg_replace('/ .*/', '', $geometryType); if (! isset($proxyClasses[$geometryType])) { throw new GeometryEngineException('Unknown geometry type: ' . $geometryType); } return $proxyClasses[$geometryType]; }
[ "private", "function", "getProxyClassName", "(", "string", "$", "geometryType", ")", ":", "string", "{", "$", "proxyClasses", "=", "[", "'CIRCULARSTRING'", "=>", "Proxy", "\\", "CircularStringProxy", "::", "class", ",", "'COMPOUNDCURVE'", "=>", "Proxy", "\\", "C...
@param string $geometryType @return string @throws GeometryEngineException
[ "@param", "string", "$geometryType" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Engine/DatabaseEngine.php#L170-L202
brick/geo
src/Engine/DatabaseEngine.php
DatabaseEngine.contains
public function contains(Geometry $a, Geometry $b) : bool { return $this->queryBoolean('ST_Contains', $a, $b); }
php
public function contains(Geometry $a, Geometry $b) : bool { return $this->queryBoolean('ST_Contains', $a, $b); }
[ "public", "function", "contains", "(", "Geometry", "$", "a", ",", "Geometry", "$", "b", ")", ":", "bool", "{", "return", "$", "this", "->", "queryBoolean", "(", "'ST_Contains'", ",", "$", "a", ",", "$", "b", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Engine/DatabaseEngine.php#L207-L210
brick/geo
src/Engine/DatabaseEngine.php
DatabaseEngine.intersects
public function intersects(Geometry $a, Geometry $b) : bool { return $this->queryBoolean('ST_Intersects', $a, $b); }
php
public function intersects(Geometry $a, Geometry $b) : bool { return $this->queryBoolean('ST_Intersects', $a, $b); }
[ "public", "function", "intersects", "(", "Geometry", "$", "a", ",", "Geometry", "$", "b", ")", ":", "bool", "{", "return", "$", "this", "->", "queryBoolean", "(", "'ST_Intersects'", ",", "$", "a", ",", "$", "b", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Engine/DatabaseEngine.php#L215-L218
brick/geo
src/Engine/DatabaseEngine.php
DatabaseEngine.union
public function union(Geometry $a, Geometry $b) : Geometry { return $this->queryGeometry('ST_Union', $a, $b); }
php
public function union(Geometry $a, Geometry $b) : Geometry { return $this->queryGeometry('ST_Union', $a, $b); }
[ "public", "function", "union", "(", "Geometry", "$", "a", ",", "Geometry", "$", "b", ")", ":", "Geometry", "{", "return", "$", "this", "->", "queryGeometry", "(", "'ST_Union'", ",", "$", "a", ",", "$", "b", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Engine/DatabaseEngine.php#L223-L226
brick/geo
src/Engine/DatabaseEngine.php
DatabaseEngine.intersection
public function intersection(Geometry $a, Geometry $b) : Geometry { return $this->queryGeometry('ST_Intersection', $a, $b); }
php
public function intersection(Geometry $a, Geometry $b) : Geometry { return $this->queryGeometry('ST_Intersection', $a, $b); }
[ "public", "function", "intersection", "(", "Geometry", "$", "a", ",", "Geometry", "$", "b", ")", ":", "Geometry", "{", "return", "$", "this", "->", "queryGeometry", "(", "'ST_Intersection'", ",", "$", "a", ",", "$", "b", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Engine/DatabaseEngine.php#L231-L234
brick/geo
src/Engine/DatabaseEngine.php
DatabaseEngine.difference
public function difference(Geometry $a, Geometry $b) : Geometry { return $this->queryGeometry('ST_Difference', $a, $b); }
php
public function difference(Geometry $a, Geometry $b) : Geometry { return $this->queryGeometry('ST_Difference', $a, $b); }
[ "public", "function", "difference", "(", "Geometry", "$", "a", ",", "Geometry", "$", "b", ")", ":", "Geometry", "{", "return", "$", "this", "->", "queryGeometry", "(", "'ST_Difference'", ",", "$", "a", ",", "$", "b", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Engine/DatabaseEngine.php#L239-L242
brick/geo
src/Engine/DatabaseEngine.php
DatabaseEngine.equals
public function equals(Geometry $a, Geometry $b) : bool { return $this->queryBoolean('ST_Equals', $a, $b); }
php
public function equals(Geometry $a, Geometry $b) : bool { return $this->queryBoolean('ST_Equals', $a, $b); }
[ "public", "function", "equals", "(", "Geometry", "$", "a", ",", "Geometry", "$", "b", ")", ":", "bool", "{", "return", "$", "this", "->", "queryBoolean", "(", "'ST_Equals'", ",", "$", "a", ",", "$", "b", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Engine/DatabaseEngine.php#L319-L322
brick/geo
src/Engine/DatabaseEngine.php
DatabaseEngine.disjoint
public function disjoint(Geometry $a, Geometry $b) : bool { return $this->queryBoolean('ST_Disjoint', $a, $b); }
php
public function disjoint(Geometry $a, Geometry $b) : bool { return $this->queryBoolean('ST_Disjoint', $a, $b); }
[ "public", "function", "disjoint", "(", "Geometry", "$", "a", ",", "Geometry", "$", "b", ")", ":", "bool", "{", "return", "$", "this", "->", "queryBoolean", "(", "'ST_Disjoint'", ",", "$", "a", ",", "$", "b", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Engine/DatabaseEngine.php#L327-L330
brick/geo
src/Engine/DatabaseEngine.php
DatabaseEngine.touches
public function touches(Geometry $a, Geometry $b) : bool { return $this->queryBoolean('ST_Touches', $a, $b); }
php
public function touches(Geometry $a, Geometry $b) : bool { return $this->queryBoolean('ST_Touches', $a, $b); }
[ "public", "function", "touches", "(", "Geometry", "$", "a", ",", "Geometry", "$", "b", ")", ":", "bool", "{", "return", "$", "this", "->", "queryBoolean", "(", "'ST_Touches'", ",", "$", "a", ",", "$", "b", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Engine/DatabaseEngine.php#L335-L338
brick/geo
src/Engine/DatabaseEngine.php
DatabaseEngine.crosses
public function crosses(Geometry $a, Geometry $b) : bool { return $this->queryBoolean('ST_Crosses', $a, $b); }
php
public function crosses(Geometry $a, Geometry $b) : bool { return $this->queryBoolean('ST_Crosses', $a, $b); }
[ "public", "function", "crosses", "(", "Geometry", "$", "a", ",", "Geometry", "$", "b", ")", ":", "bool", "{", "return", "$", "this", "->", "queryBoolean", "(", "'ST_Crosses'", ",", "$", "a", ",", "$", "b", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Engine/DatabaseEngine.php#L343-L346
brick/geo
src/Engine/DatabaseEngine.php
DatabaseEngine.within
public function within(Geometry $a, Geometry $b) : bool { return $this->queryBoolean('ST_Within', $a, $b); }
php
public function within(Geometry $a, Geometry $b) : bool { return $this->queryBoolean('ST_Within', $a, $b); }
[ "public", "function", "within", "(", "Geometry", "$", "a", ",", "Geometry", "$", "b", ")", ":", "bool", "{", "return", "$", "this", "->", "queryBoolean", "(", "'ST_Within'", ",", "$", "a", ",", "$", "b", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Engine/DatabaseEngine.php#L351-L354
brick/geo
src/Engine/DatabaseEngine.php
DatabaseEngine.overlaps
public function overlaps(Geometry $a, Geometry $b) : bool { return $this->queryBoolean('ST_Overlaps', $a, $b); }
php
public function overlaps(Geometry $a, Geometry $b) : bool { return $this->queryBoolean('ST_Overlaps', $a, $b); }
[ "public", "function", "overlaps", "(", "Geometry", "$", "a", ",", "Geometry", "$", "b", ")", ":", "bool", "{", "return", "$", "this", "->", "queryBoolean", "(", "'ST_Overlaps'", ",", "$", "a", ",", "$", "b", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Engine/DatabaseEngine.php#L359-L362
brick/geo
src/Engine/DatabaseEngine.php
DatabaseEngine.relate
public function relate(Geometry $a, Geometry $b, string $matrix) : bool { return $this->queryBoolean('ST_Relate', $a, $b, $matrix); }
php
public function relate(Geometry $a, Geometry $b, string $matrix) : bool { return $this->queryBoolean('ST_Relate', $a, $b, $matrix); }
[ "public", "function", "relate", "(", "Geometry", "$", "a", ",", "Geometry", "$", "b", ",", "string", "$", "matrix", ")", ":", "bool", "{", "return", "$", "this", "->", "queryBoolean", "(", "'ST_Relate'", ",", "$", "a", ",", "$", "b", ",", "$", "mat...
{@inheritdoc}
[ "{" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Engine/DatabaseEngine.php#L367-L370
brick/geo
src/Engine/DatabaseEngine.php
DatabaseEngine.locateAlong
public function locateAlong(Geometry $g, float $mValue) : Geometry { return $this->queryGeometry('ST_LocateAlong', $g, $mValue); }
php
public function locateAlong(Geometry $g, float $mValue) : Geometry { return $this->queryGeometry('ST_LocateAlong', $g, $mValue); }
[ "public", "function", "locateAlong", "(", "Geometry", "$", "g", ",", "float", "$", "mValue", ")", ":", "Geometry", "{", "return", "$", "this", "->", "queryGeometry", "(", "'ST_LocateAlong'", ",", "$", "g", ",", "$", "mValue", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Engine/DatabaseEngine.php#L375-L378
brick/geo
src/Engine/DatabaseEngine.php
DatabaseEngine.locateBetween
public function locateBetween(Geometry $g, float $mStart, float $mEnd) : Geometry { return $this->queryGeometry('ST_LocateBetween', $g, $mStart, $mEnd); }
php
public function locateBetween(Geometry $g, float $mStart, float $mEnd) : Geometry { return $this->queryGeometry('ST_LocateBetween', $g, $mStart, $mEnd); }
[ "public", "function", "locateBetween", "(", "Geometry", "$", "g", ",", "float", "$", "mStart", ",", "float", "$", "mEnd", ")", ":", "Geometry", "{", "return", "$", "this", "->", "queryGeometry", "(", "'ST_LocateBetween'", ",", "$", "g", ",", "$", "mStart...
{@inheritdoc}
[ "{" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Engine/DatabaseEngine.php#L383-L386
brick/geo
src/Engine/DatabaseEngine.php
DatabaseEngine.distance
public function distance(Geometry $a, Geometry $b) : float { return $this->queryFloat('ST_Distance', $a, $b); }
php
public function distance(Geometry $a, Geometry $b) : float { return $this->queryFloat('ST_Distance', $a, $b); }
[ "public", "function", "distance", "(", "Geometry", "$", "a", ",", "Geometry", "$", "b", ")", ":", "float", "{", "return", "$", "this", "->", "queryFloat", "(", "'ST_Distance'", ",", "$", "a", ",", "$", "b", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Engine/DatabaseEngine.php#L391-L394
brick/geo
src/Engine/DatabaseEngine.php
DatabaseEngine.buffer
public function buffer(Geometry $g, float $distance) : Geometry { return $this->queryGeometry('ST_Buffer', $g, $distance); }
php
public function buffer(Geometry $g, float $distance) : Geometry { return $this->queryGeometry('ST_Buffer', $g, $distance); }
[ "public", "function", "buffer", "(", "Geometry", "$", "g", ",", "float", "$", "distance", ")", ":", "Geometry", "{", "return", "$", "this", "->", "queryGeometry", "(", "'ST_Buffer'", ",", "$", "g", ",", "$", "distance", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Engine/DatabaseEngine.php#L399-L402
brick/geo
src/Engine/DatabaseEngine.php
DatabaseEngine.symDifference
public function symDifference(Geometry $a, Geometry $b) : Geometry { return $this->queryGeometry('ST_SymDifference', $a, $b); }
php
public function symDifference(Geometry $a, Geometry $b) : Geometry { return $this->queryGeometry('ST_SymDifference', $a, $b); }
[ "public", "function", "symDifference", "(", "Geometry", "$", "a", ",", "Geometry", "$", "b", ")", ":", "Geometry", "{", "return", "$", "this", "->", "queryGeometry", "(", "'ST_SymDifference'", ",", "$", "a", ",", "$", "b", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Engine/DatabaseEngine.php#L415-L418
brick/geo
src/Engine/DatabaseEngine.php
DatabaseEngine.snapToGrid
public function snapToGrid(Geometry $g, float $size) : Geometry { return $this->queryGeometry('ST_SnapToGrid', $g, $size); }
php
public function snapToGrid(Geometry $g, float $size) : Geometry { return $this->queryGeometry('ST_SnapToGrid', $g, $size); }
[ "public", "function", "snapToGrid", "(", "Geometry", "$", "g", ",", "float", "$", "size", ")", ":", "Geometry", "{", "return", "$", "this", "->", "queryGeometry", "(", "'ST_SnapToGrid'", ",", "$", "g", ",", "$", "size", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Engine/DatabaseEngine.php#L423-L426
brick/geo
src/Engine/DatabaseEngine.php
DatabaseEngine.simplify
public function simplify(Geometry $g, float $tolerance) : Geometry { return $this->queryGeometry('ST_Simplify', $g, $tolerance); }
php
public function simplify(Geometry $g, float $tolerance) : Geometry { return $this->queryGeometry('ST_Simplify', $g, $tolerance); }
[ "public", "function", "simplify", "(", "Geometry", "$", "g", ",", "float", "$", "tolerance", ")", ":", "Geometry", "{", "return", "$", "this", "->", "queryGeometry", "(", "'ST_Simplify'", ",", "$", "g", ",", "$", "tolerance", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Engine/DatabaseEngine.php#L431-L434
brick/geo
src/Engine/DatabaseEngine.php
DatabaseEngine.maxDistance
public function maxDistance(Geometry $a, Geometry $b) : float { return $this->queryFloat('ST_MaxDistance', $a, $b); }
php
public function maxDistance(Geometry $a, Geometry $b) : float { return $this->queryFloat('ST_MaxDistance', $a, $b); }
[ "public", "function", "maxDistance", "(", "Geometry", "$", "a", ",", "Geometry", "$", "b", ")", ":", "float", "{", "return", "$", "this", "->", "queryFloat", "(", "'ST_MaxDistance'", ",", "$", "a", ",", "$", "b", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Engine/DatabaseEngine.php#L439-L442
brick/geo
src/CircularString.php
CircularString.of
public static function of(Point $point1, Point ...$pointN) : CircularString { return new CircularString($point1->coordinateSystem(), $point1, ...$pointN); }
php
public static function of(Point $point1, Point ...$pointN) : CircularString { return new CircularString($point1->coordinateSystem(), $point1, ...$pointN); }
[ "public", "static", "function", "of", "(", "Point", "$", "point1", ",", "Point", "...", "$", "pointN", ")", ":", "CircularString", "{", "return", "new", "CircularString", "(", "$", "point1", "->", "coordinateSystem", "(", ")", ",", "$", "point1", ",", "....
Creates a non-empty CircularString composed of the given points. @param Point $point1 The first point. @param Point ...$pointN The subsequent points. @return CircularString @throws InvalidGeometryException If the number of points is invalid. @throws CoordinateSystemException If the points use different coordinate systems.
[ "Creates", "a", "non", "-", "empty", "CircularString", "composed", "of", "the", "given", "points", "." ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/CircularString.php#L70-L73
brick/geo
src/CircularString.php
CircularString.pointN
public function pointN(int $n) : Point { if (! isset($this->points[$n - 1])) { throw new NoSuchGeometryException('There is no Point in this CircularString at index ' . $n); } return $this->points[$n - 1]; }
php
public function pointN(int $n) : Point { if (! isset($this->points[$n - 1])) { throw new NoSuchGeometryException('There is no Point in this CircularString at index ' . $n); } return $this->points[$n - 1]; }
[ "public", "function", "pointN", "(", "int", "$", "n", ")", ":", "Point", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "points", "[", "$", "n", "-", "1", "]", ")", ")", "{", "throw", "new", "NoSuchGeometryException", "(", "'There is no Point ...
Returns the specified Point N in this CircularString. @param int $n The point number, 1-based. @return Point @throws NoSuchGeometryException If there is no Point at this index.
[ "Returns", "the", "specified", "Point", "N", "in", "this", "CircularString", "." ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/CircularString.php#L118-L125
brick/geo
src/CircularString.php
CircularString.toArray
public function toArray() : array { $result = []; foreach ($this->points as $point) { $result[] = $point->toArray(); } return $result; }
php
public function toArray() : array { $result = []; foreach ($this->points as $point) { $result[] = $point->toArray(); } return $result; }
[ "public", "function", "toArray", "(", ")", ":", "array", "{", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "points", "as", "$", "point", ")", "{", "$", "result", "[", "]", "=", "$", "point", "->", "toArray", "(", ")", "...
{@inheritdoc}
[ "{" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/CircularString.php#L160-L169
brick/geo
src/GeometryCollection.php
GeometryCollection.of
public static function of(Geometry $geometry1, Geometry ...$geometryN) : GeometryCollection { return new static($geometry1->coordinateSystem(), $geometry1, ...$geometryN); }
php
public static function of(Geometry $geometry1, Geometry ...$geometryN) : GeometryCollection { return new static($geometry1->coordinateSystem(), $geometry1, ...$geometryN); }
[ "public", "static", "function", "of", "(", "Geometry", "$", "geometry1", ",", "Geometry", "...", "$", "geometryN", ")", ":", "GeometryCollection", "{", "return", "new", "static", "(", "$", "geometry1", "->", "coordinateSystem", "(", ")", ",", "$", "geometry1...
Creates a non-empty GeometryCollection composed of the given geometries. @param Geometry $geometry1 The first geometry. @param Geometry ...$geometryN The subsequent geometries, if any. @return static @throws CoordinateSystemException If the geometries use different coordinate systems. @throws UnexpectedGeometryException If a geometry is not a valid type for a sub-class of GeometryCollection.
[ "Creates", "a", "non", "-", "empty", "GeometryCollection", "composed", "of", "the", "given", "geometries", "." ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/GeometryCollection.php#L91-L94
brick/geo
src/GeometryCollection.php
GeometryCollection.geometryN
public function geometryN(int $n) : Geometry { if (! isset($this->geometries[$n - 1])) { throw new NoSuchGeometryException('There is no Geometry in this GeometryCollection at index ' . $n); } return $this->geometries[$n - 1]; }
php
public function geometryN(int $n) : Geometry { if (! isset($this->geometries[$n - 1])) { throw new NoSuchGeometryException('There is no Geometry in this GeometryCollection at index ' . $n); } return $this->geometries[$n - 1]; }
[ "public", "function", "geometryN", "(", "int", "$", "n", ")", ":", "Geometry", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "geometries", "[", "$", "n", "-", "1", "]", ")", ")", "{", "throw", "new", "NoSuchGeometryException", "(", "'There is...
Returns the specified geometry N in this GeometryCollection. @param int $n The geometry number, 1-based. @return Geometry @throws NoSuchGeometryException If there is no Geometry at this index.
[ "Returns", "the", "specified", "geometry", "N", "in", "this", "GeometryCollection", "." ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/GeometryCollection.php#L115-L122
brick/geo
src/GeometryCollection.php
GeometryCollection.dimension
public function dimension() : int { $dimension = 0; foreach ($this->geometries as $geometry) { $dim = $geometry->dimension(); if ($dim > $dimension) { $dimension = $dim; } } return $dimension; }
php
public function dimension() : int { $dimension = 0; foreach ($this->geometries as $geometry) { $dim = $geometry->dimension(); if ($dim > $dimension) { $dimension = $dim; } } return $dimension; }
[ "public", "function", "dimension", "(", ")", ":", "int", "{", "$", "dimension", "=", "0", ";", "foreach", "(", "$", "this", "->", "geometries", "as", "$", "geometry", ")", "{", "$", "dim", "=", "$", "geometry", "->", "dimension", "(", ")", ";", "if...
{@inheritdoc}
[ "{" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/GeometryCollection.php#L157-L170
brick/geo
src/GeometryCollection.php
GeometryCollection.toArray
public function toArray() : array { $result = []; foreach ($this->geometries as $geometry) { $result[] = $geometry->toArray(); } return $result; }
php
public function toArray() : array { $result = []; foreach ($this->geometries as $geometry) { $result[] = $geometry->toArray(); } return $result; }
[ "public", "function", "toArray", "(", ")", ":", "array", "{", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "geometries", "as", "$", "geometry", ")", "{", "$", "result", "[", "]", "=", "$", "geometry", "->", "toArray", "(", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/GeometryCollection.php#L175-L184
brick/geo
src/Engine/SQLite3Engine.php
SQLite3Engine.executeQuery
protected function executeQuery(string $query, array $parameters) : array { if (isset($this->statements[$query])) { $statement = $this->statements[$query]; $statement->reset(); } else { // Temporary set the error reporting level to 0 to avoid any warning. $errorReportingLevel = error_reporting(0); $statement = $this->sqlite3->prepare($query); // Restore the original error reporting level. error_reporting($errorReportingLevel); $errorCode = $this->sqlite3->lastErrorCode(); if ($errorCode !== 0) { $exception = new SQLite3Exception($this->sqlite3->lastErrorMsg(), $errorCode); if ($errorCode === 1) { // SQL error cause by a missing function, this must be reported with a GeometryEngineException. throw GeometryEngineException::operationNotSupportedByEngine($exception); } else { // Other SQLite3 error; we cannot trigger the original E_WARNING, so we throw this exception instead. throw $exception; } } else { $this->statements[$query] = $statement; } } $index = 1; foreach ($parameters as $parameter) { if ($parameter instanceof Geometry) { if ($parameter->isEmpty()) { $statement->bindValue($index++, $parameter->asText(), SQLITE3_TEXT); $statement->bindValue($index++, $parameter->SRID(), SQLITE3_INTEGER); } else { $statement->bindValue($index++, $parameter->asBinary(), SQLITE3_BLOB); $statement->bindValue($index++, $parameter->SRID(), SQLITE3_INTEGER); } } else { if ($parameter === null) { $type = SQLITE3_NULL; } elseif (is_int($parameter)) { $type = SQLITE3_INTEGER; } elseif (is_float($parameter)) { $type = SQLITE3_FLOAT; } else { $type = SQLITE3_TEXT; } $statement->bindValue($index++, $parameter, $type); } } $result = $statement->execute(); return $result->fetchArray(SQLITE3_NUM); }
php
protected function executeQuery(string $query, array $parameters) : array { if (isset($this->statements[$query])) { $statement = $this->statements[$query]; $statement->reset(); } else { // Temporary set the error reporting level to 0 to avoid any warning. $errorReportingLevel = error_reporting(0); $statement = $this->sqlite3->prepare($query); // Restore the original error reporting level. error_reporting($errorReportingLevel); $errorCode = $this->sqlite3->lastErrorCode(); if ($errorCode !== 0) { $exception = new SQLite3Exception($this->sqlite3->lastErrorMsg(), $errorCode); if ($errorCode === 1) { // SQL error cause by a missing function, this must be reported with a GeometryEngineException. throw GeometryEngineException::operationNotSupportedByEngine($exception); } else { // Other SQLite3 error; we cannot trigger the original E_WARNING, so we throw this exception instead. throw $exception; } } else { $this->statements[$query] = $statement; } } $index = 1; foreach ($parameters as $parameter) { if ($parameter instanceof Geometry) { if ($parameter->isEmpty()) { $statement->bindValue($index++, $parameter->asText(), SQLITE3_TEXT); $statement->bindValue($index++, $parameter->SRID(), SQLITE3_INTEGER); } else { $statement->bindValue($index++, $parameter->asBinary(), SQLITE3_BLOB); $statement->bindValue($index++, $parameter->SRID(), SQLITE3_INTEGER); } } else { if ($parameter === null) { $type = SQLITE3_NULL; } elseif (is_int($parameter)) { $type = SQLITE3_INTEGER; } elseif (is_float($parameter)) { $type = SQLITE3_FLOAT; } else { $type = SQLITE3_TEXT; } $statement->bindValue($index++, $parameter, $type); } } $result = $statement->execute(); return $result->fetchArray(SQLITE3_NUM); }
[ "protected", "function", "executeQuery", "(", "string", "$", "query", ",", "array", "$", "parameters", ")", ":", "array", "{", "if", "(", "isset", "(", "$", "this", "->", "statements", "[", "$", "query", "]", ")", ")", "{", "$", "statement", "=", "$"...
{@inheritdoc}
[ "{" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Engine/SQLite3Engine.php#L53-L113
brick/geo
src/CoordinateSystem.php
CoordinateSystem.coordinateName
public function coordinateName() : string { $name = 'XY'; if ($this->hasZ) { $name .= 'Z'; } if ($this->hasM) { $name .= 'M'; } return $name; }
php
public function coordinateName() : string { $name = 'XY'; if ($this->hasZ) { $name .= 'Z'; } if ($this->hasM) { $name .= 'M'; } return $name; }
[ "public", "function", "coordinateName", "(", ")", ":", "string", "{", "$", "name", "=", "'XY'", ";", "if", "(", "$", "this", "->", "hasZ", ")", "{", "$", "name", ".=", "'Z'", ";", "}", "if", "(", "$", "this", "->", "hasM", ")", "{", "$", "name"...
Returns a name for the coordinates in this system, such as XY or XYZ. @return string
[ "Returns", "a", "name", "for", "the", "coordinates", "in", "this", "system", "such", "as", "XY", "or", "XYZ", "." ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/CoordinateSystem.php#L134-L147
brick/geo
src/CoordinateSystem.php
CoordinateSystem.coordinateDimension
public function coordinateDimension() : int { $coordinateDimension = 2; if ($this->hasZ) { $coordinateDimension++; } if ($this->hasM) { $coordinateDimension++; } return $coordinateDimension; }
php
public function coordinateDimension() : int { $coordinateDimension = 2; if ($this->hasZ) { $coordinateDimension++; } if ($this->hasM) { $coordinateDimension++; } return $coordinateDimension; }
[ "public", "function", "coordinateDimension", "(", ")", ":", "int", "{", "$", "coordinateDimension", "=", "2", ";", "if", "(", "$", "this", "->", "hasZ", ")", "{", "$", "coordinateDimension", "++", ";", "}", "if", "(", "$", "this", "->", "hasM", ")", ...
Returns the coordinate dimension of this coordinate system. The coordinate dimension is the total number of coordinates in the coordinate system. @return int 2 for (X,Y), 3 for (X,Y,Z) and (X,Y,M), 4 for (X,Y,Z,M).
[ "Returns", "the", "coordinate", "dimension", "of", "this", "coordinate", "system", "." ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/CoordinateSystem.php#L156-L169
brick/geo
src/CoordinateSystem.php
CoordinateSystem.withSRID
public function withSRID(int $srid) : CoordinateSystem { if ($srid === $this->srid) { return $this; } $that = clone $this; $that->srid = $srid; return $that; }
php
public function withSRID(int $srid) : CoordinateSystem { if ($srid === $this->srid) { return $this; } $that = clone $this; $that->srid = $srid; return $that; }
[ "public", "function", "withSRID", "(", "int", "$", "srid", ")", ":", "CoordinateSystem", "{", "if", "(", "$", "srid", "===", "$", "this", "->", "srid", ")", "{", "return", "$", "this", ";", "}", "$", "that", "=", "clone", "$", "this", ";", "$", "...
Returns a copy of this CoordinateSystem with the SRID altered. @param int $srid @return CoordinateSystem
[ "Returns", "a", "copy", "of", "this", "CoordinateSystem", "with", "the", "SRID", "altered", "." ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/CoordinateSystem.php#L190-L200
brick/geo
src/CoordinateSystem.php
CoordinateSystem.check
public static function check(Geometry $reference, Geometry ...$geometries) : void { $referenceCS = $reference->coordinateSystem(); foreach ($geometries as $geometry) { $geometryCS = $geometry->coordinateSystem(); if ($geometryCS == $referenceCS) { // by-value comparison. continue; } if ($geometryCS->srid !== $referenceCS->srid) { throw CoordinateSystemException::sridMix($reference, $geometry); } throw CoordinateSystemException::dimensionalityMix($reference, $geometry); } }
php
public static function check(Geometry $reference, Geometry ...$geometries) : void { $referenceCS = $reference->coordinateSystem(); foreach ($geometries as $geometry) { $geometryCS = $geometry->coordinateSystem(); if ($geometryCS == $referenceCS) { // by-value comparison. continue; } if ($geometryCS->srid !== $referenceCS->srid) { throw CoordinateSystemException::sridMix($reference, $geometry); } throw CoordinateSystemException::dimensionalityMix($reference, $geometry); } }
[ "public", "static", "function", "check", "(", "Geometry", "$", "reference", ",", "Geometry", "...", "$", "geometries", ")", ":", "void", "{", "$", "referenceCS", "=", "$", "reference", "->", "coordinateSystem", "(", ")", ";", "foreach", "(", "$", "geometri...
@param Geometry $reference The geometry holding the reference coordinate system. @param Geometry ...$geometries The geometries to check against this coordinate system. @return void @throws CoordinateSystemException If the coordinate systems differ.
[ "@param", "Geometry", "$reference", "The", "geometry", "holding", "the", "reference", "coordinate", "system", ".", "@param", "Geometry", "...", "$geometries", "The", "geometries", "to", "check", "against", "this", "coordinate", "system", "." ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/CoordinateSystem.php#L210-L227
brick/geo
src/IO/AbstractWKTReader.php
AbstractWKTReader.readGeometry
protected function readGeometry(WKTParser $parser, int $srid) : Geometry { $geometryType = $parser->getNextWord(); $word = $parser->getOptionalNextWord(); $hasZ = false; $hasM = false; $isEmpty = false; if ($word !== null) { if ($word === 'Z') { $hasZ = true; } elseif ($word === 'M') { $hasM = true; } elseif ($word === 'ZM') { $hasZ = true; $hasM = true; } elseif ($word === 'EMPTY') { $isEmpty = true; } else { throw new GeometryIOException('Unexpected word in WKT: ' . $word); } if (! $isEmpty) { $word = $parser->getOptionalNextWord(); if ($word === 'EMPTY') { $isEmpty = true; } elseif ($word !== null) { throw new GeometryIOException('Unexpected word in WKT: ' . $word); } } } $cs = new CoordinateSystem($hasZ, $hasM, $srid); switch ($geometryType) { case 'POINT': if ($isEmpty) { return new Point($cs); } return $this->readPointText($parser, $cs); case 'LINESTRING': if ($isEmpty) { return new LineString($cs); } return $this->readLineStringText($parser, $cs); case 'CIRCULARSTRING': if ($isEmpty) { return new CircularString($cs); } return $this->readCircularStringText($parser, $cs); case 'COMPOUNDCURVE': if ($isEmpty) { return new CompoundCurve($cs); } return $this->readCompoundCurveText($parser, $cs); case 'POLYGON': if ($isEmpty) { return new Polygon($cs); } return $this->readPolygonText($parser, $cs); case 'CURVEPOLYGON': if ($isEmpty) { return new CurvePolygon($cs); } return $this->readCurvePolygonText($parser, $cs); case 'MULTIPOINT': if ($isEmpty) { return new MultiPoint($cs); } return $this->readMultiPointText($parser, $cs); case 'MULTILINESTRING': if ($isEmpty) { return new MultiLineString($cs); } return $this->readMultiLineStringText($parser, $cs); case 'MULTIPOLYGON': if ($isEmpty) { return new MultiPolygon($cs); } return $this->readMultiPolygonText($parser, $cs); case 'GEOMETRYCOLLECTION': if ($isEmpty) { return new GeometryCollection($cs); } return $this->readGeometryCollectionText($parser, $cs); case 'POLYHEDRALSURFACE': if ($isEmpty) { return new PolyhedralSurface($cs); } return $this->readPolyhedralSurfaceText($parser, $cs); case 'TIN': if ($isEmpty) { return new TIN($cs); } return $this->readTINText($parser, $cs); case 'TRIANGLE': if ($isEmpty) { return new Triangle($cs); } return $this->readTriangleText($parser, $cs); } throw new GeometryIOException('Unknown geometry type: ' . $geometryType); }
php
protected function readGeometry(WKTParser $parser, int $srid) : Geometry { $geometryType = $parser->getNextWord(); $word = $parser->getOptionalNextWord(); $hasZ = false; $hasM = false; $isEmpty = false; if ($word !== null) { if ($word === 'Z') { $hasZ = true; } elseif ($word === 'M') { $hasM = true; } elseif ($word === 'ZM') { $hasZ = true; $hasM = true; } elseif ($word === 'EMPTY') { $isEmpty = true; } else { throw new GeometryIOException('Unexpected word in WKT: ' . $word); } if (! $isEmpty) { $word = $parser->getOptionalNextWord(); if ($word === 'EMPTY') { $isEmpty = true; } elseif ($word !== null) { throw new GeometryIOException('Unexpected word in WKT: ' . $word); } } } $cs = new CoordinateSystem($hasZ, $hasM, $srid); switch ($geometryType) { case 'POINT': if ($isEmpty) { return new Point($cs); } return $this->readPointText($parser, $cs); case 'LINESTRING': if ($isEmpty) { return new LineString($cs); } return $this->readLineStringText($parser, $cs); case 'CIRCULARSTRING': if ($isEmpty) { return new CircularString($cs); } return $this->readCircularStringText($parser, $cs); case 'COMPOUNDCURVE': if ($isEmpty) { return new CompoundCurve($cs); } return $this->readCompoundCurveText($parser, $cs); case 'POLYGON': if ($isEmpty) { return new Polygon($cs); } return $this->readPolygonText($parser, $cs); case 'CURVEPOLYGON': if ($isEmpty) { return new CurvePolygon($cs); } return $this->readCurvePolygonText($parser, $cs); case 'MULTIPOINT': if ($isEmpty) { return new MultiPoint($cs); } return $this->readMultiPointText($parser, $cs); case 'MULTILINESTRING': if ($isEmpty) { return new MultiLineString($cs); } return $this->readMultiLineStringText($parser, $cs); case 'MULTIPOLYGON': if ($isEmpty) { return new MultiPolygon($cs); } return $this->readMultiPolygonText($parser, $cs); case 'GEOMETRYCOLLECTION': if ($isEmpty) { return new GeometryCollection($cs); } return $this->readGeometryCollectionText($parser, $cs); case 'POLYHEDRALSURFACE': if ($isEmpty) { return new PolyhedralSurface($cs); } return $this->readPolyhedralSurfaceText($parser, $cs); case 'TIN': if ($isEmpty) { return new TIN($cs); } return $this->readTINText($parser, $cs); case 'TRIANGLE': if ($isEmpty) { return new Triangle($cs); } return $this->readTriangleText($parser, $cs); } throw new GeometryIOException('Unknown geometry type: ' . $geometryType); }
[ "protected", "function", "readGeometry", "(", "WKTParser", "$", "parser", ",", "int", "$", "srid", ")", ":", "Geometry", "{", "$", "geometryType", "=", "$", "parser", "->", "getNextWord", "(", ")", ";", "$", "word", "=", "$", "parser", "->", "getOptional...
@param WKTParser $parser @param int $srid @return Geometry @throws GeometryIOException
[ "@param", "WKTParser", "$parser", "@param", "int", "$srid" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/AbstractWKTReader.php#L37-L167
brick/geo
src/IO/AbstractWKTReader.php
AbstractWKTReader.readPoint
private function readPoint(WKTParser $parser, CoordinateSystem $cs) : Point { $dim = $cs->coordinateDimension(); $coords = []; for ($i = 0; $i < $dim; $i++) { $coords[] = $parser->getNextNumber(); } return new Point($cs, ...$coords); }
php
private function readPoint(WKTParser $parser, CoordinateSystem $cs) : Point { $dim = $cs->coordinateDimension(); $coords = []; for ($i = 0; $i < $dim; $i++) { $coords[] = $parser->getNextNumber(); } return new Point($cs, ...$coords); }
[ "private", "function", "readPoint", "(", "WKTParser", "$", "parser", ",", "CoordinateSystem", "$", "cs", ")", ":", "Point", "{", "$", "dim", "=", "$", "cs", "->", "coordinateDimension", "(", ")", ";", "$", "coords", "=", "[", "]", ";", "for", "(", "$...
x y @param WKTParser $parser @param CoordinateSystem $cs @return Point
[ "x", "y" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/AbstractWKTReader.php#L177-L187
brick/geo
src/IO/AbstractWKTReader.php
AbstractWKTReader.readPointText
private function readPointText(WKTParser $parser, CoordinateSystem $cs) : Point { $parser->matchOpener(); $point = $this->readPoint($parser, $cs); $parser->matchCloser(); return $point; }
php
private function readPointText(WKTParser $parser, CoordinateSystem $cs) : Point { $parser->matchOpener(); $point = $this->readPoint($parser, $cs); $parser->matchCloser(); return $point; }
[ "private", "function", "readPointText", "(", "WKTParser", "$", "parser", ",", "CoordinateSystem", "$", "cs", ")", ":", "Point", "{", "$", "parser", "->", "matchOpener", "(", ")", ";", "$", "point", "=", "$", "this", "->", "readPoint", "(", "$", "parser",...
(x y) @param WKTParser $parser @param CoordinateSystem $cs @return Point
[ "(", "x", "y", ")" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/AbstractWKTReader.php#L197-L204
brick/geo
src/IO/AbstractWKTReader.php
AbstractWKTReader.readMultiPoint
private function readMultiPoint(WKTParser $parser, CoordinateSystem $cs) : array { $parser->matchOpener(); $points = []; do { $points[] = $this->readPoint($parser, $cs); $nextToken = $parser->getNextCloserOrComma(); } while ($nextToken === ','); return $points; }
php
private function readMultiPoint(WKTParser $parser, CoordinateSystem $cs) : array { $parser->matchOpener(); $points = []; do { $points[] = $this->readPoint($parser, $cs); $nextToken = $parser->getNextCloserOrComma(); } while ($nextToken === ','); return $points; }
[ "private", "function", "readMultiPoint", "(", "WKTParser", "$", "parser", ",", "CoordinateSystem", "$", "cs", ")", ":", "array", "{", "$", "parser", "->", "matchOpener", "(", ")", ";", "$", "points", "=", "[", "]", ";", "do", "{", "$", "points", "[", ...
(x y, ...) @param WKTParser $parser @param CoordinateSystem $cs @return Point[]
[ "(", "x", "y", "...", ")" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/AbstractWKTReader.php#L214-L225
brick/geo
src/IO/AbstractWKTReader.php
AbstractWKTReader.readLineStringText
private function readLineStringText(WKTParser $parser, CoordinateSystem $cs) : LineString { $points = $this->readMultiPoint($parser, $cs); return new LineString($cs, ...$points); }
php
private function readLineStringText(WKTParser $parser, CoordinateSystem $cs) : LineString { $points = $this->readMultiPoint($parser, $cs); return new LineString($cs, ...$points); }
[ "private", "function", "readLineStringText", "(", "WKTParser", "$", "parser", ",", "CoordinateSystem", "$", "cs", ")", ":", "LineString", "{", "$", "points", "=", "$", "this", "->", "readMultiPoint", "(", "$", "parser", ",", "$", "cs", ")", ";", "return", ...
(x y, ...) @param WKTParser $parser @param CoordinateSystem $cs @return LineString
[ "(", "x", "y", "...", ")" ]
train
https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/AbstractWKTReader.php#L235-L240