try {
Map<String, Object> results = new HashMap<String, Object>();
OutputObjectsSet outputs = m_Algorithm.getOutputObjects();
for (int i = 0; i < outputs.getOutputObjectsCount(); i++) {
Output output = outputs.getOutput(i);
Object outputObject = output.getOutputObject();
// if the output object is a layer or a table, we return
// the inner GeoTools object
if (outputObject instanceof IDataObject){
IDataObject dataObject = (IDataObject) outputObject;
Object wrapped = dataObject.getBaseDataObject();
if(wrapped instanceof FeatureSource) {
results.put(output.getName(), ((FeatureSource) wrapped).getFeatures());
} else if(wrapped instanceof GridCoverage2D) {
results.put(output.getName(), wrapped);
} else {
results.put(output.getName(), wrapped);
}
}
else{
results.put(output.getName(), outputObject);
}
}
return results;
} catch(Throwable t) {
throw new RuntimeException(t);