/** * * @see KVDgis_GeomGeometry::setGeometryFromText() * @param string $wkt vb. LINESTRING(1 2,4 5, 8 9). * @throws <b>InvalidArgumentException</b> - Indien de wkt-string ongeldig is. */ public function setGeometryFromText($wkt) { $this->clear(); if ($wkt == 'EMPTY') { return; } if (substr($wkt, 0, 10) != 'LINESTRING') { throw new InvalidArgumentException('Ongeldige Well-Known Text string: ' . $wkt . "\n. De string zou moeten beginnen met 'LINESTRING'."); } $stringLineString = $this->getStringBetweenBraces($wkt); $points = explode(",", $stringLineString); foreach ($points as $point) { if (strpos($point, '(') === false) { $stringPoint = trim($point); } else { throw new InvalidArgumentException('Ongeldige Well-Known Text string: ' . $wkt . "\n. Een xy-paar mag niet omgeven worden door ronde haakjes."); } $punten = explode(" ", $stringPoint); $pointObj = new KVDgis_GeomPoint($this->getSrid()); $pointObj->setX($punten['0']); $pointObj->setY($punten['1']); $this->addPoint($pointObj); } }
/** * * @see KVDgis_GeomGeometry::setGeometryFromText() * @param string $wkt vb. MULTIPOINT((1 2), (4 5), (8 9)). * Het ongeldige type dat postgis en de meeste * andere paketten aanmaken kan ook gelezen worden. * @throws <b>InvalidArgumentException</b> - Indien de wkt-string ongeldig is. */ public function setGeometryFromText($wkt) { if ($wkt == 'EMPTY') { $this->clearPoints(); return; } if (substr($wkt, 0, 10) != 'MULTIPOINT') { throw new InvalidArgumentException('Ongeldige Well-Known Text string: ' . $wkt . "\n. De string zou moeten beginnen met 'MULTIPOINT'."); } $this->clearPoints(); $stringMultiPoint = $this->getStringBetweenBraces($wkt); $points = explode(",", $stringMultiPoint); foreach ($points as $point) { if (strpos($point, '(') === false) { $stringPoint = trim($point); } else { $stringPoint = $this->getStringBetweenBraces($point); } $punten = explode(" ", $stringPoint); $pointObj = new KVDgis_GeomPoint($this->getSrid()); $pointObj->setX($punten['0']); $pointObj->setY($punten['1']); $this->addPoint($pointObj); } }