/** * Constructor. * * @param float[][][]|LineString[] $lineStrings * @param CoordinateResolutionSystem|BoundingBox $arg,... */ public function __construct(array $lineStrings) { $this->coordinates = array_map(function ($lineString) { if (!$lineString instanceof LineString) { $lineString = new LineString($lineString); } return $lineString->getCoordinates(); }, $lineStrings); if (func_num_args() > 1) { $this->setOptionalConstructorArgs(array_slice(func_get_args(), 1)); } }
/** * Constructor * * @param array $positions The Point array */ public function __construct(array $positions) { if (count($positions) > 1) { parent::__construct($positions); } else { throw new Exception("Linestring with less than two points"); } }
/** * Find the outermost point from the centroid * * @returns Point The outermost point */ public function outermostPoint() { $centroid = $this->getCentroid(); $max = array('length' => 0, 'point' => null); foreach ($this->getPoints() as $point) { $lineString = new LineString(array($centroid, $point)); if ($lineString->length() > $max['length']) { $max['length'] = $lineString->length(); $max['point'] = $point; } } return $max['point']; }
/** * (non-PHPdoc) * @see lib/Geometry/Collection#addComponent($component, $index) */ public function addComponent($component, $index = null) { $added = false; $lastPoint = array_pop($this->components); if ($index != null || empty($lastPoint) || !$component->equals($lastpoint)) { $added = parent::addComponent($component, $index); } //TODO cas index != null à traiter //append copy of first point $firstPoint = $this->components[0]; parent::addComponent($firstPoint); return $added; }
public function __construct($components) { $first = $components[0]; $last = end($components); if (!$first->equals($last)) { throw new InvalidFeature(__CLASS__, "LinearRing must be closed"); } parent::__construct($components); }
public function addLineString(LineString $lineString) { $this->coordinates[] = $lineString->getCoordinates(); return $this; }