protected void stitchNeighbors(Set<Sector> neighbors, GeoPoint center) {
   assert gatedAssertion(
       neighbors.size() == 6
           || neighbors.size() == 5 && countDistinctGlobalSectors(neighbors) == 5);
   if (!sector.equals(neighbors.iterator().next())) {
     return;
   }
   Map<GeoPoint, GeoPoint> nextPoints = new HashMap<GeoPoint, GeoPoint>();
   Sector second = null;
   for (Sector s : neighbors) {
     char vertex = s.getVertex(center);
     Sector.Triangle cornerTriangle = s.getCornerTriangle(vertex);
     GeoPoint[] geoPoints = cornerTriangle.getPoints(vertex);
     nextPoints.put(geoPoints[1], geoPoints[2]);
     if (second == null && countShared(s.points, sector.points) == 1) {
       second = s;
     }
   }
   assert gatedAssertion(second != null);
   if (second != null) {
     GeoPoint[] acre = new GeoPoint[nextPoints.size()];
     GeoPoint point = nextPoints.values().iterator().next();
     for (int idx = 0; idx < nextPoints.size(); idx++) {
       assert !Arrays.asList(acre).contains(point);
       acre[idx] = point;
       point = nextPoints.get(point);
       assert gatedAssertion(point != null);
       if (point == null) {
         return;
       }
     }
     Sector[] others = new Sector[neighbors.size() - 2];
     int idx = 0;
     for (Sector s : neighbors) {
       if (s != sector && s != second) {
         others[idx++] = s;
       }
     }
     Acre newAcre = new Acre(1, sector, second, Arrays.asList(others), center, acre);
     CartographicElementView cartographicElementView = getFor(subdivisions);
     for (Sector s : neighbors) {
       char vertex = s.getVertex(center);
       assert vertex == 'A' || vertex == 'B' || vertex == 'C';
       Edge e = Edge.values()[vertex - 'A'];
       List<Acre> vertexAcre =
           cartographicElementView.get(
               s.getSharedAcres(), CartographicElementView.Position.Vertex, e, false);
       assert vertexAcre.size() == 1;
       assert vertexAcre.get(0) == null;
       vertexAcre.set(0, newAcre);
     }
     consume(newAcre);
   }
 }
 private void stitchEdge(Edge edge, Neighbor neighbor) {
   CartographicElementView elementView = getFor(subdivisions);
   List<Sector.Triangle> myEdge =
       elementView.get(sector.triangles, CartographicElementView.Position.Border, edge, false);
   List<Sector.Triangle> urEdge =
       elementView.get(
           neighbor.sector.triangles,
           CartographicElementView.Position.Border,
           neighbor.edge,
           neighbor.reverse);
   List<Acre> sharedAcres =
       elementView.get(
           sector.getSharedAcres(), CartographicElementView.Position.Shared, edge, false);
   makeAcres(myEdge, urEdge, neighbor, sharedAcres);
   assert !sharedAcres.subList(1, sharedAcres.size() - 1).contains(null);
 }
  private int updateSharedAcres(
      Edge edge, int count, Neighbor neighbor, CartographicElementView elementView) {
    try {
      List<Acre> myShared =
          elementView.get(
              sector.getSharedAcres(), CartographicElementView.Position.Shared, edge, false);
      List<Acre> urShared =
          elementView.get(
              neighbor.sector.getSharedAcres(),
              CartographicElementView.Position.Shared,
              neighbor.edge,
              true);
      assert myShared.size() == urShared.size();
      for (int i = 0, l = myShared.size(); i < l; i++) {
        updateSharedAcre(myShared, urShared, i);
      }

      Acre[] myInner = sector.getInnerAcres();
      Acre[] urInner = neighbor.sector.getInnerAcres();
      List<Acre> myNear =
          elementView.get(myInner, CartographicElementView.Position.Near, edge, false);
      List<Acre> myBorder =
          elementView.get(myInner, CartographicElementView.Position.Border, edge, false);
      List<Acre> urBorder =
          elementView.get(urInner, CartographicElementView.Position.Border, neighbor.edge, true);

      count += addNeighbors(myShared.subList(1, myShared.size() - 1), myNear);
      count += addNeighbors(myBorder, urBorder);
      count += addNeighbors(myShared.subList(0, myShared.size() - 1), myBorder);
      count += addNeighbors(myShared.subList(1, myShared.size()), myBorder);
    } finally {
      (sector.id < neighbor.sector.id ? neighbor.sector.sharedAcresLock : sector.sharedAcresLock)
          .writeLock()
          .unlock();
      (sector.id < neighbor.sector.id ? sector.sharedAcresLock : neighbor.sector.sharedAcresLock)
          .writeLock()
          .unlock();
    }
    return count;
  }