[geos-devel] Geometry/Rectangle Intersection: line touching rectangle

Sandro Santilli strk at keybit.net
Wed Sep 10 07:07:34 PDT 2014


So I've modified the RectangleIntersection algorithm to include
boundary points/lines in the output and updated the test to
expect those additional parts in the result.

Additionally, I've modified the tester to also run the current
overlay-based intersection and compare the results, and so far
I got the same results, so it would sound closer to be a transparent
replacement.

Tests are very welcome.

NOTE: if you build with -DUSE_RECTANGLE_INTERSECTION=1 you'll get
a version of GEOS automatically using the new algoritm whenever
GEOSIntersection (Geometry::intersection) is called with either
operands being a rectangle.

--strk;

On Tue, Sep 09, 2014 at 05:53:00PM +0200, Sandro Santilli wrote:
> On Tue, Sep 09, 2014 at 06:44:49PM +0300, Mika Heiskanen wrote:
> > On 09/09/2014 06:27 PM, Sandro Santilli wrote:
> > >>I'd like to see a reference where all such special cases
> > >>are defined explicitly. (No, I never looked for one, as explained
> > >>before.) In your previous example a linestring was split in half
> > >>because a vertex is on the rectangle edge. This is kind of consistent
> > >>with the interpretation that the vertex is considered to be out.
> > >>However, the example presented here is consistent with the
> > >>interpretation that the vertex should be considered to be in.
> > >
> > >Indeed the results are formally confusing.
> > >I hope Martin Davis can chime in, being the author of the currently
> > >used algorithm.
> > 
> > Our algorithm discards all points on the rectangle edges unless they
> > are required to represent the resulting geometry. This means
> > intermediate vertices might be skipped when the edges are travelling
> > along the rectangle edge.
> > 
> > I do see however that someone might wish original vertices on the edges
> > to be preserved during polygon clipping, for example if the geometry is
> > to be projected afterwards.
> 
> Yep. Best would be if all these options could be available as parameters
> of the RectangleIntersection class.
> 
> Beside, re-thinking about the consistency of the split, I think the reason
> why the linestring was split was not because the boundary of the rectangle
> was not considered part of the result, but rather just a subproduct of
> the geomgraph building algorithm. I'm saying this because in the case of
> a linestring laying on a single edge of the rectangle, that line also
> becomes a multiline, for no apparent reason. 
> 
> So my guess is that boundary intersections are always included in
> the result as either points, lines or polygons depending on the
> dimension of the intersection.
> 
> --strk; 
> 
>  ()  ASCII ribbon campaign  --  Keep it simple !
>  /\  http://strk.keybit.net/rants/ascii_mails.txt  

-- 

 ()  ASCII ribbon campaign  --  Keep it simple !
 /\  http://strk.keybit.net/rants/ascii_mails.txt  


More information about the geos-devel mailing list