Add spatial types
| Q | A |
|---|---|
| Type | feature |
| Fixed issues | #7081 |
Summary
This PR introduces spatial data type support for DBAL, starting with PostgreSQL/PostGIS and MySQL. This implementation is intended to serve as a reference and guide for adding support for other database platforms in the future.
Core Spatial Types
- GeometryType (
Types::GEOMETRY) - For planar coordinate systems - GeographyType (
Types::GEOGRAPHY) - For spherical earth coordinates - Both types handle GeoJSON format for data exchange
Schema API Integration
- Extended
ColumnandColumnEditorwithgeometryTypeandsridproperties - Clean fluent API:
Column::editor()->setGeometryType('POINT')->setSrid(4326) - Full PostgreSQL platform support with PostGIS-specific SQL generation
- Schema introspection and table creation/modification support
What's next
- [ ] Discuss the PR
- [X] Add other platforms (PostgreSQL/PostGIS, MySQL)
- [X] Add spatial index (PostgreSQL/PostGIS, MySQL already support creation of spatial indexes)
Adding spatial index management would be interesting for this PR I think :).
For instance:
CREATE INDEX mytable_geom_x ON mytable USING GIST (geom)
Sources:
- https://postgis.net/documentation/faq/spatial-indexes/
- https://postgis.net/workshops/postgis-intro/indexing.html
- https://postgis.net/docs/using_postgis_dbmanagement.html#build-indexes
Adding spatial index management would be interesting
Thanks for the advice — I agree, index management is definitely an important aspect when working with geometry data. I haven’t investigated it in depth yet, but it looks like this might already be supported by specifying the index type. A quick search in the repository shows an IndexType enum with a SPATIAL option, so I’ll take a closer look at how that could be integrated here.
Wow, that's exactly what I'd like to see integrated into Doctrine soon. Great work!
Hi @derrabus
I’ve addressed all the feedback received so far and updated the PR accordingly. When you get a chance, could you please let me know if there’s anything else I can do to help move this forward?
Thanks a lot for your time
Thank your for all the work you've put into this PR. Your changes look very promising.
Thanks a lot for your review and the detailed feedback! I really appreciate the time you took to go through the PR. I’ll work on the requested changes as soon as possible and hopefully be able to address everything within the next week.