Browse Source

odevzani bp

pesvan 4 years ago
parent
commit
657c06280f

+ 100 - 0
README.txt

@@ -0,0 +1,100 @@
+Readme k bakalarske praci "Kontrola turistickych tras v KCT v datech OSM"
+
+10/2014 - 05/2015
+
+Autor:
+Petr Svana, xsvana00@stud.fit.vutbr.cz nebo petr.svana@gmail.com
+
+URL aplikace:
+http://osm.fit.vutbr.cz/xsvana00/
+
+Prace s aplikaci bez instalace:
+K prohlizeni aplikace staci novejsi verze soucasnych internetovych prohlizecu, aplikace muze vykazovat problemy v prohlizeci Internet Explorer 9 a starsi.
+Je potreba povolit vykonavani JavaScriptu.
+Ovladani a moznosti uzivatele aplikace jsou popsany v textu bakalarske prace v kapitole c. 6: Manual k vysledne aplikaci
+
+uzivatelske ucty:
+aplikace je nepouziva s jednou vyjimkou, a to je zneviditelneni uzivatelskeho vstupu, pro vyzkouseni teto funkcionality pouzijte parametry:
+username: ukazka, heslo: fit_v_brne
+
+SW pozadavky pro vlastni instanci aplikace:
+postgresql 9.3, postgis 2.1, osmosis, webovy server (apache), php 5 + GL knihovna, osmconvert, osmfilter, osmupdate
+
+Instalace vlastni instance(v zavorkach odkazy do textove casti bakalarske prace):
+1) Konfigurace databaze (5.2.1)
+2) Prvotni import dat do databaze (5.2.2)
+3) Nastaveni pravidelneho vykonavani skriptu src/update.sh pomoci nastroje cronjob
+4) Vytvoreni uzivatelskych tabulek pomoci sql souboru umistenych v src/sql_import/
+5) Zkopirovani obsahu slozky src/ na Vas webovy server
+
+Zdrojovy kod je mj. dostupny take na GitHubu:
+https://github.com/pesvan/OsmHiCheck
+
+
+Adresarova struktura aplikace:
+src/ - root projektu
+src/css/ - css soubory k webovemu rozcestniku mezi mapovou a tabukovou casti
+src/images/ - obrazky k vzhledu rozcestniku mezi mapovou a tabukovou casti
+src/map/ - implementace mapove casti
+src/map/css/ - css soubory k mapove casti
+src/map/css/leaflet/ - css soubory pouzite knihovny leaflet a jejich zasuvnych modulu
+src/map/images/ - pouzite obrazky pro vzhled mapove casti
+src/map/js/ - funkcionalita na strane klienta
+src/map/js/jquery/
+src/map/js/leaflet/ - pouzite JS knihovny a zasuvne moduly
+src/map/json/ - ukazkove soubory pro import
+src/map/php/ - soubory zajistujici serverovou cast aplikace
+src/sql_import/ - soubory pro vytvoreni tabulek mimo OSM data
+src/tables/ - implementace tabulkove casti
+src/tables/css/ - css soubory k tabulkove casti
+src/tables/php - funkcionalita tabulkove casti v PHP
+src/tables/php/phplot - knihovna pro vytvoreni grafu
+src/uploads/ - slozka, kam se ukladaji uzivateli nahrane obrazky
+
+...
+src/db_conf.php - konfiguracni soubor pro databazove udaje
+src/update.sh - skript pro pravidelnou aktualizaci databaze
+
+soubory vygenerovane skriptem src/update.sh :
+src/error.log - obsahuje posledni chybovy vystup aktualizace
+src/last_update.txt - obsahuje datum a cas posledni aktualizace OSM dat
+src/update.log - logovaci soubor pravidelnych updatu OSM databaze
+
+
+Seznam pouzitych externich zasuvnych modulu a knihoven:
+[nazev] - [ucel v aplikaci]
+    [url adresa projektu]
+    [typ a url licence]
+
+Mapova cast, JavaScript:
+Leaflet - zaklad pro vykresleni mapy
+    leafletjs.com
+    https://github.com/Leaflet/Leaflet/blob/master/LICENSE
+Leaflet Control OSM Geocoder - vyhledavani v mape
+    https://github.com/k4r573n/leaflet-control-osm-geocoder
+    https://github.com/k4r573n/leaflet-control-osm-geocoder/blob/master/LICENSE
+Leaflet Control LineStringSelect - usnadneni implementace vyberu useku cesty uzivatelem
+    https://github.com/w8r/L.Control.LineStringSelect
+    [MIT] https://github.com/w8r/L.Control.LineStringSelect/blob/master/LICENSE
+Leaflet Control Sidebar - zaklad postranniho panelu aplikace
+    https://github.com/turbo87/leaflet-sidebar/
+    [MIT] https://github.com/Turbo87/leaflet-sidebar/blob/master/LICENSE
+Leaflet Control Zoomslider - posuvny zoom
+    https://github.com/kartena/Leaflet.zoomslider
+    https://github.com/kartena/Leaflet.zoomslider/blob/master/LICENSE
+Leaflet Awesome Markers - design zobrazovanych znacek
+    https://github.com/lvoogdt/Leaflet.awesome-markers
+    https://github.com/lvoogdt/Leaflet.awesome-markers/blob/master/LICENSE
+Leaflet FileLayer - nahravani gpx a podobnych souboru do mapy
+    https://github.com/makinacorpus/Leaflet.FileLayer
+    [MIT] https://github.com/makinacorpus/Leaflet.FileLayer/blob/master/LICENSE
+Leafet Hash - hash aktualni polohy a zoomu v adresnim radku
+    http://mlevans.github.io/leaflet-hash/
+    https://github.com/mlevans/leaflet-hash/blob/master/LICENSE.md
+ToGeoJSON - pomocny modul pro Leaflet FileLayer
+    https://github.com/mapbox/togeojson
+    [ok] https://github.com/mapbox/togeojson/blob/master/LICENSE
+
+Tabulkova cast, PHP:
+PHPlot - vykresleni grafu
+    http://www.phplot.com

+ 7 - 1
css/stylesheet.css

@@ -1,3 +1,5 @@
+/** CSS soubor k zobrazeni rozcestniku mezi mapou a tabulkou */
+
 body {
   background-color: #fff;
   font-family: "PT Sans", helvetica, arial, sans-serif;
@@ -43,5 +45,9 @@ a:visited {
 }
 
 .image-left {
-    background-image: url('http://osm.fit.vutbr.cz/xsvana00/screen.png');
+    background-image: url('http://osm.fit.vutbr.cz/xsvana00/images/screen.png');
+}
+
+img {
+  width: 200px;
 }

+ 6 - 0
db_conf.php

@@ -0,0 +1,6 @@
+<?php
+
+const USERNAME = "xsvana00";
+const PASSWORD = "osm";
+const DATABASE = "xsvana00";
+const SERVER = "localhost";

BIN
images/screen.png


+ 3 - 1
map/css/stylesheet.css

@@ -43,7 +43,9 @@ a {
     text-decoration: underline;
 }
 
-
+img {
+    width: 300px;
+}
 body {
   background-color: #fff;
   font-family: 'Open Sans', sans-serif;

+ 1 - 1
map/data.html

@@ -14,4 +14,4 @@ if (selectedElement == undefined) {
                 getGuideInfo(selected[NODE].id);
             }
         }
-</script type="text/javascript">
+</script>

+ 1 - 1
map/import.html

@@ -1,6 +1,6 @@
 <script type="text/javascript">
     function openWin(file){
-        window.open(file, file, "width=400, height=400");
+        window.open(file, file, "width=400, height=400, scrollbars=yes");
     }
 </script>
 <div id="error" class="red center"></div>

+ 7 - 11
map/index.html

@@ -4,20 +4,16 @@
 
     <title>OsmHiCheck - Mapa</title>
     <meta charset="utf-8"/>
-<link href='http://fonts.googleapis.com/css?family=Open+Sans:300&subset=latin-ext' rel='stylesheet' type='text/css'>
+    <link href='http://fonts.googleapis.com/css?family=Open+Sans:300&subset=latin-ext' rel='stylesheet' type='text/css'>
     <link rel="stylesheet" type="text/css" href="css/leaflet/leaflet.css"/>
     <link rel="stylesheet" type="text/css" href="css/leaflet/Control.OSMGeocoder.css"/>
     <link rel="stylesheet" type="text/css" href="css/leaflet/L.Control.Sidebar.css"/>
     <link rel="stylesheet" type="text/css" href="css/leaflet/L.Control.Zoomslider.css"/>
     <link rel="stylesheet" type="text/css" href="css/stylesheet.css"/>
     <link rel="stylesheet" type="text/css" href="http://maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" />
-    <link rel="stylesheet" type="text/css" href="css/leaflet/MarkerCluster.css" />
-    <link rel="stylesheet" type="text/css" href="css/leaflet/MarkerCluster.Default.css" />
     <link rel="stylesheet" type="text/css" href="css/leaflet/leaflet.awesome-markers.css" />
     <link rel="stylesheet" type="text/css" href="http://code.ionicframework.com/ionicons/1.5.2/css/ionicons.min.css">
 
-   
-
     <script type="text/javascript" src="js/leaflet/leaflet.js"></script>
     <script type="text/javascript" src="js/leaflet/leaflet-hash.js"></script>
     <script type="text/javascript" src="js/leaflet/Control.OSMGeocoder.js">//vyhledavani</script>
@@ -25,9 +21,8 @@
     <script type="text/javascript" src="js/leaflet/leaflet.filelayer.js">//nahravani ext. souboru</script>
     <script type="text/javascript" src="js/leaflet/togeojson.js"></script>
     <script type="text/javascript" src="js/leaflet/L.Control.Sidebar.js">//sidebar</script>
-    <script type="text/javascript" src="js/leaflet/leaflet.markercluster.js">//maker cluster</script>
-    <script type="text/javascript" src="js/leaflet/L.Control.LineStringSelect.js">//sidebar</script>
-    <script type="text/javascript" src="js/leaflet/leaflet.awesome-markers.js">//sidebar</script>
+    <script type="text/javascript" src="js/leaflet/L.Control.LineStringSelect.js"></script>
+    <script type="text/javascript" src="js/leaflet/leaflet.awesome-markers.js"></script>
     <script type="text/javascript" src="js/jquery/jquery-1.11.2.min.js"></script>
     <script type="text/javascript" src="js/OsmHiCheck.js"></script>
 </head>
@@ -51,8 +46,8 @@
                                 <ul>
                                     <li>
                                         <ul>
-                                            <li id="inner"><a onclick="changeSidebarContent(CR_NODE1)">Bod s poznámkou</a></li> 
-                                            <li id="inner"><a onclick="changeSidebarContent(CR_PART1)">Část trasy s poznámkou</a></li>
+                                            <li><a onclick="changeSidebarContent(CR_NODE1)">Bod s poznámkou</a></li>
+                                            <li><a onclick="changeSidebarContent(CR_PART1)">Část trasy s poznámkou</a></li>
                                         </ul>
                                     </li>
                                 </ul>
@@ -71,11 +66,12 @@
     <div id="side-layer"></div>
     <div id="side-layer2">
         <div>Dodatečné volby:</div>
-       <label><input type="checkbox" id="cycle" onclick="processCheckbox()"/>Zahrnout cyklotrasy</label>
+       <label><input type="checkbox" id="cycle" onclick="processCheckbox()"/>Zahrnout cyklotrasy bez kct barvy</label>
     </div>
 </div>
 
 <script type="text/javascript">
+    /* prepinani s rolovanim*/
     jQuery(window).load(function() {
         $("#nav > li > a").click(function () {
             if ($(this).parent().hasClass('selected')) {

+ 272 - 136
map/js/OsmHiCheck.js

@@ -1,10 +1,9 @@
-
-
-var NODES_WAYS_EDGE = 12;
-
+/** globalni promenne */
 
 var map;
 
+//hranicni hodnota zoomu pro rozmezi mezi zobrazenim relace jako linie a jako relace
+var NODES_WAYS_EDGE = 12;
 //promenna pro manipulaci s prvkem - ovladani vrstev
 var controlLayersHandler;
 //manipulace s postrannim panelem
@@ -37,10 +36,11 @@ for (i = 0; i < layerNames.length; i++){
 // stavove promenne pro vrstvy
 var cycleRelationsAreOn = false;
 
-//pomocna promenna pro zamezeni opakovemu nahravani ve stejny moment
+//pomocne promenne pro zamezeni opakovemu nahravani ve stejny moment
 var canGetData = true;
 var canGetData2 = true;
 
+//ulozeni typu vybraneho elementu
 var selectedElement;
 
 /** imitace enum - konstanty pro lepsi orientaci */
@@ -64,15 +64,15 @@ var DATA = 0;
 var LAYERS = 1;
 var CR_NODE1 = 2;
 var CR_NODE2 = 3;
-var NODE_LIST = 4;
 var CR_PART1 = 5;
 var CR_PART2 = 6;
 var GUIDEPOST_INFO = 7;
 var IMPORT = 8;
 
-
+//stavova promenna pro vytvoreni uzivatelskeho bodu
 var CREATE_NODE = false;
 
+//zpravy uzivateli
 var msgCreateNodeBefore = "Pro vytvoření bodu s poznámkou klikněte na požadovanou lokaci na mapě.";
 var msgError = "Nevyplněno vše";
 var msgErrorCoords = "Špatný formát souřadnic";
@@ -82,19 +82,18 @@ var msgErrorFile = "Nevybrán žádný soubor";
 var msgErrorFileType = "Soubor není povoleného typu";
 var msgErrorSelect = "Nebyl vybrán žádný typ";
 var msgErrorImage = "Špatný formát jednoho nebo více obrázků";
-var msgUserClickedOnRelation = "Bylo kliknuto na trasu nebo na prvek, poznámka bude obsahovat referenci na tyto prvky.";
 var msgCreateLineBefore = "Pro vyznačení části trasy klikněte na požadovaný úsek. Při úrovni zoomu 15 a blíže (tzn. měřítko vlevo dole ukazuje 300 m a méně) se zobrazí také ostatní cesty, které nejsou součástí turistických relací (way:highway=)";
 
+//vytvoreni bodu - pomocne promenne
 var lngLatFromClick = null;
 var dataFromClick = false;
 //pomocny marker
 var temporaryMarker = null;
-
+var tempIcon;
+// promenna pro manipulaci s usekem cesty
 var selectedWayToControl;
-
+// ulozeni soucasneho stavu sidebaru
 var sidebarContent = null;
-var tempIcon;
-
 
 //vypnuti cachovani AJAXU
 $.ajaxSetup({    
@@ -102,14 +101,13 @@ $.ajaxSetup({
 });
 
 function initMap() {
-
     document.getElementById('cycle').checked = false;
     /** mapa **/
     map = new L.Map('mymap', {
         zoomControl: false
     });
     map.user = "";
-    /** podklady **/
+    /** podklad **/
     var osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
     var osmAttrib = 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors';
     var osm = new L.TileLayer(osmUrl, {
@@ -117,11 +115,7 @@ function initMap() {
         maxZoom: 19,
         attribution: osmAttrib
     });
-    var none = new L.TileLayer(null, {
-        minZoom: 1,
-        maxZoom: 19,
-        attribution: osmAttrib
-    });
+
 
     map.setView(new L.LatLng(48.952, 16.734), 13);
     map.addLayer(osm);
@@ -295,10 +289,14 @@ function initMap() {
     layers[USERNOTES].layer = L.geoJson(null, {
         id: USERNOTES,
         pointToLayer: function (feature, latlng) {
+            var image = "";
             var osmLink = ""; //vytvoreni odkazu na OSM, pokud to uzivatel potvrdil pri vytvoreni
             if(feature.properties.osm==1){
                 osmLink += "<a target='_blank' href='http://www.openstreetmap.org/user/"+feature.properties.user+"'>(OSM uživatel)</a>";
             }
+            if(feature.properties.image.length>0){
+                image += "<a href='../uploads/"+feature.properties.image+"' target='_blank'><img src='../uploads/"+feature.properties.image+"'/></a><br />";
+            }
             return L.marker(latlng, {
                 icon: layers[USERNOTES].icon
             }).bindPopup(
@@ -307,6 +305,7 @@ function initMap() {
                 "poznámka: " + feature.properties.note + "<br/>" +
                 "aktuálnost poznámky:" + feature.properties.date + "<br/>" +
                 "čas vložení: " + feature.properties.timestamp + "<br/>" +
+                 image +
                 "uživatel: " + feature.properties.user + " " + osmLink +"<br/>" +
                 "<a onclick='deleteUserContent(CR_NODE1,"+ feature.properties.id+")'>Odstranit poznámku</a><br/>"
             );
@@ -365,12 +364,18 @@ function initMap() {
     map.on('click', onClickElsewhere);
     map.on('zoomend', mapZoomed);
 
+    /** zobrazeni udaje o aktualnosti a odkazu na github v attribution*/
     jQuery.get("../last_update.txt", function (data) {
         var x= document.getElementsByClassName('leaflet-control-attribution');
         x[0].innerHTML = "<a href='https://github.com/pesvan/OsmHiCheck'>Github</a> | OSM data updated: "+data+" <br /> "+x[0].innerHTML;
     });
 }
 
+/**
+ * funkce zajistujici vytvoreni docasneho uzlu
+ * @param e
+ * @param bind
+ */
 function createNode(e, bind) {
     if (CREATE_NODE) {
         lngLatFromClick = e.latlng;
@@ -384,6 +389,11 @@ function createNode(e, bind) {
     }
 }
 
+/** *
+ * nastaveni reakce na kliknuti na prvek
+ * @param feature
+ * @param layer
+ */
 function onEachFeature(feature, layer) {
     setTimeout(function () {
         setSidebarLoading(false);
@@ -391,6 +401,11 @@ function onEachFeature(feature, layer) {
     layer.on('click', onClick);
 }
 
+/**
+ * nastaveni reakce na kliknuti na uzivatelem vyznaceny usek cesty
+ * @param feature
+ * @param layer
+ */
 function onEachFeatureUserPart(feature, layer){
     var osmLink = "";
     if(feature.properties.osm==1){
@@ -408,6 +423,10 @@ function onEachFeatureUserPart(feature, layer){
     );
 }
 
+/**
+ * interakce uzivatele po kliknuti na prvek v mape
+ * @param e
+ */
 function onClick(e) {
     if (CREATE_NODE) {
         createNode(e, true);
@@ -417,7 +436,7 @@ function onClick(e) {
             feature: e.target.feature
         });
         changeSidebarContent(CR_PART2);
-    } else {
+    } else { //ulozeni informaci o kliknutem prvku
         selected[RELATION].id= e.target.feature.relation_id;
         selected[RELATION].errorNumber = e.target.feature.properties.errValue;
         selected[RELATION].incorrectNumber = e.target.feature.properties.incValue;
@@ -437,10 +456,18 @@ function onClick(e) {
     }
 }
 
+/**
+ * @param e
+ */
 function onClickElsewhere(e) {
     createNode(e, false);
 }
 
+
+/**
+ * zapnuti dane vrstvy po pridani do mapy
+ * @param e
+ */
 function onOverlayAdd(e) {
     //fix, aby se funkce nevolala 2x po sobe
     if (!canGetData) {
@@ -455,7 +482,7 @@ function onOverlayAdd(e) {
 }
 
 /**
- *
+ *  vycisteni dat a vypnuti dane vrstvy pri odebrani
  * @param e
  */
 function onOverlayRemove(e) {
@@ -464,7 +491,7 @@ function onOverlayRemove(e) {
     layers[id].list = [];
     layers[id].drawn = [];
     layers[id].layer.clearLayers();
-    if(map.getZoom()<NODES_WAYS_EDGE){
+    if(map.getZoom()<NODES_WAYS_EDGE){// fix pro spravne zobrazovani
         if((id==WARNINGS || id==ERRORS) && layers[TRACKS].isOn){
             resetLayer(TRACKS);
             getData();
@@ -475,7 +502,9 @@ function onOverlayRemove(e) {
         }
     }
 }
-
+/**
+ * pri pohybu mapou je treba zjistit nova data
+ */
 function mapMoved() {
     getData();
 }
@@ -600,14 +629,12 @@ function processListDataOSM(data) {
     } else {
         setSidebarLoading(false);
     }
-
-    
-
-    
-
-
 }
 
+/**
+ * zvlastni processing vsech cest, kvuli jinemu charakteru se zpracovava v samostatne funkci
+ * @param data
+ */
 function processListDataAllWays(data){
     var toDraw = filterNewWays(data);
     deleteUnusedGeoJSONRelations($(layers[ALLWAYS].layer).not(data).get(), layers[ALLWAYS].layer);
@@ -703,7 +730,6 @@ function deleteUnusedGeoJSONRelations(data, layer) {
             var obj = layer._layers[object];
             for (var relation in data) {
                 if (obj.feature.relation_id == relation) {
-                    //delete touristRelationsLayer._layers[object];
                     layer.removeLayer(obj);
                 }
             }
@@ -780,6 +806,10 @@ function getWaysToDraw(rid, controlType) {
     })
 }
 
+/**
+ * ziskani uzivatelskych inforaci o rozcestniku
+ * @param nid
+ */
 function getGuideInfo(nid) {
     if (!canGetData2) {
         return;
@@ -791,61 +821,82 @@ function getGuideInfo(nid) {
         data: 'nid=' + nid,
         success: function(data){
             printGuideInfo(data);
-            setTimeout(function () {
+            setTimeout(function () { //opet fix pro synchronizaci
                 canGetData2 = true;
             }, 500);
         }
     });
 }
 
+/**
+ * vypis uzivatelskych inforaci o rozcestniku na strance prislusneho rozcestniku
+ * @param data
+ */
 function printGuideInfo(data){
     if(sidebarContent==DATA){
-        var load = document.getElementById('side-load');
+        var layer = document.getElementById('side-layer');
         for(var info in data){
             if(data.hasOwnProperty(info)){
                 var osmLink = "";
                 if(data[info].osm_name==1){
                     osmLink += "<a target='_blank' href='http://www.openstreetmap.org/user/"+data[info].hi_user_id+"'>(OSM uživatel)</a>";
                 }
-                load.innerHTML += "Uživatel: "+data[info].hi_user_id + " " + osmLink + "<br />";
-                load.innerHTML += "Typ: "+resolveSelectType(data[info].type)+"</span><br />";
-                load.innerHTML += "Komentář: "+data[info].note+"<br />";
-                load.innerHTML += "Platné k datu: "+data[info].date+"<br />";
-                load.innerHTML += "<a onclick='deleteUserContent(GUIDEPOST_INFO,"+data[info].id+")'>(Odstranit)</a>";
-                load.innerHTML += "<br />";
+                layer.innerHTML += "Uživatel: "+data[info].hi_user_id + " " + osmLink + "<br />";
+                layer.innerHTML += "Typ: "+resolveSelectType(data[info].type)+"</span><br />";
+                layer.innerHTML += "Komentář: "+data[info].note+"<br />";
+                layer.innerHTML += "Platné k datu: "+data[info].date+"<br />";
+                if(data[info].image!='null' && data[info].image!=null){
+                    layer.innerHTML += "<a href='../uploads/"+data[info].image+"' target='_blank'><img src='../uploads/"+data[info].image+"'/></a><br />";
+                }
+                layer.innerHTML += "<a onclick='deleteUserContent(GUIDEPOST_INFO,"+data[info].id+")'>(Odstranit)</a>";
+                layer.innerHTML += "<br />";
+                layer.innerHTML += "<br />";
             }
         }
     }
 }
 
+/**
+ * zneviditelneni uzivatelskeho vstupu, je treba zadat jmeno a heslo superuzivatele
+ * @param type
+ * @param id
+ */
 function deleteUserContent(type, id){
-    var r = confirm("Opravdu chcete tento uživatelský příspevěk smazat?");
-    if(r){
-        $.ajax({
-            url: 'php/deleteUserContent.php',
-            dataType: 'json',
-            data: 'uid='+ id + '&type='+type,
-            complete: function(){
-                if(type==GUIDEPOST_INFO){
-                    changeSidebarContent(DATA);
-                } else if(type==CR_NODE1){
-                    resetLayer(USERNOTES);
-                    getData();
-                } else if(type==CR_PART1){
-                    resetLayer(USERPARTS);
-                    getData();
-                }
-
+    var user = prompt("Zadejte prosím jméno super-uživatele");
+    var hash = prompt("Zadejte heslo");
+    $.post('php/deleteUserContent.php',
+        {
+        uid: id,
+        type: type,
+        user: user,
+            hash: hash
+    },function(data){
+            if(type==GUIDEPOST_INFO){
+                changeSidebarContent(DATA);
+            } else if(type==CR_NODE1){
+                resetLayer(USERNOTES);
+                getData();
+            } else if(type==CR_PART1){
+                resetLayer(USERPARTS);
+                getData();
             }
-        })
-    }
+    });
 }
 
+/**
+ * pomocna funkce pro reset vrstvy
+ * @param layer
+ */
 function resetLayer(layer){
     layers[layer].layer.clearLayers();
     layers[layer].list = [];
 }
 
+/**
+ * prislusne zabarveni uzivatelske poznamky
+ * @param type
+ * @returns {string}
+ */
 function resolveSelectType(type){
     if(type==1){
         return "<span class='green'>OK</span>";
@@ -928,6 +979,11 @@ function JSONToTable(data) {
     return table;
 }
 
+/**
+ *
+ * @param incorrect
+ * @param errNum
+ */
 function setWrongMessage(incorrect, errNum){
     var element = document.getElementById('side-whatswrong');
     element.innerHTML = "";
@@ -989,6 +1045,13 @@ function getMissingTags(tags) {
     return missing;
 }
 
+/**
+ * Ziskani spatnych hodnot tagu
+ * @param tags
+ * @param kctKey
+ * @param number
+ * @returns {Array}
+ */
 function getIncorrectTags(tags, kctKey, number){
     var incorrect = [];
     if(number>=128){
@@ -1042,6 +1105,13 @@ function getIncorrectTags(tags, kctKey, number){
     return incorrect;
 }
 
+/**
+ * ziskani rozporu ve znackach
+ * @param tags
+ * @param kctKey
+ * @param number
+ * @returns {Array}
+ */
 function getErrorTags(tags, kctKey, number){
     var error = [];
     if(number>=4){
@@ -1205,13 +1275,10 @@ function changeSidebarContent(content) {
             $('#side-content').load("import.html");
         })
     }
-
-
-    
 }
 
 /**
- * Vytvoreni linku pro otevreni dane casti v JOSM
+ * Vytvoreni odkazu pro otevreni dane casti v JOSM
  * @param relation
  * @param type
  * @param element
@@ -1232,15 +1299,6 @@ function JOSMLinkBuilder(relation, type, element) {
 }
 
 /**
- *
- * @param data
- * @param element
- */
-function printUserNodes(data, element) {
-    element.innerHTML += JSON.stringify(data);
-}
-
-/**
  * Funkce pro ovladani checkboxu pro zahrnuti cyklotras
  */
 function processCheckbox() {
@@ -1251,54 +1309,61 @@ function processCheckbox() {
     getData();
 }
 
+/**
+ * priprava formulare pro vlozeni uzivatelskeho bodu
+ */
 function prepareForm() {
     var element = document.forms["addNote"];
     element['lat'].value = lngLatFromClick.lat;
     element['lng'].value = lngLatFromClick.lng;
-    var div = document.getElementById('notice');
-  /*  if (dataFromClick) { //featura, ktera nestihla deadline BP
-        div.innerHTML = msgUserClickedOnRelation;
-    } else {
-        div.innerHTML = "";
-    }*/
     if (map.user!=""){
         element['name'].value = map.user;
     }
     prepareDate(document.forms["addNote"]);
 }
 
+/**
+ * predpripraveni aktualniho data
+ * @param element
+ */
 function prepareDate(element){
     var date = new Date();
     element['date'].value = date.getDate()+"/"+(date.getMonth()+1)+"/"+date.getFullYear();
 
 }
 
-function saveNote() {
-    if (validateFormNote()) {
-        setError("");
-        dataFromClick = false;
-        $.post('php/saveNote.php', {
-            lng: getFormValue('lng', 'addNote'),
-            lat: getFormValue('lat', 'addNote'),
-            name: getFormValue('name', 'addNote'),
-            note: getFormValue('note', 'addNote'),
-            date: getFormValue('date', 'addNote'),
-            osm: getOsmNameValue(),
-            type: getSelectedValue()
-        }, function (data) {
-            if (map.hasLayer(temporaryMarker)) {
-                map.removeLayer(temporaryMarker);
-                map.user = getFormValue('name', 'addNote');
-            }
-            console.log(data);
-            layers[USERNOTES].layer.clearLayers();
-            layers[USERNOTES].list = [];
-            getData();
-            changeSidebarContent(LAYERS);
-        });
-    }
+/**
+ * ulozeni uzivatelskeho bodu
+ * @param images
+ */
+function saveNote(images) {
+    setError("");
+    dataFromClick = false;
+    $.post('php/saveNote.php', {
+        lng: getFormValue('lng', 'addNote'),
+        lat: getFormValue('lat', 'addNote'),
+        name: getFormValue('name', 'addNote'),
+        note: getFormValue('note', 'addNote'),
+        date: getFormValue('date', 'addNote'),
+        osm: getOsmNameValue(),
+        type: getSelectedValue(),
+        images: images  
+    }, function (data) {
+        if (map.hasLayer(temporaryMarker)) {
+            map.removeLayer(temporaryMarker);
+            map.user = getFormValue('name', 'addNote');
+        }
+        layers[USERNOTES].layer.clearLayers();
+        layers[USERNOTES].list = [];
+        getData();
+        changeSidebarContent(LAYERS);
+    });
+    
 }
 
+/**
+ * ulozeni useku
+ */
 function savePart() {
     if (validateFormPart()) {
         setError("");
@@ -1318,23 +1383,29 @@ function savePart() {
     }
 }
 
-function saveGuideInfo() {
-    if (validateFormGuideInfo()) {
-        setError("");
-        $.post('php/saveGuideInfo.php', {
-            name: getFormValue('name', 'addGuideInfo'),
-            note: getFormValue('note', 'addGuideInfo'),
-            date: getFormValue('date', 'addGuideInfo'),
-            node: getFormValue('node', 'addGuideInfo'),
-            type: getSelectedValue(),
-            osm: getOsmNameValue()
+/**
+ * ulozeni informace k rozcestniku
+ * @param images
+ */
+function saveGuideInfo(images) {
+    setError("");
+    $.post('php/saveGuideInfo.php', {
+        name: getFormValue('name', 'addGuideInfo'),
+        note: getFormValue('note', 'addGuideInfo'),
+        date: getFormValue('date', 'addGuideInfo'),
+        node: getFormValue('node', 'addGuideInfo'),
+        type: getSelectedValue(),
+        osm: getOsmNameValue(),
+        images: images    
     }, function (data) {
-            map.user = getFormValue('name', 'addGuideInfo');
-            changeSidebarContent(DATA);
-        });
-    }
+        map.user = getFormValue('name', 'addGuideInfo');
+        changeSidebarContent(DATA);
+    });    
 }
 
+/**
+ * importovani dat - klientska cast
+ */
 function importData() {
     setError("");
     var file = document.getElementById('file-select').files[0];
@@ -1349,6 +1420,7 @@ function importData() {
     var reader = new FileReader();
     reader.readAsText(file);
     reader.onload = function(){
+
         if(file.type!="application/json"){
             setError(msgErrorFileType);
             return;
@@ -1364,6 +1436,9 @@ function importData() {
 
 }
 
+/**
+ * @returns {boolean}
+ */
 function validateFormPart() {
     var element = document.forms["addPart"];
     if (!(validateSelect())){
@@ -1387,6 +1462,9 @@ function validateFormPart() {
 
 }
 
+/**
+ * @returns {boolean}
+ */
 function validateFormGuideInfo() {
     var element = document.forms["addGuideInfo"];
     if (!(validateSelect())){
@@ -1405,10 +1483,18 @@ function validateFormGuideInfo() {
         setError(msgErrorImage);
         return false;
     }
+    if(element['photos[]'].files.length>0){
+        uploadImages(document.forms["addGuideInfo"]['photos[]'].files, getFormValue('name', 'addGuideInfo'), GUIDEPOST_INFO);
+    } else {
+        saveGuideInfo(null);
+    }
+       
     return true;
-
 }
 
+/**
+ * @returns {boolean}
+ */
 function validateFormNote() {
     var element = document.forms["addNote"];
     if (CoordsDMS) { //pro ulozeni do db potrebuji decimal format souradnice
@@ -1431,25 +1517,49 @@ function validateFormNote() {
         setError(msgErrorDate);
         return false;
     }
-
-
-    //uploadImages(element['photos[]'].files, element['name'].value);
+    if(!(validateImages(element['photos[]'].files))){
+        setError(msgErrorImage);
+        return false;
+    }
+    if(element['photos[]'].files.length>0){
+        uploadImages(document.forms["addNote"]['photos[]'].files, element["name"].value, USERNOTES);
+    } else {
+        saveNote(null);
+    }
     return true;
 }
 
+/**
+ * pom. funkce pro zjisteni hodnoty daneho prvku formulare
+ * @returns {string|Number|value|*|.serializeArray.value|Document.addNote.lat}
+ */
 function getSelectedValue(){
     var e = document.getElementById('select');
     return e.options[e.selectedIndex].value;
 }
 
+/**
+ *
+ * @returns {number}
+ */
 function getOsmNameValue(){
     return document.getElementById('osm_name').checked ? 1 : 0;
 }
 
+/**
+ *
+ * kontrola vybranych moznosti
+ * @returns {boolean}
+ */
 function validateSelect(){
     return getSelectedValue()!=0;
 }
 
+/**
+ * kontrola obrazku
+ * @param files
+ * @returns {boolean}
+ */
 function validateImages(files){
     var type;
     for(var i = 0; i < files.length; i++) {
@@ -1461,26 +1571,35 @@ function validateImages(files){
     return true;
 }
 
-function uploadImages(files, name){
-    console.log(files, name);
-    var names = [];
-    for(var i = 0; i < files.length; i++){
-        var file = files[i];
-        var reader = new FileReader();
-        reader.readAsDataURL(file);
-        reader.onload = function(event){
-            $.post('php/uploadImage.php', {
-                name: name+"_"+i,
-                data: event.target.result
-            }, function(data){
-                console.log(data);
-                names[names.length] = data;
-            })
-        }
+/**
+ * nahrani obrazku na server
+ * @param files
+ * @param name
+ * @param type
+ */
+function uploadImages(files, name, type){
+    var reader = new FileReader();    
+    reader.readAsDataURL(files[0]);
+    reader.onload = function(event){
+        $.post('php/uploadImage.php', {
+            name: name,
+            data: event.target.result
+        }, function(data){
+            if(type==GUIDEPOST_INFO) {
+                saveGuideInfo(data);
+            } else if(type==USERNOTES) {
+                saveNote(data);
+            }   
+                
+        })
     }
-    return names;
 }
 
+/**
+ * overeni platnosti data
+ * @param date
+ * @returns {boolean}
+ */
 function validateDate(date){
     var re = /[0-9]{1,2}[\/][0-9]{1,2}[\/][0-9]{4}/;
     var m;
@@ -1491,6 +1610,11 @@ function validateDate(date){
     }
 }
 
+/**
+ * overeni souradnic
+ * @param coordValue
+ * @returns {boolean}
+ */
 function validateCoords(coordValue) {
     var re = /[0-9]{1,2}[.][0-9]+/;
     var m;
@@ -1520,7 +1644,11 @@ function getFormValue(element, form) {
 }
 
 
-
+/**
+ * prevodni funkce
+ * @param decimal
+ * @returns {Array}
+ */
 function degreesDecimalToDMS(decimal) {
     var DMS = [];
     decimal = parseFloat(decimal);
@@ -1537,6 +1665,11 @@ function DMSToDecimal(DMS) {
     return (parseInt(DMS[0]) + (parseInt(DMS[1]) / 60) + (parseInt(DMS[2]) / 3600)).toFixed(5);
 }
 
+/**
+ *
+ * @param DMSString
+ * @returns {*}
+ */
 function simpleParseDMS(DMSString) {
     var DMS = [];
     var reDeg = /[0-9]{1,2}(?=°)/;
@@ -1556,6 +1689,9 @@ function simpleParseDMS(DMSString) {
     }
 }
 
+/**
+ * prepnuti zobrazeni souradnic
+ */
 function changeCoordinatesRepresentation() {
     if (CoordsDMS) {
         CoordsDMS = false;

+ 9 - 6
map/json/example_guidepost_info.json

@@ -1,17 +1,19 @@
 [
   {
-    "user": "Petr \u0160va\u0148a",
+    "user": "Petr Švaňa",
     "type": "PROBLEM",
-    "note": "ss",
-    "date": "11\/5\/2015",
+    "note": "Na tomto miste chybi rozcestnik",
+    "image": "http://example.cz/image.png",
+    "date": "11/5/2015",
     "user_is_osm": "1",
     "node_id": "1445764671"
   },
   {
     "user": "Petr",
     "type": "OK",
-    "note": "aas",
-    "date": "11\/5\/2015",
+    "note": "Zkontrolovano, v poradku",
+    "image": "http://example.cz/image2.png",
+    "date": "11/5/2015",
     "user_is_osm": "0",
     "node_id": "1445764671"
   },
@@ -19,7 +21,8 @@
     "user": "Petr",
     "type": "COMMENT",
     "note": "komentar",
-    "date": "11\/5\/2015",
+    "image": "",
+    "date": "11/5/2015",
     "user_is_osm": "0",
     "node_id": "1445764671"
   }

+ 12 - 9
map/json/example_point.json

@@ -2,42 +2,45 @@
   {
     "date": "11\/5\/2015",
     "user": "username",
-    "note": "nadrazi",
+    "note": "namesti vypada v poradku",
+    "image": "http:\/\/fit.pesvan.cz\/BP\/text\/IMG2.jpg",
     "type": "OK",
     "user_is_osm": "1",
     "geometry": {
       "type": "Point",
       "coordinates": [
-        16.736333333333,
-        48.937222222222
+        0.736333333333,
+        1.937222222222
       ]
     }
   },
   {
     "date": "11\/5\/2015",
     "user": "username",
-    "note": "nadrazi",
+    "note": "na nadrazi chybi rozcestnik",
+    "image": "http:\/\/fit.pesvan.cz\/BP\/text\/IMG1.jpg",
     "type": "PROBLEM",
     "user_is_osm": "0",
     "geometry": {
       "type": "Point",
       "coordinates": [
-        16.736111111111,
-        48.937444444444
+        0.736111111111,
+        1.937444444444
       ]
     }
   },
   {
     "date": "11\/5\/2015",
     "user": "username",
-    "note": "nadrazi",
+    "note": "doplnuji dalsi fotografie k nadrazi",
+    "image": "http:\/\/fit.pesvan.cz\/BP\/text\/IMG3.jpg",
     "type": "COMMENT",
     "user_is_osm": "1",
     "geometry": {
       "type": "Point",
       "coordinates": [
-        16.736111111111,
-        48.937222222222
+        2.736111111111,
+        3.937222222222
       ]
     }
   }

+ 2 - 3
map/new_guide_info.html

@@ -34,11 +34,10 @@
     <input type="text" name="date" maxlength="10"/>
 
     <h4>Fotografie</h4>
-    <label>Můžete vložit relevantní fotografie (png/jpeg). Maximalní velikost obrázku je 5MB. Obrázky přesahujíci jedním rozměrem 1200px budou přislusně zmenšeny</label>
-    <div class="red center">Upload obrazku momentalne nefunkcni (chybi GD knihovna (abych nezapomel))</div>
+    <label>Můžete vložit relevantní fotografii (png/jpeg). Maximalní velikost obrázku je 5MB. Obrázky přesahujíci jedním rozměrem 1200px budou přislusně zmenšeny</label>
     <input type="file" id="file-select" name="photos[]" multiple/>
     <br />
     <br />
-    <input class="button" type="button" value="Vložit" onclick="saveGuideInfo()"/>
+    <input class="button" type="button" value="Vložit" onclick="validateFormGuideInfo()"/>
     <input class="button" type="button" value="Reset" onclick="changeSidebarContent(DATA)"/>
 </form>

+ 1 - 3
map/new_note.html

@@ -34,11 +34,9 @@
 
     <h4>Fotografie</h4>
     <label>Můžete vložit relevantní fotografie (png/jpeg). Maximalní velikost obrázku je 5MB. Obrázky přesahujíci jedním rozměrem 1200px budou přislusně změněny</label>
-    <div class="red center">Upload obrazku momentalne nefunkcni (chybi GD knihovna (abych nezapomel))</div>
-
     <input type="file" id="file-select" name="photos[]" multiple/>
     <br />
     <br />
-    <input class="button" type="button" value="Vložit" onclick="saveNote()"/>
+    <input class="button" type="button" value="Vložit" onclick="validateFormNote()"/>
     <input class="button" type="button" value="Reset" onclick="changeSidebarContent(CR_NODE1)"/>
 </form>

+ 2 - 1
map/php/db.php

@@ -1,3 +1,4 @@
 <?php
-  $db = pg_connect("host=localhost dbname=xsvana00 user=xsvana00 password=osm");
+require_once dirname(__FILE__).'/../../db_conf.php';
+$db = pg_connect("host=".SERVER." dbname=".DATABASE." user=".USERNAME." password=".PASSWORD);
 ?>

+ 22 - 16
map/php/deleteUserContent.php

@@ -1,31 +1,37 @@
 <?php
+/* skript pro skryti uziatelskeho vstupu*/
 require 'db.php';
-
+/* konstanty pro lepsi orientaci */
 const REMOVE_GUIDEPOST_INFO = 7;
 const REMOVE_USER_NOTE = 2;
 const REMOVE_USER_PART = 5;
 
-// Same as error_reporting(E_ALL);
-ini_set('display_errors', 1);
-ini_set('error_reporting', E_ALL);// Same as error_reporting(E_ALL);
-
-if((isset($_GET['uid'])) && (isset($_GET['type']))){
-    $id = $_GET['uid'];
-    $type = $_GET['type'];
+if((isset($_POST['uid'])) && (isset($_POST['type']))
+    && (isset($_POST['user'])) && (isset($_POST['hash']))){
+    $id = $_POST['uid'];
+    $type = $_POST['type'];
+    $user = $_POST['user'];
+    $hash = hash('sha512',$_POST['hash']); //jen autorizovany uzivatel muze tuto akci provadet
+    $result = pg_num_rows(pg_query($db, "SELECT id FROM hicheck.superuser WHERE name='$user' and password='$hash'"));
+    if($result!=1){
+        $ajxres=array();
+        $ajxres['resp']=4;
+        $ajxres['dberror']=0;
+        $ajxres['msg']='wrong username or password';
+        exit(json_encode($ajxres));
+    }
 } else {
     $ajxres=array();
     $ajxres['resp']=4;
     $ajxres['dberror']=0;
-    $ajxres['msg']='missing bounding box or type of data';
-    send($ajxres);
+    $ajxres['msg']='missing element id or type of data';
+    exit(json_encode($ajxres));
 }
 if($type==REMOVE_GUIDEPOST_INFO){//poznamky u rozcestniku
-    $query_string = "DELETE FROM hicheck.checked_guideposts WHERE id='$id'";
+    $query_string = "UPDATE hicheck.checked_guideposts SET hidden=1 WHERE id='$id'";
 } else if($type==REMOVE_USER_NOTE) { //poznamka obecna uzivatelska
-    $query_string = "DELETE FROM hicheck.notes WHERE id='$id'";
+    $query_string = "UPDATE hicheck.notes SET hidden=1 WHERE id='$id'";
 } else if($type==REMOVE_USER_PART) { //uzivatelem vyznaceny usek
-    $query_string = "DELETE FROM hicheck.parts WHERE id='$id'";
+    $query_string = "UPDATE hicheck.parts SET hidden=1 WHERE id='$id'";
 }
-$query = pg_query($query_string);
-
-exit(json_encode($arrayOfValues));
+$query = pg_query($query_string);

+ 37 - 88
map/php/func.php

@@ -23,6 +23,9 @@ function getNetworkValueList(){
     return array(array("lwn", "rwn", "nwn"), array("lcn", "rcn", "ncn"));
 }
 
+/**
+ * @return array
+ */
 function getKctKeyList(){
     return array("kct_blue", "kct_green", "kct_red", "kct_white", "kct_yellow", "kct_none", "kct_black", "kct_purple", "kct_orange");
 }
@@ -124,9 +127,6 @@ function getKctOsmcTable(){
     );
 }
 
-
-
-
 /** funkce pro zajisteni automaticke kontroly - kontrola validity hodnot */
 
 /**
@@ -162,10 +162,19 @@ function checkTagsValidValues($tags, $kctKey){
     return $errNum;
 }
 
+/**
+ * @param $network
+ * @return int
+ */
 function checkTagNetwork($network){
     $netList = getNetworkValueList();
     return in_array($network, $netList[0]) || in_array($network, $netList[1]) ? 0 : 1;
 }
+
+/**
+ * @param $kct
+ * @return int
+ */
 function checkKeyKct($kct){
     return in_array($kct, getKctKeyList()) ? 0 : 1;
 }
@@ -243,6 +252,12 @@ function checkTagNetworkKct($network, $kct){
     }
 }
 
+/**
+ * @param $osmc
+ * @param $kct
+ * @param $route
+ * @return int
+ */
 function checkTagOsmcKctRoute($osmc, $kct, $route){
     $osmc = parseOsmc($osmc);
     $route_kct = getRouteKctTable();
@@ -260,12 +275,21 @@ function checkTagOsmcKctRoute($osmc, $kct, $route){
     return 0;
 }
 
+/**
+ * @param $osmc
+ * @param $kctColor
+ * @return int
+ */
 function checkTagOsmcKctColor($osmc, $kctColor){
     $osmcColor = getOsmcTrackColor($osmc);
     return $osmcColor==$kctColor ? 0 : 1;
 }
 
 
+/**
+ * @param $osmc
+ * @return array|null
+ */
 function parseOsmc($osmc){
     $parts = explode(":",$osmc);
     if(count($parts)!=3){
@@ -290,10 +314,6 @@ function getKctTag($tags){
     return $kct_;
 }
 
-
-
-
-//funkce pro zjisteni shody tagu kct_barva a osmc:barva
 /**
  * @param $osmc_color
  * @param $kct_color
@@ -303,9 +323,9 @@ function kctColorVsOsmcColor($osmc_color, $kct_color){
 	return $osmc_color == $kct_color ? true : false;
 }
 
-//funkce pro zjisteni barvy z tagu kct_barva
 /**
- * @param $row
+ * @param $kctKey
+ * @param $route
  * @return int
  */
 function getKctTrackColor($kctKey, $route){
@@ -324,9 +344,8 @@ function getKctTrackColor($kctKey, $route){
 	}
 	return $color;
 }
-
-//funkce pro zjisteni barvy z tagu osmc:symbol
 /**
+ * funkce pro zjisteni barvy z tagu osmc:symbol
  * @param $osmc
  * @return int
  */
@@ -353,48 +372,21 @@ function getOsmcTrackColor($osmc){
 	return $ret;
 	
 }
-/** momentalne nepouzivano */
-function getOsmcBackgroundColor($osmc){
-	$pieces = explode(":", $osmc);
-	return $pieces[1];
-}
 
 /**funkce pro pripravu dat na odeslani*/
-
 function prepareData($data){
     $aux = json_encode($data);
     $aux = "".$aux."";
     return $aux;
 }
 /** funkce pro filtrovani uzlu na zaklade zoomu */
-
-
-//jednoduchy filtr pro uzly
 /**
+ * slozitejsi filtr na zaklade vypoctu smeru vektoru
  * @param $nodes
- * @return array
- */
-function filterNodes($nodes){
-    $cnt = count($nodes);
-    $filtered = array();
-    $filtered[] = $nodes[0];
-    for ($i = 1; $i < $cnt-1; $i++){
-        if($i%2==0){
-            $filtered[] = $nodes[$i];
-        }
-    }
-    $filtered[] = $nodes[$cnt-1];
-    return $filtered;
-}
-
-//slozitejsi filtr na zaklade vypoctu smeru vektoru
-/**
- * @param $nodes
- * @param $id
  * @param $filter
  * @return array
  */
-function efficientFilter($nodes, $id, $filter){
+function efficientFilter($nodes, $filter){
     $cnt = count($nodes);
     $filtered = array();
     $filtered[] = $nodes[0];
@@ -416,41 +408,22 @@ function efficientFilter($nodes, $id, $filter){
     return $filtered;
 }
 
-//funkce pro prispusobeni filtru na zaklade zoomu
 /**
+ * funkce pro prispusobeni filtru na zaklade zoomu
  * @param $zoom
  * @return float|int
  */
 function getFilterFromZoom($zoom){
     if($zoom >= 16){
         return 0;
-    } else if($zoom <16 && $zoom >= 14) {
+    } else if($zoom <16 && $zoom >= 15) {
         return 0.00005;
-    } else if($zoom <14 && $zoom >= 12) {
+    } else if($zoom <15 && $zoom >= 13) {
         return 0.0001;
-    } else if($zoom == 11) {
-        return 0.008;
-    } else if($zoom == 11) {
-        return 0.001;
-    } else if($zoom == 10) {
-        return 0.005;
-    } else if($zoom == 9){
+    } else if($zoom == 12) {
         return 0.008;
     } else return 1;
 }
-/** momentalne nepouzivano */
-//zjisteni prostredniho bodu cesty
-/**
- * @param $start
- * @param $end
- * @return array
- */
-function getCenterPoint($start, $end){
-    $center = array();
-    $center[0] = ($start[0] + $end[0])/2;
-    $center[1] = ($start[1] + $end[1])/2;
-    return $center;
-}
 
 //vypocitani vektoru dvou bodu
 /**
@@ -465,30 +438,7 @@ function getVector($start, $end){
     return $vector;
 }
 
-//vypocitani vzdalenosti pomoci z vektoru
-/**
- * @param $vec
- * @return float
- */
-function getDistanceFromVector($vec){
-    return sqrt(($vec[0]*$vec[0])+($vec[1]*$vec[1]));
-}
-
-//vypocet vzdalenosti z bodu
-/**
- * @param $start
- * @param $end
- * @return float|int
- */
-function getDistanceFromPoints($start, $end){
-    if($start[0]==$end[0] && $start[1]==$end[1]){
-        return 0;
-    } else {
-        return getDistanceFromVector(getVector($start, $end));
-    }
-}
-
-//serazeni cest do jedne relace - pravdepodobne nebude pouzito
+//serazeni cest do jedne relace - mozne vylepseni efektivity zobrazeni do budoucna
 /**
  * @param $firstAndLast
  * @param $coordinates
@@ -551,7 +501,6 @@ function getOrderAndReversedList($firstAndLast){
     return $return;
 }
 
-//...
 /**
  * @param $a
  * @param $b

+ 23 - 20
map/php/getData.php

@@ -1,11 +1,15 @@
 <?php
-
+/** skript stahujee geograficka data ke konkretni relaci, prohihaji zde take kontroly a optimalizace */
 ini_set('display_errors', 1);
-ini_set('error_reporting', E_ALL);// Same as error_reporting(E_ALL);
+ini_set('error_reporting', E_ALL);
 require 'db.php';
 require 'func.php';
-// Same as error_reporting(E_ALL);
 
+const BASE = 0;
+const ERRORS = 2;
+const WARNINGS = 1;
+const GUIDEPOSTS = 3;
+const ALL_WAYS_ = 5;
 
 if((isset($_GET['rid'])) && (isset($_GET['control'])) && (isset($_GET['zoom']))){
     $id = $_GET['rid'];
@@ -16,13 +20,13 @@ if((isset($_GET['rid'])) && (isset($_GET['control'])) && (isset($_GET['zoom'])))
     $ajxres=array();
     $ajxres['resp']=4;
     $ajxres['dberror']=0;
-    $ajxres['msg']='missing bounding box or type of data';
+    $ajxres['msg']='missing bounding box, type of control or type of data';
     send($ajxres);
 }
 
 
  //zakladni query string pro cesty
-if($controlLevel<=2){
+if($controlLevel<=ERRORS){
     $query_string = "SELECT relations.id as rid,
     hstore_to_json(relations.tags) as tags, ways.id as mid, ST_AsGeoJSON(linestring)
     from relations
@@ -30,24 +34,24 @@ if($controlLevel<=2){
     inner join ways on relation_members.member_id = ways.id
     where relations.id = '$id'";
 
-    if($controlLevel==1){ //warnings
+    if($controlLevel==WARNINGS){ //warnings
         $query_string .= " and (not exist(relations.tags,'network')";
         $query_string .= " or not exist(relations.tags,'complete')";
         $query_string .= " or not exist(relations.tags,'osmc:symbol')";
         $query_string .= " or not exist(relations.tags,'destinations'))";
         //$query_string .= " or not exist(relations.tags,'abandoned'))";
     }
-    if($controlLevel==2){ //error
+    if($controlLevel==ERRORS){ //error
         $query_string .= " and exist(relations.tags,'osmc:symbol')";
     }
-} else if($controlLevel==3){ //rozcestniky
+} else if($controlLevel==GUIDEPOSTS){ //rozcestniky
     $query_string = "SELECT relation_members.relation_id as rid, nodes.id as mid, relation_members.member_type as type, ST_AsGeoJSON(nodes.geom) from relation_members inner join nodes on relation_members.member_id = nodes.id where relation_members.relation_id = '$id'";
-} else if($controlLevel==5){ //vsechny cesty
+} else if($controlLevel==ALL_WAYS_){ //vsechny cesty
     $query_string = "SELECT id, ST_AsGeoJSON(linestring) FROM ways WHERE id='$id'";
 }
 $data = pg_query($db, $query_string);
 $info = array();
-if($controlLevel==5){
+if($controlLevel==ALL_WAYS_){
     $row = pg_fetch_assoc($data);
     $geom = json_decode($row['st_asgeojson']);
     $aux = array();
@@ -66,7 +70,7 @@ if($controlLevel==5){
     $firstIteration = true;
     while($row = pg_fetch_assoc($data)) {
         if($firstIteration){
-            if($controlLevel!=3){
+            if($controlLevel!=GUIDEPOSTS){
                 $tags = json_decode($row['tags'], true);
                 $kct = getKctTag($tags);
                 $kctKey = count($kct) > 0 ? $kct[0] : null;
@@ -76,11 +80,11 @@ if($controlLevel==5){
 
             $errorValue = 0;
             $incorrectValues = 0;
-            if ($controlLevel <= 2) { //ziskani kct barvy
+            if ($controlLevel <= ERRORS) { //ziskani kct barvy
                 $color = getKctTrackColor($kctKey, $tags['route']);
             }
 
-            if($controlLevel==2 && $kctKey!=null){
+            if($controlLevel==ERRORS && $kctKey!=null){
 
 
 
@@ -101,12 +105,11 @@ if($controlLevel==5){
                 if(array_key_exists('osmc:symbol', $tags)){
                     $errorValue += checkTagOsmcKctColor($tags['osmc:symbol'], $color)*4;
                 }
-                //echo "$errorValue, $incorrectValues";
                 //nepokracuje se dal, nenalezena chyba
                 if($errorValue==0){
                     exit();
                 }
-            } else if($controlLevel==2 && $kctKey==null){
+            } else if($controlLevel==ERRORS && $kctKey==null){
                 $errorValue = 128;
             }
         }
@@ -117,16 +120,16 @@ if($controlLevel==5){
         $prop['errValue']=$errorValue;
         $prop['incValue']=$incorrectValues;
         $prop['kctkey']=$kctKey;
-        if($controlLevel<=2){
+        if($controlLevel<=ERRORS){
             $prop['color'] = $color;
             $aux['int_type']=1;
         } 	else {
             $aux['int_type']=2;
         }
         $geom = json_decode($row['st_asgeojson']);
-        if($controlLevel!=3 && $zoomLevel>=NODES_WAYS_EDGE){
-            $geom->coordinates = efficientFilter($geom->coordinates, $row['mid'], $zoom);
-        } else if($zoomLevel<12 && $controlLevel!=3){ //redukce relace na jeden bod
+        if($controlLevel!=GUIDEPOSTS && $zoomLevel>=NODES_WAYS_EDGE){
+            $geom->coordinates = efficientFilter($geom->coordinates, $zoom);
+        } else if($zoomLevel<NODES_WAYS_EDGE && $controlLevel!=GUIDEPOSTS){ //redukce relace na jeden bod
             $geom->coordinates = $geom->coordinates[0];
             $geom->type = "Point";
         }
@@ -136,7 +139,7 @@ if($controlLevel==5){
         $aux['properties']=$prop;
         $aux['geometry']=$geom;
         $info[] = $aux;
-        if($zoomLevel<NODES_WAYS_EDGE && $controlLevel!=3){ //redukce relace na jeden bod
+        if($zoomLevel<NODES_WAYS_EDGE && $controlLevel!=GUIDEPOSTS){ //redukce relace na jeden bod, v iteraci se nepokracuje
             break;
         }
     }

+ 8 - 3
map/php/getElement.php

@@ -1,4 +1,5 @@
 <?php
+/** ziskani vsech dat k dane relaci/ceste/uzlu */
 include 'db.php';
 // Same as error_reporting(E_ALL);
 ini_set('display_errors', 1);
@@ -14,13 +15,17 @@ if (isset($_GET['data']) && isset($_GET['type'])) {
 		send($ajxres);
 }
 
+const RELATION = 0;
+const WAY = 1;
+const NODE = 2;
+
 $query_string = "SELECT id, version, user_id, tstamp, changeset_id, hstore_to_json(tags) as tags from ";
 
-if($type==0){
+if($type==RELATION){
 	$query_string.="relations ";
-}else if($type==1) {
+}else if($type==WAY) {
 	$query_string.="ways ";
-}else if($type==2) {
+}else if($type==NODE) {
 	$query_string.="nodes ";
 } else {
 	$ajxres=array();

+ 3 - 3
map/php/getGuideInfo.php

@@ -1,8 +1,8 @@
 <?php
+/** ziskani uzivatelskych informaci k danemu rozcestniku */
 require 'db.php';
-// Same as error_reporting(E_ALL);
 ini_set('display_errors', 1);
-ini_set('error_reporting', E_ALL);// Same as error_reporting(E_ALL);
+ini_set('error_reporting', E_ALL);
 
 if(isset($_GET['nid'])){
     $node_id = $_GET['nid'];
@@ -16,7 +16,7 @@ if(isset($_GET['nid'])){
 
 $arrayOfValues = array();
 
-$query_string = "SELECT id, tstamp, hi_user_id, type, note, image, date, osm_name FROM hicheck.checked_guideposts WHERE node='$node_id'";
+$query_string = "SELECT id, tstamp, hi_user_id, type, note, image, date, osm_name FROM hicheck.checked_guideposts WHERE node='$node_id' and hidden='0'";
 
 $query = pg_query($query_string);
 

+ 1 - 3
map/php/getList.php

@@ -1,9 +1,7 @@
 <?php
+/** ziskani listu relaci na zaklade bounding boxu okna prohlizece */
 require 'db.php';
 require 'func.php';
-// Same as error_reporting(E_ALL);
-ini_set('display_errors', 1);
-ini_set('error_reporting', E_ALL);// Same as error_reporting(E_ALL);
 
 if((isset($_GET['bbox'])) && (isset($_GET['type'])) && isset($_GET['bicycle'])){
     $type = $_GET['type'];

+ 7 - 3
map/php/getNote.php

@@ -1,4 +1,5 @@
 <?php
+/** ziskani informaci o uzivatelskem bodu */
 require 'db.php';
 require 'func.php';
 
@@ -25,11 +26,11 @@ $ways['type'] = 'FeatureCollection';
 
 
 if($type==USERNOTES){
-    $query_string = "SELECT id, tstamp, type, hi_user_id, note, date, osm_name, ST_AsGeoJSON(geom)
-from hicheck.notes where hicheck.notes.id = '$note_id'";
+    $query_string = "SELECT id, tstamp, type, hi_user_id, note, date, osm_name, ST_AsGeoJSON(geom), image
+from hicheck.notes where hicheck.notes.id = '$note_id' and hidden='0'";
 } else if($type==USERPARTS){
     $query_string = "SELECT id, tstamp, type, hi_user_id, note, date, osm_name, ST_AsGeoJSON(geom)
-from hicheck.parts where hicheck.parts.id = '$note_id'";
+from hicheck.parts where hicheck.parts.id = '$note_id' and hidden='0'";
 }
 
 
@@ -46,6 +47,9 @@ while($row = pg_fetch_assoc($data)){
     $prop['user']=$row['hi_user_id'];
     $prop['note']=$row['note'];
     $prop['type']=$row['type'];
+    if($type==USERNOTES){
+        $prop['image']=$row['image'];
+    }
     $prop['osm']=$row['osm_name'];
     $aux['type']='Feature';
     $aux['id']  = $row['id'];

+ 12 - 2
map/php/import.php

@@ -1,4 +1,5 @@
 <?php
+/** skript pro hromadny import dat */
 include 'db.php';
 
 const IMPORT_NOTES = 1;
@@ -16,24 +17,33 @@ function getNumberFromType($type){
         return 0;
     }
 }
+ /** TODO: funguje, ale osetrit */
+function getImageFromUrl($url, $user){
+    $parts = explode("/", $url);
+    $file = time()."_".$user;
+    copy($url, '../../uploads/'.$file."_".$parts[count($parts)-1]);
+    return $file."_".$parts[count($parts)-1];
+}
+
 $type = $_POST['type'];
 $data = json_decode($_POST['data'], true);
 $import_id = time().rand(10,99);
 $query_string = "";
 $cnt = count($data);
 if($type==IMPORT_NOTES) {
-    $query_string = "INSERT INTO hicheck.notes (hi_user_id, geom, note, date, type, osm_name, import_id) VALUES ";
+    $query_string = "INSERT INTO hicheck.notes (hi_user_id, geom, note, date, type, osm_name, import_id, image) VALUES ";
 
     for ($i = 0; $i < $cnt; $i++) {
         $user = $data[$i]['user'];
         $date = $data[$i]['date'];
         $note = $data[$i]['note'];
+        $image = getImageFromUrl($data[$i]['image'], $user);
         $type = getNumberFromType($data[$i]['type']);
         $osm = $data[$i]['user_is_osm'];
         $lng = $data[$i]['geometry']['coordinates'][0];
         $lat = $data[$i]['geometry']['coordinates'][1];
         $query_string .= " ('$user',ST_SetSRID(ST_MakePoint($lng,$lat), 4326),
-    '$note','$date','$type', '$osm', '$import_id')";
+    '$note','$date','$type', '$osm', '$import_id', '$image')";
         if ($i != $cnt - 1) {
             $query_string .= ", ";
         }

+ 4 - 2
map/php/saveGuideInfo.php

@@ -1,4 +1,5 @@
 <?php
+/** ulozeni informace o rozcestniku do databaze */
 include 'db.php';
 
 $name = pg_escape_string($_POST['name']);
@@ -7,9 +8,10 @@ $date = pg_escape_string($_POST['date']);
 $type = pg_escape_string($_POST['type']);
 $node = pg_escape_string($_POST['node']);
 $osm = pg_escape_string($_POST['osm']);
+$images = pg_escape_string($_POST['images']);
 var_dump($_POST);
-$sql = "INSERT INTO hicheck.checked_guideposts (hi_user_id, type, note, date, node, osm_name)
-     VALUES ('$name', '$type','$note', '$date', '$node', '$osm')";
+$sql = "INSERT INTO hicheck.checked_guideposts (hi_user_id, type, note, date, node, osm_name, image)
+     VALUES ('$name', '$type','$note', '$date', '$node', '$osm', '$images')";
 
 pg_query($db, $sql);
 

+ 6 - 3
map/php/saveNote.php

@@ -1,4 +1,6 @@
 <?php
+/** ulozeni uzivatelskeho bodu do databaze */
+
 include 'db.php';
 
 $lng = pg_escape_string($_POST['lng']);
@@ -8,10 +10,11 @@ $note = pg_escape_string($_POST['note']);
 $date = pg_escape_string($_POST['date']);
 $type = pg_escape_string($_POST['type']);
 $osm = pg_escape_string($_POST['osm']);
+$image = pg_escape_string($_POST['images']);
 $point = "POINT $lng $lat";
-$sql = "INSERT INTO hicheck.notes (hi_user_id, geom, note, date, type, osm_name)
-     VALUES ('$name', ST_SetSRID(ST_MakePoint($lng,$lat), 4326),'$note', '$date', '$type', '$osm')";
-
+$sql = "INSERT INTO hicheck.notes (hi_user_id, geom, note, date, type, osm_name, image)
+     VALUES ('$name', ST_SetSRID(ST_MakePoint($lng,$lat), 4326),'$note', '$date', '$type', '$osm', '$image')";
+var_dump($_POST);
 pg_query($db, $sql);
 
 exit(pg_last_error($db));

+ 2 - 0
map/php/savePart.php

@@ -1,4 +1,6 @@
 <?php
+/** ulozeni casti cesty do databaze */
+
 include 'db.php';
 ini_set('display_errors', 1);
 ini_set('error_reporting', E_ALL);

+ 46 - 25
map/php/uploadImage.php

@@ -1,45 +1,66 @@
 <?php
+/* zpracovani obrazku*/
 ini_set('display_errors', 1);
 ini_set('error_reporting', E_ALL);
-//$data = $_POST['data'];
-//$name = pg_escape_string($_POST['name']);
-//$file = time()."_".$name;
-//$info = getimagesize($data);
+$data = $_POST['data'];
+$name = pg_escape_string($_POST['name']);
+$file = time()."_".$name;
+$info = getimagesize($data);
 
 /** kontrola obrazku - velikost, typ*/
-/*if($info[0]*$info[1] > 5242880 || ($info['mime']!="image/jpeg" && $info['mime']!="image/png")){
-    echo 'ss';
-    exit(1);*/
-//}
-echo 'ss';
-/*$myfile = fopen("testfile.txt", "w") 
-fwrite($myfile,'lk');
-fclose($myfile);*/
-/*list($type, $data) = explode(';', $data);
-list(, $data) = explode(',', $data);
+if(($info['mime']!="image/jpeg" && $info['mime']!="image/png")){
+    exit();
+}
+
+list($type, $data) = explode(';', $data);
+list(, $data) = explode(',',$data);
 $data = base64_decode($data);
-file_put_contents("".$file.".png", $data);*/
-/** zmenseni *//*
+
+/** zmenseni */
 if($info['mime']=="image/png"){
+    file_put_contents("../../uploads/".$file.".png", $data);
     $width = $info[0];
     $height = $info[1];
-    $image = imagecreatefrompng($name);
+    $image = imagecreatefrompng("../../uploads/".$file.".png");
     if($width>=$height){
         if($width>1200){
             $newWidth = 1200;
             $newHeight= $height*($newWidth/$width);
+            $image_new = imagecreatetruecolor($newWidth, $newHeight);
+            imagecopyresampled($image_new, $image, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height);
         }
     } else {
         if($height>1200){
             $newHeight = 1200;
             $newWidth = $width*($newHeight/$height);
+            $image_new = imagecreatetruecolor($newWidth, $newHeight);
+            imagecopyresampled($image_new, $image, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height);
         }
     }
-    imagecopyresampled($image, $image, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height);
-    imagepng($image, "../../upload/".$file);
-
-
-}*/
-
-
-//exit($_POST['name']);
+    
+    imagepng($image, "../../uploads/".$file.".png");
+    exit($file.".png");
+} else if($info['mime']=="image/jpeg"){
+    file_put_contents("../../uploads/".$file.".jpg", $data);
+    $width = $info[0];
+    $height = $info[1];
+    $image = imagecreatefromjpeg("../../uploads/".$file.".jpg");
+    if($width>=$height){
+        if($width>1200){
+            $newWidth = 1200;
+            $newHeight= $height*($newWidth/$width);
+            $image_new = imagecreatetruecolor($newWidth, $newHeight);
+            imagecopyresampled($image_new, $image, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height);
+        }
+    } else {
+        if($height>1200){
+            $newHeight = 1200;
+            $newWidth = $width*($newHeight/$height);
+            $image_new = imagecreatetruecolor($newWidth, $newHeight);
+            imagecopyresampled($image_new, $image, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height);
+        }
+    }
+    
+    imagejpeg($image, "../../uploads/".$file.".jpg");
+    exit($file.".jpg");
+}

+ 3 - 2
sql_import/hicheck_db_checked_guideposts.sql

@@ -1,4 +1,4 @@
-
+/** vytvoreni tabulky pro ulozeni informace k rozcestniku */
 DROP TABLE IF EXISTS hicheck.checked_guideposts;
 
 DROP TABLE IF EXISTS checked_guideposts;
@@ -15,7 +15,8 @@ CREATE TABLE checked_guideposts (
   image text,
   osm_name int,
   import_id bigint,
-  date varchar(10)
+  date varchar(10),
+  hidden int default 0
 );
 
 ALTER TABLE ONLY checked_guideposts ADD CONSTRAINT pk_checked_guideposts PRIMARY KEY  (id);

+ 3 - 1
sql_import/hicheck_db_notes.sql

@@ -1,3 +1,4 @@
+/** vytvoreni tabulky pro ulozeni uzivatelske poznamky */
 
 DROP TABLE IF EXISTS hicheck.notes;
 
@@ -15,7 +16,8 @@ CREATE TABLE notes (
   type int,
   osm_name int,
   import_id bigint,
-  date varchar(10)
+  date varchar(10),
+  hidden int default 0
 );
 
 SELECT AddGeometryColumn('notes','geom',4326,'POINT',2);

+ 3 - 1
sql_import/hicheck_db_parts.sql

@@ -1,3 +1,4 @@
+/** vytvoreni tabulky pro ulozeni uzivatelem vyznacene trasy */
 
 DROP TABLE IF EXISTS hicheck.parts;
 
@@ -13,7 +14,8 @@ CREATE TABLE parts (
   type int,
   osm_name int,
   import_id bigint,
-  date varchar(10)
+  date varchar(10),
+  hidden int default 0
 );
 
 SELECT AddGeometryColumn('parts','geom',4326,'LINESTRING',2);

+ 1 - 0
sql_import/hicheck_db_stats.sql

@@ -1,3 +1,4 @@
+/** vytvoreni tabulky pro ulozeni statistik - zatim vyuzito castecne */
 
 DROP TABLE IF EXISTS hicheck.stats;
 

+ 18 - 0
sql_import/hicheck_db_superusers.sql

@@ -0,0 +1,18 @@
+/** vytvoreni tabulky pro ulozen uzvatelu s pravem skryvani uzivatelskych vstupu */
+
+DROP TABLE IF EXISTS hicheck.superuser;
+
+DROP TABLE IF EXISTS superuser;
+
+
+
+CREATE TABLE superuser (
+  id SERIAL,
+  tstamp TIMESTAMP default CURRENT_TIMESTAMP,
+  name varchar(30),
+  password varchar(600)
+);
+
+ALTER TABLE ONLY superuser ADD CONSTRAINT pk_superuser PRIMARY KEY (id);
+
+ALTER TABLE superuser SET SCHEMA hicheck;

+ 3 - 0
tables/css/stylesheet.css

@@ -1,3 +1,6 @@
+/** CSS soubor k zobrazeni tabulkove casti */
+
+
 body {
   background-color: #fff;
   font-family: "PT Sans", helvetica, arial, sans-serif;

+ 2 - 1
tables/php/db.php

@@ -1,3 +1,4 @@
 <?php
-  $db = pg_connect("host=localhost dbname=xsvana00 user=xsvana00 password=osm");
+    require_once dirname(__FILE__).'/../../db_conf.php';
+    $db = pg_connect("host=".SERVER." dbname=".DATABASE." user=".USERNAME." password=".PASSWORD);
 ?>

+ 58 - 7
tables/php/funcTables.php

@@ -1,8 +1,12 @@
 <?php
-
+/** soubor s funkcemi, ktere vyuziva tabulkova cast */
 const ALL = 0;
 const WARNING = 1;
 
+
+/**
+ * konstanta, jenz se pridava do sql dotazu - vycleneni cyklisitckych tras bez barvy
+ */
 const NOT_CYCLO = "relations.tags->'route'!='bicycle' and (
     not exist(relations.tags,'kct_red') or 
     not exist(relations.tags,'kct_blue') or 
@@ -10,10 +14,12 @@ const NOT_CYCLO = "relations.tags->'route'!='bicycle' and (
     not exist(relations.tags,'kct_greeen') or 
     not exist(relations.tags,'kct_none'))";
 
-function getCount(){
-    $result = array();
 
-    
+/**
+ * funkce pro ziskani statistik z OSM databaze
+ * @return array|resource
+ */
+function getCount(){
     $query = "SELECT ";
     $query .="(SELECT COUNT(*) FROM relations where ".NOT_CYCLO.") AS total,";
 	$query .="(SELECT COUNT(*) FROM relations where ".NOT_CYCLO." and (not exist(relations.tags,'network')
@@ -29,6 +35,10 @@ function getCount(){
     return $res;
 }
 
+/**
+ * funkce pro spocitani konkretnich chyb v relacich
+ * @return array
+ */
 function getCountErrors(){
     $ret = array();
     $ret['count'] = 0;
@@ -42,13 +52,11 @@ function getCountErrors(){
     $ret['err_network'] = 0;
     $query = "SELECT hstore_to_json(tags) as tags FROM relations where ".NOT_CYCLO;
     $result = pg_query($query);
-    $isWrong = false;
     while ($row = pg_fetch_assoc($result)){
         $isWrong = false;
         $tags = json_decode($row['tags'], true);
         $kct = getKctTag($tags);
         $kctKey = count($kct) > 0 ? $kct[0] : "";
-        $checked = getCheckedValues($kctKey);
         $incorrect = checkTagsValidValues($tags, $kctKey);
         $incorrect = getWrong($incorrect, $kctKey);
         foreach ($incorrect as $key => $value) {
@@ -100,6 +108,10 @@ function getCountErrors(){
     return $ret;
 }
 
+/**
+ * funkce, ktera ziska statistiky ktere se pravidelne zadavaji do databaze pro vykresleni grafu
+ * @return array
+ */
 function getStatsForGraphs(){
     $result = pg_query("SELECT date, relations_missing, relations_wrong FROM hicheck.stats ORDER BY date DESC LIMIT 31");
     $ret = array();
@@ -113,6 +125,11 @@ function getStatsForGraphs(){
     return $ret;
 }
 
+/**
+ * funkce pripravi datum pro graf, take doplni chybejici dny
+ * @param $data
+ * @return array
+ */
 function prepareGraphs($data){
     $cnt = count($data);
     if($cnt<31){
@@ -127,6 +144,13 @@ function prepareGraphs($data){
     return array_reverse($data);
 }
 
+/**
+ * funkce pro ziskani procentualni hodnoty
+ * @param $arr
+ * @param $total
+ * @param $percent
+ * @return array
+ */
 function getPercentageFromArray($arr, $total, $percent){
     $res = array();
     foreach ($arr as $i => $value) {
@@ -143,17 +167,31 @@ function getPercentageFromArray($arr, $total, $percent){
     return $res;
 }
 
+/**
+ * @param $total
+ * @param $part
+ * @return float
+ */
 function getPercent($total, $part){
     return $total!=0 ? round((100/$total)*$part, 2) : 0.00;
 }
 
+/**
+ * @param $kctKey
+ * @return array
+ */
 function getCheckedValues($kctKey)
 {
-
     return array('destinations', 'complete',  'osmc:symbol', $kctKey, 'network','route');
 }
 
 
+/**
+ * zjisteni chyb relace
+ * @param $errNum
+ * @param $kctKey
+ * @return array
+ */
 function getWrong($errNum, $kctKey)
 {
     $red = array();
@@ -189,6 +227,12 @@ function getWrong($errNum, $kctKey)
 
 }
 
+/**
+ * zjisteni chybejicich hodnot v relaci
+ * @param $tags
+ * @param $kctKey
+ * @return array
+ */
 function getMissing($tags, $kctKey)
 {
     $orange = array();
@@ -202,6 +246,13 @@ function getMissing($tags, $kctKey)
     return $orange;
 }
 
+/**
+ * pomocna funkce pro zapsani tagu jako td element
+ * @param $tag
+ * @param $tags
+ * @param $kctKey
+ * @return string
+ */
 function writeTag($tag, $tags, $kctKey)
 {
     if (array_key_exists($tag, $tags)) {

+ 4 - 8
tables/php/graph.php

@@ -1,22 +1,18 @@
 <?php
-//Include the code
+/* skript pro vykresleni grafu pomoci knihony phplot*/
+
 include 'db.php';
 include 'funcTables.php';
 require_once 'phplot/phplot.php';
 
-//Define the object
 $plot = new PHPlot(1200, 400);
 
-//Define some data
+
 $data = getStatsForGraphs();
 $data = prepareGraphs($data);
 $plot->SetDataValues($data);
 
-//Turn off X axis ticks and labels because they get in the way:
-$plot->SetXTickLabelPos('none');
-$plot->SetXTickPos('none');
-
 $plot->SetLegend(array("%: relace s chybejicimi tagy", "%: relace s chybami"));
 $plot->SetLegendPosition(0.0,0.0, 'image', 0.2,0.05);
-//Draw it
+
 $plot->DrawGraph();

+ 2 - 1
tables/php/saveStats.php

@@ -1,6 +1,7 @@
 <?php
+/* skript pro ulozeni pravidelnych statistik */
 ini_set('display_errors', 1);
-ini_set('error_reporting', E_ALL);// Same as error_reporting(E_ALL);
+ini_set('error_reporting', E_ALL);
 require 'db.php';
 require 'funcTables.php';
 require dirname(__FILE__).'/../../map/php/func.php';

+ 4 - 2
tables/stats.php

@@ -1,4 +1,7 @@
-<?php $statistics = getCount(); ?>
+
+<?php
+/** PHP skript pro generovani statistik  */
+$statistics = getCount(); ?>
 <?php $percentage = getPercentageFromArray($statistics, $statistics['total'], true); ?>
 <?php $error_stats = getCountErrors(); ?>
 <?php $error_perc = getPercentageFromArray($error_stats, $statistics['total'], true); ?>
@@ -24,7 +27,6 @@
     <tr><td>typ cesty v rozporu s ostatnimi u tagu osmc:symbol, kct_* nebo route: <td><a href="index.php?pg=table&area=all&specific=err_type"><?php echo $error_stats['err_type']; ?></a><td><?php echo $error_perc['err_type'];?>
     <tr><td>barva cesty v rozporu u osmc:symbol a kct_*: <td><a href="index.php?pg=table&area=all&specific=err_color"><?php echo $error_stats['err_color']; ?></a><td><?php echo $error_perc['err_color'];?>
 </table>
-<?php getCountErrors(); ?>
 </div>
 
 <div class="graphs">

+ 5 - 5
tables/table.php

@@ -1,4 +1,5 @@
 <?php
+/** PHP skript pro generovani tabulkove reprezentace relaci */
 if(isset($_GET['specific'])){
     $specific = $_GET['specific'];
 } else {
@@ -46,7 +47,7 @@ $result = pg_query($db, $query);
                 $incorrect = checkTagsValidValues($tags, $kctKey);
                 $red = getWrong($incorrect, $kctKey);
 
-                
+                    /* filtrovani */
                 if( ($filter=='w_network' && !in_array('network', $red)) 
                 || ($filter=='w_complete' && !in_array('complete', $red)) 
                 || ($filter=='w_osmc:symbol' && !in_array('osmc:symbol', $red)) 
@@ -55,7 +56,7 @@ $result = pg_query($db, $query);
                     continue;
                  }
                     
-                 
+                 /* vyhledavani chyb */
                 
                 $orange = getMissing($tags, $kctKey);
 
@@ -110,15 +111,14 @@ $result = pg_query($db, $query);
                     if($filter=='err_color'){
                             continue;
                     }
-                } 
-
-
+                }
                 $orange = array_diff($orange, $red);
                 ?>
 
         <tr>
             <td><?php echo $row['id']; ?></td>
             <?php
+            /* vyber spravneho stylu na zaklade spravnosti prvku */
             $rid = $row['id'];
                 foreach($checked as $key){
                     if(array_key_exists($key, $tags) && $key==$kctKey){