Exemplo n.º 1
0
 public function import_data()
 {
     $data = json_decode(file_get_contents(__DIR__ . '/places.json'), true);
     foreach ($data as $k => $v) {
         $new = new Place();
         $coordinate = new Coordinate();
         $coordinate->setLongitude($v['coordinate']['longitude']);
         $coordinate->setLatitude($v['coordinate']['latitude']);
         $new->setCoordinate($coordinate);
         $new->setAddress($v['address']);
         $new->setTitle($v['title']);
         $this->dm->persist($new);
         $this->output->writeln($v['address']);
     }
     $this->output->writeln('importing...');
     $this->dm->flush($new);
     $this->output->writeln(' done');
     return true;
 }
Exemplo n.º 2
0
 public function coordinateFilter(Coordinate $coordinate, $type = null)
 {
     list($lon, $lat) = $this->container->get('geo.location')->WGStoGCJ($coordinate->getLongitude(), $coordinate->getLatitude());
     $coordinate->setLatitude($lat);
     $coordinate->setLongitude($lon);
     if ($type == 'lat') {
         return $lat;
     }
     if ($type == 'lon') {
         return $lon;
     }
     return $coordinate;
 }