IOUtils.closeQuietly(ifos);
}
//create a new shapefile feature store
ShapefileDataStoreFactory shpFactory = new ShapefileDataStoreFactory();
DirectoryDataStore dir = new DirectoryDataStore(mosaic.getFile(),
new ShapefileDataStoreFactory.ShpFileStoreFactory(shpFactory, new HashMap()));
try {
dir.createSchema(typeBuilder.buildFeatureType());
FeatureWriter<SimpleFeatureType, SimpleFeature> w =
dir.getFeatureWriterAppend(mosaic.getName(), Transaction.AUTO_COMMIT);
try {
for (Granule g : mosaic.granules()) {
if (g.getEnvelope() == null) {
LOGGER.warning("Skipping " + g.getFile().getAbsolutePath() + ", no envelope");
}
SimpleFeature f = w.next();
f.setDefaultGeometry(JTS.toGeometry((BoundingBox)g.getEnvelope()));
f.setAttribute("location", g.getFile().getName());
if (mosaic.getTimeMode() != TimeMode.NONE) {
f.setAttribute("time", g.getTimestamp());
}
w.write();
//track total bounds
envelope.include(g.getEnvelope());
}
}
finally {
w.close();
}
}
finally {
dir.dispose();
}
// have the image mosaic write the property file
ImageMosaicFormat format = new ImageMosaicFormat();
ImageMosaicReader reader = format.getReader(mosaic.getFile());