[Gvsig_english] gvSIG gdbms shape driver

Vicente Caballero Navarro vicente.caballero at iver.es
Tue Oct 10 16:14:49 CEST 2006


Hello Erwan,

We need to see the ".log" with the trace of the error to be able to help you in the future. Nevertheless, with the code that you have sent a "NullPointerException" exists as a minimum in the object "field", that is null.  

You should create the "LayerDefinition" and to add him to the the fields that consider, to initialize the "Writer" and finally to stop the edition.  

I include you a piece of code by if helps you:

  ILayerDefinition lyrDef = EditionUtilities.createLayerDefinition(layer);

    //Here, modify the LayerDefinition
    
  writer.initialize(lyrDef);
  vea.stopEdition(writer, EditionEvent.GRAPHIC);

I expect to have clarified something.

Regards.

Vicente Caballero Navarro
Grupo desarrollo gvSIG.
www.gvsig.gva.es
www.iver.es
  ----- Original Message ----- 
  From: erwan bocher 
  To: Users and Developers mailing list 
  Sent: Tuesday, October 10, 2006 9:53 AM
  Subject: [Gvsig_english] gvSIG gdbms shape driver


  Hello,


  I try to use GDBMS to read and write values and fields in a shapefile. I used the code below. I have an error about com.iver.cit.gvsig.fmap.drivers.shp.IndexedShpDriver.

  //Ici on va chercher le ou les drivers necessaires driver 
          LayerFactory.setDriversPath("C:/Temp/driver");
          
          Driver driver = LayerFactory.getDM().getDriver("gvSIG shp driver");
                   
            if (driver!=null){ //Si le driver est trouvé alors on continue 
                
                System.out.println(driver.getName()); //On affiche son petit nom.
                
              LayerFactory.getDataSourceFactory().addFileDataSource("gvSIG shp driver", "macouche", 
              "C:/Temp/countries.shp");
              
              // SelectableDataSource permet de travailler sur la table
              
              SelectableDataSource sds = new SelectableDataSource( LayerFactory.getDataSourceFactory().createRandomDataSource("macouche", DataSourceFactory.MANUAL_OPENING));
              EditableAdapter ea = new EditableAdapter();
              ea.setOriginalDataSource(sds); 
                      
              ea.startEdition(0);
              IWriter writer = ea.getWriter();
              
              FieldDescription field = null;
              
              field.setFieldName("myfield"); 
              
              ea.addField(field);
              
              ea.stopEdition(writer, 0);

  Thanks

  R1.






------------------------------------------------------------------------------


  _______________________________________________
  Gvsig_internacional mailing list
  Gvsig_internacional at runas.cap.gva.es
  http://runas.cap.gva.es/mailman/listinfo/gvsig_internacional
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://runas.cap.gva.es/pipermail/gvsig_internacional/attachments/20061010/d111fa83/attachment-0001.htm


More information about the Gvsig_internacional mailing list