Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After swapping the X and Y coordinates, ST_Contains gives the incorrect answer. #24

Open
cuteDen-ECNU opened this issue Nov 22, 2023 · 0 comments

Comments

@cuteDen-ECNU
Copy link
Owner

Consider the following statements:

SET @g1 = ST_GeomFromText('LINESTRING(280 990,20 100)');
SET @g2 = ST_GeomFromText('GEOMETRYCOLLECTION(LINESTRING(280 990,20 100),POLYGON((60 360,620 850,420 870,60 360)))');


SELECT ST_Contains(@g2, @g1);
-- result{1}
SELECT ST_Contains(ST_SwapXY(@g2), ST_SwapXY(@g1));
-- expected{1}; actual{0}

After swapping the X and Y coordinates, MySQL GIS gives the incorrect answer.

GeometryCollection g2 completely contains g1. But MySQL GIS returns 0, which seems an issue.

Besides, if we shrink the coordinate to 1/10 of the previous one, MySQL GIS gives the right answer:

SET @g1 = ST_GeomFromText('LINESTRING(28 99,2 10)');
SET @g2 = ST_GeomFromText('GEOMETRYCOLLECTION(LINESTRING(28 99,2 10),POLYGON((6 36,62 85,42 87,6 36)))');

SELECT ST_Contains(@g2, @g1);
--result{1}
SELECT ST_Contains(ST_SwapXY(@g2), ST_SwapXY(@g1));
--result{1}

Version:
8.2.0
the latest version in Github:
87307d4ddd88405117e3f1e51323836d57ab1f57

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant