/** * Merge multiple {@link MultiPolygon}s into one. If the two {@link MultiPolygon}s happen to * have the same outer polygon, then the two's inner polygons will be added to the same list. * * @param other * The other {@link MultiPolygon} to merge. * @return The concatenated {@link MultiPolygon} */ public MultiPolygon merge(final MultiPolygon other) { final MultiMap<Polygon, Polygon> result = new MultiMap<>(); result.putAll(getOuterToInners()); result.addAll(other.getOuterToInners()); return new MultiPolygon(result); }
/** * Concatenate multiple {@link MultiPolygon}s into one. If the two {@link MultiPolygon}s happen * to have the same outer polygon, then the other's inner polygons will be added and the * current's inner polygons will be erased. * * @param other * The other {@link MultiPolygon} to concatenate. * @return The concatenated {@link MultiPolygon} */ public MultiPolygon concatenate(final MultiPolygon other) { final MultiMap<Polygon, Polygon> result = new MultiMap<>(); result.putAll(getOuterToInners()); result.putAll(other.getOuterToInners()); return new MultiPolygon(result); }
/** * @param polyLine * A {@link PolyLine} item * @return True if the {@link MultiPolygon} contains the provided {@link PolyLine}. */ @Override public boolean fullyGeometricallyEncloses(final PolyLine polyLine) { for (final Polygon outer : outers()) { if (outer.fullyGeometricallyEncloses(polyLine)) { return this.getOuterToInners().get(outer).stream() .noneMatch(inner -> inner.overlaps(polyLine)); } } return false; }
enclosedWithoutInnerOverlap = this.getOuterToInners().get(thisOuter).stream() .noneMatch(that::overlaps);