public boolean intersects(final PolyLine polyLine) { for (final Polygon outer : this.outers()) { if (outer.intersects(polyLine)) { return true; } } for (final Polygon inner : this.inners()) { if (inner.intersects(polyLine)) { return true; } } return false; }
private boolean overlapsInternal(final PolyLine polyline, final boolean runReverseCheck) { for (final Location location : polyline) { if (fullyGeometricallyEncloses(location)) { return true; } } if (runReverseCheck && polyline instanceof Polygon && ((Polygon) polyline).overlapsInternal(this, false)) { return true; } return this.intersects(polyline); }
private void verifyNoIntersection(final Atlas atlas) { Assert.assertFalse( atlas.area(1).asPolygon().intersects(atlas.edge(159019301).asPolyLine())); Assert.assertFalse( atlas.area(1).asPolygon().intersects(atlas.edge(-159019301).asPolyLine())); }
private void verifyIntersection(final Atlas atlas) { Assert.assertTrue(atlas.area(1).asPolygon().intersects(atlas.edge(159019301).asPolyLine())); Assert.assertTrue( atlas.area(1).asPolygon().intersects(atlas.edge(-159019301).asPolyLine())); }
private void verifyIntersection(final Atlas atlas) { Assert.assertTrue(atlas.area(1).asPolygon().intersects(atlas.area(2).asPolygon())); }
private void verifyNoIntersection(final Atlas atlas) { Assert.assertFalse(atlas.area(1).asPolygon().intersects(atlas.area(2).asPolygon())); }
@Test public void testIntersects() { final Set<Location> intersection = this.quadrant.intersections(new Segment(Location.TEST_5, new Location(Location.TEST_3.getLatitude(), Location.TEST_5.getLongitude()))); Assert.assertEquals(2, intersection.size()); final Set<Location> intersections = this.quadrant.intersections(this.rectangle); Assert.assertEquals(3, intersections.size()); Assert.assertTrue(this.quadrant.intersects(this.rectangle)); }
@Test public void testArea() { final Area area1 = this.atlas.area(45); final Area area2 = this.atlas.area(54); logger.trace(area1.toString()); logger.trace(area2.toString()); Assert.assertTrue(area1.asPolygon().intersects(area2.asPolygon())); Assert.assertEquals(Location.TEST_6, area1.asPolygon().intersections(area2.asPolygon()).iterator().next()); Assert.assertEquals("golf_course", area1.getTags().get("leisure")); Assert.assertEquals("grassland", area1.getTags().get("natural")); Assert.assertFalse(AerowayTag.get(area1).isPresent()); Assert.assertEquals(LeisureTag.GOLF_COURSE, LeisureTag.get(area1).orElseThrow(CoreException.supplier("No tag"))); Assert.assertEquals(NaturalTag.GRASSLAND, NaturalTag.get(area1).orElseThrow(CoreException.supplier("No tag"))); Assert.assertFalse(WaterTag.get(area1).isPresent()); Assert.assertFalse(AerowayTag.get(area2).isPresent()); Assert.assertEquals(LeisureTag.SWIMMING_POOL, LeisureTag.get(area2).orElseThrow(CoreException.supplier("No tag"))); Assert.assertEquals(SportTag.SWIMMING, SportTag.get(area2).orElseThrow(CoreException.supplier("No tag"))); Assert.assertFalse(NaturalTag.get(area2).isPresent()); Assert.assertFalse(WaterTag.get(area2).isPresent()); }
@Test public void testConcave() { final Polygon concave = new Polygon(Location.forString("1, -1"), Location.forString("1,1"), Location.forString("-1,1"), Location.forString("0,0"), Location.forString("-1,-1")); final Location outside1 = Location.forString("-1, 0"); final Location outside2 = Location.forString("0, 2"); final Location outside3 = Location.forString("-2, 0"); final Location inside1 = Location.forString("-0.5, 0.8"); final Location onBoundary1 = Location.forString("-0.5, 0.5"); final Location onBoundary2 = Location.forString("0, 1"); Assert.assertTrue(concave.fullyGeometricallyEncloses(inside1)); Assert.assertTrue(concave.fullyGeometricallyEncloses(onBoundary1)); // see awt definition of contains Assert.assertFalse(concave.fullyGeometricallyEncloses(onBoundary2)); Assert.assertFalse(concave.fullyGeometricallyEncloses(outside1)); Assert.assertFalse(concave.fullyGeometricallyEncloses(outside2)); Assert.assertTrue(concave.intersects(new Segment(outside1, inside1))); Assert.assertTrue(concave.intersects(new Segment(outside1, outside2))); Assert.assertFalse(concave.intersects(new Segment(outside1, outside3))); }