@Override
public VectorDataNode readVectorDataNode(File file, Product product, ProgressMonitor pm) throws IOException {
DefaultFeatureCollection featureCollection = FeatureUtils.loadShapefileForProduct(file,
product,
crsProvider,
pm);
Style[] styles = SLDUtils.loadSLD(file);
ProductNodeGroup<VectorDataNode> vectorDataGroup = product.getVectorDataGroup();
String name = VectorDataNodeImporter.findUniqueVectorDataNodeName(featureCollection.getSchema().getName().getLocalPart(),
vectorDataGroup);
if (styles.length > 0) {
SimpleFeatureType featureType = SLDUtils.createStyledFeatureType(featureCollection.getSchema());
VectorDataNode vectorDataNode = new VectorDataNode(name, featureType);
DefaultFeatureCollection styledCollection = vectorDataNode.getFeatureCollection();
String defaultCSS = vectorDataNode.getDefaultStyleCss();
SLDUtils.applyStyle(styles[0], defaultCSS, featureCollection, styledCollection);
return vectorDataNode;
} else {
return new VectorDataNode(name, featureCollection);
}
}
}