Incorrect geological distance with MongoDB ODM

I am using DoctrineMongoDBBundle with Symfony2 and I am having a problem with geocoordinates. This works great, but when the longitude, for example, is this: 0.635467 the code does not work. I have more geocoordinates and only crash when it starts at 0. and the distance field is NULL.

This is my code:

$locations = $dm->createQueryBuilder('MyBundle:Location')
                    ->field('id')->in($arrayIds)
                    ->field('geocoordinates')
                    ->geoNear($geocodes['lat'],$geocodes['lon'])
                    ->getQuery()->execute()->toArray();

I follow this link: http://docs.doctrine-project.org/projects/doctrine-mongodb-odm/en/latest/reference/geospatial-queries.html , but using the geonear method.

0
source share
1 answer

geoNear() . near() - , field(). , Builder.php doctrine/mongodb. , geoNear() ( , update()). Query.php ( switch) , . , , map/reduce geoNear, .

, :

$dm->createQueryBuilder('MyBundle:Location')
    ->geoNear($geocodes['lat'],$geocodes['lon'])
    ->field('id')->in($arrayIds)
    ->getQuery()->execute()->toArray();

, , Query.php Collection::near(). , , , Query::getQuery().

+2

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


All Articles