AW: Re: AW: Re: [Qgis-developer] provider.getNextFeature(fet) with
PostGIS
Düster Horst
Horst.Duester at bd.so.ch
Wed Feb 13 07:45:26 EST 2008
Here is the complete code:
def makeIntersection(self, writer, vlayerA, vlayerB):
providerA = vlayerA.getDataProvider()
providerB = vlayerB.getDataProvider()
featA = QgsFeature()
featB = QgsFeature()
allAttrsA = providerA.allAttributesList()
allAttrsB = providerB.allAttributesList()
#select only to the intersection square of the bounding boxes
combinedExtent = vlayerB.extent().intersect(vlayerA.extent())
providerA.select(allAttrsA, combinedExtent)
providerB.select(allAttrsB, combinedExtent)
# Detect the number of all involved objects for later use
# with progressbar (nFeat)
tmpIndexA = self.createIndex(providerA)
tmpIntersectsA = tmpIndexA.intersects(vlayerB.extent())
tmpIndexB = self.createIndex(providerB)
tmpIntersectsB = tmpIndexB.intersects(vlayerA.extent())
nFeat = len(tmpIntersectsA) + len(tmpIntersectsB)
index = self.createIndex(providerB)
nElement = 0
self.geo_ctrl.progressBar.setValue(0)
self.geo_ctrl.progressBar.setRange(0, nFeat)
providerA.getNextFeature(featA)
attribA = featA.attributeMap()
geomA = featA.geometry()
print "N-Features: "+str(providerA.featureCount())
print "Geomtry: "+geomA.exportToWkt()
print "AttributeMap: "+str(attribA)
return 0
Regards
Horst
------------------------------------------------
Dr. Horst Düster
GIS-Koordinator, Stv. Amtschef
Kanton Solothurn
Bau- und Justizdepartement
Amt für Geoinformation
SO!GIS Koordination
Rötistrasse 4
CH-4501 Solothurn
Telefon ++41(0)32 627 25 32
Telefax ++41(0)32 627 22 14
mailto:horst.duester at bd.so.ch
http://www.agi.so.ch
-----Ursprüngliche Nachricht-----
Von: Marco Hugentobler [mailto:marco.hugentobler at karto.baug.ethz.ch]
Gesendet am: Mittwoch, 13. Februar 2008 13:00
An: Düster Horst
Cc: qgis-developer
Betreff: Re: AW: Re: [Qgis-developer] provider.getNextFeature(fet) with
PostGIS
And what were the arguments you provided for the select() call of the
provider?
Marco
Am Mittwoch 13 Februar 2008 12:52:34 schrieb Düster Horst:
> Code and corresponding outputs with respect to an example postgis
layer:
>
>
> ...
> print "N-Features: "+str(provider.featureCount())
> # Output: "N-Features: 4 "
>
> provider.getNextFeature(feat)
> attrib = feat.attributeMap()
> geom = feat.geometry()
>
> print "Geomtry: "+geom.exportToWkt()
> # Error message: AttributeError: 'NoneType' object has no attribute
> 'exportToWkt'
> print "AttributeMap: "+str(attrib)
> # Output: "AttributeMap: {}"
> ...
>
> The number of features is correct but no geometry and no attributeMap
>
> Regards
> Horst
> ------------------------------------------------
>
> Dr. Horst Düster
> GIS-Koordinator, Stv. Amtschef
>
> Kanton Solothurn
> Bau- und Justizdepartement
> Amt für Geoinformation
> SO!GIS Koordination
> Rötistrasse 4
> CH-4501 Solothurn
>
> Telefon ++41(0)32 627 25 32
> Telefax ++41(0)32 627 22 14
>
> mailto:horst.duester at bd.so.ch
> http://www.agi.so.ch
>
>
>
> -----Ursprüngliche Nachricht-----
> Von: Marco Hugentobler [mailto:marco.hugentobler at karto.baug.ethz.ch]
> Gesendet am: Mittwoch, 13. Februar 2008 12:39
> An: qgis-developer at lists.osgeo.org
> Cc: Düster Horst
> Betreff: Re: [Qgis-developer] provider.getNextFeature(fet) with
PostGIS
>
> I recently did some changes in the postgres provider to enhance
> efficiency.
> Maybe this is a side-effect of my changes? It would therefore be
> interesting
> to know what exactly does not work. Is the geometry empty? Or the
> attribute
> information missing? Also, it would be good to know the arguments you
> passed
> to 'getNextFeature'.
>
> As it works with .shp layers, I think it is very unlikely that it is a
> python
> bindings problem.
>
> Regards,
> Marco
>
> Am Mittwoch 13 Februar 2008 12:14:29 schrieb Düster Horst:
> > Martin
> >
> > Thank you for Rev. 8153 now setAttributeMap() works fine. But now
I'm
> > faced with the next problem.
> >
> > provider.getNextFeature()
> >
> > doesn't work no more with PostGIS layers. It works fine with *.shp
> > layers.
> >
> > Maybe the same issue like setAttributeMap()???
> >
> > Geoprocessing Plugin:
> > >In my opinion you can put your plugin to the repository, maybe some
> > >people would like to join your efforts!
> >
> > How can I put the plugin to the repository??
> >
> > Regards
> > Horst
> >
> > ------------------------------------------------
> >
> > Dr. Horst Düster
> > GIS-Koordinator, Stv. Amtschef
> >
> > Kanton Solothurn
> > Bau- und Justizdepartement
> > Amt für Geoinformation
> > SO!GIS Koordination
> > Rötistrasse 4
> > CH-4501 Solothurn
> >
> > Telefon ++41(0)32 627 25 32
> > Telefax ++41(0)32 627 22 14
> >
> > mailto:horst.duester at bd.so.ch
> > http://www.agi.so.ch
--
Dr. Marco Hugentobler
Institute of Cartography
ETH Zurich
Technical Advisor QGIS Project Steering Committee
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/qgis-developer/attachments/20080213/e804072c/attachment-0001.html
More information about the Qgis-developer
mailing list