%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /www/loslex/demo/vendor/asanikovich/laravel-spatial/src/Geometry/
Upload File :
Create Path :
Current File : /www/loslex/demo/vendor/asanikovich/laravel-spatial/src/Geometry/MultiLineString.php

<?php

declare(strict_types=1);

namespace ASanikovich\LaravelSpatial\Geometry;

use ASanikovich\LaravelSpatial\Exceptions\LaravelSpatialException;
use Illuminate\Support\Collection;

/**
 * @property Collection<int, LineString> $geometries
 *
 * @method Collection<int, LineString> getGeometries()
 * @method LineString offsetGet(int $offset)
 * @method void offsetSet(int $offset, LineString $value)
 */
class MultiLineString extends GeometryCollection
{
    protected string $collectionOf = LineString::class;

    protected int $minimumGeometries = 1;

    /**
     * @param  Collection<int, LineString>|array<int, LineString>  $geometries
     *
     * @throws LaravelSpatialException
     */
    public function __construct(Collection|array $geometries, int $srid = 0)
    {
        // @phpstan-ignore-next-line
        parent::__construct($geometries, $srid);
    }

    public function toWkt(): string
    {
        $wktData = $this->getWktData();

        return sprintf('MULTILINESTRING(%s)', $wktData);
    }

    public function getWktData(): string
    {
        return $this->geometries
            ->map(static function (LineString $lineString): string {
                $wktData = $lineString->getWktData();

                return sprintf('(%s)', $wktData);
            })
            ->join(', ');
    }
}

Zerion Mini Shell 1.0