GIS extension for Doctrine 2

I want to write a GIS (Geospatial Data) extension for my Doctrine 2 project.

I know how to write simple user-defined functions and types. To adapt to the special MySQL storage format, I need to use some SQL function (GeomFromWKB () and AsBinary ()) when retrieving / storing data.

I can’t find a place where I will talk about this doctrine 2. As I can see, the convertToPHPValue () and convertToDatabaseValue () methods are not a suitable place.

+6
source share
3 answers

What I have found out so far: According to the IRC channel, convertToPHPValueSQL () and convertToDatabaseValueSQL () will be part of the next version and will offer the required functions. Once this is available, the definition of CustomType is pretty simple.

+1
source

If you want to call the SQL function in doctrine2, you can do this with Expression Func , but this will only work with DQL.

Here is an example that will tell you how to use the DATE_DIFF function, which is not included in the doctrine.

$qb = $repository->createQueryBuilder('l'); $qb->expr()->lte(new Doctrine\ORM\Query\Expr\Func('DATE_DIFF',array('lo.start_date', 'CURRENT_DATE()')),'0'); 
+1
source

Update / Alternative:

I found a symfony2 extension that satisfies most of my needs. I forked it and added what I need:

https://github.com/tvogt/doctrine2-spatial/

0
source

Source: https://habr.com/ru/post/902995/


All Articles