return;
}
ShapefileDataStoreFactory dsfac = new ShapefileDataStoreFactory();
File tmp = File.createTempFile(layers[0].getName() + "_" + layers[1].getName() + "_diff", ".shp"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
DataStore ds = dsfac.createDataStore(tmp.toURL());
final SimpleFeatureType newSchema = FeatureTypes.newFeatureType(
fromLayer.getSchema().getAttributeDescriptors().toArray(
new AttributeDescriptor[0]), "diff"); //$NON-NLS-1$
ds.createSchema(newSchema);
final FeatureSource<SimpleFeatureType, SimpleFeature> fromSource = fromLayer.getResource(FeatureSource.class, monitor);
final FeatureSource<SimpleFeatureType, SimpleFeature> diffSource = diffLayer.getResource(FeatureSource.class, monitor);
if (isGeometryCollection(fromSource.getSchema().getGeometryDescriptor())) {
MessageDialog.openError(display.getActiveShell(), Messages.differenceOp_inputError, fromLayer.getName() + Messages.differenceOp_multiGeoms);
return;
}
if (isGeometryCollection(diffSource.getSchema().getGeometryDescriptor())) {
MessageDialog.openError(display.getActiveShell(), Messages.differenceOp_inputError, fromLayer.getName() + Messages.differenceOp_multiGeoms);
return;
}
final DefaultFeatureCollection diffFeatures = new DefaultFeatureCollection();
diffFeatures.addAll(diffSource.getFeatures());
FeatureStore<SimpleFeatureType, SimpleFeature> destStore = (FeatureStore<SimpleFeatureType, SimpleFeature>)ds.getFeatureSource("diff"); //$NON-NLS-1$
// TODO: figure out whatever this FeatureReader is doing; and make it a feature collection instead
destStore.addFeatures(DataUtilities.collection(new FeatureReader<SimpleFeatureType, SimpleFeature>(){
// TODO this needs an undo
// ((FeatureStore<SimpleFeatureType, SimpleFeature>)fromSource).setFeatures(new FeatureReader() {