1 |
b8edf218
|
vastja
|
<?php
|
2 |
|
|
|
3 |
|
|
namespace App\Controller;
|
4 |
|
|
|
5 |
|
|
use Symfony\Component\Routing\Annotation\Route;
|
6 |
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
7 |
5d0f8ac1
|
vastja
|
use Doctrine\ODM\MongoDB\DocumentManager;
|
8 |
|
|
use App\Entity\OpenData;
|
9 |
fd4fa4af
|
vastja
|
use MongoDB\Driver\Manager;
|
10 |
|
|
use MongoDB\Driver\Query;
|
11 |
b8edf218
|
vastja
|
|
12 |
|
|
class HeatmapController extends AbstractController {
|
13 |
|
|
|
14 |
|
|
/**
|
15 |
|
|
* @Route("/heatmap")
|
16 |
|
|
*/
|
17 |
|
|
public function index() {
|
18 |
|
|
|
19 |
fd4fa4af
|
vastja
|
$manager = new Manager(
|
20 |
|
|
'mongodb://root:root@database'
|
21 |
5d0f8ac1
|
vastja
|
);
|
22 |
|
|
|
23 |
fd4fa4af
|
vastja
|
$openData = $manager->executeQuery('open-data-db.KOLOBEZKY31102018', new Query([], []));
|
24 |
|
|
$openData->setTypeMap([
|
25 |
|
|
'array' => 'array',
|
26 |
|
|
'document' => 'array',
|
27 |
|
|
'root' => 'array'
|
28 |
|
|
]);
|
29 |
|
|
|
30 |
b8edf218
|
vastja
|
return $this->render('heatmap.html.twig', [
|
31 |
5d0f8ac1
|
vastja
|
'open_data' => $openData->toArray()
|
32 |
b8edf218
|
vastja
|
]);
|
33 |
fd4fa4af
|
vastja
|
|
34 |
b8edf218
|
vastja
|
}
|
35 |
20ecec4e
|
vastja
|
|
36 |
|
|
/**
|
37 |
|
|
* @Route("heatmap/opendata", name="opendata")
|
38 |
|
|
*/
|
39 |
|
|
public function opendata() {
|
40 |
|
|
|
41 |
|
|
$manager = new Manager(
|
42 |
|
|
'mongodb://root:root@database'
|
43 |
|
|
);
|
44 |
|
|
|
45 |
|
|
$openData = $manager->executeQuery('open-data-db.KOLOBEZKY31102018', new Query([], []));
|
46 |
|
|
$openData->setTypeMap([
|
47 |
|
|
'array' => 'array',
|
48 |
|
|
'document' => 'array',
|
49 |
|
|
'root' => 'array'
|
50 |
|
|
]);
|
51 |
|
|
|
52 |
|
|
return $this->json($openData->toArray());
|
53 |
|
|
|
54 |
|
|
}
|
55 |
b8edf218
|
vastja
|
}
|