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

MySQL: fix/workaround server-side spatial filtering when SRS is geographic with MySQL >= 8 (fixes qgis/QGIS#55463) #9152

Merged
merged 1 commit into from
Feb 1, 2024

Conversation

rouault
Copy link
Member

@rouault rouault commented Jan 28, 2024

(fixes qgis/QGIS#55463)

It seems spatial predicates are not directly usable when using geographic SRS. For some reason

select MBRIntersects(ST_GeomFromText('POLYGON((-90 -90, 90 -90, 90 90, -90 90, -90 -90))', 4326), ST_GeomFromText('POINT(0 0)', 4326));

returns true as expected

But

select MBRIntersects(ST_GeomFromText('POLYGON((-179 -89, 179 -89, 179 89, -179 89, -179 -89))', 4326, 'axis-order=long-lat'), ST_GeomFromText('POINT(0 0)', 4326));

returns false !!!!

And

select MBRIntersects(ST_GeomFromText('POLYGON((-179 -89, 179 -89, 179 89, -179 89, -179 -89))', 32631), ST_GeomFromText('POINT(0 0)', 32631));

returns true as expected

Consequence, we need to force a projected SRS for the arguments of MBRIntersects()

@rouault rouault changed the title MySQL: disable server-side filtering when SRS is geographic with MySQL >= 8 MySQL: disable server-side spatial filtering when SRS is geographic with MySQL >= 8 Jan 28, 2024
@coveralls
Copy link
Collaborator

coveralls commented Jan 28, 2024

Coverage Status

coverage: 68.806% (+0.005%) from 68.801%
when pulling 69a9dda on rouault:mysql_fixes
into a79a07c on OSGeo:master.

@rouault rouault changed the title MySQL: disable server-side spatial filtering when SRS is geographic with MySQL >= 8 MySQL: fix/workaround server-side spatial filtering when SRS is geographic with MySQL >= 8 (fixes qgis/QGIS#55463) Jan 28, 2024
…aphic with MySQL >= 8 (fixes qgis/QGIS#55463)

It seems spatial predicates are not directly usable when using geographic SRS. For some reason

select MBRIntersects(ST_GeomFromText('POLYGON((-90 -90, 90 -90, 90 90, -90 90, -90 -90))', 4326), ST_GeomFromText('POINT(0 0)', 4326));

returns true as expected

But

select MBRIntersects(ST_GeomFromText('POLYGON((-179 -89, 179 -89, 179 89, -179 89, -179 -89))', 4326, 'axis-order=long-lat'), ST_GeomFromText('POINT(0 0)', 4326));

returns false !!!!

And

select MBRIntersects(ST_GeomFromText('POLYGON((-179 -89, 179 -89, 179 89, -179 89, -179 -89))', 32631), ST_GeomFromText('POINT(0 0)', 32631));

returns true as expected

Consequence, we need to force a projected SRS for the arguments of MBRIntersects()
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

Successfully merging this pull request may close these issues.

Vector layer points are not being imported/shown from MySQL datasource
3 participants