function testConstructor() { $testPolygon = new KVDgis_GeomPolygon(31300, $this->testLinearRing1, array($this->testLinearRing2)); $this->assertEquals($testPolygon->getAsText(), 'POLYGON((178000 212000, 100000 150000), (178000 212000, 100000 150000))'); $this->assertEquals(31300, $testPolygon->getSrid()); }
/** * * @see KVDgis_GeomGeometry::setGeometryFromText() * @param string $wkt vb. MULTIPOLYGON(((1 2, 3 4, 5 6)), * ((7 8, 9 10, 11 12, 13 14),(15 16, 17 18, 19 20))). * @throws <b>InvalidArgumentException</b> - Indien de wkt-string ongeldig is. */ public function setGeometryFromText($wkt) { $this->clearPolygons(); if ($wkt == 'EMPTY') { return; } if (substr($wkt, 0, 12) != 'MULTIPOLYGON') { throw new InvalidArgumentException('Ongeldige Well-Known Text string: ' . $wkt . "\n. De string zou moeten beginnen met 'MULTIPOLYGON'."); } $stringMultiPoly = $this->getStringBetweenBraces($wkt); $polystrings = array(); preg_match_all('#\\s*' . $this->RE_POLYGON . '\\s*#', $wkt, $polystrings); foreach ($polystrings[0] as $poly) { $polyWKT = 'POLYGON' . $poly; $p = new KVDgis_GeomPolygon($this->getSrid()); $p->setGeometryFromText($polyWKT); $this->addPolygon($p); } }