diff --git a/CHANGELOG b/CHANGELOG index c2dc6c2..70123a4 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -11,6 +11,8 @@ * Search in Description of Polygons * Change Sani to Rettungsdienst * Display GateCounting Boxes in a line not a collumn +* Create Aliases for Camera Count +* Filter Fight under level ## 1.2.9 ### New Features diff --git a/Lora-Map/Model/Settings.cs b/Lora-Map/Model/Settings.cs index ed88be4..b448814 100644 --- a/Lora-Map/Model/Settings.cs +++ b/Lora-Map/Model/Settings.cs @@ -12,7 +12,7 @@ namespace Fraunhofer.Fit.IoT.LoraMap.Model { public Double Startloclat { get; private set; } public Double Startloclon { get; private set; } public Dictionary>>> Grid { get; private set; } - public Dictionary>> FightDedection { get; private set; } + public Dictionary FightDedection { get; private set; } public Dictionary DensityArea { get; private set; } public Settings() => this.ParseJson(); @@ -39,9 +39,11 @@ namespace Fraunhofer.Fit.IoT.LoraMap.Model { } } if(json.ContainsKey("FightDedection") && json["FightDedection"].IsObject) { - Dictionary>> fight = new Dictionary>>(); + Dictionary fights = new Dictionary(); foreach (KeyValuePair entry in json["FightDedection"]) { - List> poly = new List>(); + Fight fight = new Fight { + Polygon = new List>() + }; if(entry.Value.ContainsKey("Poly") && entry.Value["Poly"].IsArray) { foreach (JsonData coord in entry.Value["Poly"]) { List coords = new List(); @@ -49,18 +51,25 @@ namespace Fraunhofer.Fit.IoT.LoraMap.Model { coords.Add((Double)coord["Lat"]); coords.Add((Double)coord["Lon"]); } - poly.Add(coords); + fight.Polygon.Add(coords); } } - fight.Add(entry.Key, poly); + if (entry.Value.ContainsKey("Level") && (entry.Value["Level"].IsDouble)) { + fight.Level = (Double)entry.Value["Level"]; + } + if (entry.Value.ContainsKey("Alias") && entry.Value["Alias"].IsString) { + fight.Alias = (String)entry.Value["Alias"]; + } + fights.Add(entry.Key, fight); } - this.FightDedection = fight; + this.FightDedection = fights; } if (json.ContainsKey("CrwodDensity") && json["CrwodDensity"].IsObject) { Dictionary densitys = new Dictionary(); foreach (KeyValuePair entry in json["CrwodDensity"]) { - Density density = new Density(); - density.Polygon = new List>(); + Density density = new Density { + Polygon = new List>() + }; if (entry.Value.ContainsKey("Poly") && entry.Value["Poly"].IsArray) { foreach (JsonData coord in entry.Value["Poly"]) { List coords = new List(); @@ -74,6 +83,9 @@ namespace Fraunhofer.Fit.IoT.LoraMap.Model { if(entry.Value.ContainsKey("Count") && (entry.Value["Count"].IsInt || entry.Value["Count"].IsDouble)) { density.Maximum = (Int32)entry.Value["Count"]; } + if(entry.Value.ContainsKey("Alias") && entry.Value["Alias"].IsString) { + density.Alias = (String)entry.Value["Alias"]; + } densitys.Add(entry.Key, density); } this.DensityArea = densitys; @@ -83,7 +95,11 @@ namespace Fraunhofer.Fit.IoT.LoraMap.Model { } private void GenerateGrid() { - if(this.Startloclat == 0 || this.Startloclon == 0 || this.gridradius == 0) { + this.Grid = new Dictionary>>> { + { "Major", new List>>() }, + { "Minor", new List>>() } + }; + if (this.Startloclat == 0 || this.Startloclon == 0 || this.gridradius == 0) { return; } MilitaryGridReferenceSystem start = new Coordinate(this.Startloclat, this.Startloclon).MGRS; @@ -92,10 +108,6 @@ namespace Fraunhofer.Fit.IoT.LoraMap.Model { Double bottom = start.Northing - this.gridradius - (start.Northing - this.gridradius) % 100; Double right = start.Easting + this.gridradius + (100 - (start.Easting + this.gridradius) % 100); Double top = start.Northing + this.gridradius + (100 - (start.Northing + this.gridradius) % 100); - this.Grid = new Dictionary>>> { - { "Major", new List>>() }, - { "Minor", new List>>() } - }; for (Double i = left; i <= right; i += 50) { Coordinate TopLeft = MilitaryGridReferenceSystem.MGRStoLatLong(new MilitaryGridReferenceSystem(start.LatZone, start.LongZone, start.Digraph, i, top)); Coordinate BottomLeft = MilitaryGridReferenceSystem.MGRStoLatLong(new MilitaryGridReferenceSystem(start.LatZone, start.LongZone, start.Digraph, i, bottom)); @@ -165,6 +177,13 @@ namespace Fraunhofer.Fit.IoT.LoraMap.Model { public struct Density { public List> Polygon { get; set; } public Int32 Maximum { get; set; } + public String Alias { get; set; } + } + + public struct Fight { + public List> Polygon { get; set; } + public Double Level { get; set; } + public String Alias { get; set; } } } } diff --git a/Lora-Map/resources/admin/js/menu.js b/Lora-Map/resources/admin/js/menu.js index 1a61b29..434ab2c 100644 --- a/Lora-Map/resources/admin/js/menu.js +++ b/Lora-Map/resources/admin/js/menu.js @@ -372,6 +372,9 @@ var Settings = { if (typeof jsonsettings.CrwodDensity === "undefined") { jsonsettings.CrwodDensity = []; } + if (typeof jsonsettings.Counting === "undefined") { + jsonsettings.Counting = []; + } var html = "
Einstellungen
"; html += "
Startpunkt: Lat, Lon
"; html += "
CellId's für DWD-Wetterwarnungen: (Trennen durch \";\", cap_warncellids_csv)
"; @@ -403,7 +406,7 @@ var Settings = { var coord = coords[j].split(";"); polyjson[j] = { "Lat": this._filterFloat(coord[0]), "Lon": this._filterFloat(coord[1]) }; } - fightjson[id] = { "Poly": polyjson }; + fightjson[id] = { "Poly": polyjson, "Alias": rowsf[i].children[2].innerText, "Level": this._filterFloat(rowsf[i].children[3].innerText) }; } ret.FightDedection = fightjson; @@ -425,7 +428,8 @@ var Settings = { } crowdjson[id] = { "Poly": polyjson, - "Count": num + "Count": num, + "Alias": rowsc[i].children[3].innerText }; } ret.CrwodDensity = crowdjson; @@ -442,11 +446,11 @@ var Settings = { }; savesettings.open("POST", "/admin/set_json_settings", true); savesettings.send(JSON.stringify(ret)); - }, + }, _renderFightDedection: function (json) { var ret = ""; ret += ""; - ret += ""; + ret += ""; ret += ""; for (var id in json) { var coords = []; @@ -456,18 +460,20 @@ var Settings = { ret += "" + "" + "" + + "" + + "" + "" + ""; } ret += ""; - ret += ""; + ret += ""; ret += "
IDKoordinaten
IDKoordinatenAliasAlertlimit
" + id + "" + coords.join("
") + "
" + json[id].Alias + "" + json[id].Level + "
"; return ret; }, _renderCrowdDensity: function (json) { var ret = ""; ret += ""; - ret += ""; + ret += ""; ret += ""; for (var id in json) { var coords = []; @@ -478,11 +484,12 @@ var Settings = { "" + "" + "" + + "" + "" + ""; } ret += ""; - ret += ""; + ret += ""; ret += "
IDPersonenanzahlKoordinaten
IDPersonenanzahlKoordinatenAlias
" + id + "" + json[id].Count + "" + coords.join("
") + "
" + json[id].Alias + "
"; return ret; }, @@ -490,6 +497,8 @@ var Settings = { var newrow = document.createElement("tr"); newrow.innerHTML = ""; newrow.innerHTML += ""; + newrow.innerHTML = ""; + newrow.innerHTML = ""; newrow.innerHTML += " "; document.getElementById("fighttable").children[1].appendChild(newrow); }, @@ -498,6 +507,7 @@ var Settings = { newrow.innerHTML = ""; newrow.innerHTML += ""; newrow.innerHTML += ""; + newrow.innerHTML = ""; newrow.innerHTML += " "; document.getElementById("crowdtable").children[1].appendChild(newrow); }, @@ -519,12 +529,18 @@ var Settings = { break; } } + if (isNaN(this._filterFloat(el.children[3].children[0].value))) { + alert("Die Eingabe des Alertlevel erwartet einen Float"); + return; + } if (fail) { alert("Die Eingabe der Koordinaten ist nicht Korrekt!\n\nBeispiel:\n50.7;7.8\n50.6;7.9"); return; } el.innerHTML = "" + el.children[0].children[0].value + "" + "" + coords + "" + + "" + el.children[2].children[0].value + "" + + "" + this._filterFloat(el.children[3].children[0].value) + "" + " "; }, SaveRowdensity: function (el) { @@ -553,6 +569,7 @@ var Settings = { el.innerHTML = "" + el.children[0].children[0].value + "" + "" + el.children[1].children[0].value + "" + "" + coords + "" + + "" + el.children[3].children[0].value + "" + " "; }, Delete: function (el) { @@ -564,12 +581,15 @@ var Settings = { EditFight: function (el) { el.innerHTML = "" + "" + + "" + + "" + " "; }, EditDensity: function (el) { el.innerHTML = "" + "" + "" + + "" + " "; }, _filterFloat: function (value) { @@ -586,7 +606,6 @@ var ExImport = { html += "
names.json (Namen und Icons)
"; html += "
geo.json (Layer on the MAP) Kml Konverter
"; html += "
settings.json (Settings of the Map)
"; - html += "
"; document.getElementById("content").innerHTML = html; document.getElementById("ex_names").value = jsonnames; diff --git a/Lora-Map/resources/js/functions.js b/Lora-Map/resources/js/functions.js index a43bc1a..af4a7f5 100644 --- a/Lora-Map/resources/js/functions.js +++ b/Lora-Map/resources/js/functions.js @@ -44,6 +44,7 @@ MapObject._ParseAJAXLayers(json["getlayer"]); MapObject._ParseAJAXGeo(json["getgeo"]); MapObject._ParseAJAXSettings(json["startup"]); + OverlayObject._ParseAJAXSettings(json["startup"]); } }; getonce.open("GET", "/getonce", true); diff --git a/Lora-Map/resources/js/map.js b/Lora-Map/resources/js/map.js index 030c671..700d8f1 100644 --- a/Lora-Map/resources/js/map.js +++ b/Lora-Map/resources/js/map.js @@ -67,26 +67,30 @@ }, _GenerateFightBoxes: function (fightdedection) { for (var cameraid in fightdedection) { - this._FightDedection[cameraid] = L.polygon(fightdedection[cameraid], { color: 'black', weight: 1 }).addTo(this.Map); - this._FightDedection[cameraid].bindPopup("Fightdedection für Kamera: " + cameraid); + this._FightDedection[cameraid] = {}; + this._FightDedection[cameraid].Box = L.polygon(fightdedection[cameraid].Polygon, { color: 'black', weight: 1 }).addTo(this.Map); + this._FightDedection[cameraid].Box.bindPopup("Fightdedection " + fightdedection[cameraid].Alias); + this._FightDedection[cameraid].Level = fightdedection[cameraid].Level; } }, _ParseAJAXFightDedection: function (json) { for (var cameraid in json) { if (this._FightDedection.hasOwnProperty(cameraid)) { var fight = json[cameraid]; - var box = this._FightDedection[cameraid]; + var box = this._FightDedection[cameraid].Box; var diff = FunctionsObject.TimeCalculation(fight["LastUpdate"], "diffraw"); - if (diff <= 10 && box.options.color === "black") { - box.setStyle({ color: 'rgb(' + fight["FightProbability"] * 255 + ',0,0)' }); - } else if (diff <= 10 && box.options.color !== "black") { - if (diff % 2 === 0) { + if (fight["FightProbability"] > this._FightDedection[cameraid].Level) { + if (diff <= 10 && box.options.color === "black") { box.setStyle({ color: 'rgb(' + fight["FightProbability"] * 255 + ',0,0)' }); - } else { - box.setStyle({ color: 'green' }); + } else if (diff <= 10 && box.options.color !== "black") { + if (diff % 2 === 0) { + box.setStyle({ color: 'rgb(' + fight["FightProbability"] * 255 + ',0,0)' }); + } else { + box.setStyle({ color: 'green' }); + } + } else if (diff > 10 && box.options.color !== "black") { + box.setStyle({ color: 'black' }); } - } else if (diff > 10 && box.options.color !== "black") { - box.setStyle({ color: 'black' }); } } } diff --git a/Lora-Map/resources/js/overlays.js b/Lora-Map/resources/js/overlays.js index f3eceae..34ae1fe 100644 --- a/Lora-Map/resources/js/overlays.js +++ b/Lora-Map/resources/js/overlays.js @@ -1,4 +1,5 @@ var OverlayObject = { + _DensitySettings: {}, Start: function () { return this; }, @@ -22,14 +23,19 @@ var densystext = ""; for (var densyid in cameradensy) { if (cameradensy.hasOwnProperty(densyid)) { - var densy = cameradensy[densyid]; - var densytext = "
"; - densytext += "" + densyid + ""; - densytext += "" + densy["DensityCount"] + ""; - densytext += "
"; - densystext += densytext; + if (this._DensitySettings.hasOwnProperty(densyid)) { + var densy = cameradensy[densyid]; + var densytext = "
"; + densytext += "" + this._DensitySettings[densyid].Alias + ""; + densytext += "" + densy["DensityCount"] + ""; + densytext += "
"; + densystext += densytext; + } } } document.getElementById("crwoddensy").innerHTML = densystext; + }, + _ParseAJAXSettings: function (json) { + this._DensitySettings = json["DensityArea"]; } }.Start(); \ No newline at end of file