Skip to content

Conversation

@MatanYadaev
Copy link
Owner

@MatanYadaev MatanYadaev commented Jul 19, 2022

No description provided.

@MatanYadaev
Copy link
Owner Author

@Gemui Can you please review it?

Matan Yadaev added 2 commits July 20, 2022 23:20
@MatanYadaev MatanYadaev changed the title [WIP] SRID support SRID support Jul 20, 2022
@MatanYadaev MatanYadaev merged commit 4ec31b7 into master Jul 20, 2022
@MatanYadaev MatanYadaev deleted the srid branch July 20, 2022 20:45
@Gemui
Copy link

Gemui commented Jul 21, 2022

@Gemui Can you please review it?

I don't know why you close #42, I was thinking you will continue work in it.

There are some important points should be handled :

  • Do you consider working with 4326 SRID, It reverse the default type of inserting.

Default MySQL inserting is something like POINT(lng, lat) but with SRID 4326 It should be POINT(lat, lng) .

the easiest solution for this problem is using axis parameter axis-order=long-lat

  • Also you removed the default SRID, It is very important feature to change the default SRID from 0 to another

@MatanYadaev
Copy link
Owner Author

@Gemui Sorry about not using your PR, it didn't have enough tests, and I had many refactors to do. But I used your code obviously.

  1. So now the order of the latitude and the longitude is wrong? Do you mean the released version has a bug? If so, can you help me to produce a failing test that shows the wrong behavior?
  2. I am ok with the default SRID - but it has to have proper tests and to be in a separated config file, and not in the Laravel's config/database.php file.

@mattcurrie
Copy link

@MatanYadaev,

Regarding item 1 above, I have written a test that shows the wrong behaviour here: eldernet@c11c552

The error is:

  • Tests\Objects\PointTest > it creates a model record that has a column with SRID defined using point with SRID
   Illuminate\Database\QueryException

  SQLSTATE[22S03]: <<Unknown error>>: 3617 Latitude 172.636500 is out of range in function st_geomfromtext. It must be within [-90.000000, 90.000000]. (SQL: insert into `test_places` (`name`, `address`, `point_with_srid`, `updated_at`, `created_at`) values (Kuvalis Loaf, 196 Lauren Underpass Apt. 893
New Emelia, SD 12125-9093, ST_GeomFromText('POINT(172.6365 -43.5309)', 4326), 2022-08-29 02:45:02, 2022-08-29 02:45:02))

This can be fixed by adding axis-order=long-lat parameter when generating WKT.

There is some background info on this issue here:
https://dev.mysql.com/blog-archive/axis-order-in-spatial-reference-systems/

@MatanYadaev
Copy link
Owner Author

@mattcurrie THANKS! Fixed it in version 2.2.0. #49

@mattcurrie
Copy link

Thank you for the quick fix!

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.

4 participants