[Gvsig_desarrolladores] añadir un field a un .shp GVSIG 1.9

Eduardo Cristóbal Enríquez edu_ce_1988 en hotmail.com
Dom Mayo 30 02:09:18 CEST 2010


Estoy intentando añadir a un shape un campo más, pero no me hace nada... no 
se dónde me puede fallar, aquí pongo el código:

FBitSet fb;
try {
fb = capaSeleccionada.queryByRect(capaSeleccionada.getFullExtent());
if (!fb.isEmpty()){
EditableAdapter vea = new EditableAdapter();
vea.setOriginalDataSource(capaSeleccionada.getRecordset());
vea.setSelection(fb);

// campo que quiero añadir
FieldDescription newField = new FieldDescription();
newField.setFieldName("COEF_ESCORRENTIA");
newField.setFieldType(Types.DOUBLE);
newField.setFieldLength(20);
newField.setDefaultValue(ValueFactory.createValue(999));
vea.addField(newField);


for(int i=0;i<vea.getRowCount();i++){
IRowEdited row = vea.getRow(i);
Value[] r = row.getAttributes();
String s = r[8].getStringValue(ValueWriter.internalValueWriter);
for(int j=0;j<r.length;j++)

r[8] = ValueFactory.createValue(new Double(s) + 2);     // r[8] porque ahí 
es donde se ha añadido newField
vea.doModifyRow(i,new DefaultRow(r),0);
}
}
v.repaint();
} catch (ExpansionFileReadException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (ReadDriverException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (VisitorException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}

A ver si alguien me puede decir qué me falta, o ponerme un ejemplo de editar 
un shape, muchas gracias.

Un saludo.

Edu. 



Más información sobre la lista de distribución gvSIG_desarrolladores