Edge cases:
- it's not detected when a line between two points is outside the polygon
- @see contains() for more restrictions
public containsGeometry ( location\GeometryInterface $geometry ) : boolean | ||
$geometry | location\GeometryInterface | |
return | boolean |
public function testIfPolygonContainsGeometryWithPointOutsideWorksAsExpected() { $polygon = new Polygon(); $polygon->addPoint(new Coordinate(52.221651719883084, 13.661613101139665)); $polygon->addPoint(new Coordinate(52.21571624279022, 13.662988655269146)); $polygon->addPoint(new Coordinate(52.21192284487188, 13.662990247830749)); $polygon->addPoint(new Coordinate(52.20800279639661, 13.664533020928502)); $polygon->addPoint(new Coordinate(52.20346977934241, 13.664621533825994)); $polygon->addPoint(new Coordinate(52.19989615492523, 13.665583860129118)); $polygon->addPoint(new Coordinate(52.19917740672827, 13.665664242580533)); $polygon->addPoint(new Coordinate(52.197426510974765, 13.664221465587616)); $polygon->addPoint(new Coordinate(52.19646820798516, 13.674150248989463)); $polygon->addPoint(new Coordinate(52.20004786737263, 13.674412602558732)); $polygon->addPoint(new Coordinate(52.20350875519216, 13.676183195784688)); $polygon->addPoint(new Coordinate(52.206863863393664, 13.678688379004598)); $polygon->addPoint(new Coordinate(52.21345723606646, 13.67043505422771)); $polygon->addPoint(new Coordinate(52.21743017435074, 13.66775787435472)); $polygon->addPoint(new Coordinate(52.22168365493417, 13.661622740328312)); $this->assertFalse($polygon->containsGeometry(new Coordinate(52.2123983502388, 13.677485324442387))); }