/** * Transforms a Point to a string "lat lng". * * @param Point|null $point * @return string */ public function transform($point) { if (null === $point) { return ''; } return implode(' ', array($point->getLatitude(), $point->getLongitude())); }
public function getNeighborhoodBoundarysByPoint(Point $point) { return $this->getNeighborhoodBoundarysByLatLng($point->getX(), $point->getY()); }
/** * @group srid */ public function testPointGeometryWithZeroSrid() { $entity = new GeometryEntity(); $point = new Point(1, 1); $point->setSrid(0); $entity->setGeometry($point); $this->_em->persist($entity); $this->_em->flush(); $id = $entity->getId(); $this->_em->clear(); $queryEntity = $this->_em->getRepository(self::GEOMETRY_ENTITY)->find($id); $this->assertEquals($entity, $queryEntity); }
public function testJson() { $expected = '{"type":"Point","coordinates":[5,5]}'; $point = new Point(array(5, 5)); $this->assertEquals($expected, $point->toJson()); }
public function addPlaceByStepsAction(Request $request, $slug, $step) { $this->denyAccessUnlessGranted('ROLE_USER', null, 'Unable to access this page!'); $serializer = $this->get('jms_serializer'); // Retrieving previous entered data for this POI, stored in a session var $session = $this->get('session'); $poi_in_session = $session->get('poi'); if (isset($poi_in_session)) { $poi = $serializer->deserialize($poi_in_session, 'AppBundle\\Entity\\POI', 'json'); } else { if ($step == 1) { $poi = new POI(); } else { // If there is no POI stored in session.. goto step 1 return $this->redirectToRoute('user_place_add', array('slug' => $slug, 'step' => 1)); } } $form = $this->createForm(new PoiForm($step), $poi); $form->handleRequest($request); if ($form->isValid()) { switch ($step) { //Paso 1 case 1: // Me descargo la página $remote_page = new RemoteCrawler(new Client()); $remote_page->setUrl($form->get('url')->getData()); $remote_page->process(); $poi->setTitle($remote_page->getTitle()); $poi->setContent($remote_page->getDescription()); $poi->setRemoteImgs($remote_page->getImg()); $poi->setUrl($form->get('url')->getData()); // Storing the POI in a session to retrive this data in the next step $session->set('poi', $serializer->serialize($poi, 'json')); // Show step2 of form return $this->redirectToRoute('user_place_add', array('slug' => $slug, 'step' => $step + 1)); break; //Paso 2 //Paso 2 case 2: $poi->setTitle($form->get('title')->getData()); $poi->setContent($form->get('content')->getData()); $poi->setExcerpt($form->get('excerpt')->getData()); // Storing the POI in a session to retrive this data in the next step $session->set('poi', $serializer->serialize($poi, 'json')); // Show step 3 of form return $this->redirectToRoute('user_place_add', array('slug' => $slug, 'step' => $step + 1)); break; // Paso 3 // Paso 3 case 3: $em = $this->getDoctrine()->getManager(); // Got Base URL $temp = parse_url($poi->getUrl()); $baseurl = $temp['scheme'] . '://' . $temp['host']; // We look for this site in the list of sites. If not found, we will create a new one $website = $em->getRepository('AppBundle:Website')->findOneByUrl($baseurl); if (!$website) { $website = new Website(); //TODO: ¿Estas dos lineas sobran, no? $website->setUrl($baseurl); $em->persist($website); } $poi->setWebsite($website); $poi->setAuthor($this->getUser()); $point = new Point($form->get('longitude')->getData(), $form->get('latitude')->getData()); $point->setSrid(4326); $poi->setCoordinate($point); $country = $em->getRepository('AppBundle:CountryGEO')->getCountryByGeo($point); /* Un ejemplo chorra de como añadir el pais automaticamente como hashtag. * Desafortunamente, primero hay que ver si el hashtag existe, igual que * hemos hecho antes con la url */ if (isset($country)) { $hashtag = $em->getRepository('AppBundle:POIHashtag')->findOneByHashtag(POIHashtag::normalize($country->getCountry_name_en())); if (!$hashtag) { $hashtag = new POIHashtag(); $hashtag->setHashtag($country->getCountry_name_en()); } $poi->addHashTag($hashtag); } $em->persist($poi); $em->flush(); // We remove the temporal info from the session to avoid repeated content $session->remove('poi'); // Procesando las imagenes despues de haber grabado una primera vez //$poi->downloadRemoteImages(200,200); //$em->persist($poi); // debug $em->flush(); // Creating a new task to process remote images in background $task = new PendingTask(); $task->setClass(get_class($this)); $task->setCall('addImagesToPOI'); $task->setParams(array($poi->getId(), $poi->getRemoteImgs(), 200, 200)); $em->persist($task); $em->flush(); return $this->redirectToRoute('place', array('slug' => $poi->getSlug())); default: // This should never happen return $this->redirectToRoute('user_place_add', array('slug' => $slug, 'step' => 1)); } } return $this->render('themes/default/user_place_form.html.twig', array('poi' => $poi, 'step' => $step, 'form' => $form->createView(), 'lat' => 48, 'lng' => 2.304183, 'zoom' => 5)); }
public function testGetType() { $point = new Point(10, 10); $result = $point->getType(); $this->assertEquals('Point', $result); }