AW: Re: Fwd: [Qgis-user] QGIS "Near"

Giuseppe Sucameli sucameli at faunalia.it
Wed Oct 27 08:30:39 PDT 2010


Hi Stefan,
your workaround works fine in my case!

I looked at the QgsSpatialIndex code and I have bad news... It uses the
bounding box
of the geometries!
This means that your workaround can work in a lot of cases but not in all
cases, e.g. if
you have more than N geometries (10 considering your workaround), ones
inside
each other.

Cheers.

On Tue, Oct 26, 2010 at 6:47 PM, Ziegler Stefan <Stefan.Ziegler at bd.so.ch>wrote:

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


-- 
Giuseppe Sucameli
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20101027/0a142957/attachment.html>


More information about the Qgis-user mailing list