Boost logo

Geometry :

Subject: Re: [geometry] point on/intersects linestring?
From: Barend Gehrels (barend_at_[hidden])
Date: 2013-09-03 16:14:34


Hi Adam,

On 3-9-2013 21:53, Adam Wulkiewicz wrote:
> Barend Gehrels wrote:
>> Hi Adam,
>>
>>
>> On 3-9-2013 15:02, Adam Wulkiewicz wrote:
>>> Adam Wulkiewicz wrote:
>>>> AFAIK there isn't and intersects() for Box-Linestring isn't yet
>>>> implemented. There is a function calculating the comparable
>>>> distance of a Linestring/Segment-Box intersection but it's in the
>>>> index::detail so currently isn't a part of the official interface.
>>>> Barend should I add some parts of it to the bg::intersects()?
>>>
>>> For example something like in the patch.
>>
>> Yeah, I looked at the referred website and the patch
>>
>> Thanks a lot for your efforts and quick work, this looks promising.
>>
>> But do we need to develop it from scratch again?
>>
>> It has a considerable overlap with the current implementation of
>> clipping a linestring (or segment) with a box. See also
>> algorithms\detail\overlay\clip_linestring.hpp This file is not
>> touched (or looked at by me) for a long long time, I just looked at
>> it again and it is a bit old style. I did not test it but it seems
>> that it (especially the liang_barsky strategy) returns exactly if a
>> segment is clipped by a box, in a comparable way.
>>
>
> Ok, I didn't know about it.
>
>> Did you write a unit-test for this when you developed this?
>
> I have written only a test for the implementation in the Index. Not
> yet for this one
>
>> I'm curious:
>> - if it works for 3d (the strategy above does not)
>
> It should work for n-dimensional cartesian boxes, segments and
> linestrings.
>
>> - does it return false when the whole segment is inside? Don't see
>> that in the article.
>
> intersects() returns true.
>
>> - does it work for degenerate segments (point 1 == point 2)? Seeing
>> the patch it will divide by zero then?
>
> Hmm, I probably haven't thought about this particular case, only the
> case when the segment is parallel to the edge (the difference of
> coordinates for this dimension is also 0), but I've just tested it and
> it works.

Because you already have this implementation ready also supporting nD,
we can merge it later with existing code, if convenient / necessary. So
yes, could you apply the patches you send? I can add cases to the unit
tests this weekend or so.

Thanks! Barend


Geometry list run by mateusz at loskot.net