<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html lang="en">
<head><meta http-equiv="Content-Type" content="text/html;">
<title>Scalix message content</title>
<style type="text/css">
<!--
.Normal { text-align: left; text-indent:0pt; margin-top:0pt; margin-bottom:0pt; font-family: Arial; font-size: 12pt; }
.Default_Paragraph_Font {font-family: Arial; color: Black; background-color: white ; font-size: 12pt; font-weight: normal; font-style: normal; font-variant: normal; vertical-align: normal; text-decoration: none;}
div.ltTOCtitle { font-family: Verdana; font-size: 8pt; font-weight: bold; text-align: center;}
div.ltTOCl1 { font-family: Verdana; font-size: 8pt; font-weight: bold; margin-left:32pt; text-indent:-32pt;}
div.ltTOCl2 { font-family: Verdana; font-size: 8pt; font-weight: bold; margin-left:40pt; text-indent:-32pt;}
div.ltTOCl3 { font-family: Verdana; font-size: 8pt; font-weight: bold; margin-left:48pt; text-indent:-32pt;}
div.ltTOCl4 { font-family: Verdana; font-size: 8pt; font-weight: bold; margin-left:56pt; text-indent:-32pt;}
div.ltTOCl5 { font-family: Verdana; font-size: 8pt; font-weight: bold; margin-left:64pt; text-indent:-32pt;}
div.ltTOCl6 { font-family: Verdana; font-size: 8pt; font-weight: bold; margin-left:72pt; text-indent:-32pt;}
-->
</style>
</head>
<body>
<div class="Normal"><span style='font-size: 10pt; '>Here is the complete
code:</span></div>
<br>
<div class="Normal"><span style='font-size: 10pt; '> def makeIntersection(self,
writer, vlayerA, vlayerB):</span><br><span style='font-size: 10pt; '>
providerA = vlayerA.getDataProvider()</span><br><span style='font-size: 10pt; '>
providerB = vlayerB.getDataProvider() </span></div>
<br>
<div class="Normal"><span style='font-size: 10pt; '> featA =
QgsFeature()</span><br><span style='font-size: 10pt; '> featB =
QgsFeature()</span></div>
<span style='font-size: 10pt; '> </span><br>
<div class="Normal"><span style='font-size: 10pt; '> allAttrsA =
providerA.allAttributesList()</span><br><span style='font-size: 10pt; '>
allAttrsB = providerB.allAttributesList() </span></div>
<br>
<div class="Normal"><span style='font-size: 10pt; '>#select only to the
intersection square of the bounding
boxes</span><br><span style='font-size: 10pt; '> combinedExtent =
vlayerB.extent().intersect(vlayerA.extent())</span></div>
<span style='font-size: 10pt; '> </span><br>
<div class="Normal"><span style='font-size: 10pt; '>
providerA.select(allAttrsA,
combinedExtent)</span><br><span style='font-size: 10pt; '>
providerB.select(allAttrsB, combinedExtent) </span></div>
<br>
<div class="Normal"><span style='font-size: 10pt; '># Detect the number of all
involved objects for later use</span><br><span style='font-size: 10pt; '># with
progressbar (nFeat) </span><br><span style='font-size: 10pt; '> tmpIndexA
= self.createIndex(providerA)</span><br><span style='font-size: 10pt; '>
tmpIntersectsA =
tmpIndexA.intersects(vlayerB.extent())</span><br><span style='font-size: 10pt; '>
tmpIndexB =
self.createIndex(providerB)</span><br><span style='font-size: 10pt; '>
tmpIntersectsB =
tmpIndexB.intersects(vlayerA.extent())</span><br><span style='font-size: 10pt; '>
nFeat = len(tmpIntersectsA) + len(tmpIntersectsB) </span></div>
<br>
<div class="Normal"><span style='font-size: 10pt; '> index =
self.createIndex(providerB) </span><br><span style='font-size: 10pt; '>
nElement = 0</span></div>
<span style='font-size: 10pt; '> </span><br>
<div class="Normal"><span style='font-size: 10pt; '>
self.geo_ctrl.progressBar.setValue(0)</span><br><span style='font-size: 10pt; '>
self.geo_ctrl.progressBar.setRange(0, nFeat) </span></div>
<span style='font-size: 10pt; '> </span><br>
<div class="Normal"><span style='font-size: 10pt; '>
providerA.getNextFeature(featA)</span><br><span style='font-size: 10pt; '>
attribA = featA.attributeMap()</span><br><span style='font-size: 10pt; '>
geomA = featA.geometry()</span><br><span style='font-size: 10pt; '> print
"N-Features:
"+str(providerA.featureCount())</span><br><span style='font-size: 10pt; '>
print "Geomtry: "+geomA.exportToWkt()</span><br><span style='font-size: 10pt; '>
print "AttributeMap: "+str(attribA)
</span><br><span style='font-size: 10pt; '> return 0</span></div>
<br>
<div class="Normal"><span style='font-size: 10pt; '>Regards</span><br><span style='font-size: 10pt; '>Horst</span><br><span style='font-size: 10pt; '>------------------------------------------------</span></div>
<br>
<div class="Normal"><span style='font-size: 10pt; '>Dr. Horst
Düster</span><br><span style='font-size: 10pt; '>GIS-Koordinator, Stv.
Amtschef</span></div>
<br>
<div class="Normal"><span style='font-size: 10pt; '>Kanton
Solothurn</span><br><span style='font-size: 10pt; '>Bau- und
Justizdepartement</span><br><span style='font-size: 10pt; '>Amt für
Geoinformation</span><br><span style='font-size: 10pt; '>SO!GIS
Koordination</span><br><span style='font-size: 10pt; '>Rötistrasse
4</span><br><span style='font-size: 10pt; '>CH-4501 Solothurn</span></div>
<br>
<div class="Normal"><span style='font-size: 10pt; '>Telefon ++41(0)32 627 25
32</span><br><span style='font-size: 10pt; '>Telefax ++41(0)32 627 22
14</span></div>
<br>
<div class="Normal"><span style='font-size: 10pt; '>mailto:horst.duester@bd.so.ch</span><br><span style='font-size: 10pt; '>http://www.agi.so.ch</span></div>
<br>
<div class="Normal"><span style='font-size: 10pt; '>-----Ursprüngliche
Nachricht-----</span><br><span style='font-size: 10pt; '>Von: Marco Hugentobler
[mailto:marco.hugentobler@karto.baug.ethz.ch]</span><br><span style='font-size: 10pt; '>Gesendet
am: Mittwoch, 13. Februar 2008
13:00</span><br><span style='font-size: 10pt; '>An: Düster
Horst</span><br><span style='font-size: 10pt; '>Cc:
qgis-developer</span><br><span style='font-size: 10pt; '>Betreff: Re: AW: Re:
[Qgis-developer] provider.getNextFeature(fet)
with</span><br><span style='font-size: 10pt; '>PostGIS</span></div>
<br>
<div class="Normal"><span style='font-size: 10pt; '>And what were the arguments
you provided for the select() call of the
</span><br><span style='font-size: 10pt; '>provider? </span></div>
<br>
<div class="Normal"><span style='font-size: 10pt; '>Marco </span></div>
<br>
<div class="Normal"><span style='font-size: 10pt; '>Am Mittwoch 13 Februar 2008
12:52:34 schrieb Düster
Horst:</span><br><span style='font-size: 10pt; '>> Code and corresponding
outputs with respect to an example postgis
layer:</span><br><span style='font-size: 10pt; '>></span><br><span style='font-size: 10pt; '>></span><br><span style='font-size: 10pt; '>>
...</span><br><span style='font-size: 10pt; '>> print "N-Features:
"+str(provider.featureCount())</span><br><span style='font-size: 10pt; '>> #
Output: "N-Features: 4
"</span><br><span style='font-size: 10pt; '>></span><br><span style='font-size: 10pt; '>>
provider.getNextFeature(feat)</span><br><span style='font-size: 10pt; '>>
attrib = feat.attributeMap()</span><br><span style='font-size: 10pt; '>>
geom =
feat.geometry()</span><br><span style='font-size: 10pt; '>></span><br><span style='font-size: 10pt; '>>
print "Geomtry:
"+geom.exportToWkt()</span><br><span style='font-size: 10pt; '>> # Error
message: AttributeError: 'NoneType' object has no
attribute</span><br><span style='font-size: 10pt; '>>
'exportToWkt'</span><br><span style='font-size: 10pt; '>> print
"AttributeMap: "+str(attrib)</span><br><span style='font-size: 10pt; '>> #
Output: "AttributeMap: {}"</span><br><span style='font-size: 10pt; '>>
...</span><br><span style='font-size: 10pt; '>></span><br><span style='font-size: 10pt; '>>
The number of features is correct but no geometry and no
attributeMap</span><br><span style='font-size: 10pt; '>></span><br><span style='font-size: 10pt; '>>
Regards</span><br><span style='font-size: 10pt; '>>
Horst</span><br><span style='font-size: 10pt; '>>
------------------------------------------------</span><br><span style='font-size: 10pt; '>></span><br><span style='font-size: 10pt; '>>
Dr. Horst Düster</span><br><span style='font-size: 10pt; '>>
GIS-Koordinator, Stv.
Amtschef</span><br><span style='font-size: 10pt; '>></span><br><span style='font-size: 10pt; '>>
Kanton Solothurn</span><br><span style='font-size: 10pt; '>> Bau- und
Justizdepartement</span><br><span style='font-size: 10pt; '>> Amt für
Geoinformation</span><br><span style='font-size: 10pt; '>> SO!GIS
Koordination</span><br><span style='font-size: 10pt; '>> Rötistrasse
4</span><br><span style='font-size: 10pt; '>> CH-4501
Solothurn</span><br><span style='font-size: 10pt; '>></span><br><span style='font-size: 10pt; '>>
Telefon ++41(0)32 627 25 32</span><br><span style='font-size: 10pt; '>>
Telefax ++41(0)32 627 22
14</span><br><span style='font-size: 10pt; '>></span><br><span style='font-size: 10pt; '>>
mailto:horst.duester@bd.so.ch</span><br><span style='font-size: 10pt; '>>
http://www.agi.so.ch</span><br><span style='font-size: 10pt; '>></span><br><span style='font-size: 10pt; '>></span><br><span style='font-size: 10pt; '>></span><br><span style='font-size: 10pt; '>>
-----Ursprüngliche
Nachricht-----</span><br><span style='font-size: 10pt; '>> Von: Marco
Hugentobler
[mailto:marco.hugentobler@karto.baug.ethz.ch]</span><br><span style='font-size: 10pt; '>>
Gesendet am: Mittwoch, 13. Februar 2008
12:39</span><br><span style='font-size: 10pt; '>> An:
qgis-developer@lists.osgeo.org</span><br><span style='font-size: 10pt; '>>
Cc: Düster Horst</span><br><span style='font-size: 10pt; '>> Betreff:
Re: [Qgis-developer] provider.getNextFeature(fet) with
PostGIS</span><br><span style='font-size: 10pt; '>></span><br><span style='font-size: 10pt; '>>
I recently did some changes in the postgres provider to
enhance</span><br><span style='font-size: 10pt; '>>
efficiency.</span><br><span style='font-size: 10pt; '>> Maybe this is a
side-effect of my changes? It would therefore
be</span><br><span style='font-size: 10pt; '>>
interesting</span><br><span style='font-size: 10pt; '>> to know what exactly
does not work. Is the geometry empty? Or
the</span><br><span style='font-size: 10pt; '>>
attribute</span><br><span style='font-size: 10pt; '>> information missing?
Also, it would be good to know the arguments
you</span><br><span style='font-size: 10pt; '>>
passed</span><br><span style='font-size: 10pt; '>> to
'getNextFeature'.</span><br><span style='font-size: 10pt; '>></span><br><span style='font-size: 10pt; '>>
As it works with .shp layers, I think it is very unlikely that it is
a</span><br><span style='font-size: 10pt; '>>
python</span><br><span style='font-size: 10pt; '>> bindings
problem.</span><br><span style='font-size: 10pt; '>></span><br><span style='font-size: 10pt; '>>
Regards,</span><br><span style='font-size: 10pt; '>>
Marco</span><br><span style='font-size: 10pt; '>></span><br><span style='font-size: 10pt; '>>
Am Mittwoch 13 Februar 2008 12:14:29 schrieb Düster
Horst:</span><br><span style='font-size: 10pt; '>> >
Martin</span><br><span style='font-size: 10pt; '>>
></span><br><span style='font-size: 10pt; '>> > Thank you for Rev. 8153
now setAttributeMap() works fine. But now
I'm</span><br><span style='font-size: 10pt; '>> > faced with the next
problem.</span><br><span style='font-size: 10pt; '>>
></span><br><span style='font-size: 10pt; '>> >
provider.getNextFeature()</span><br><span style='font-size: 10pt; '>>
></span><br><span style='font-size: 10pt; '>> > doesn't work no more
with PostGIS layers. It works fine with
*.shp</span><br><span style='font-size: 10pt; '>> >
layers.</span><br><span style='font-size: 10pt; '>>
></span><br><span style='font-size: 10pt; '>> > Maybe the same issue
like setAttributeMap()???</span><br><span style='font-size: 10pt; '>>
></span><br><span style='font-size: 10pt; '>> > Geoprocessing
Plugin:</span><br><span style='font-size: 10pt; '>> > >In my opinion
you can put your plugin to the repository, maybe
some</span><br><span style='font-size: 10pt; '>> > >people would like
to join your efforts!</span><br><span style='font-size: 10pt; '>>
></span><br><span style='font-size: 10pt; '>> > How can I put the
plugin to the repository??</span><br><span style='font-size: 10pt; '>>
></span><br><span style='font-size: 10pt; '>> >
Regards</span><br><span style='font-size: 10pt; '>> >
Horst</span><br><span style='font-size: 10pt; '>>
></span><br><span style='font-size: 10pt; '>> >
------------------------------------------------</span><br><span style='font-size: 10pt; '>>
></span><br><span style='font-size: 10pt; '>> > Dr. Horst
Düster</span><br><span style='font-size: 10pt; '>> > GIS-Koordinator,
Stv. Amtschef</span><br><span style='font-size: 10pt; '>>
></span><br><span style='font-size: 10pt; '>> > Kanton
Solothurn</span><br><span style='font-size: 10pt; '>> > Bau- und
Justizdepartement</span><br><span style='font-size: 10pt; '>> > Amt
für Geoinformation</span><br><span style='font-size: 10pt; '>> >
SO!GIS Koordination</span><br><span style='font-size: 10pt; '>> >
Rötistrasse 4</span><br><span style='font-size: 10pt; '>> > CH-4501
Solothurn</span><br><span style='font-size: 10pt; '>>
></span><br><span style='font-size: 10pt; '>> > Telefon ++41(0)32 627
25 32</span><br><span style='font-size: 10pt; '>> > Telefax ++41(0)32 627
22 14</span><br><span style='font-size: 10pt; '>>
></span><br><span style='font-size: 10pt; '>> >
mailto:horst.duester@bd.so.ch</span><br><span style='font-size: 10pt; '>>
> http://www.agi.so.ch</span></div>
<br>
<div class="Normal"><span style='font-size: 10pt; '>--
</span><br><span style='font-size: 10pt; '>Dr. Marco
Hugentobler</span><br><span style='font-size: 10pt; '>Institute of
Cartography</span><br><span style='font-size: 10pt; '>ETH
Zurich</span><br><span style='font-size: 10pt; '>Technical Advisor QGIS Project
Steering Committee</span></div>
</body>
</html>