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

SRID POINT Mysql 8+ Not saved #17

Open
tebaly opened this issue Aug 24, 2021 · 4 comments
Open

SRID POINT Mysql 8+ Not saved #17

tebaly opened this issue Aug 24, 2021 · 4 comments
Labels
enhancement New feature or request help wanted Extra attention is needed MySQL This bug only concerns MySQL Platform

Comments

@tebaly
Copy link

tebaly commented Aug 24, 2021

Mysql 8 can save PONT like this: ST_SRID(POINT(...), 4326)
But

            $point = new Point($lon, $lat);
            $point->setSrid(4326); # !!!!!!!!!!
            $entity->setPoint($point);

Not working - SRID did not saved

@tebaly tebaly changed the title SRID PONT Mysql 8+ Not saved SRID POINT Mysql 8+ Not saved Aug 24, 2021
@Alexandre-T Alexandre-T added enhancement New feature or request help wanted Extra attention is needed labels Aug 25, 2021
@Alexandre-T Alexandre-T added this to the 3.1 milestone Aug 25, 2021
@Alexandre-T
Copy link
Contributor

Alexandre-T commented Aug 25, 2021

Hello,

Currently the MySQL code doesn't use the SRID value. This is something that'll need to be implemented. Currently SRID are saved, but they aren't persisted.

We have to enhance the convertToDatabaseValueSQL in the MySQL classes for the Geographic types, but if someone wants to contribute, he should be careful and check the MySQL functionalities, because I remember that it wasn't compliant with first versions of MySQL5. I even don't know if SRID are now compliant with MySQL5.*

@Alexandre-T Alexandre-T modified the milestones: 3.1, Version 5.2 Apr 25, 2024
@Alexandre-T Alexandre-T added the MySQL This bug only concerns MySQL Platform label May 8, 2024
Alexandre-T added a commit that referenced this issue Jul 12, 2024
@c1tru55
Copy link

c1tru55 commented Oct 8, 2024

saving srid for MySQL is critical, because it affects on lat/lon order. see:

SELECT
    ST_AsText(ST_GeomFromText('POINT(45 90)')),
    ST_X(ST_GeomFromText('POINT(45 90)')),
    ST_Y(ST_GeomFromText('POINT(45 90)')),
#     ST_Latitude(ST_GeomFromText('POINT(45 90)')),
#     ST_Longitude(ST_GeomFromText('POINT(45 90)')),
    ST_SRID(ST_GeomFromText('POINT(45 90)')),

    ST_AsText(ST_GeomFromText('POINT(45 90)', 4326)),
    ST_X(ST_GeomFromText('POINT(45 90)', 4326)),
    ST_Y(ST_GeomFromText('POINT(45 90)', 4326)),
    ST_Latitude(ST_GeomFromText('POINT(45 90)', 4326)),
    ST_Longitude(ST_GeomFromText('POINT(45 90)', 4326)),
    ST_SRID(ST_GeomFromText('POINT(45 90)', 4326)),

    ST_AsText(POINT(45, 90)),
    ST_X(POINT(45, 90)),
    ST_Y(POINT(45, 90)),
#     ST_Latitude(POINT(45, 90)),
#     ST_Longitude(POINT(45, 90)),
    ST_SRID(POINT(45, 90)),

    ST_AsText(ST_SRID(POINT(45, 90), 4326)),
    ST_X(ST_SRID(POINT(45, 90), 4326)),
    ST_Y(ST_SRID(POINT(45, 90), 4326)),
    ST_Latitude(ST_SRID(POINT(45, 90), 4326)),
    ST_Longitude(ST_SRID(POINT(45, 90), 4326)),
    ST_SRID(ST_SRID(POINT(45, 90), 4326))
;
| ST_AsText(ST_GeomFromText('POINT(45 90)'))          | POINT(45 90) |
| ST_X(ST_GeomFromText('POINT(45 90)'))               | 45           |
| ST_Y(ST_GeomFromText('POINT(45 90)'))               | 90           |
| ST_SRID(ST_GeomFromText('POINT(45 90)'))            | 0            |
| ST_AsText(ST_GeomFromText('POINT(45 90)', 4326))    | POINT(45 90) |
| ST_X(ST_GeomFromText('POINT(45 90)', 4326))         | 45           |
| ST_Y(ST_GeomFromText('POINT(45 90)', 4326))         | 90           |
| ST_Latitude(ST_GeomFromText('POINT(45 90)', 4326))  | 45           |
| ST_Longitude(ST_GeomFromText('POINT(45 90)', 4326)) | 90           |
| ST_SRID(ST_GeomFromText('POINT(45 90)', 4326))      | 4326         |
| ST_AsText(POINT(45, 90))                            | POINT(45 90) |
| ST_X(POINT(45, 90))                                 | 45           |
| ST_Y(POINT(45, 90))                                 | 90           |
| ST_SRID(POINT(45, 90))                              | 0            |
| ST_AsText(ST_SRID(POINT(45, 90), 4326))             | POINT(90 45) | <---
| ST_X(ST_SRID(POINT(45, 90), 4326))                  | 90           | <---
| ST_Y(ST_SRID(POINT(45, 90), 4326))                  | 45           | <---
| ST_Latitude(ST_SRID(POINT(45, 90), 4326))           | 90           | <---
| ST_Longitude(ST_SRID(POINT(45, 90), 4326))          | 45           | <---
| ST_SRID(ST_SRID(POINT(45, 90), 4326))               | 4326         |

PS: also it is possible to define SRID in MySQL column definition, like:

p POINT SRID 4326

see: https://dev.mysql.com/doc/refman/8.4/en/spatial-type-overview.html
but currently it is ignored, and resulting SQL is just:

g POINT DEFAULT NULL COMMENT \'(DC2Type:geography_point)\'

@Alexandre-T
Copy link
Contributor

Yes, it is. I'm currently working on it. MySQL has its own method to store data and Doctrine ORM only accepts one parameter, I cannot store coordinates and SRID with the current engine. So, I'm working on sub-libraries to convert the point into the internal binary storage system of MySQL. IMO, I still need 7 or 8 days of development to make it working. But I only work on it on my free time.

@Alexandre-T
Copy link
Contributor

If you're waiting for this new feature, you can yet use the SRID method with a second argument. This is not a good solution, but this is a temporary way to do it. (The best way, currently, is to update your column to specify a default SRID)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed MySQL This bug only concerns MySQL Platform
Projects
None yet
Development

No branches or pull requests

3 participants