Bug #117042 ST_Within gives unexpected result with Linestring and Polygon in WGS84.
Submitted: 25 Dec 2024 6:56 Modified: 30 Dec 2024 13:43
Reporter: shijie li Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: GIS Severity:S2 (Serious)
Version:8.0.40 OS:Windows
Assigned to: CPU Architecture:Any

[25 Dec 2024 6:56] shijie li
Description:
In WGS84, ST_Within gives TRUE when the Polygon does not contains the Linestring.
Considering following queries, the x-axis coordinates of the Polygon are all within the range of (37, 38), which is completely different from the x-axis coordinates of the Linestring. However, the output of the ST_Within, Linestring, is included in the Polygon, which is not as expected.

How to repeat:
SET @point:= ST_GeomFromText('LINESTRING(40.5024977 126.9660053, 42.5941684 126.9660053)', 4326);
SET @polygon := ST_GeomFromText('POLYGON((37.399190586836184 126.965669993654370,37.398563808320795 126.966005172597650,37.398563484045880 126.966005467513980,37.398563277873926 126.966005991634870,37.398563316804754 126.966006603730260,37.398687101343120 126.966426067601090,37.398687548434204 126.966426689671760,37.398687946717580 126.966426805810510,37.398688339525570 126.966426692691090,37.399344708725290 126.966027255005050,37.399344924786035 126.966026657464910,37.399344862437594 126.966026073608450,37.399285401380960 126.965848242476900,37.399284911074280 126.965847737879930,37.399284239833094 126.965847784502270,37.399260339325880 126.965861778579070,37.399191408765940 126.965670657332960,37.399191087858530 126.965670183150050,37.399190586836184 126.965669993654370))', 4326);
SELECT ST_Within(@point, @polygon), MBRIntersects(@point, @polygon), ST_Isvalid(@polygon);

-- expected:{f,f,t}
-- actual  :{t,f,t}
[26 Dec 2024 6:36] MySQL Verification Team
Hello shijie li,

Thank you for the report and feedback.

regards,
Umesh
[30 Dec 2024 13:43] shijie li
If possible, please let me know the reason for the bug and whether you will fix this bug. Thank you.