private void goToFeature() throws IOException {
if (featureList == null) {
initLayer();
}
SimpleFeature currentFeature = featureList.get(index);
SimpleFeatureType featureType = currentFeature.getFeatureType();
List<AttributeDescriptor> attributeDescriptors = featureType.getAttributeDescriptors();
List<String> attributeNames = new ArrayList<String>();
for( AttributeDescriptor attributeDescriptor : attributeDescriptors ) {
String name = attributeDescriptor.getLocalName();
attributeNames.add(name);
}
final StringBuilder infoSb = new StringBuilder();
for( String name : attributeNames ) {
Object attribute = currentFeature.getAttribute(name);
if (attribute != null) {
infoSb.append(name).append(" = ").append(attribute.toString()).append("\n");
}
}
final StringBuilder numSb = new StringBuilder();
numSb.append(" (");
numSb.append(index + 1);
numSb.append("/");
numSb.append(featureList.size());
numSb.append(")");
index++;
if (index == featureList.size()) {
index = 0;
}
Display.getDefault().asyncExec(new Runnable(){
public void run() {
currentFeatureInfo.setText(infoSb.toString());
featureNumLabel.setText(numSb.toString());
}
});
Geometry geometry = (Geometry) currentFeature.getDefaultGeometry();
Envelope envelope = geometry.getEnvelopeInternal();
envelope.expandBy(zoomBuffer);
ReferencedEnvelope ref = new ReferencedEnvelope(envelope, crs);
try {
ref = ref.transform(activeMap.getViewportModel().getCRS(), true);