@Test public void testNoIntersection() { List<Point2D<Integer>> bounds = new ArrayList<>(); bounds.add(new Point2D<>(11, 0)); bounds.add(new Point2D<>(15, 0)); bounds.add(new Point2D<>(11, 10)); AreaMeasurement am = new AreaMeasurement(bounds); ILink link = am.toLink(); Optional<ILink> result = fn.apply(link); assertTrue(!result.isPresent()); }
@Override public Optional<ILink> apply(ILink link) { if (AreaMeasurement.IS_AREA_MEASUREMENT_PREDICATE.test(link)) { Polygon polygon = toPolygon.apply(link); Area area = new Area(polygon); area.intersect(acceptableBounds); Polygon trimmedPolygon = areaToPolygon(area); if (trimmedPolygon.npoints >= 3) { AreaMeasurement trimmedAreaMeasurement = polygonToAreaMeasurement(trimmedPolygon); return Optional.of(trimmedAreaMeasurement.toLink()); } else { return Optional.empty(); } } else { return Optional.of(link); } }
TrimAreaMeasurementsFn implements Function<ILink, Optional<ILink>> { @Override public Optional<ILink> apply(ILink link) { if (AreaMeasurement.IS_AREA_MEASUREMENT_PREDICATE.test(link)) { Polygon polygon = toPolygon.apply(link); Area area = new Area(polygon); area.intersect(acceptableBounds); Polygon trimmedPolygon = areaToPolygon(area); if (trimmedPolygon.npoints >= 3) { AreaMeasurement trimmedAreaMeasurement = polygonToAreaMeasurement(trimmedPolygon); return Optional.of(trimmedAreaMeasurement.toLink()); } else { return Optional.empty(); } } else { return Optional.of(link); } } }
TrimAreaMeasurementsFn implements Function<ILink, Optional<ILink>> { @Override public Optional<ILink> apply(ILink link) { if (AreaMeasurement.IS_AREA_MEASUREMENT_PREDICATE.test(link)) { Polygon polygon = toPolygon.apply(link); Area area = new Area(polygon); area.intersect(acceptableBounds); Polygon trimmedPolygon = areaToPolygon(area); if (trimmedPolygon.npoints >= 3) { AreaMeasurement trimmedAreaMeasurement = polygonToAreaMeasurement(trimmedPolygon); return Optional.of(trimmedAreaMeasurement.toLink()); } else { return Optional.empty(); } } else { return Optional.of(link); } } TrimAreaMeasurementsFn(java.util.List<Point2D<Integer>> bounds); }
TrimAreaMeasurementsFn implements Function<ILink, Optional<ILink>> { @Override public Optional<ILink> apply(ILink link) { if (AreaMeasurement.IS_AREA_MEASUREMENT_PREDICATE.test(link)) { Polygon polygon = toPolygon.apply(link); Area area = new Area(polygon); area.intersect(acceptableBounds); Polygon trimmedPolygon = areaToPolygon(area); if (trimmedPolygon.npoints >= 3) { AreaMeasurement trimmedAreaMeasurement = polygonToAreaMeasurement(trimmedPolygon); return Optional.of(trimmedAreaMeasurement.toLink()); } else { return Optional.empty(); } } else { return Optional.of(link); } } TrimAreaMeasurementsFn(java.util.List<Point2D<Integer>> bounds); @Override Optional<ILink> apply(ILink link); }
TrimAreaMeasurementsFn implements Function<ILink, Optional<ILink>> { @Override public Optional<ILink> apply(ILink link) { if (AreaMeasurement.IS_AREA_MEASUREMENT_PREDICATE.test(link)) { Polygon polygon = toPolygon.apply(link); Area area = new Area(polygon); area.intersect(acceptableBounds); Polygon trimmedPolygon = areaToPolygon(area); if (trimmedPolygon.npoints >= 3) { AreaMeasurement trimmedAreaMeasurement = polygonToAreaMeasurement(trimmedPolygon); return Optional.of(trimmedAreaMeasurement.toLink()); } else { return Optional.empty(); } } else { return Optional.of(link); } } TrimAreaMeasurementsFn(java.util.List<Point2D<Integer>> bounds); @Override Optional<ILink> apply(ILink link);  }