Toplogical relation between Polyline and Point feature is always disjoint

#1

(In the dev version)
When I add a new Point feature snapped to a line segment of a polyline feature and then later on try to get related shapes (featureSet.GetRelatedShapes(…)) using the point as the referenceShape, I get an empty list of indeces as result. Manually checking the two features:

var filtergeom; // I get this before, it’s not null
var testline = featureSet.GetGeometry(9807);
var contains = testline.Contains(filtergeom);
var within = testline.Within(filtergeom);
var touches = testline.Touches(filtergeom);
var overlap = testline.Overlaps(filtergeom);
var isects = testline.Intersects(filtergeom);
var disj = testline.Disjoint(filtergeom);
var cross = testline.Crosses(filtergeom);

only yields ‘True’ for the Disjoint

The polyline I tested this against in question has 2 point with these coordinates:
x,y
73647.8558546319,224394.875641653
73556.0590934128,224129.463266824
The point itself had coordinates:
73605.6678152168,224272.897179866

If I check in excel there is a small rounding error (like 2e-13) - but this is inevitable when working with floating point numbers… surely this can’t be the reason?

my workaround for now would be to make a tiny buffer around the point - but this is probably a bug

0 Likes

#2

We use the related GEOS methods to perform these geospatial operations.

What did you expect the results would be?

PostGIS is also using GEOS and their documentation is a bit more readable:
https://postgis.net/docs/ST_Crosses.html
At the bottom of this page are 4 examples. I assume your situation is like image 1:
And you expect true as the return value, right?

0 Likes

#3

I tried using PostGIS and it returns the same results. Everything is false, except disjoint.

This is the query:

SELECT 
  ST_Contains(ST_GeomFromText('LINESTRING(73647.8558546319 224394.875641653,73556.0590934128 224129.463266824)'), ST_GeomFromText('POINT(73605.6678152168 224272.897179866)'))
, ST_Contains(ST_GeomFromText('POINT(73605.6678152168 224272.897179866)'), ST_GeomFromText('LINESTRING(73647.8558546319 224394.875641653,73556.0590934128 224129.463266824)'))
, ST_Within(ST_GeomFromText('LINESTRING(73647.8558546319 224394.875641653,73556.0590934128 224129.463266824)'), ST_GeomFromText('POINT(73605.6678152168 224272.897179866)'))
, ST_Within(ST_GeomFromText('POINT(73605.6678152168 224272.897179866)'), ST_GeomFromText('LINESTRING(73647.8558546319 224394.875641653,73556.0590934128 224129.463266824)'))
, ST_Touches(ST_GeomFromText('LINESTRING(73647.8558546319 224394.875641653,73556.0590934128 224129.463266824)'), ST_GeomFromText('POINT(73605.6678152168 224272.897179866)'))
, ST_Touches(ST_GeomFromText('POINT(73605.6678152168 224272.897179866)'), ST_GeomFromText('LINESTRING(73647.8558546319 224394.875641653,73556.0590934128 224129.463266824)'))
, ST_Overlaps(ST_GeomFromText('LINESTRING(73647.8558546319 224394.875641653,73556.0590934128 224129.463266824)'), ST_GeomFromText('POINT(73605.6678152168 224272.897179866)'))
, ST_Overlaps(ST_GeomFromText('POINT(73605.6678152168 224272.897179866)'), ST_GeomFromText('LINESTRING(73647.8558546319 224394.875641653,73556.0590934128 224129.463266824)'))
, ST_Intersects(ST_GeomFromText('LINESTRING(73647.8558546319 224394.875641653,73556.0590934128 224129.463266824)'), ST_GeomFromText('POINT(73605.6678152168 224272.897179866)'))
, ST_Intersects(ST_GeomFromText('POINT(73605.6678152168 224272.897179866)'), ST_GeomFromText('LINESTRING(73647.8558546319 224394.875641653,73556.0590934128 224129.463266824)'))
, ST_Disjoint(ST_GeomFromText('LINESTRING(73647.8558546319 224394.875641653,73556.0590934128 224129.463266824)'), ST_GeomFromText('POINT(73605.6678152168 224272.897179866)'))
, ST_Disjoint(ST_GeomFromText('POINT(73605.6678152168 224272.897179866)'), ST_GeomFromText('LINESTRING(73647.8558546319 224394.875641653,73556.0590934128 224129.463266824)'))
, ST_Crosses(ST_GeomFromText('LINESTRING(73647.8558546319 224394.875641653,73556.0590934128 224129.463266824)'), ST_GeomFromText('POINT(73605.6678152168 224272.897179866)'))
, ST_Crosses(ST_GeomFromText('POINT(73605.6678152168 224272.897179866)'), ST_GeomFromText('LINESTRING(73647.8558546319 224394.875641653,73556.0590934128 224129.463266824)'))

So it seems your assumption is not correct. I’m not sure how to solve this. Perhaps your buffer option is not that bad after all.

0 Likes

#4

Thanks for looking at this Paul.

I also have the same result when testing on SQLServer. Buffering with a value as small as 1E-10 does the trick… weird

0 Likes

#5

Since the workaround is working and the weirdness is in GEOS, I’m closing this question.

0 Likes

closed #6
0 Likes