protected function execute(InputInterface $input, OutputInterface $output)
 {
     if ($input->getOption('desde')) {
         $desde = (int) $input->getOption('desde');
     } else {
         $desde = 0;
     }
     if ($input->getOption('hasta')) {
         $hasta = (int) $input->getOption('hasta');
     } else {
         $hasta = 0;
     }
     $output->writeln('Geocodificando partidas...');
     $cantidadTotal = $hasta - $desde;
     $progress = null;
     $em = $this->getContainer()->get('doctrine')->getManager();
     $Helper = new \Yacare\CatastroBundle\Helper\PartidaHelper($this->getContainer(), $em);
     $Partidas = $em->getRepository('Yacare\\CatastroBundle\\Entity\\Partida')->findBy(array('Ubicacion' => null), array('id' => 'ASC'), $desde ?: null, $cantidadTotal ?: null);
     $progress = new ProgressBar($output, count($Partidas));
     $progress->start();
     foreach ($Partidas as $Partida) {
         $Helper->ObtenerGeoCoding($Partida);
         $progress->advance();
         $em->flush();
         // Dormir entre unos segundos entre consulta y consulta
         sleep(rand(10, 20));
     }
     $em->clear();
     $progress->finish();
     $output->writeln('');
     $output->writeln('Geocodificación terminada, se procesaron ' . count($Partidas) . ' registros.');
 }
Exemplo n.º 2
0
 /**
  * @Route("ver/")
  * @Template()
  */
 public function verAction(Request $request)
 {
     $ResultadoVer = $this->parent_verAction($request);
     $res = $ResultadoVer['res'];
     $Inmueble = $res->Entidad;
     if (!$Inmueble->getUbicacion()) {
         $em = $this->getEm();
         $Helper = new \Yacare\CatastroBundle\Helper\PartidaHelper($this->container, $em);
         $Helper->ObtenerUbicacionPorDomicilio($Inmueble);
         $em->flush();
     }
     if ($Inmueble->getUbicacion()) {
         // Creo un mapa con la ubicación
         $Mapa = new Maps\Map();
         $Marcador = new Maps\Marker();
         $Marcador->setPosition(new Maps\Point($Inmueble->getUbicacion()->getX(), $Inmueble->getUbicacion()->getY()));
         $Marcador->setDescription($Inmueble->getDomicilioReal());
         $Mapa->addMarker($Marcador);
         $res->Mapa = $Mapa;
     }
     return $ResultadoVer;
 }