Hi Stefan, <br><br><div class="gmail_quote">On Thu, Oct 28, 2010 at 7:48 AM, Ziegler Stefan <span dir="ltr"><<a href="mailto:Stefan.Ziegler@bd.so.ch">Stefan.Ziegler@bd.so.ch</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

thanks for looking into this. Do you think it's worth filling out a bug report since the nearestNeighbor method does not the  keep the promise or is this the normal behaviour of a spatial index based method?<br><div class="im">

</div></blockquote><div>I think we should fill a bug report because the nearestNeighbor doesn't work as <br>expected. <br>I don't know if the QgsSpatialIndex can be improved to manage complex geometries, <br>but AFAICS in the few inline comments within the code, in this moment it manages only <br>

Points, Lines and Regions (rectangles), so every polygonal geometry must be <br>converted to Regions.<br><br>This issue could take a lot of time to be fixed, but we can use the ticket to require <br>the documentation about the QgsSpatialIndex class. In this moment it's missing.<br>

<br>Cheers.<br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div class="im">

----- Originalnachricht -----<br>
Von: "Giuseppe Sucameli" <<a href="mailto:sucameli@faunalia.it">sucameli@faunalia.it</a>><br>
</div>Gesendet: Mit, 27.10.2010 17:30<br>
<div><div></div><div class="h5">An: "Ziegler Stefan" <<a href="mailto:Stefan.Ziegler@bd.so.ch">Stefan.Ziegler@bd.so.ch</a>><br>
Cc: "Jim Hammack" <<a href="mailto:hammack@gotslack.org">hammack@gotslack.org</a>> ; qgis-user <<a href="mailto:qgis-user@lists.osgeo.org">qgis-user@lists.osgeo.org</a>><br>
Betreff: Re: AW: Re: Fwd: [Qgis-user] QGIS "Near"<br>
<br>
Hi Stefan,<br>
your workaround works fine in my case!<br>
<br>
I looked at the QgsSpatialIndex code and I have bad news... It uses the bounding box<br>
of the geometries!<br>
This means that your workaround can work in a lot of cases but not in all cases, e.g. if<br>
<br>
<br>
you have more than N geometries (10 considering your workaround), ones inside<br>
each other.<br>
<br>
Cheers.<br>
<br>
On Tue, Oct 26, 2010 at 6:47 PM, Ziegler Stefan <<a href="mailto:Stefan.Ziegler@bd.so.ch">Stefan.Ziegler@bd.so.ch</a>> wrote:<br>
<br>
<br>
<br>
Hi Giuseppe<br>
<br>
<br>
<br>
I wrote a little workaround. Could you please update to 0.0.6 and check it with your test case? Thanks.<br>
<br>
<br>
<br>
regards<br>
<br>
Stefan<br>
<br>
<br>
<br>
mit freundlichem Gruss<br>
<br>
Stefan Ziegler<br>
<br>
<br>
<br>
<br>
<br>
----- Originalnachricht -----<br>
<br>
Von: "Giuseppe Sucameli" <<a href="mailto:sucameli@faunalia.it">sucameli@faunalia.it</a>><br>
<br>
Gesendet: Mon, 25.10.2010 14:09<br>
<br>
An: "Ziegler Stefan" <<a href="mailto:Stefan.Ziegler@bd.so.ch">Stefan.Ziegler@bd.so.ch</a>><br>
<br>
Cc: "Jim Hammack" <<a href="mailto:hammack@gotslack.org">hammack@gotslack.org</a>> ; qgis-user <<a href="mailto:qgis-user@lists.osgeo.org">qgis-user@lists.osgeo.org</a>><br>
<br>
<br>
<br>
Betreff: Re: AW: Re: Fwd: [Qgis-user] QGIS "Near"<br>
<br>
<br>
<br>
Hi all,<br>
<br>
<br>
<br>
two days ago I wrote a similar plugin for a LD talk  in Pisa.<br>
<br>
I was unaware of the QgsSpatialIndex class (seems there's no documentation<br>
<br>
about it in the online QGis API  pages or maybe I missed it) so I wrote a simple<br>
<br>
<br>
<br>
<br>
<br>
loop to find the closest feature.<br>
<br>
<br>
<br>
Now I tried also the Nearest plugin and they are different behavior!<br>
<br>
See the scheenshots [1] [2].<br>
<br>
<br>
<br>
AFAICS, Nearest select a wrong polygon.<br>
<br>
I see the plugin's code and I think it could a QgsSpatialIndex bug, but it could be<br>
<br>
<br>
<br>
<br>
<br>
also the normal behaviour (I didn't found its documentation on the API pages<br>
<br>
so I don't know).<br>
<br>
<br>
<br>
I'm going to add my plugin (ClosestFeatureFinded) to the Faunalia repo so you<br>
<br>
can try it and check the different behavior.<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
I hope this can help to find the bug (if any).<br>
<br>
If you confirm it, I'll fill a bug report.<br>
<br>
<br>
<br>
Cheers.<br>
<br>
<br>
<br>
[1] <a href="http://img87.imageshack.us/img87/3232/nearest.jpg" target="_blank">http://img87.imageshack.us/img87/3232/nearest.jpg</a><br>
<br>
<br>
<br>
<br>
<br>
[2] <a href="http://img64.imageshack.us/img64/2066/closest.jpg" target="_blank">http://img64.imageshack.us/img64/2066/closest.jpg</a><br>
<br>
<br>
<br>
On Fri, Oct 22, 2010 at 9:19 AM, Ziegler Stefan <<a href="mailto:Stefan.Ziegler@bd.so.ch">Stefan.Ziegler@bd.so.ch</a>> wrote:<br>
<br>
<br>
<br>
<br>
<br>
there is some strange behaviour when using it with polygon features (at least I think it's a bit strange): sometimes when you click into a polygon I would expect that it selects the polygon I clicked into but it selects an adjacent polygon. This is probably due to the nearestNeighbor method of the spatial index. Since the two neighboring polygons share a common border the distance would be equal but the spatial index does not check if the coordindates of the mouse click lies within one of the two polygons.<br>


<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
regards<br>
<br>
<br>
<br>
Stefan<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
mit freundlichem Gruss<br>
<br>
<br>
<br>
Stefan Ziegler<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
----- Originalnachricht -----<br>
<br>
<br>
<br>
Von: "Jim Hammack" <hammack@GotSlack.org><br>
<br>
<br>
<br>
Gesendet: Don, 21.10.2010 19:20<br>
<br>
<br>
<br>
An: "Ziegler Stefan" <<a href="mailto:Stefan.Ziegler@bd.so.ch">Stefan.Ziegler@bd.so.ch</a>><br>
<br>
<br>
<br>
Cc: qgis-user <<a href="mailto:qgis-user@lists.osgeo.org">qgis-user@lists.osgeo.org</a>><br>
<br>
<br>
<br>
Betreff: Re: AW: Re: Fwd: [Qgis-user] QGIS "Near"<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
    Stefan,<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
             I was looking for the same functionality as Zoran so have<br>
<br>
<br>
<br>
        also been working with your "Nearest" plugin.  It is exactly<br>
<br>
<br>
<br>
        what I need and seems to work well.<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
                                                                Thanks!<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
                                                                    Jim<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
    On 10/20/2010 01:54 PM, Ziegler Stefan wrote:<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
      Hi Zoran<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
      I had some time left, took all<br>
<br>
<br>
<br>
            my code snippets and also the one from Carson. Please try<br>
<br>
<br>
<br>
            the plugin "Nearest" that should cover your example 1:<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
      <a href="http://www.catais.org/qgis/plugins.xml" target="_blank">http://www.catais.org/qgis/plugins.xml</a><br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
      regards<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
      Stefan<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
        -----Ursprüngliche<br>
<br>
<br>
<br>
            Nachricht-----<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
            Von: Zoran Jankovic [mailto:<a href="mailto:zoran.jankovic@zisis.hr">zoran.jankovic@zisis.hr</a>]<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
            Gesendet am: Mittwoch, 20. Oktober 2010 19:21<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
            An: qgis-user<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
            Betreff: Re: Fwd: [Qgis-user] QGIS "Near"<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
          Hi Joe,<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
          On Wed, Oct 20, 2010 at 5:06 PM, Joe<br>
<br>
<br>
<br>
            Larson <<a href="mailto:joelarso@gmail.com">joelarso@gmail.com</a>><br>
<br>
<br>
<br>
            wrote:<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
              Does the function 'snapWithContext'<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
              <a href="http://doc.qgis.org/head/classQgsVectorLayer.html#733b974dce13d587e05cf3d4fc24f208" target="_blank">http://doc.qgis.org/head/classQgsVectorLayer.html#733b974dce13d587e05cf3d4fc24f208</a><br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
              which "Snaps to segment or vertex within given tolerance."<br>
<br>
<br>
<br>
              seem like<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
              what you're looking for? I came across it while trying to<br>
<br>
<br>
<br>
              get Quantum<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
              Navigator working recently...seemed relative, but I'm no<br>
<br>
<br>
<br>
              expert!<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
            This is similar to the mentioned solution with<br>
<br>
<br>
<br>
              selecting by radius, or changing the tolerance of ID tool.<br>
<br>
<br>
<br>
              Close, but no cigar. Since this is not very urgent, I've<br>
<br>
<br>
<br>
              decided to continue pursuing that outlined solution Carson<br>
<br>
<br>
<br>
              gave, and write a plugin i Python based on that. Since I<br>
<br>
<br>
<br>
              actually never used Python before, it may take a while,<br>
<br>
<br>
<br>
              but hey, I get to learn sth. new :-).<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
            I never got the word back from Carson, has he developed<br>
<br>
<br>
<br>
              anything along these lines, but I have to presume he<br>
<br>
<br>
<br>
              didn't...<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
            Anyone interested in joning me, or even earning some<br>
<br>
<br>
<br>
              money, is still invited to jump on board. My GIS<br>
<br>
<br>
<br>
              implementation project is well on the way, and it seems<br>
<br>
<br>
<br>
              there'll even be some money involved :-).<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
            Zoran<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
              ~joe<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
              On Tue, Oct 19, 2010 at 9:55 AM, Andreas Neumann<br>
<br>
<br>
<br>
              <a.neumann at <a href="http://carto.net" target="_blank">carto.net</a>>wrote:<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
                  > Hi Zoran,<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
                  ><br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
                  > I believe the infrastructure of what you want is<br>
<br>
<br>
<br>
                  already wihtin the<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
                  > selection and identify tools in QGIS. Isn't this<br>
<br>
<br>
<br>
                  almost implemented in the<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
                  > current identify tool?<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
                  ><br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
                  ><br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
                  It sort of is, but not completely. Identify will ID<br>
<br>
<br>
<br>
                  all the features within<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
                  certain radios (percentage of extent), but it will ID<br>
<br>
<br>
<br>
                  _all_ of the features<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
                  within this radius. I only need the nearest, no matter<br>
<br>
<br>
<br>
                  how far away... Let<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
                  us say it is, for simplicity, within current extent.<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
                  > The current identify tool selects "near" or<br>
<br>
<br>
<br>
                  "close by" features within a<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
                  > certain tolerance. This tolerance can be set in<br>
<br>
<br>
<br>
                  "Options" --> "Map tools"<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
                  > "search radius". I believe it currently only<br>
<br>
<br>
<br>
                  effects the identify tool. Do<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
                  > you want the same tolerance also be used for the<br>
<br>
<br>
<br>
                  click-selection tool?<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
                  ><br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
                  ><br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
                  Look above. This could be useful, but it is not the<br>
<br>
<br>
<br>
                  functionality I'm<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
                  currently looking after.<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
                  > Are you also aware that in QGIS 1.6 there are new<br>
<br>
<br>
<br>
                  selection tools?<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
                  ><br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
                  > * by click<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
                  > * by rectangle<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
                  > * by polygon<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
                  > * by freehand<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
                  > * by radius<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
                  ><br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
                  ><br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
                  Yup, these are great, but they all select _multiple_<br>
<br>
<br>
<br>
                  features within radius,<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
                  rectangle, etc.<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
                  > Maybe this also helps to address your needs?<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
                  ><br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
                  > Of course you can combine it with previous<br>
<br>
<br>
<br>
                  selections by pressing the ctrl<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
                  > key.<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
                  ><br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
                  ><br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
                  BR,<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
                  ---<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
                  Zoran Jankovic<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
                  ZIS-Izrada softvera i savjetovanje / ZIS - Software<br>
<br>
<br>
<br>
                  Development and<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
                  Consulting<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
                  <a href="http://www.zisis.hr" target="_blank">http://www.zisis.hr</a><br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
                  M: 00 385 98 682 902<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
                  T:  00 385 44 683 374<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
                  A. Senoe 4<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
                  44320 Kutina<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
                  Croatia<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
                _______________________________________________<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
                  Qgis-user mailing list<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
                  <a href="mailto:Qgis-user@lists.osgeo.org">Qgis-user@lists.osgeo.org</a><br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
                  <a href="http://lists.osgeo.org/mailman/listinfo/qgis-user" target="_blank">http://lists.osgeo.org/mailman/listinfo/qgis-user</a><br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
_______________________________________________<br>
<br>
<br>
<br>
Qgis-user mailing list<br>
<br>
<br>
<br>
<a href="mailto:Qgis-user@lists.osgeo.org">Qgis-user@lists.osgeo.org</a><br>
<br>
<br>
<br>
<a href="http://lists.osgeo.org/mailman/listinfo/qgis-user" target="_blank">http://lists.osgeo.org/mailman/listinfo/qgis-user</a><br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
_______________________________________________<br>
<br>
<br>
<br>
Qgis-user mailing list<br>
<br>
<br>
<br>
<a href="mailto:Qgis-user@lists.osgeo.org">Qgis-user@lists.osgeo.org</a><br>
<br>
<br>
<br>
<a href="http://lists.osgeo.org/mailman/listinfo/qgis-user" target="_blank">http://lists.osgeo.org/mailman/listinfo/qgis-user</a><br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
--<br>
<br>
Giuseppe Sucameli<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
--<br>
Giuseppe Sucameli<br>
<br>
<br>
_______________________________________________<br>
Qgis-user mailing list<br>
<a href="mailto:Qgis-user@lists.osgeo.org">Qgis-user@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/qgis-user" target="_blank">http://lists.osgeo.org/mailman/listinfo/qgis-user</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Giuseppe Sucameli<br><br>