Lines Matching refs:geometry

31  * "Tiny Well-known Binary is is a multi-purpose format for serializing vector geometry data into a byte buffer,
36 * - reading and writing all geometry types (1-7)
76 * Read TWKB into geometry objects
97 $geometry = $this->getGeometry();
101 return $geometry;
172 $geometry = $this->getPoint($options);
175 $geometry = $this->getLineString($options);
178 $geometry = $this->getPolygon($options);
181 $geometry = $this->getMulti('Point', $options);
184 $geometry = $this->getMulti('LineString', $options);
187 $geometry = $this->getMulti('Polygon', $options);
190 $geometry = $this->getMulti('Geometry', $options);
199 return $geometry;
324 * @param Geometry $geometry The geometry
329 * @param bool $includeSizes Includes the size in bytes of the remainder of the geometry after the size attribute. Default is false
334 public function write(Geometry $geometry, $writeAsHex = false, $decimalDigitsXY = null, $decimalDigitsZ = null, $decimalDigitsM = null, $includeSizes = false, $includeBoundingBoxes = false)
354 $twkb = $this->writeGeometry($geometry);
360 * @param Geometry $geometry
363 protected function writeGeometry($geometry)
365 $this->writeOptions['hasZ'] = $geometry->hasZ();
366 $this->writeOptions['hasM'] = $geometry->isMeasured();
369 $type = self::$typeMap[$geometry->geometryType()] +
381 $metadataHeader += ($geometry->hasZ() || $geometry->isMeasured()) << 3;
382 // Is this an empty geometry?
383 $metadataHeader += $geometry->isEmpty() << 4;
388 if (!$geometry->isEmpty()) {
391 switch ($geometry->geometryType()) {
393 /** @var Point $geometry */
394 $twkbGeom .= $this->writePoint($geometry);
397 /** @var LineString $geometry */
398 $twkbGeom .= $this->writeLineString($geometry);
401 /** @var Polygon $geometry */
402 $twkbGeom .= $this->writePolygon($geometry);
408 /** @var Collection $geometry */
409 $twkbGeom .= $this->writeMulti($geometry);
415 $bBox = $geometry->getBoundingBox();
422 if ($geometry->hasZ()) {
423 $bBox['minz'] = $geometry->minimumZ();
424 $bBox['maxz'] = $geometry->maximumZ();
428 if ($geometry->isMeasured()) {
429 $bBox['minm'] = $geometry->minimumM();
430 $bBox['maxm'] = $geometry->maximumM();
437 if ($geometry->hasZ() || $geometry->isMeasured()) {
439 if ($geometry->hasZ()) {
440 $extendedPrecision |= ($geometry->hasZ() ? 0x1 : 0) | ($this->writeOptions['decimalDigitsZ'] << 2);
442 if ($geometry->isMeasured()) {
443 $extendedPrecision |= ($geometry->isMeasured() ? 0x2 : 0) | ($this->writeOptions['decimalDigitsM'] << 5);
455 * @param Point $geometry
458 protected function writePoint($geometry)
460 $x = round($geometry->x() * $this->writeOptions['xyFactor']);
461 $y = round($geometry->y() * $this->writeOptions['xyFactor']);
462 $z = round($geometry->z() * $this->writeOptions['zFactor']);
463 $m = round($geometry->m() * $this->writeOptions['mFactor']);
480 * @param LineString $geometry
483 protected function writeLineString($geometry)
485 $twkb = $this->writer->writeUVarInt($geometry->numPoints());
486 foreach ($geometry->getComponents() as $component) {
493 * @param Polygon $geometry
496 protected function writePolygon($geometry)
498 $twkb = $this->writer->writeUVarInt($geometry->numGeometries());
499 foreach ($geometry->getComponents() as $component) {
506 * @param Collection $geometry
509 protected function writeMulti($geometry)
511 $twkb = $this->writer->writeUVarInt($geometry->numGeometries());
512 //if ($geometry->hasIdList()) {
513 // foreach ($geometry->getComponents() as $component) {
517 foreach ($geometry->getComponents() as $component) {
518 if ($geometry->geometryType() !== Geometry::GEOMETRY_COLLECTION) {