Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

ST_Overlaps gives unexpected result

27 views
Skip to first unread message

Shijie li

unread,
Dec 25, 2024, 4:36:02 AM12/25/24
to SpatiaLite Users
Defination of ST_Overlaps :TRUE if the intersection of g1 and g2 results in a value of the same dimension as g1 and g2 that is different from both g1 and g2.

SELECT
ST_Overlaps(ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))'),
ST_GeomFromText('MULTIPOLYGON(((0 0, 0 2, 2 2, 2 0, 0 0)),((3 1,1 1,1 3, 3 1)))')),

ST_Overlaps(ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))'),
ST_GeomFromText('MULTIPOLYGON(((0 0, 0 2, 2 2, 2 0, 0 0)))'));

-- expected:{f, f}
-- acutal      :{t, f}

It should return false because MULTIPOLYGON(((0 0, 0 2, 2 2, 2 0, 0 0)),((3 1,1 1,1 3, 3 1))) includes POLYGON((0 0, 0 2, 2 2, 2 0, 0 0)).

a.fu...@lqt.it

unread,
Dec 25, 2024, 6:00:09 AM12/25/24
to spatiali...@googlegroups.com
your second Geometry is an invalid one (the two members of the
MultiPolygon are mutually intersecting)
this causes ST_Intersection(g1, g2) to fail returning NULL, and
any further step will consequently give inconsistent results.

counterproof:

SELECT
ST_IsValid(ST_GeomFromText('MULTIPOLYGON(((0 0, 0 2, 2 2, 2 0, 0 0)),
((3 1,1 1,1 3, 3 1)))'));
--------------------
0



just applying a little shift so to avoid this issue gives the
expected result:

SELECT
ST_Overlaps(ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))'),
ST_GeomFromText('MULTIPOLYGON(((0 0, 0 2, 2 2, 2 0, 0 0)),((13 1,11
1,11 3, 13 1)))')),

ST_Overlaps(ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))'),
ST_GeomFromText('MULTIPOLYGON(((0 0, 0 2, 2 2, 2 0, 0 0)))'));
------------------------
0, 0

Merry Christmas,
Sandro

Shijie li

unread,
Dec 25, 2024, 6:30:40 AM12/25/24
to SpatiaLite Users
Thanks for your professional answer. 


Wishing you a Merry Christmas too!
Reply all
Reply to author
Forward
0 new messages