Getting wrong predicate result

38 views
Skip to first unread message

kaar...@gmail.com

unread,
Sep 19, 2017, 2:22:18 PM9/19/17
to NetTopologySuite

I have two geometries as below listed in wkt. One geometry touched the other - however\ I am getting disjoint result. any suggestion as to how I can get the expected result of touch? I have tried different precision models but that hasn't helper. I also tested in JTS testrunner - that too fails to give the expected result. Can anyone here help throw any light on this and help? Thank you!

The following two geometries give the wrong result (disjoint)

GeomA: LINESTRING (31.26822419712768 13.10560781249994, 33.12591323377792 15.99391676083394, 35.37062066594295 16.870724851333293)

GeomB: LINESTRING (34.233240446942204 16.426451284228865, 34.98360215508764 15.581301171439307, 34.26116755535489 14.059781270564386)


The following two geometries give the expected result of touch.

GeomA: LINESTRING (45.786635465274315 13.801200800883471, 48.286635465274315 16.30120080088347, 51.786635465274315 16.30120080088347)

GeomB: LINESTRING (50.786635465274315 16.30120080088347, 50.786635465274315 14.301200800883471, 48.286635465274315 13.801200800883471)

FObermaier

unread,
Sep 29, 2017, 4:26:50 AM9/29/17
to NetTopologySuite
This is a precision issue.

var snr = NetTopologySuite.SnapRound.SnapRoundFunctions.SnapRound(wkt1, wkt2, 1000000000);
var touches = snr.GetGeometryN(0).Touches(snr.GetGeometryN(1));

Snap-rounding is in beta state, you will have to get the dependant code from the `NetTopologySuite.Lab` project and compile it yourself (https://github.com/NetTopologySuite/NetTopologySuite/tree/develop/NetTopologySuite.Lab).

Karu Kaarigar

unread,
Oct 9, 2017, 6:57:31 PM10/9/17
to nettopol...@googlegroups.com
Thank you for the help. I was able to get the code and compile in VS2017. It does give me expected result. However the question now is how does the snapping work and should I always use snap-rounding before evaluating the spatial relationship between geometries? Also, any reason why it is VS2017 solution? Is there any specific dependency on that version?

Thanks for the help - I really appreciate it!

--
You received this message because you are subscribed to a topic in the Google Groups "NetTopologySuite" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/nettopologysuite/1Cnlq7plcz4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to nettopologysuite+unsubscribe@googlegroups.com.
To post to this group, send email to nettopologysuite@googlegroups.com.
Visit this group at https://groups.google.com/group/nettopologysuite.
For more options, visit https://groups.google.com/d/optout.

FObermaier

unread,
Oct 10, 2017, 8:06:37 AM10/10/17
to NetTopologySuite
It is now a VS2017 solution because it was easier to adopt NetTopologySuite to .Net-Standard that way.
You can think of snap-rounding as some gridding algorithm along with noding.
I suggest you use a fixed precision model for your geometry factories. That should save you a lot of hustle.
To unsubscribe from this group and all its topics, send an email to nettopologysui...@googlegroups.com.
To post to this group, send email to nettopol...@googlegroups.com.

Karu Kaarigar

unread,
Oct 10, 2017, 12:17:42 PM10/10/17
to nettopol...@googlegroups.com
Thank you. I have tried previously using the fixed precision model for the geometry factories but that didn't give me the expected result in case of these geometries. However, the snap-rounding gave me the expected result. I guess the fixed precision model results depend upon the number of fixed position? How to determine the number of fixed position for a given set of coordinates of a geometry to get consistent spatial relation results? Thanks for all the help!

To unsubscribe from this group and all its topics, send an email to nettopologysuite+unsubscribe@googlegroups.com.
To post to this group, send email to nettopologysuite@googlegroups.com.

Karu Kaarigar

unread,
Oct 10, 2017, 4:55:43 PM10/10/17
to nettopol...@googlegroups.com
Also, the call to SnapRoundFunctions.SnapRound throws an exception An item with the same key has already been added. Presumably when the geometries being snapped are equal. Presumably because the SnapRound.CreateGeometryCollection call fails due to duplicate key.

FObermaier

unread,
Oct 11, 2017, 2:15:30 AM10/11/17
to NetTopologySuite
This is begging for a unit test to prove.

FObermaier

unread,
Oct 11, 2017, 2:24:08 AM10/11/17
to NetTopologySuite
There is no heuristic that I know of. I tend to choose it higher than what I actually need. For example if my need were an accuracy of millimeter I choose a precision of micrometer.

kaar...@gmail.com

unread,
Oct 20, 2017, 4:36:09 PM10/20/17
to NetTopologySuite
Is there a way to speed up the SnapRound()? Checking for 1000 geometries for touch relationship takes a very long time.

I have tried using various precisionmodels and different scales but that hasn't helped. Are there any other alternatives? Thanks!
Reply all
Reply to author
Forward
0 new messages