geocoder-php/BazingaGeocoderBundle — pull request #47 by Baachi (2013-08-27 20:15:45+00:00)
Title: [WIP] Doctrine

Hey guys!

I spend some time to implement a mapping support for the geocoder service.
And i want to add a DQL function, which calculate the distance between two entities (like the geocodable behaviour for propel it does).

Here a example how it works:

```php

use Bazinga\Bundle\GeocoderBundle\Mapping\Annotation as Geocoder;

/**
* @Geocoder\Geocodable
*/
class Event
{
/**
* @Geocoder\Address
*/
private $address;

/**
* @Geocoder\Latitude
*/
private $latitude;

/**
* @Geocoder\Longitude
*/
private $longitude;
}

$event = new Event();
$event->setAddress('Brandenburger Tor, Pariser Platz, Berlin');

$em->persist($event);
$em->flush();

echo $event->getLatitude(); // will output 52.516325
echo $event->getLongitude(); // will output 13.377264

```

Here are an example of the DQL function:

```php

$q = $em->createQuery('SELECT e FROM Event e ORDER BY DISTANCE(e, :event)');
$q->setParameter('event', $event);
$events = $q->getResult(); // Events order by distance
```

If someone have some ideas or improvments, please comment it!
I have no expierence with load mapping information from value objects. So i would love if someone can
review my implementation and give me some ideas. // cc @willdurand @toin0u

- [ ] Mapping
- [ ] Tests
- [ ] Documention
- [ ] DQL Function