commit 61ff77180f76d81e88c30bb8e27068e9caa54e07
Author: vastja <vastja@gmail.com>
Date:   Sat May 16 14:21:47 2020 +0200

    Re #8092, Re #8085
    + data source points location layer - circles
    + total number of activity in aggregation

diff --git a/website/public/js/zcu-heatmap.js b/website/public/js/zcu-heatmap.js
index 9677ba0..e79dbfd 100644
--- a/website/public/js/zcu-heatmap.js
+++ b/website/public/js/zcu-heatmap.js
@@ -1,5 +1,6 @@
 var mymap;
 var heatmapLayer = null;
+var marksLayer = null;
 
 var startX = 49.7248;
 var startY = 13.3521;
@@ -46,11 +47,13 @@ function showInfo(e) {
   var lat = 0;
   var lng = 0;
 
+  var total = 0;
   data[currentTime]['items'].forEach(element => {
     if (e.latlng.distanceTo(new L.LatLng(element.x, element.y)) < radius) {
       lat += element.x
       lng += element.y;
       info[i] = {'place' : element.place, 'number' : element.number};
+      total += parseInt(element.number);
       i++;
     }
   });
@@ -62,10 +65,10 @@ function showInfo(e) {
                   })
                   .setLatLng([lat / i, lng / i])
                   .setContent('<strong>Zařízení a počet:</strong><div id=\'place-info\'>' + info[currenInfo].place + '</div>' +
-                              '<div id=\'number-info\'>' + info[currenInfo].number + '</div>' +
+                              '<div id=\'number-info\'><span id=\'digit-info\'>' + info[currenInfo].number + '</span>' + '<span id=\'total-info\' style="font-size: large">/' + total +'</span></div>' + 
                               '<div class=\'popup-controls\'>' +
                                 '<button id=\'previous-info-btn\' class=\'circle-button\' onclick=\'previousInfo()\'></button>' +
-                                '<div id=\'count-info\'>' + (currenInfo + 1) + '/' + info.length + '</div>' +
+                                '<div id=\'count-info\'>' + (currenInfo + 1) + ' z ' + info.length + '</div>' +
                                 '<button id=\'next-info-btn\' onclick=\'nextInfo()\' class=\'circle-button next\'></button>' +
                               '</div>'
                               )
@@ -92,8 +95,8 @@ function nextInfo() {
 
 function displayInfoText() {
   $('#place-info').html(info[currenInfo].place)
-  $('#number-info').html(info[currenInfo].number)
-  $('#count-info').html(currenInfo + 1 + '/' + info.length);
+  $('#digit-info').html(info[currenInfo].number)
+  $('#count-info').html(currenInfo + 1 + ' z ' + info.length);
 }
 
 function setMapView(latitude = startX, longitude = startY, zoom = startZoom) {
@@ -155,30 +158,52 @@ function setTimeline() {
   $('#timeline').attr('class', 'time hour-' + currentTime);
 }
 
-function loadCurrentTimeHeatmap(route) {
+function loadCurrentTimeHeatmap(opendataRoute, positionsRoute) {
 
-  dataSourceRoute = route;
   data = []
 
-  name = $('#type').children("option:selected").text();
+  name = $('#type').children("option:selected").val();
   date = $('#date').val()
   currentTime = parseInt($('#time').children("option:selected").val());
   setTimeline();
 
   $.ajax({
     type: "POST",
-    url: dataSourceRoute + '/' +  name + '/' + date + '/' + currentTime,
+    url: opendataRoute + '/' +  name + '/' + date + '/' + currentTime,
     success: function(result) {
       data[currentTime] = result;
       drawHeatmap(data[currentTime]);
     }
   });
 
+  $.ajax({
+    type: 'POST',
+    url: positionsRoute + '/' + name,
+    success: function(result) {
+      drawDataSourceMarks(result)
+    }
+  });
+
   preload(currentTime, 1);
   preload(currentTime, -1);
 
 }
 
+function drawDataSourceMarks(data) {
+
+  if (marksLayer != null) {
+    L.removeLayer(marksLayer);
+  }
+
+  marksLayer = L.layerGroup();
+  for (var key in data) {
+    marksLayer.addLayer(L.circle([data[key]['x'], data[key]['y']], {radius: 1, color: 'black'}));
+  }
+
+  marksLayer.addTo(mymap);
+
+}
+
 function preload(time, change) {
 
   var ntime = time + change; 
diff --git a/website/src/Controller/HeatmapController.php b/website/src/Controller/HeatmapController.php
index 948c11b..35b6f0b 100644
--- a/website/src/Controller/HeatmapController.php
+++ b/website/src/Controller/HeatmapController.php
@@ -61,4 +61,11 @@ class HeatmapController extends AbstractController {
     public function datesWithAvailableDatasets(IOpenDataManager $manager) {
         return $this->json($manager->getDatesWithAvailableCollection());
     }
+
+    /**
+     * @Route("heatmap/positions/{name}", name="positions")
+     */
+    public function dataSourcePoistions(IOpenDataManager $manager, $name = 'NONE') {
+        return $this->json($manager->getDataSourcePositions($name));
+    }
 }
diff --git a/website/src/IOpenDataManager.php b/website/src/IOpenDataManager.php
index 59cae8d..a46d6e8 100644
--- a/website/src/IOpenDataManager.php
+++ b/website/src/IOpenDataManager.php
@@ -14,4 +14,6 @@ interface IOpenDataManager {
     public function getDatesWithAvailableCollection();
 
     public function getMaxCollectionNumberAtDay($name, $date);
+
+    public function getDataSourcePositions($name);
 }
diff --git a/website/src/OpenDataManager.php b/website/src/OpenDataManager.php
index e8f89b8..640fc8d 100644
--- a/website/src/OpenDataManager.php
+++ b/website/src/OpenDataManager.php
@@ -29,7 +29,7 @@ class OpenDataManager implements IOpenDataManager {
     }
 
     public function getAvailableCollections() {
-        $openData = $this->manager->executeQuery('open-data-db.DATASETS', new Query([], ['projection' => ['name' => 1, '_id' => 0]]));
+        $openData = $this->manager->executeQuery('open-data-db.DATASETS', new Query([], ['projection' => ['key-name' => 1, 'display-name' => 1, '_id' => 0]]));
 
         $openData->setTypeMap([
             'array' => 'array',
@@ -45,8 +45,8 @@ class OpenDataManager implements IOpenDataManager {
         $available = $this->getAvailableCollections();
         $index = 0;
         foreach ($available as $key => $value) {
-            if ($this->isCollectionAvailable($value['name'], $date) && false == array_key_exists($value['name'], $availableInDate)) {
-                $availableInDate[$value['name']] = $value['name'];
+            if ($this->isCollectionAvailable($value['key-name'], $date) && false == array_key_exists($value['key-name'], $availableInDate)) {
+                $availableInDate[$value['key-name']] = $value['display-name'];
             }
         }
 
@@ -87,4 +87,16 @@ class OpenDataManager implements IOpenDataManager {
 
         return empty($result) ? 1 : $result[0]['number'];
     }
+
+    public function getDataSourcePositions($name = 'NONE') {
+        $positions = $this->manager->executeQuery('open-data-db.'.$name.'DEVICES', new Query([], []));
+
+        $positions->setTypeMap([
+            'array' => 'array',
+            'document' => 'array',
+            'root' => 'array',
+        ]);
+
+        return $positions->toArray();
+    }
 }
diff --git a/website/src/Utils/Utils.php b/website/src/Utils/Utils.php
index 658132c..92a70ee 100644
--- a/website/src/Utils/Utils.php
+++ b/website/src/Utils/Utils.php
@@ -8,8 +8,8 @@ class Utils {
 
         $index = 0;
         foreach ($datasets as $key => $value) {
-            if (false == array_key_exists($value['name'], $names)) {
-                $names[$value['name']] = $value['name'];
+            if (false == array_key_exists($value['key-name'], $names)) {
+                $names[$value['display-name']] = $value['key-name'];
             }
         }
 
diff --git a/website/templates/heatmap.html.twig b/website/templates/heatmap.html.twig
index 27fd05f..736dada 100644
--- a/website/templates/heatmap.html.twig
+++ b/website/templates/heatmap.html.twig
@@ -160,7 +160,7 @@
         initMap();
         checkDataSetsAvailability("{{ path('available') }}")
         {% if submitted %}
-          loadCurrentTimeHeatmap("{{ path('opendata') }}");
+          loadCurrentTimeHeatmap("{{ path('opendata') }}", "{{ path('positions') }}");
         {% endif %}
       
         var datesetDates = '23-04-2019,24-04-2019,25-04-2019,24-05-2020,27-05-2020'.split(',');
