The console scripting code:
JGrassFeatureValueSet featureSet = null;
jgrass {
$featureSet = v.read --iflayer-in adige_bacini_bz20 --oshapefile-out *
}
FeatureCollection fColl = featureSet.getFeatureCollection();
FeatureIterator featureIterator = fColl.features();
print("Read " + fColl.size() + " features");
while( featureIterator.hasNext() ) {
Feature feature = featureIterator.next();
String id = feature.getID();
Geometry geometry = feature.getDefaultGeometry();
Coordinate[] coords = geometry.getCoordinates();
double area = geometry.getArea();
double length = geometry.getLength();
print("Feature with ID=" + id + " has area=" + area + " and length=" + length + " and consists of " + coords.length + " nodes.");
}
And two screenshots to show how it works:
1) select feature on layer:
2) launch the script: