[geos-devel] Geometry/Rectangle Intersection, line merging ?

Sandro Santilli strk at keybit.net
Tue Sep 9 06:55:04 PDT 2014


On Tue, Sep 09, 2014 at 04:45:11PM +0300, Mika Heiskanen wrote:
> On 09/09/2014 04:06 PM, Sandro Santilli wrote:

> >One failing test (when using ST_Intersection) is this one
> >(number 87 in the unit test):
> >
> >     // triangle corner at left edge
> >     Input:   LINESTRING (3 3,0 6,3 9)
> >     Desired: LINESTRING (3 3,0 6,3 9)
> >
> >ST_Intersection outputs this instead:
> >
> >     Output:  MULTILINESTRING ((0 6, 3 9), (0 6, 3 3))
> 
> I do not see why the output should be split unless it has been
> agreed in some (de facto?) standard. Has it?

Not really. It just happen to be the case due to the algorithm used
for the overlay based intersection. When the topology is built the
edge do not get sewed unless needed (ie: for polygons).

I think avoiding the re-join is just done to do less work, as if needed
it can be obtained by a subsequent step.

> The first thing I'd do, if you want the original GEOS behavior, would
> be to change code as follows:
> 
> 156  if(pos != Rectangle::Inside)
> 
> 163     if(x <= rect.xmin())
> 164       while(i < n && cs[i].x <= rect.xmin())
> 165          ++i
> 
> and similarly for lines 167-177. I fear some escalation is bound to
> happen after that.

Yep, I was looking there. Not sure if it's worth the trouble really,
or if I should just update the test to check for spatial (rather
than structural) equality.

--strk;

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


More information about the geos-devel mailing list