Improved BeanShell script to turn MultiLineStrings into LineStrings
{
featureCollection = wc.layerManager.getLayer("CattaneoLayer").featureCollectionWrapper;
for (feature : new ArrayList(featureCollection.features))
{
if (feature.geometry instanceof com.vividsolutions.jts.geom.LineString) { continue; }
for (int i = 0; i < feature.geometry.numGeometries; i++) {
Feature newFeature = feature.clone();
newFeature.geometry = feature.geometry.getGeometryN(i);
featureCollection.add(newFeature);
}
featureCollection.remove(feature);
}
}
featureCollection = wc.layerManager.getLayer("CattaneoLayer").featureCollectionWrapper;
for (feature : new ArrayList(featureCollection.features))
{
if (feature.geometry instanceof com.vividsolutions.jts.geom.LineString) { continue; }
for (int i = 0; i < feature.geometry.numGeometries; i++) {
Feature newFeature = feature.clone();
newFeature.geometry = feature.geometry.getGeometryN(i);
featureCollection.add(newFeature);
}
featureCollection.remove(feature);
}
}
0 Comments:
Post a Comment
<< Home