Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Storing spatial points in Symfony 2 / Doctrine 2 Entities?

Symfony 2 doesn't have the spatial points datatype that MySQL supports. I couldn't find anything on the Doctrine 2 documentation about this particular data type, so, does anyone know how to work with points in Symfony 2? Also, how to query based on a radius? Thanks! :)

like image 216
vinnylinux Avatar asked Apr 25 '12 02:04

vinnylinux


3 Answers

The easiest way would be to implement custom types for the spatial data types, and then declare custom DQL functions to make querying them simpler.

I wrote about this here: http://codeutopia.net/blog/2011/02/19/using-spatial-data-in-doctrine-2/

like image 141
Jani Hartikainen Avatar answered Nov 18 '22 05:11

Jani Hartikainen


Another option would be to use the djlambert/doctrine2-spatial bundle, found here: https://github.com/creof/doctrine2-spatial

No need to implement any custom stuff.

like image 26
Jens Wegar Avatar answered Nov 18 '22 05:11

Jens Wegar


If you speak french, youd could get some inspiration with another article here : http://blog.fastre.info/2012/02/doctrine2-2-2-et-types-geographiques/

This classes were build for a Postgresql + Postgis Database.

like image 1
Julien Fastré Avatar answered Nov 18 '22 07:11

Julien Fastré