php - How to save and retrieve latitude and longitude from a point in Symfony2 and Doctrine2 -
i have symfony2/doctrine application has need store , retrieve latitude/longitude values.
i've found plenty of bundles handle geolocation, appears people's needs different own , can't seem solve simple problem...
all need @ moment save latitude , longitude properties of entity point column, , when entity loaded, load latitude , longitude point.
i've followed http://codeutopia.net/blog/2011/02/19/using-spatial-data-in-doctrine-2/ , have "location" property on entity maps point column. great. don't quite see how set point lat/long, or how retrieve lat/long point, without doing custom dql time need load/save entity.
in non-symfony/doctrine application like: "select *, x(location) latitude, y(location) longitude from...
load latitude , longitude, sf2 , doctrine can't seem figure out need do.
can point me in right direction?
considering entity has field of "point" type linked, manipulating coordinates simple in these 3 examples :
/* returns latitude of existing entity */ $entity->getpoint()->getlatitude(); /* creates new point of coordinates (42,42) , sets entity's coordinates */ $point = new point(42, 42); $entity->setpoint($point); /* adds 1 existing entity's latitude */ $tmp = $entity->getpoint(); $tmp->setlatitude($tmp->getlatitude() + 1); $entity->setpoint($tmp);
Comments
Post a Comment