[Gfoss] qgis: layer not valid

giuliano su Tiscali giulianc a tiscali.it
Lun 16 Apr 2012 23:12:55 CEST


ciao a tutti,

sono riuscito a far partire un'applicazione standalone basata su
qgis, seguendo la guida qgis-1.6.0_coding-compilation_guide_en.pdf;

sembra tutto a posto ma quando carico un layer (che sono certo essere
corretto in quanto qGis lo legge perfettamente) questo non supera il
controllo di validitĂ ; indagando ho visto che non ha dataProvider
(None);

dove potrei cercare l'intoppo?

grazie, ciao,
giuliano

PS: se servissero, quì sono le linee coinvolte:

  ........
# Add an OGR layer to the map
  def addLayer(self):
    file = QFileDialog.getOpenFileName(self, "Open Shapefile", ".", "Shapefiles (*.shp)")
    fileInfo = QFileInfo(file)
    print "file:", file (*)
    print "fileInfo:", fileInfo (*)
    print "fileInfo.filename():", fileInfo.fileName() (*)

#   Add the layer
    layer = QgsVectorLayer(file, fileInfo.fileName(), "ogr")
    print "layer:", layer (*)
    print "layer data provider:", layer.dataProvider() (*)
    print "layer validity:", layer.isValid() (*)

    if not layer.isValid():
      print "oops: the layer is not valid"
      return ++++++++ il codice si ferma qui ++++++++++++++

#   Change the color of the layer to gray
    symbols = layer.renderer().symbols()
    symbol = symbols[0]
    symbol.setFillColor(QColor.fromRgb(192,192,192))

#   Add layer to the registry
    QgsMapLayerRegistry.instance().addMapLayer(layer);
    .....

(*) aggiunte da me per indagare l'errore;


Maggiori informazioni sulla lista Gfoss