-
Notifications
You must be signed in to change notification settings - Fork 11.3k
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
[5.5] Geo Spatial blueprint methods #21056
[5.5] Geo Spatial blueprint methods #21056
Conversation
*/ | ||
protected function typeGeometry(Fluent $column) | ||
{ | ||
throw new \Exception('Geometry data type not supported for current database engine.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't know what type of exception would be better to throw here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've thought about RuntimeException
too.
Thank you! ❤️ This change removes about to 12 classes from the package. |
Any Eloquent guide for this? |
@edsamonte this PR includes only blueprint methods to create spatial data columns. To add Spatial queries to Eloquent there are much more things should be solved. First of all implement all geometry classes, WKT & WKB format parsers and generators. |
Why do you say that the |
@denaje thank you for raising this important question! I excluded |
Indeed, this is an interesting question. Thanks @denaje! 👍 There are two different spatial types used in PostGIS:
This applies to SQL Server as well: https://docs.microsoft.com/en-us/sql/relational-databases/spatial/spatial-data-sql-server MySQL implementation is more simplified. By default every geometry feature type is planar (SRID 0), requiring you to use appropriate functions (e.g. We are deliberately using the So in short we can't return the The To help in the matter I just tested creating a column with With all that said, I think it would be really welcome to fix this mistake. 👍 😉 |
Thanks for the thorough analysis @paulofreitas! I was not aware about the difference between |
Any progress on eloquent support? this would keep eloquent base clean(ish) but provides an easy way to query GIS types? |
I've targeted it to 5.5 but if 5.6 (master) is more appropriate for it - I'm ready to make another one PR.
This PR introduces Geo spatial blueprint methods to MySQL, PostgreSQL, SQLite. It allows to create database engine agnostic spatial data types columns without using raw expressions and conditionals.
Complete list of methods:
geometry
(not supported by PostgreSQL)point
lineString
polygon
geometryCollection
multiPoint
multiLineString
multiPolygon
If blueprints PR will be accepted I will continue integration of query\eloquent Geo spatial related methods. They are much more complicated and requires to implement all geometry classes. As for now I'm making it as external package. Current functionality already implemented in package too, but it's pretty common stuff and doesn't require any new dependencies.
Note: Latest stable MySQL and PostgreSQL has spatial data types support out of the box. SQLite has extended version called SpatiaLite.