Unfortunately the DE-9IM model (which is used to define the OGC SFS spatial
predicates which JTS implements) doesn't allow specifying true line
crossing (as far as I can tell). So there's no direct way to compute this
using existing JTS predicates.
Determining this condition would require building a simple topological
structure for each LineString (essentially a chain of segments). Then each
segment can be checked against all others to determine if a true crossing
exists. There are three situations which need to be checked: a) crossing
at interior point of 2 segments, (b) crossing at a vertex on one segment,
and (c) crossing at vertices on both segments. (This is why the full
topology is required, rather than just checking segments individually). To
make this performant, the segments would need to be indexed in some way
(for instance, using the JTS STRtree
This seems like a useful predicate to have for JTS. Feel free to post the
code if you implement it.
On Mon, Oct 20, 2014 at 6:28 AM, Tore Halset <[email protected]> wrote:
> Hello.
>
> I have two LineString depth contours that I want to check for crossing.
> For this domain, overlap/touch is fine, but not crossing.
>
> The following junit-formatted example show two LineStrings that touch each
> other in (2 2). This is reported as a crossing by
> LineString#crosses(LineString), but for my domain this is not a cross.
>
> public void testCrosses() throws ParseException {
> WKTReader r = new WKTReader();
> LineString ls1 = (LineString) r.read("LINESTRING (1 2, 3 2)");
> LineString ls2 = (LineString) r.read("LINESTRING (1 1, 2 2, 3 1)");
> assertFalse(ls1.crosses(ls2));
> }
>
> Any tips to how I can check for crossing, but not touches like this?
>
> Regards,
> Tore Halset.
>
> ------------------------------------------------------------------------------
> Comprehensive Server Monitoring with Site24x7.
> Monitor 10 servers for $9/Month.
> Get alerted through email, SMS, voice calls or mobile push notifications.
> Take corrective actions from your mobile device.
> http://p.sf.net/sfu/Zoho
> _______________________________________________
> Jts-topo-suite-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/jts-topo-suite-user
>
------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://p.sf.net/sfu/Zoho
_______________________________________________
Jts-topo-suite-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jts-topo-suite-user