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

Sandro Santilli strk at keybit.net
Thu Sep 11 06:52:21 PDT 2014

```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

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 ?

--strk;
```