<!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&uuml;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&uuml;r
Geoinformation</span><br><span style='font-size: 10pt; '>SO!GIS
Koordination</span><br><span style='font-size: 10pt; '>R&ouml;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&uuml;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&uuml;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&uuml;ster
Horst:</span><br><span style='font-size: 10pt; '>&gt; Code and corresponding
outputs with respect to an example postgis
layer:</span><br><span style='font-size: 10pt; '>&gt;</span><br><span style='font-size: 10pt; '>&gt;</span><br><span style='font-size: 10pt; '>&gt;
...</span><br><span style='font-size: 10pt; '>&gt;     print "N-Features:
"+str(provider.featureCount())</span><br><span style='font-size: 10pt; '>&gt; #
Output: "N-Features: 4
"</span><br><span style='font-size: 10pt; '>&gt;</span><br><span style='font-size: 10pt; '>&gt;
provider.getNextFeature(feat)</span><br><span style='font-size: 10pt; '>&gt;    
attrib = feat.attributeMap()</span><br><span style='font-size: 10pt; '>&gt;    
geom =
feat.geometry()</span><br><span style='font-size: 10pt; '>&gt;</span><br><span style='font-size: 10pt; '>&gt;
print "Geomtry:
"+geom.exportToWkt()</span><br><span style='font-size: 10pt; '>&gt; # Error
message: AttributeError: 'NoneType' object has no
attribute</span><br><span style='font-size: 10pt; '>&gt;
'exportToWkt'</span><br><span style='font-size: 10pt; '>&gt;     print
"AttributeMap: "+str(attrib)</span><br><span style='font-size: 10pt; '>&gt; #
Output: "AttributeMap: {}"</span><br><span style='font-size: 10pt; '>&gt;
...</span><br><span style='font-size: 10pt; '>&gt;</span><br><span style='font-size: 10pt; '>&gt;
The number of features is correct but no geometry and no
attributeMap</span><br><span style='font-size: 10pt; '>&gt;</span><br><span style='font-size: 10pt; '>&gt;
Regards</span><br><span style='font-size: 10pt; '>&gt;
Horst</span><br><span style='font-size: 10pt; '>&gt;
------------------------------------------------</span><br><span style='font-size: 10pt; '>&gt;</span><br><span style='font-size: 10pt; '>&gt;
Dr. Horst D&uuml;ster</span><br><span style='font-size: 10pt; '>&gt;
GIS-Koordinator, Stv.
Amtschef</span><br><span style='font-size: 10pt; '>&gt;</span><br><span style='font-size: 10pt; '>&gt;
Kanton Solothurn</span><br><span style='font-size: 10pt; '>&gt; Bau- und
Justizdepartement</span><br><span style='font-size: 10pt; '>&gt; Amt f&uuml;r
Geoinformation</span><br><span style='font-size: 10pt; '>&gt; SO!GIS
Koordination</span><br><span style='font-size: 10pt; '>&gt; R&ouml;tistrasse
4</span><br><span style='font-size: 10pt; '>&gt; CH-4501
Solothurn</span><br><span style='font-size: 10pt; '>&gt;</span><br><span style='font-size: 10pt; '>&gt;
Telefon ++41(0)32 627 25 32</span><br><span style='font-size: 10pt; '>&gt;
Telefax ++41(0)32 627 22
14</span><br><span style='font-size: 10pt; '>&gt;</span><br><span style='font-size: 10pt; '>&gt;
mailto:horst.duester@bd.so.ch</span><br><span style='font-size: 10pt; '>&gt;
http://www.agi.so.ch</span><br><span style='font-size: 10pt; '>&gt;</span><br><span style='font-size: 10pt; '>&gt;</span><br><span style='font-size: 10pt; '>&gt;</span><br><span style='font-size: 10pt; '>&gt;
-----Urspr&uuml;ngliche
Nachricht-----</span><br><span style='font-size: 10pt; '>&gt; Von: Marco
Hugentobler
[mailto:marco.hugentobler@karto.baug.ethz.ch]</span><br><span style='font-size: 10pt; '>&gt;
Gesendet am: Mittwoch, 13. Februar 2008
12:39</span><br><span style='font-size: 10pt; '>&gt; An:
qgis-developer@lists.osgeo.org</span><br><span style='font-size: 10pt; '>&gt;
Cc: D&uuml;ster Horst</span><br><span style='font-size: 10pt; '>&gt; Betreff:
Re: [Qgis-developer] provider.getNextFeature(fet) with
PostGIS</span><br><span style='font-size: 10pt; '>&gt;</span><br><span style='font-size: 10pt; '>&gt;
I recently did some changes in the postgres provider to
enhance</span><br><span style='font-size: 10pt; '>&gt;
efficiency.</span><br><span style='font-size: 10pt; '>&gt; Maybe this is a
side-effect of my changes? It would therefore
be</span><br><span style='font-size: 10pt; '>&gt;
interesting</span><br><span style='font-size: 10pt; '>&gt; to know what exactly
does not work. Is the geometry empty? Or
the</span><br><span style='font-size: 10pt; '>&gt;
attribute</span><br><span style='font-size: 10pt; '>&gt; information missing?
Also, it would be good to know the arguments
you</span><br><span style='font-size: 10pt; '>&gt;
passed</span><br><span style='font-size: 10pt; '>&gt; to
'getNextFeature'.</span><br><span style='font-size: 10pt; '>&gt;</span><br><span style='font-size: 10pt; '>&gt;
As it works with .shp layers, I think it is very unlikely that it is
a</span><br><span style='font-size: 10pt; '>&gt;
python</span><br><span style='font-size: 10pt; '>&gt; bindings
problem.</span><br><span style='font-size: 10pt; '>&gt;</span><br><span style='font-size: 10pt; '>&gt;
Regards,</span><br><span style='font-size: 10pt; '>&gt;
Marco</span><br><span style='font-size: 10pt; '>&gt;</span><br><span style='font-size: 10pt; '>&gt;
Am Mittwoch 13 Februar 2008 12:14:29 schrieb D&uuml;ster
Horst:</span><br><span style='font-size: 10pt; '>&gt; &gt;
Martin</span><br><span style='font-size: 10pt; '>&gt;
&gt;</span><br><span style='font-size: 10pt; '>&gt; &gt; Thank you for Rev. 8153
now setAttributeMap() works fine. But now
I'm</span><br><span style='font-size: 10pt; '>&gt; &gt; faced with the next
problem.</span><br><span style='font-size: 10pt; '>&gt;
&gt;</span><br><span style='font-size: 10pt; '>&gt; &gt;
provider.getNextFeature()</span><br><span style='font-size: 10pt; '>&gt;
&gt;</span><br><span style='font-size: 10pt; '>&gt; &gt; doesn't work no more
with PostGIS layers. It works fine with
*.shp</span><br><span style='font-size: 10pt; '>&gt; &gt;
layers.</span><br><span style='font-size: 10pt; '>&gt;
&gt;</span><br><span style='font-size: 10pt; '>&gt; &gt; Maybe the same issue
like setAttributeMap()???</span><br><span style='font-size: 10pt; '>&gt;
&gt;</span><br><span style='font-size: 10pt; '>&gt; &gt; Geoprocessing
Plugin:</span><br><span style='font-size: 10pt; '>&gt; &gt; &gt;In my opinion
you can put your plugin to the repository, maybe
some</span><br><span style='font-size: 10pt; '>&gt; &gt; &gt;people would like
to join your efforts!</span><br><span style='font-size: 10pt; '>&gt;
&gt;</span><br><span style='font-size: 10pt; '>&gt; &gt; How can I put the
plugin to the repository??</span><br><span style='font-size: 10pt; '>&gt;
&gt;</span><br><span style='font-size: 10pt; '>&gt; &gt;
Regards</span><br><span style='font-size: 10pt; '>&gt; &gt;
Horst</span><br><span style='font-size: 10pt; '>&gt;
&gt;</span><br><span style='font-size: 10pt; '>&gt; &gt;
------------------------------------------------</span><br><span style='font-size: 10pt; '>&gt;
&gt;</span><br><span style='font-size: 10pt; '>&gt; &gt; Dr. Horst
D&uuml;ster</span><br><span style='font-size: 10pt; '>&gt; &gt; GIS-Koordinator,
Stv. Amtschef</span><br><span style='font-size: 10pt; '>&gt;
&gt;</span><br><span style='font-size: 10pt; '>&gt; &gt; Kanton
Solothurn</span><br><span style='font-size: 10pt; '>&gt; &gt; Bau- und
Justizdepartement</span><br><span style='font-size: 10pt; '>&gt; &gt; Amt
f&uuml;r Geoinformation</span><br><span style='font-size: 10pt; '>&gt; &gt;
SO!GIS Koordination</span><br><span style='font-size: 10pt; '>&gt; &gt;
R&ouml;tistrasse 4</span><br><span style='font-size: 10pt; '>&gt; &gt; CH-4501
Solothurn</span><br><span style='font-size: 10pt; '>&gt;
&gt;</span><br><span style='font-size: 10pt; '>&gt; &gt; Telefon ++41(0)32 627
25 32</span><br><span style='font-size: 10pt; '>&gt; &gt; Telefax ++41(0)32 627
22 14</span><br><span style='font-size: 10pt; '>&gt;
&gt;</span><br><span style='font-size: 10pt; '>&gt; &gt;
mailto:horst.duester@bd.so.ch</span><br><span style='font-size: 10pt; '>&gt;
&gt; 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>