### Question:
AvoidAreasEdgeFilter implements EdgeFilter { @Override public final boolean accept(EdgeIteratorState iter ) { if (env == null) return true; boolean inEnv = false; PointList pl = iter.fetchWayGeometry(3); int size = pl.getSize(); double eMinX = Double.MAX_VALUE; double eMinY = Double.MAX_VALUE; double eMaxX = Double.MIN_VALUE; double eMaxY = Double.MIN_VALUE; for (int j = 0; j < pl.getSize(); j++) { double x = pl.getLon(j); double y = pl.getLat(j); if (env.contains(x, y)) { inEnv = true; break; } if (x < eMinX) eMinX = x; if (y < eMinY) eMinY = y; if (x > eMaxX) eMaxX = x; if (y > eMaxY) eMaxY = y; } if (inEnv || !(eMinX > env.getMaxX() || eMaxX < env.getMinX() || eMinY > env.getMaxY() || eMaxY < env.getMinY())) { coordSequence = new DefaultCoordinateSequence(new Coordinate[1], 1); if (size >= 2) { coordSequence.resize(size); for (int j = 0; j < size; j++) { double x = pl.getLon(j); double y = pl.getLat(j); Coordinate c = coordSequence.getCoordinate(j); if (c == null) { c = new Coordinate(x, y); coordSequence.setCoordinate(j, c); } else { c.x = x; c.y = y; } } LineString ls = geomFactory.createLineString(coordSequence); for (int i = 0; i < polys.length; i++) { Polygon poly = polys[i]; if (poly.contains(ls) || ls.crosses(poly)) { return false; } } } else { return false; } } return true; } AvoidAreasEdgeFilter(Polygon[] polys); @Override final boolean accept(EdgeIteratorState iter );  }### Answer:
@Test public void TestAvoidPolygons() { EdgeIteratorState iter1 = _graphStorage.edge(0, 1, 100, true); iter1.setWayGeometry(Helper.createPointList(0, 0, 10, 0)); EdgeIteratorState iter2 = _graphStorage.edge(0, 2, 200, true); iter2.setWayGeometry(Helper.createPointList(0, 0, -10, 0)); GeometryFactory gf = new GeometryFactory(); Polygon poly = gf.createPolygon(new Coordinate[]{ new Coordinate(-1,5), new Coordinate(1,5), new Coordinate(1,6), new Coordinate(-1,5)}); AvoidAreasEdgeFilter filter = new AvoidAreasEdgeFilter(new Polygon[] {poly}); assertFalse(filter.accept(iter1)); assertTrue(filter.accept(iter2)); }