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

Sandro Santilli strk at keybit.net
Thu Sep 11 06:58:32 PDT 2014


On Thu, Sep 11, 2014 at 03:52:21PM +0200, Sandro Santilli wrote:
> On Wed, Sep 10, 2014 at 06:59:53PM -0700, Martin Davis wrote:
> > Sandro, are the two cases below currently in JTS?  If not I should add
> > them...
> 
> I hadn't checked, but I'm using GEOS results as reference, so it gives
> the results I'm reporting already.
> 
> Actually one result I'm looking at is perplexing.
> One operand is the usual rectangle, the other is a polygon which
> is cut by the right-edge of the rectangle and has a rectangular
> hole whose right edge is covered by the rectangle edge:
> 
>  POLYGON(
>   (5 2,5 8,15 8,15 2,5 2),
>   (8 4, 8 6, 10 6, 10 4, 8 4)
>  )
> 
> 10 +-----------+
>    |           |
>  8 |    +------+----+
>    |    |      :    |   h: hole
>  6 |    |  +---+    |   s: shell
>    |    |  | h |    |   
>  4 |    |  +---+    |
>    |    |      :    |
>    |    |   s  :  s |
>  2 |    +------+----+
>    |           |
>  0 +-----------+
>    0    5  8  10   15
> 
> GEOS intersection result is:
> 
>  GEOMETRYCOLLECTION (
>    POLYGON ((8 4, 8 6, 10 6, 10 4, 8 4)),
>    LINESTRING (10 2, 5 2, 5 8, 10 8)
>  )
> 
> Visually:
> 
> 10 . . . . . . .
>    .           .
>  8 .    +------+     
>    .    |      .        
>  6 .    |  +---+       
>    .    |  |   |        
>  4 .    |  +---+     
>    .    |      .     
>    .    |      .     
>  2 .    +------+     
>    .           .
>  0 . . . . . . .
>    0    5  8  10   15
> 
> Does JTS give the correct answer for that ?

Sorry, I've accidentally sent the result obtained by the new
RectangleIntersection code (the one returning lines rather than
rectangle) instead of the one returned by GEOS.

The one returned by GEOS is still suspicious:

 GEOMETRYCOLLECTION (
  LINESTRING (10 6, 10 4),
  POLYGON ((5 2, 5 8, 10 8, 10 6, 8 6, 8 4, 10 4, 10 2, 5 2))
 )

That is, the polygon I'd expect plus a dangling line I would
not expect to see in output.  Visually: 

 10 . . . . . . .
    .           .
  8 .    +------+
    .    |      |
  6 .    |  +---+
    .    |  |   |<-- spurious line
  4 .    |  +---+
    .    |      |
    .    |    s | <-- s: shell
  2 .    +------+
    .           .
  0 . . . . . . .
    0    5  8  10 

Is the dangling line expected to be in output ? If so, why ?
Does JTS also include it ?

--strk;

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


More information about the geos-devel mailing list