Hi all, <br><br>two days ago I wrote a similar plugin for a LD talk in Pisa.<br>I was unaware of the QgsSpatialIndex class (seems there's no documentation <br>about it in the online QGis API pages or maybe I missed it) so I wrote a simple <br>
loop to find the closest feature.<br><br>Now I tried also the Nearest plugin and they are different behavior!<br>See the scheenshots [1] [2].<br><br>AFAICS, Nearest select a wrong polygon.<br>I see the plugin's code and I think it could a QgsSpatialIndex bug, but it could be <br>
also the normal behaviour (I didn't found its documentation on the API pages <br>so I don't know).<br><br>I'm going to add my plugin (ClosestFeatureFinded) to the Faunalia repo so you <br>can try it and check the different behavior. <br>
<br>I hope this can help to find the bug (if any). <br>If you confirm it, I'll fill a bug report.<br><br>Cheers.<br><br>[1] <a href="http://img87.imageshack.us/img87/3232/nearest.jpg">http://img87.imageshack.us/img87/3232/nearest.jpg</a><br>
[2] <a href="http://img64.imageshack.us/img64/2066/closest.jpg">http://img64.imageshack.us/img64/2066/closest.jpg</a><br><br><div class="gmail_quote">On Fri, Oct 22, 2010 at 9:19 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;">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>
regards<br>
Stefan<br>
<br>
mit freundlichem Gruss<br>
Stefan Ziegler<br>
<br>
<br>
----- Originalnachricht -----<br>
Von: "Jim Hammack" <hammack@GotSlack.org><br>
Gesendet: Don, 21.10.2010 19:20<br>
An: "Ziegler Stefan" <<a href="mailto:Stefan.Ziegler@bd.so.ch">Stefan.Ziegler@bd.so.ch</a>><br>
Cc: 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>
<div><div></div><div class="h5"><br>
<br>
Stefan,<br>
<br>
<br>
<br>
I was looking for the same functionality as Zoran so have<br>
also been working with your "Nearest" plugin. It is exactly<br>
what I need and seems to work well.<br>
<br>
<br>
<br>
Thanks!<br>
<br>
Jim<br>
<br>
<br>
<br>
On 10/20/2010 01:54 PM, Ziegler Stefan wrote:<br>
<br>
<br>
Hi Zoran<br>
<br>
<br>
<br>
I had some time left, took all<br>
my code snippets and also the one from Carson. Please try<br>
the plugin "Nearest" that should cover your example 1:<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>
regards<br>
<br>
Stefan<br>
<br>
<br>
-----Ursprüngliche<br>
Nachricht-----<br>
<br>
Von: Zoran Jankovic [mailto:<a href="mailto:zoran.jankovic@zisis.hr">zoran.jankovic@zisis.hr</a>]<br>
<br>
Gesendet am: Mittwoch, 20. Oktober 2010 19:21<br>
<br>
An: qgis-user<br>
<br>
Betreff: Re: Fwd: [Qgis-user] QGIS "Near"<br>
<br>
<br>
<br>
Hi Joe,<br>
<br>
<br>
<br>
<br>
<br>
<br>
On Wed, Oct 20, 2010 at 5:06 PM, Joe<br>
Larson <<a href="mailto:joelarso@gmail.com">joelarso@gmail.com</a>><br>
wrote:<br>
<br>
<br>
Does the function 'snapWithContext'<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>
which "Snaps to segment or vertex within given tolerance."<br>
seem like<br>
<br>
what you're looking for? I came across it while trying to<br>
get Quantum<br>
<br>
Navigator working recently...seemed relative, but I'm no<br>
expert!<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
This is similar to the mentioned solution with<br>
selecting by radius, or changing the tolerance of ID tool.<br>
Close, but no cigar. Since this is not very urgent, I've<br>
decided to continue pursuing that outlined solution Carson<br>
gave, and write a plugin i Python based on that. Since I<br>
actually never used Python before, it may take a while,<br>
but hey, I get to learn sth. new :-).<br>
<br>
I never got the word back from Carson, has he developed<br>
anything along these lines, but I have to presume he<br>
didn't...<br>
<br>
Anyone interested in joning me, or even earning some<br>
money, is still invited to jump on board. My GIS<br>
implementation project is well on the way, and it seems<br>
there'll even be some money involved :-).<br>
<br>
<br>
<br>
Zoran<br>
<br>
<br>
<br>
<br>
<br>
~joe<br>
<br>
<br>
<br>
On Tue, Oct 19, 2010 at 9:55 AM, Andreas Neumann<br>
<a.neumann at <a href="http://carto.net" target="_blank">carto.net</a>>wrote:<br>
<br>
<br>
<br>
<br>
> Hi Zoran,<br>
<br>
><br>
<br>
> I believe the infrastructure of what you want is<br>
already wihtin the<br>
<br>
> selection and identify tools in QGIS. Isn't this<br>
almost implemented in the<br>
<br>
> current identify tool?<br>
<br>
><br>
<br>
><br>
<br>
It sort of is, but not completely. Identify will ID<br>
all the features within<br>
<br>
certain radios (percentage of extent), but it will ID<br>
_all_ of the features<br>
<br>
within this radius. I only need the nearest, no matter<br>
how far away... Let<br>
<br>
us say it is, for simplicity, within current extent.<br>
<br>
<br>
<br>
<br>
<br>
> The current identify tool selects "near" or<br>
"close by" features within a<br>
<br>
> certain tolerance. This tolerance can be set in<br>
"Options" --> "Map tools"<br>
<br>
> "search radius". I believe it currently only<br>
effects the identify tool. Do<br>
<br>
> you want the same tolerance also be used for the<br>
click-selection tool?<br>
<br>
><br>
<br>
><br>
<br>
Look above. This could be useful, but it is not the<br>
functionality I'm<br>
<br>
currently looking after.<br>
<br>
<br>
<br>
<br>
<br>
> Are you also aware that in QGIS 1.6 there are new<br>
selection tools?<br>
<br>
><br>
<br>
> * by click<br>
<br>
> * by rectangle<br>
<br>
> * by polygon<br>
<br>
> * by freehand<br>
<br>
> * by radius<br>
<br>
><br>
<br>
><br>
<br>
Yup, these are great, but they all select _multiple_<br>
features within radius,<br>
<br>
rectangle, etc.<br>
<br>
<br>
<br>
<br>
<br>
> Maybe this also helps to address your needs?<br>
<br>
><br>
<br>
> Of course you can combine it with previous<br>
selections by pressing the ctrl<br>
<br>
> key.<br>
<br>
><br>
<br>
><br>
<br>
<br>
<br>
BR,<br>
<br>
<br>
<br>
<br>
<br>
---<br>
<br>
Zoran Jankovic<br>
<br>
ZIS-Izrada softvera i savjetovanje / ZIS - Software<br>
Development and<br>
<br>
Consulting<br>
<br>
<br>
<br>
<a href="http://www.zisis.hr" target="_blank">http://www.zisis.hr</a><br>
<br>
<br>
<br>
M: 00 385 98 682 902<br>
<br>
T: 00 385 44 683 374<br>
<br>
<br>
<br>
A. Senoe 4<br>
<br>
44320 Kutina<br>
<br>
Croatia<br>
<br>
<br>
<br>
<br>
_______________________________________________<br>
<br>
Qgis-user mailing list<br>
<br>
<a href="mailto:Qgis-user@lists.osgeo.org">Qgis-user@lists.osgeo.org</a><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>
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>
<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>