Created
January 10, 2014 14:55
-
-
Save kovagoz/8355716 to your computer and use it in GitHub Desktop.
Doctrine geospatial query with GeoJson
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use GeoJson\Geometry\Point; | |
$city = new City; | |
$city->name = 'Budapest'; | |
$city->coordinates = new Coordinates(47.51, 19.03); | |
$city->save(); | |
$city = DB::createQueryBuilder('City') | |
->field('coordinates')->geoNear(new Point([47.52, 19.12])) | |
->limit(1) | |
->getQuery() | |
->getSingleResult(); | |
echo $city->name; | |
var_dump($city->distance); // in meters |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment