Program: 175137
Project: 175137
Buggy source:
/** 
 * @param imageP poligono creato con i punti di riferimento dell'immagine
 * @param geoName
 * @param dataStore  shape file
 * @param fc
 * @param schema
 * @param types
 * @return Polygons (geometry) that are the intersection between the shape file and the sar image
 * @throws IOException
 */
public static GeometricLayer createFromSimpleGeometry(final Polygon imageP,final String geoName,FeatureCollection fc,final String[] schema,final String[] types,boolean applayTransformation,GeoTransform transform) throws IOException {
  GeometricLayer out=null;
  GeometryFactory gf=new GeometryFactory();
  if (geoName.contains("String_Node_Str") || geoName.contains("String_Node_Str")) {
    out=new GeometricLayer(GeometricLayer.POLYGON);
    out.setFeatureCollection(fc);
    FeatureIterator<?> fi=fc.features();
    try {
      ThreadPoolExecutor executor=new ThreadPoolExecutor(2,Runtime.getRuntime().availableProcessors(),2,TimeUnit.SECONDS,new LinkedBlockingQueue<Runnable>());
      List<Callable<Object[][]>> tasks=new ArrayList<Callable<Object[][]>>();
      while (fi.hasNext()) {
        final Feature f=fi.next();
        Callable<Object[][]> run=new Callable<Object[][]>(){
          Geometry g=(Geometry)f.getDefaultGeometryProperty().getValue();
          @Override public Object[][] call(){
            List<Object[]> result=java.util.Collections.synchronizedList(new ArrayList<Object[]>());
            try {
              AttributesGeometry at=new AttributesGeometry(schema);
              for (int i=0; i < f.getProperties().size(); i++) {
                if (f.getProperty(schema[i]).getValue() != null)                 at.set(schema[i],f.getProperty(schema[i]).getValue());
              }
              g=PolygonOp.removeInteriorRing(g);
              Geometry gbuff=g.buffer(0);
              if (imageP.contains(gbuff)) {
                Object[] o=new Object[2];
                o[0]=gbuff;
                o[1]=at;
                result.add(o);
              }
 else               if (imageP.intersects(gbuff)) {
                Geometry p2=EnhancedPrecisionOp.intersection(imageP,gbuff);
                p2=p2.buffer(0);
                if (!p2.isEmpty()) {
                  for (int ii=0; ii < p2.getNumGeometries(); ii++) {
                    Object[] o=new Object[2];
                    o[0]=p2.getGeometryN(ii);
                    o[1]=at;
                    result.add(o);
                  }
                }
              }
            }
 catch (            Exception ex) {
              logger.error(ex.getMessage(),ex);
            }
            return result.toArray(new Object[0][]);
          }
        }
;
        tasks.add(run);
      }
      List<Future<Object[][]>> results=executor.invokeAll(tasks);
      executor.shutdown();
      for (      Future<Object[][]> f : results) {
        Object o[][]=f.get();
        if (o != null) {
          for (int i=0; i < o.length; i++) {
            Geometry g=gf.createGeometry((Geometry)o[i][0]);
            if (applayTransformation && transform != null)             g=transform.transformGeometryPixelFromGeo(g);
            out.put(g,(AttributesGeometry)o[i][1]);
            System.out.println(g.toText());
          }
        }
      }
    }
 catch (    Exception e) {
      logger.error(e.getMessage(),e);
    }
 finally {
      fi.close();
    }
  }
 else   if (geoName.contains("String_Node_Str")) {
    out=new GeometricLayer(GeometricLayer.POINT);
    FeatureIterator<?> fi=fc.features();
    try {
      while (fi.hasNext()) {
        Feature f=fi.next();
        AttributesGeometry at=new AttributesGeometry(schema);
        for (int i=0; i < f.getProperties().size(); i++) {
          at.set(schema[i],f.getProperty(schema[i]).getValue());
        }
        Geometry p2=((Geometry)(f.getDefaultGeometryProperty().getValue())).intersection(imageP);
        if (!p2.isEmpty()) {
          if (applayTransformation && transform != null)           p2=transform.transformGeometryPixelFromGeo(p2);
          out.put(p2,at);
        }
      }
    }
 catch (    Exception e) {
      logger.error(e.getMessage(),e);
    }
 finally {
      fi.close();
    }
  }
  return out;
}

Fixed version (ground truth):
/** 
 * @param imageP poligono creato con i punti di riferimento dell'immagine
 * @param geoName
 * @param dataStore  shape file
 * @param fc
 * @param schema
 * @param types
 * @return Polygons (geometry) that are the intersection between the shape file and the sar image
 * @throws IOException
 */
public static GeometricLayer createFromSimpleGeometry(final Polygon imageP,final String geoName,FeatureCollection fc,final String[] schema,final String[] types,boolean applayTransformation,GeoTransform transform) throws IOException {
  GeometricLayer out=null;
  GeometryFactory gf=new GeometryFactory();
  if (geoName.contains("String_Node_Str") || geoName.contains("String_Node_Str")) {
    out=new GeometricLayer(GeometricLayer.POLYGON);
    out.setFeatureCollection(fc);
    FeatureIterator<?> fi=fc.features();
    try {
      ThreadPoolExecutor executor=new ThreadPoolExecutor(2,Runtime.getRuntime().availableProcessors(),2,TimeUnit.SECONDS,new LinkedBlockingQueue<Runnable>());
      List<Callable<Object[][]>> tasks=new ArrayList<Callable<Object[][]>>();
      while (fi.hasNext()) {
        final Feature f=fi.next();
        Callable<Object[][]> run=new Callable<Object[][]>(){
          Geometry g=(Geometry)f.getDefaultGeometryProperty().getValue();
          @Override public Object[][] call(){
            List<Object[]> result=java.util.Collections.synchronizedList(new ArrayList<Object[]>());
            try {
              AttributesGeometry at=new AttributesGeometry(schema);
              for (int i=0; i < f.getProperties().size(); i++) {
                if (f.getProperty(schema[i]).getValue() != null)                 at.set(schema[i],f.getProperty(schema[i]).getValue());
              }
              g=PolygonOp.removeInteriorRing(g);
              Geometry gbuff=g.buffer(0);
              if (imageP.contains(gbuff)) {
                Object[] o=new Object[2];
                o[0]=gbuff;
                o[1]=at;
                result.add(o);
              }
 else               if (imageP.intersects(gbuff)) {
                Geometry p2=EnhancedPrecisionOp.intersection(imageP,gbuff);
                p2=p2.buffer(0);
                if (!p2.isEmpty()) {
                  for (int ii=0; ii < p2.getNumGeometries(); ii++) {
                    Object[] o=new Object[2];
                    o[0]=p2.getGeometryN(ii);
                    o[1]=at;
                    result.add(o);
                  }
                }
              }
            }
 catch (            Exception ex) {
              logger.error(ex.getMessage(),ex);
            }
            return result.toArray(new Object[0][]);
          }
        }
;
        tasks.add(run);
      }
      List<Future<Object[][]>> results=executor.invokeAll(tasks);
      executor.shutdown();
      for (      Future<Object[][]> f : results) {
        Object o[][]=f.get();
        if (o != null) {
          for (int i=0; i < o.length; i++) {
            Geometry g=gf.createGeometry((Geometry)o[i][0]);
            if (applayTransformation && transform != null)             g=transform.transformGeometryPixelFromGeo(g);
            if (!g.isValid()) {
              if (!g.isSimple()) {
                Geometry b0=g.buffer(0);
                Coordinate[] cc=g.getCoordinates();
                CoordinateList cl=new CoordinateList();
                cl.add(cc,false);
                for (int ii=0; ii < cl.size(); ii++) {
                  if (b0.contains(gf.createPoint(cl.getCoordinate(ii))) || b0.touches(gf.createPoint(cl.getCoordinate(ii)))) {
                    cl.remove(ii);
                  }
                }
                Geometry newGeom=gf.createPolygon(cl.toCoordinateArray());
                g=newGeom.buffer(0);
              }
            }
            out.put(g,(AttributesGeometry)o[i][1]);
          }
        }
      }
    }
 catch (    Exception e) {
      logger.error(e.getMessage(),e);
    }
 finally {
      fi.close();
    }
  }
 else   if (geoName.contains("String_Node_Str")) {
    out=new GeometricLayer(GeometricLayer.POINT);
    FeatureIterator<?> fi=fc.features();
    try {
      while (fi.hasNext()) {
        Feature f=fi.next();
        AttributesGeometry at=new AttributesGeometry(schema);
        for (int i=0; i < f.getProperties().size(); i++) {
          at.set(schema[i],f.getProperty(schema[i]).getValue());
        }
        Geometry p2=((Geometry)(f.getDefaultGeometryProperty().getValue())).intersection(imageP);
        if (!p2.isEmpty()) {
          if (applayTransformation && transform != null)           p2=transform.transformGeometryPixelFromGeo(p2);
          out.put(p2,at);
        }
      }
    }
 catch (    Exception e) {
      logger.error(e.getMessage(),e);
    }
 finally {
      fi.close();
    }
  }
  return out;
}