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
Vector layer points are not being imported/shown from MySQL datasource #55463
Comments
@Sakoes, thanks for reporting. In the issue report you mentioned QGIS 3.04 (maybe QGIS 3.4?), QGIS 3.24 which is no longer supported and QGIS 3.28. Could you please clarify with which version exactly the issue didn't occur and with which currently supported version the issue occurs? Please also provide the full version info of the currently supported versions with which the issue occurs ("In the QGIS Help menu -> About, click in the table, Ctrl+A and then Ctrl+C. Finally paste here. Do not make a screenshot.") as requested in the issue report form. |
@agiudiceandrea yes my apologies. I switched up some versions in my head.
I'll update it in the original post |
Please also provide the full version info of the currently supported versions with which the issue occurs ("In the QGIS Help menu -> About, click in the table, Ctrl+A and then Ctrl+C. Finally paste here. Do not make a screenshot.") |
QGIS version Active Python plugins |
See also this thread: https://lists.osgeo.org/pipermail/qgis-developer/2024-January/066352.html In short: if mysql does not have a crs defined on the geom column in the table, QGIS will never be able to show the geoms (though it IS retrieving the data and able to show attributes). Longer anwer: It looks like mysql has 2 places to store crs information: on the column (geom column registration during creation of the the table) and in the geometry. With the help of Even R it is easy to reproduce in a docker container:
Some queries to show the differences (with help of https://ant.burnett.com.au/adding-spatial-column-to-existing-mysql-table/ )"
Fixing the srid of the geom:
Still makes QGIS not show the geom as the QgsCoordinateReferenceSystem is invalid:
BUT fixing the columns crs (in the INFORMATION_SCHEMA, see the link above):
NOW also the INFORMATION_SCHEMA holds the crs:
And QGIS is showing the point and reporting a valid crs:
Only question I have is why QGIS, even when telling that the layer the right crs, is still not able to show the features. |
…L >= 8 (fixes qgis/QGIS#55463) It seems spatial predicates are totally broken 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, it seems safer to disable spatial filtering on layers with geographic coordinates with MySQL...
Likely resolution in the OGR MySQL driver queued in OSGeo/gdal#9152 |
…ith MySQL >= 8 (fixes qgis/QGIS#55463) It seems spatial predicates are totally broken 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, it seems safer to disable spatial filtering on layers with geographic coordinates with MySQL...
…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()
…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()
MySQL: fix/workaround server-side spatial filtering when SRS is geographic with MySQL >= 8 (fixes qgis/QGIS#55463)
…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()
[Backport release/3.8] MySQL: fix/workaround server-side spatial filtering when SRS is geographic with MySQL >= 8 (fixes qgis/QGIS#55463)
Daniel Baston (1): CI: Remove redundant clang-format check Even Rouault (47): EEDA/EEDAI: use 'crsWkt' element gdalinfo: do not emit errors if corner coordinate reprojection fails HOWTO-RELEASE: update [ci skip] CSV: do not quote numeric fields even if STRING_QUOTING=ALWAYS (3.8.1 regression) (fixes qgis/QGIS#55808) OGR2SQLITE_Setup(): robustify against potential crashing scenario WMS: fix nullptr dereference on invalid document (fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=65772) gdalwarp: do not enable blank line detection when -tap and -te are specified (fixes #9059) CI fedora_rawhide: explicitly install python3-setuptools FindECW.cmake: make it work for Windows 32-bit builds (fixes #9106) Arrow/Parquet: add (minimum) support for libarrow 15.0 OGRArrowLayer::MapArrowTypeToOGR(): make the code robust to potentially new entries in the arrow::Type enumeration GMLAS: recognize GeometricPrimitivePropertyType wms.py: set timeout on one test resource Restore use of gmtime_r and localtime_r; extend to ctime_r; use Windows variants too netCDF: use VSILocalTime() Internal libopencad: use localtime_r() or localtime_s() when possible PCIDSK SDK: use ctime_r() or ctime_s() when possible degrib: use gmtime_r() or gmtime_s() when possible ExecuteSQL(dialect=SQLite): support 'SELECT\n' for example (fixes #9093) ogr2ogr: Arrow code path: take into account -limit parameter for MAX_FEATURES_IN_BATCH FindSQLite3.cmake: improve detection of static libsqlite3.a (fixes #9096) PDS: fix compilation with Emscripten version 3.1.7 Python bindings: remove run of 'python -m lib2to3' that is a no-op, given that lib2to3 is removed in python 3.13 (fixes #9173) BMP: fix reading images larger than 4GB MySQL: fix/workaround server-side spatial filtering when SRS is geographic with MySQL >= 8 (fixes qgis/QGIS#55463) OGRGeometryFactory::createGeometry(): do not assert on wkbUnkown input docker/ubuntu-full/Dockerfile: update to Arrow 15.0.0 (fixes #9183) [ci skip] OGRGeometryFactory::forceTo(): fix assertion with empty geometry and target type = unknown bmp_read.py: fix wrong driver name /vsisparse/: fix Stat() on files larger than 4 GB on 32-bit builds docker/ubuntu-full/Dockerfile: disable AVX2 when building TileDB [ci skip] PDF: correctly initialize PAM when opening a subdataset (specific page for example) GDALOverviewDataset: avoid setting SetEnableOverviews(false) during lifetime of object. Just do it transiently VRTPansharpenedRasterBand::GetOverviewCount(): robustify against potential failure of GDALCreateOverviewDataset() LIBKML: fix crash on a gx:Track without when subelements (fixes qgis/QGIS#55963) CPLAtof()/CPLStrtod(): recognize again INF and -INF /vsicurl/: fix potential multithreaded crash when downloading the same region in parallel and that the download fails ODS: fix parsing of large cells on Windows (at least with mingw64) with new expat 2.6.0 release GeoRSS: harmonize on a 8192 byte large parsing buffer on all platforms GPX: harmonize on a 8192 byte large parsing buffer on all platforms JML: harmonize on a 8192 byte large parsing buffer on all platforms KML: harmonize on a 8192 byte large parsing buffer on all platforms LVBAG: harmonize on a 8192 byte large parsing buffer on all platforms SVG: harmonize on a 8192 byte large parsing buffer on all platforms XLSX: harmonize on a 8192 byte large parsing buffer on all platforms PDF vector stream parser: correcly parse structures like '[3 3.5] 0 d ' Prepare for GDAL 3.8.4 Georg Semmler (1): Allow the project_binary_dir to contain a whitespace Patrik Sylve (1): PAM only unset GPF_DIRTY flag Per Mildner (1): docker/ubuntu-full/Dockerfile: pin libarrow-acero-dev version (fixes #9183) Tamas Szekeres (1): MSSQLSpatial Fix BCP performance problem (#9112) Key imported: --list-packet: # off=0 ctb=99 tag=6 hlen=3 plen=269 :public key packet: version 4, algo 1, created 1434650461, expires 0 pkey[0]: [2048 bits] pkey[1]: [17 bits] keyid: 33EBBFC47B3DD87D # off=272 ctb=b4 tag=13 hlen=2 plen=41 :user ID packet: "Even Rouault <even.rouault@spatialys.com>" # off=315 ctb=89 tag=2 hlen=3 plen=312 :signature packet: algo 1, keyid 33EBBFC47B3DD87D --fingerprint: pub rsa2048 2015-06-18 [SC] B1FA 7D81 EEB8 E663 9917 8B97 33EB BFC4 7B3D D87D uid [ unknown] Even Rouault <even.rouault@spatialys.com> sub rsa2048 2015-06-18 [E]
…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()
What is the bug or the crash?
Issue
QGis 3.28.13 does not visualise/import points from a vector layer with a MySQL datasource anymore.
In QGis 3.28.13, I import a table from a MySQL datasource as a vector layer. However, the points are not being visualized. I suspect QGis is not importing the data correctly.
I classified this as a bug because this worked fine in QGis 3.4. I had to upgrade because my SQL provider does not accept the TLS version used by QGis 3.4 anymore.
Context
In the images below following can be observed: The coord (coordinate) column from the MySQL database, containing the points that need to be plotted, is missing from the QGis table structure.
I suspect that is the reason why QGis is not plotting/visualizing any points.
It looks like QGis is incorrectly converting the coord column into a geometry column.
Compare images below:
MySQL table structure
The coord column is a "point" datatype:
QGis 3.28.13 table structure
The coord column is missing, a geometry is added
MySQL record example
The coord column contains coordinates:
QGis 3.28.13 example record:
The geometry column only contains the word "POINT"
Questions
Steps to reproduce the issue
Steps
Versions
3.4 -> worked fine, but uses a deprecated TLS version
3.28.13 -> issue described above
Supported QGIS version
New profile
Additional context
No response
The text was updated successfully, but these errors were encountered: