Bug #113205 After swapping the X and Y coordinates, ST_Crosses gives the incorrect answer.
Submitted: 24 Nov 2023 3:06 Modified: 24 Nov 2023 5:59
Reporter: Wendy Deng Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: GIS Severity:S3 (Non-critical)
Version:8.2.0, 8.0.35 OS:Any
Assigned to: CPU Architecture:Any

[24 Nov 2023 3:06] Wendy Deng
Description:
After swapping the X and Y coordinates, ST_Crosses gives the incorrect answer.

How to repeat:
Consider the following statements:
```sql
SET @g1 = ST_GeomFromText('MULTILINESTRING((280 990,20 100))');
SET @g2 = ST_GeomFromText('GEOMETRYCOLLECTION(MULTILINESTRING((280 990,20 100)),POLYGON((60 360,620 850,420 850,60 360)))');

SELECT ST_Crosses(@g1, @g2);
-- result{0}
SELECT ST_Crosses(ST_SwapXY(@g1), ST_SwapXY(@g2));
-- expected {0}; actual {1}
```
After swapping the X and Y coordinates, MySQL GIS gives the incorrect answer.

LineString g1 doesn't cross g2 because g2 covers g1, according to the following definition.
> g1 crosses g2 if the interior of g2 has points in common with the interior of g1, but g2 does not cover the entire interior of g1.

But MySQL GIS returns 1, which seems an issue.

Besides, if we shrink the coordinate to 1/10 of the previous one, MySQL GIS gives the right answer:
```sql
SET @g1 = ST_GeomFromText('MULTILINESTRING((28 99,2 10))');
SET @g2 = ST_GeomFromText('GEOMETRYCOLLECTION(MULTILINESTRING((28 99,2 10)),POLYGON((6 36,62 85,42 85,6 36)))');

SELECT ST_Crosses(@g1, @g2);
-- result{0}
SELECT ST_Crosses(ST_SwapXY(@g1), ST_SwapXY(@g2));
-- result{0}
```

Version:
8.2.0
the latest version in Github:
87307d4ddd88405117e3f1e51323836d57ab1f57
[24 Nov 2023 5:59] MySQL Verification Team
Hello Wendy,

Thank you for the report and test case.
Verified as described.

regards,
Umesh