Boost logo

Boost Users :

Subject: Re: [Boost-users] Interprenting nearest's neighbor's output
From: Georgios Samaras (georgesamarasdit_at_[hidden])
Date: 2014-04-15 05:54:40


I changed the code to use points, but order the items are returned is not
understandable by me.

I request the 5 NNs of the query point (0, 0), in a dataset of points (0,
0), (1, 1), .., (9, 9).

The output I receive is this:
knn query result:
POINT(4 4)
POINT(3 3)
POINT(2 2)
POINT(0 0)
POINT(1 1)

If you need the code, let me know. I remember that I read that the order is
not specified, but does that mean that there is no logic in the results? I
mean, clearly the 1st NN is (0, 0).

Thanks for the reply,
George

On Mon, Apr 14, 2014 at 5:19 PM, Adam Wulkiewicz
<adam.wulkiewicz_at_[hidden]>wrote:

> Hi Georgios,
>
>
> Georgios Samaras wrote:
>
>> I am running the code found here
>> http://www.boost.org/doc/libs/1_54_0_beta1/libs/geometry/
>> doc/html/geometry/spatial_indexes/rtree_examples/quick_start.html
>>
>> (not the intersect query, only the nn).
>>
>> The output is this:
>> "
>> knn query point:
>> POINT(0 0)
>> knn query result:
>> POLYGON((4 4,4 4.5,4.5 4.5,4.5 4,4 4)) - 4
>> POLYGON((3 3,3 3.5,3.5 3.5,3.5 3,3 3)) - 3
>> POLYGON((2 2,2 2.5,2.5 2.5,2.5 2,2 2)) - 2
>> POLYGON((0 0,0 0.5,0.5 0.5,0.5 0,0 0)) - 0
>> POLYGON((1 1,1 1.5,1.5 1.5,1.5 1,1 1)) - 1
>> "
>>
>> What are the integers on the right? Indices of the polygons?
>> Actually is not really clear to me what are we inserting in the tree..I
>> tried finding some documentation on these methods, but I only found info on
>> how to call them...
>>
>>
> In the rtree we're storing values defined in the line:
>
> typedef std::pair<box, unsigned> value;
>
>
> so it's a pair of a Box and some number. This is the classic approach
> where in the spatial index you store AABB (Axis-Aligned Bounding Box) of
> some geometry and an ID of this geometry.
>
> So why Polygons are printed when you're storing Boxes? Those lines are
> generated by this code:
>
> std::cout << bg::wkt<box>(v.first) << " -" << v.second <<
> std::endl;
>
>
> First the Box is printed in WKT format, then " - " and the ID. But WKT
> standard (http://en.wikipedia.org/wiki/Well-known_text) doesn't define
> how Boxes should be described. Boost.Geometry uses WKT Polygons for this.
> That's just a text output.
>
>
> What I want, is simply inserting some points in the tree and then search
>> for nn of a query point.
>>
>>
> If you don't need any additional data, instead of std::pair<box, unsigned>
> just use point type from the same example.
>
> Regards,
> Adam
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net