[Gvsig_desarrolladores] Error al copiar geometrías de una capa a otra por código

David Alda Fernandez de Lezea dalda en ikt.es
Vie Jul 1 12:19:43 CEST 2011


Hola,

Me he encontrado con un error que ocurre arbitrariamente, a veces si y otras no, a la hora de copiar una serie de geometrias de una capa a otra. La capa origen de geometrías tiene bastantes geometrías. Estoy trabajando con gvSIG 1.11. El error que me aparece es este:

DEBUG [Thread-35] (NotificationManager.java:104) - 
java.lang.NegativeArraySizeException
	at com.iver.cit.gvsig.fmap.core.GeneralPathX.<init>(GeneralPathX.java:195)
	at com.iver.cit.gvsig.fmap.core.GeneralPathX.<init>(GeneralPathX.java:175)
	at com.iver.cit.gvsig.fmap.drivers.shp.IndexedShpDriver.getShape(IndexedShpDriver.java:286)
	at com.iver.cit.gvsig.fmap.layers.VectorialFileAdapter.getShape(VectorialFileAdapter.java:144)
	at com.iver.cit.gvsig.fmap.layers.VectorialFileAdapter.getFeature(VectorialFileAdapter.java:210)
	at com.iver.cit.gvsig.fmap.edition.VectorialEditableAdapter.getRow(VectorialEditableAdapter.java:524)
	at com.iver.cit.gvsig.controlesdfg.ui.LoadExpediente2SHPForm.copyPasteGeometries(LoadExpediente2SHPForm.java:651)

Y la linea 651 de micódigo es:

modelRow = vea.getRow((int)i);

Y esto esta en el contexto de este codigo:

private void copyPasteGeometries(FLyrVect newLyr, FLyrVect lyr, Vector lineas) throws StopWriterVisitorException, StartEditionLayerException{
		VectorialLayerEdited vle = (VectorialLayerEdited)CADExtension.getEditionManager().getLayerEdited(newLyr);
		VectorialEditableAdapter vea = vle.getVEA();
		SelectableDataSource sds = null;
		try {
		sds = lyr.getRecordset();
		for (int j=0; j<=lineas.size()-1;j++){
			for (long i=0;i<=sds.getRowCount()-1;i++){
				Value[] data = sds.getRow(i);
				sds.getFieldIndexByName("RECINTO");
				String refSipgacRecinto = data[sds.getFieldIndexByName("PROVINCIA")].toString() + "-" + data[sds.getFieldIndexByName("MUNICIPIO")].toString() + "-" 
					+ data[sds.getFieldIndexByName("POLIGONO")].toString() + "-" + data[sds.getFieldIndexByName("PARCELA")].toString() + "-"
					+ data[sds.getFieldIndexByName("RECINTO")].toString();

				if (((LineaDeclaracion)lineas.get(j)).getRefSigpac().equals(refSipgacRecinto)){
					FBitSet fbs = new FBitSet();
					
					fbs.set((int)i, true);
					
					ReadableVectorial va = ((SingleLayer) lyr).getSource();
					
					IFeature featRecintos = va.getFeature((int)i);
					
					//Cojo la geometria en si
	        		IGeometry geom = va.getShape((int)i);
	        		
	        		IRow modelRow = null;
	        		modelRow = vea.getRow((int)i);
	        		
	        		//Cojo el modelo de la estructura de los atributos para luego ir rellenando
	        		Value[] modeloAtributos = modelRow.getAttributes();
	        		
	        		LineaDeclaracion temp = ((LineaDeclaracion)lineas.get(j));
	        		
	        		try {
	        			
	        			//Copia de atributos
					...
	        			
					} catch (ReadDriverException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
					
					//Le asigno un nuevo FID
	        		String newFID = vea.getNewFID();
	        		
	        		//Creo la feature
	        		DefaultFeature df = new DefaultFeature(geom, modeloAtributos, newFID);
	        		
	        		//Añado la feature
	        		try {
			        	vea.doAddRow(df,EditionEvent.GRAPHIC);
					} catch (ExpansionFileWriteException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					} catch (ExpansionFileReadException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					} catch (ReadDriverException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
					
					//Una vez encontrado saltamos al siguiente 
					break;
					
				}
				
			}
		}
		
		}catch (ReadDriverException e) {
			// TODO Auto-generated catch block
			newLyr.setProperty("stoppingEditing",new Boolean(true));
			//VectorialEditableAdapter vea = (VectorialEditableAdapter) newLyr.getSource();
			ISpatialWriter writer = (ISpatialWriter) vea.getWriter();
			vea.stopEdition(writer, EditionEvent.GRAPHIC);
			newLyr.setProperty("stoppingEditing",new Boolean(false));
			newLyr.setWaitTodraw(false);
			newLyr.setEditing(false);
			e.printStackTrace();
			
		} 
			

	}

¿Alguna idea?

Gracias de antemano.
 
Un saludo,
 
··················································································

David Alda Fernández de Lezea
Lurralde eta Biodibertsitate Saila / Dpto. de Territorio y Biodiversidad
 
IKT
Granja Modelo s/n · 01192 · Arkaute (Araba)

··················································································
Tlfnos.: 945-00-32-95                         Fax: 945-00.32.90
··················································································
email: dalda en ikt.es                                web: www.ikt.es
··················································································


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