Program: 186349
Project: 186349
Buggy source:
/** 
 * adds the overlap between two   {@link MapArea}s to both, if it exists
 */
private static void addOverlapBetween(MapArea area1,MapArea area2){
  for (  MapAreaSegment area1Segment : area1.getAreaSegments()) {
    for (    MapAreaSegment area2Segment : area2.getAreaSegments()) {
      if (area1Segment.sharesBothNodes(area2Segment)) {
        MapOverlapAA newOverlap=new MapOverlapAA(area1,area2,MapOverlapType.SHARE_SEGMENT);
        area1.addOverlap(newOverlap);
        area2.addOverlap(newOverlap);
        return;
      }
    }
  }
  boolean contains;
  boolean intersects;
{
    final PolygonWithHolesXZ polygon1=area1.getPolygon();
    final PolygonWithHolesXZ polygon2=area2.getPolygon();
    Set<VectorXZ> commonNodes=new HashSet<VectorXZ>();
    for (    SimplePolygonXZ p : polygon1.getPolygons()) {
      commonNodes.addAll(p.getVertices());
    }
    Set<VectorXZ> nodes2=new HashSet<VectorXZ>();
    for (    SimplePolygonXZ p : polygon2.getPolygons()) {
      nodes2.addAll(p.getVertices());
    }
    commonNodes.retainAll(nodes2);
    intersects=false;
    intersectionPosCheck:     for (    VectorXZ pos : polygon1.intersectionPositions(polygon2)) {
      for (      VectorXZ commonNode : commonNodes) {
        if (distance(pos,commonNode) > 0.01) {
          intersects=true;
          break intersectionPosCheck;
        }
      }
    }
    contains=polygon1.contains(polygon2.getOuter()) || polygon2.contains(polygon2.getOuter());
  }
  if (contains || intersects) {
    MapOverlapAA newOverlap=new MapOverlapAA(area1,area2,intersects ? MapOverlapType.INTERSECT : MapOverlapType.CONTAIN);
    area1.addOverlap(newOverlap);
    area2.addOverlap(newOverlap);
  }
}

Fixed version (ground truth):
/** 
 * adds the overlap between two   {@link MapArea}s to both, if it exists
 */
private static void addOverlapBetween(MapArea area1,MapArea area2){
  for (  MapAreaSegment area1Segment : area1.getAreaSegments()) {
    for (    MapAreaSegment area2Segment : area2.getAreaSegments()) {
      if (area1Segment.sharesBothNodes(area2Segment)) {
        MapOverlapAA newOverlap=new MapOverlapAA(area1,area2,MapOverlapType.SHARE_SEGMENT);
        area1.addOverlap(newOverlap);
        area2.addOverlap(newOverlap);
        return;
      }
    }
  }
  boolean contains;
  boolean intersects;
{
    final PolygonWithHolesXZ polygon1=area1.getPolygon();
    final PolygonWithHolesXZ polygon2=area2.getPolygon();
    Set<VectorXZ> commonNodes=new HashSet<VectorXZ>();
    for (    SimplePolygonXZ p : polygon1.getPolygons()) {
      commonNodes.addAll(p.getVertices());
    }
    Set<VectorXZ> nodes2=new HashSet<VectorXZ>();
    for (    SimplePolygonXZ p : polygon2.getPolygons()) {
      nodes2.addAll(p.getVertices());
    }
    commonNodes.retainAll(nodes2);
    intersects=false;
    intersectionPosCheck:     for (    VectorXZ pos : polygon1.intersectionPositions(polygon2)) {
      boolean trueIntersection=true;
      for (      VectorXZ commonNode : commonNodes) {
        if (distance(pos,commonNode) < 0.01) {
          trueIntersection=false;
        }
      }
      if (trueIntersection) {
        intersects=true;
        break intersectionPosCheck;
      }
    }
    contains=polygon1.contains(polygon2.getOuter()) || polygon2.contains(polygon2.getOuter());
  }
  if (contains || intersects) {
    MapOverlapAA newOverlap=new MapOverlapAA(area1,area2,intersects ? MapOverlapType.INTERSECT : MapOverlapType.CONTAIN);
    area1.addOverlap(newOverlap);
    area2.addOverlap(newOverlap);
  }
}