public function testToWkt() { $wkt = 'MULTIPOLYGON(((1 1, 5 1, 5 5, 1 5, 1 1),(2 2, 3 2, 3 3, 2 3, 2 2)),((3 3, 6 2, 6 4, 3 3)))'; $multipolygone = new MultiPolygon([new Polygon([[[1, 1], [5, 1], [5, 5], [1, 5], [1, 1]], [[2, 2], [3, 2], [3, 3], [2, 3], [2, 2]]]), new Polygon([[[3, 3], [6, 2], [6, 4], [3, 3]]])]); $this->assertEquals($wkt, $multipolygone->toWkt()); }
/** * Check if a point is inside a multipolygon geometry. * * @param MultiPolygon $mpolygon * @param Point $point * @return bool */ function treasurehunt_check_point_in_multipolygon($mpolygon, $point) { $polygons = $mpolygon->getComponents(); foreach ($polygons as $polygon) { if ($polygon instanceof Polygon) { $result = $polygon->pointInPolygon($point); if ($result) { return true; } } } return false; }