Skip to content

Commit 6b1fca9

Browse files
committed
Create Aliases for Camera Count
Filter Fight under level
1 parent 286f931 commit 6b1fca9

File tree

6 files changed

+89
-38
lines changed

6 files changed

+89
-38
lines changed

CHANGELOG

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
* Search in Description of Polygons
1212
* Change Sani to Rettungsdienst
1313
* Display GateCounting Boxes in a line not a collumn
14+
* Create Aliases for Camera Count
15+
* Filter Fight under level
1416

1517
## 1.2.9
1618
### New Features

Lora-Map/Model/Settings.cs

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class Settings {
1212
public Double Startloclat { get; private set; }
1313
public Double Startloclon { get; private set; }
1414
public Dictionary<String, List<Dictionary<String, List<Double>>>> Grid { get; private set; }
15-
public Dictionary<String, List<List<Double>>> FightDedection { get; private set; }
15+
public Dictionary<String, Fight> FightDedection { get; private set; }
1616
public Dictionary<String, Density> DensityArea { get; private set; }
1717

1818
public Settings() => this.ParseJson();
@@ -39,28 +39,37 @@ private void ParseJson() {
3939
}
4040
}
4141
if(json.ContainsKey("FightDedection") && json["FightDedection"].IsObject) {
42-
Dictionary<String, List<List<Double>>> fight = new Dictionary<String, List<List<Double>>>();
42+
Dictionary<String, Fight> fights = new Dictionary<String, Fight>();
4343
foreach (KeyValuePair<String, JsonData> entry in json["FightDedection"]) {
44-
List<List<Double>> poly = new List<List<Double>>();
44+
Fight fight = new Fight {
45+
Polygon = new List<List<Double>>()
46+
};
4547
if(entry.Value.ContainsKey("Poly") && entry.Value["Poly"].IsArray) {
4648
foreach (JsonData coord in entry.Value["Poly"]) {
4749
List<Double> coords = new List<Double>();
4850
if (coord.ContainsKey("Lat") && coord["Lat"].IsDouble && coord.ContainsKey("Lon") && coord["Lon"].IsDouble) {
4951
coords.Add((Double)coord["Lat"]);
5052
coords.Add((Double)coord["Lon"]);
5153
}
52-
poly.Add(coords);
54+
fight.Polygon.Add(coords);
5355
}
5456
}
55-
fight.Add(entry.Key, poly);
57+
if (entry.Value.ContainsKey("Level") && (entry.Value["Level"].IsDouble)) {
58+
fight.Level = (Double)entry.Value["Level"];
59+
}
60+
if (entry.Value.ContainsKey("Alias") && entry.Value["Alias"].IsString) {
61+
fight.Alias = (String)entry.Value["Alias"];
62+
}
63+
fights.Add(entry.Key, fight);
5664
}
57-
this.FightDedection = fight;
65+
this.FightDedection = fights;
5866
}
5967
if (json.ContainsKey("CrwodDensity") && json["CrwodDensity"].IsObject) {
6068
Dictionary<String, Density> densitys = new Dictionary<String, Density>();
6169
foreach (KeyValuePair<String, JsonData> entry in json["CrwodDensity"]) {
62-
Density density = new Density();
63-
density.Polygon = new List<List<Double>>();
70+
Density density = new Density {
71+
Polygon = new List<List<Double>>()
72+
};
6473
if (entry.Value.ContainsKey("Poly") && entry.Value["Poly"].IsArray) {
6574
foreach (JsonData coord in entry.Value["Poly"]) {
6675
List<Double> coords = new List<Double>();
@@ -74,6 +83,9 @@ private void ParseJson() {
7483
if(entry.Value.ContainsKey("Count") && (entry.Value["Count"].IsInt || entry.Value["Count"].IsDouble)) {
7584
density.Maximum = (Int32)entry.Value["Count"];
7685
}
86+
if(entry.Value.ContainsKey("Alias") && entry.Value["Alias"].IsString) {
87+
density.Alias = (String)entry.Value["Alias"];
88+
}
7789
densitys.Add(entry.Key, density);
7890
}
7991
this.DensityArea = densitys;
@@ -83,7 +95,11 @@ private void ParseJson() {
8395
}
8496

8597
private void GenerateGrid() {
86-
if(this.Startloclat == 0 || this.Startloclon == 0 || this.gridradius == 0) {
98+
this.Grid = new Dictionary<String, List<Dictionary<String, List<Double>>>> {
99+
{ "Major", new List<Dictionary<String, List<Double>>>() },
100+
{ "Minor", new List<Dictionary<String, List<Double>>>() }
101+
};
102+
if (this.Startloclat == 0 || this.Startloclon == 0 || this.gridradius == 0) {
87103
return;
88104
}
89105
MilitaryGridReferenceSystem start = new Coordinate(this.Startloclat, this.Startloclon).MGRS;
@@ -92,10 +108,6 @@ private void GenerateGrid() {
92108
Double bottom = start.Northing - this.gridradius - (start.Northing - this.gridradius) % 100;
93109
Double right = start.Easting + this.gridradius + (100 - (start.Easting + this.gridradius) % 100);
94110
Double top = start.Northing + this.gridradius + (100 - (start.Northing + this.gridradius) % 100);
95-
this.Grid = new Dictionary<String, List<Dictionary<String, List<Double>>>> {
96-
{ "Major", new List<Dictionary<String, List<Double>>>() },
97-
{ "Minor", new List<Dictionary<String, List<Double>>>() }
98-
};
99111
for (Double i = left; i <= right; i += 50) {
100112
Coordinate TopLeft = MilitaryGridReferenceSystem.MGRStoLatLong(new MilitaryGridReferenceSystem(start.LatZone, start.LongZone, start.Digraph, i, top));
101113
Coordinate BottomLeft = MilitaryGridReferenceSystem.MGRStoLatLong(new MilitaryGridReferenceSystem(start.LatZone, start.LongZone, start.Digraph, i, bottom));
@@ -165,6 +177,13 @@ private void GenerateGrid() {
165177
public struct Density {
166178
public List<List<Double>> Polygon { get; set; }
167179
public Int32 Maximum { get; set; }
180+
public String Alias { get; set; }
181+
}
182+
183+
public struct Fight {
184+
public List<List<Double>> Polygon { get; set; }
185+
public Double Level { get; set; }
186+
public String Alias { get; set; }
168187
}
169188
}
170189
}

Lora-Map/resources/admin/js/menu.js

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,9 @@ var Settings = {
372372
if (typeof jsonsettings.CrwodDensity === "undefined") {
373373
jsonsettings.CrwodDensity = [];
374374
}
375+
if (typeof jsonsettings.Counting === "undefined") {
376+
jsonsettings.Counting = [];
377+
}
375378
var html = "<div id='settingseditor'><div class='title'>Einstellungen</div>";
376379
html += "<div class='startloc'>Startpunkt: <input value='" + jsonsettings.StartPos.lat + "' id='startlat'> Lat, <input value='" + jsonsettings.StartPos.lon + "' id='startlon'> Lon</div>";
377380
html += "<div class='wetterwarnings'>CellId's für DWD-Wetterwarnungen: <input value='" + jsonsettings.CellIds.join(";") + "' id='wetterids'> (Trennen durch \";\", <a href='https://www.dwd.de/DE/leistungen/opendata/help/warnungen/cap_warncellids_csv.html'>cap_warncellids_csv</a>)</div>";
@@ -403,7 +406,7 @@ var Settings = {
403406
var coord = coords[j].split(";");
404407
polyjson[j] = { "Lat": this._filterFloat(coord[0]), "Lon": this._filterFloat(coord[1]) };
405408
}
406-
fightjson[id] = { "Poly": polyjson };
409+
fightjson[id] = { "Poly": polyjson, "Alias": rowsf[i].children[2].innerText, "Level": this._filterFloat(rowsf[i].children[3].innerText) };
407410
}
408411
ret.FightDedection = fightjson;
409412

@@ -425,7 +428,8 @@ var Settings = {
425428
}
426429
crowdjson[id] = {
427430
"Poly": polyjson,
428-
"Count": num
431+
"Count": num,
432+
"Alias": rowsc[i].children[3].innerText
429433
};
430434
}
431435
ret.CrwodDensity = crowdjson;
@@ -442,11 +446,11 @@ var Settings = {
442446
};
443447
savesettings.open("POST", "/admin/set_json_settings", true);
444448
savesettings.send(JSON.stringify(ret));
445-
},
449+
},
446450
_renderFightDedection: function (json) {
447451
var ret = "";
448452
ret += "<table id='fighttable' class='settingstable'>";
449-
ret += "<thead><tr><th width='150'>ID</th><th width='250'>Koordinaten</th><th width='50'></th></tr></thead>";
453+
ret += "<thead><tr><th width='150'>ID</th><th width='250'>Koordinaten</th><th width='150'>Alias</th><th width='150'>Alertlimit</th><th width='50'></th></tr></thead>";
450454
ret += "<tbody>";
451455
for (var id in json) {
452456
var coords = [];
@@ -456,18 +460,20 @@ var Settings = {
456460
ret += "<tr>" +
457461
"<td>" + id + "</td>" +
458462
"<td>" + coords.join("<br>") + "</td>" +
463+
"<td>" + json[id].Alias + "</td>" +
464+
"<td>" + json[id].Level + "</td>" +
459465
"<td><img src='../icons/general/edit.png' onclick='Settings.EditFight(this.parentNode.parentNode)' class='pointer'> <img src='../icons/general/remove.png' onclick='Settings.Delete(this.parentNode.parentNode)' class='pointer'></td>" +
460466
"</tr>";
461467
}
462468
ret += "</tbody>";
463-
ret += "<tfoot><tr><td></td><td></td><td><img src='../icons/general/add.png' onclick='Settings.AddFight()' class='pointer'></td></tr></tfoot>";
469+
ret += "<tfoot><tr><td></td><td></td><td></td><td></td><td><img src='../icons/general/add.png' onclick='Settings.AddFight()' class='pointer'></td></tr></tfoot>";
464470
ret += "</table>";
465471
return ret;
466472
},
467473
_renderCrowdDensity: function (json) {
468474
var ret = "";
469475
ret += "<table id='crowdtable' class='settingstable'>";
470-
ret += "<thead><tr><th width='150'>ID</th><th width='200'>Personenanzahl</th><th width='250'>Koordinaten</th><th width='50'></th></tr></thead>";
476+
ret += "<thead><tr><th width='150'>ID</th><th width='200'>Personenanzahl</th><th width='250'>Koordinaten</th><th width='150'>Alias</th><th width='50'></th></tr></thead>";
471477
ret += "<tbody>";
472478
for (var id in json) {
473479
var coords = [];
@@ -478,18 +484,21 @@ var Settings = {
478484
"<td>" + id + "</td>" +
479485
"<td>" + json[id].Count + "</td>" +
480486
"<td>" + coords.join("<br>") + "</td>" +
487+
"<td>" + json[id].Alias + "</td>" +
481488
"<td><img src='../icons/general/edit.png' onclick='Settings.EditDensity(this.parentNode.parentNode)' class='pointer'> <img src='../icons/general/remove.png' onclick='Settings.Delete(this.parentNode.parentNode)' class='pointer'></td>" +
482489
"</tr>";
483490
}
484491
ret += "</tbody>";
485-
ret += "<tfoot><tr><td></td><td></td><td></td><td><img src='../icons/general/add.png' onclick='Settings.AddDensity()' class='pointer'></td></tr></tfoot>";
492+
ret += "<tfoot><tr><td></td><td></td><td></td><td></td><td><img src='../icons/general/add.png' onclick='Settings.AddDensity()' class='pointer'></td></tr></tfoot>";
486493
ret += "</table>";
487494
return ret;
488495
},
489496
AddFight: function () {
490497
var newrow = document.createElement("tr");
491498
newrow.innerHTML = "<td><input style='width: 145px;'/></td>";
492499
newrow.innerHTML += "<td><textarea style='width: 240px;height: 60px;'></textarea></td>";
500+
newrow.innerHTML = "<td><input style='width: 145px;'/></td>";
501+
newrow.innerHTML = "<td><input style='width: 145px;'/></td>";
493502
newrow.innerHTML += "<td><img src='../icons/general/save.png' onclick='Settings.SaveRowfight(this.parentNode.parentNode)' class='pointer'> <img src='../icons/general/remove.png' onclick='Settings.Abort(this.parentNode.parentNode)' class='pointer'></td>";
494503
document.getElementById("fighttable").children[1].appendChild(newrow);
495504
},
@@ -498,6 +507,7 @@ var Settings = {
498507
newrow.innerHTML = "<td><input style='width: 145px;'/></td>";
499508
newrow.innerHTML += "<td><input style='width: 195px;'/></td>";
500509
newrow.innerHTML += "<td><textarea style='width: 240px;height: 60px;'></textarea></td>";
510+
newrow.innerHTML = "<td><input style='width: 145px;'/></td>";
501511
newrow.innerHTML += "<td><img src='../icons/general/save.png' onclick='Settings.SaveRowdensity(this.parentNode.parentNode)' class='pointer'> <img src='../icons/general/remove.png' onclick='Settings.Abort(this.parentNode.parentNode)' class='pointer'></td>";
502512
document.getElementById("crowdtable").children[1].appendChild(newrow);
503513
},
@@ -519,12 +529,18 @@ var Settings = {
519529
break;
520530
}
521531
}
532+
if (isNaN(this._filterFloat(el.children[3].children[0].value))) {
533+
alert("Die Eingabe des Alertlevel erwartet einen Float");
534+
return;
535+
}
522536
if (fail) {
523537
alert("Die Eingabe der Koordinaten ist nicht Korrekt!\n\nBeispiel:\n50.7;7.8\n50.6;7.9");
524538
return;
525539
}
526540
el.innerHTML = "<td>" + el.children[0].children[0].value + "</td>" +
527541
"<td>" + coords + "</td>" +
542+
"<td>" + el.children[2].children[0].value + "</td>" +
543+
"<td>" + this._filterFloat(el.children[3].children[0].value) + "</td>" +
528544
"<td><img src='../icons/general/edit.png' onclick='Settings.EditFight(this.parentNode.parentNode)' class='pointer'> <img src='../icons/general/remove.png' onclick='Settings.DeleteFight(this.parentNode.parentNode)' class='pointer'></td>";
529545
},
530546
SaveRowdensity: function (el) {
@@ -553,6 +569,7 @@ var Settings = {
553569
el.innerHTML = "<td>" + el.children[0].children[0].value + "</td>" +
554570
"<td>" + el.children[1].children[0].value + "</td>" +
555571
"<td>" + coords + "</td>" +
572+
"<td>" + el.children[3].children[0].value + "</td>" +
556573
"<td><img src='../icons/general/edit.png' onclick='Settings.EditDensity(this.parentNode.parentNode)' class='pointer'> <img src='../icons/general/remove.png' onclick='Settings.DeleteFight(this.parentNode.parentNode)' class='pointer'></td>";
557574
},
558575
Delete: function (el) {
@@ -564,12 +581,15 @@ var Settings = {
564581
EditFight: function (el) {
565582
el.innerHTML = "<td><input style='width: 145px;' value='" + el.children[0].innerText + "'/></td>" +
566583
"<td><textarea style='width: 240px;height: 60px;'>" + el.children[1].innerText + "</textarea></td>" +
584+
"<td><input style='width: 145px;' value='" + el.children[2].innerText + "'/></td>" +
585+
"<td><input style='width: 145px;' value='" + el.children[3].innerText + "'/></td>" +
567586
"<td><img src='../icons/general/save.png' onclick='Settings.SaveRowfight(this.parentNode.parentNode)' class='pointer'> <img src='../icons/general/remove.png' onclick='Settings.Abort(this.parentNode.parentNode)' class='pointer'></td>";
568587
},
569588
EditDensity: function (el) {
570589
el.innerHTML = "<td><input style='width: 145px;' value='" + el.children[0].innerText + "'/></td>" +
571590
"<td><input style='width: 195px;' value='" + el.children[1].innerText + "'/></td>" +
572591
"<td><textarea style='width: 240px;height: 60px;'>" + el.children[2].innerText + "</textarea></td>" +
592+
"<td><input style='width: 145px;' value='" + el.children[3].innerText + "'/></td>" +
573593
"<td><img src='../icons/general/save.png' onclick='Settings.SaveRowdensity(this.parentNode.parentNode)' class='pointer'> <img src='../icons/general/remove.png' onclick='Settings.Abort(this.parentNode.parentNode)' class='pointer'></td>";
574594
},
575595
_filterFloat: function (value) {
@@ -586,7 +606,6 @@ var ExImport = {
586606
html += "<div class='names'>names.json (Namen und Icons)<br/><textarea id='ex_names'></textarea> <img src='../icons/general/save.png' onclick='ExImport.SaveNames()' class='pointer'></div>";
587607
html += "<div class='names'>geo.json (Layer on the MAP) <a href='https://mapbox.github.io/togeojson/'>Kml Konverter</a><br/><textarea id='ex_geo'></textarea> <img src='../icons/general/save.png' onclick='ExImport.SaveGeo()' class='pointer'></div>";
588608
html += "<div class='names'>settings.json (Settings of the Map)<br/><textarea id='ex_settings'></textarea> <img src='../icons/general/save.png' onclick='ExImport.SaveSettings()' class='pointer'></div>";
589-
590609
html += "</div>";
591610
document.getElementById("content").innerHTML = html;
592611
document.getElementById("ex_names").value = jsonnames;

Lora-Map/resources/js/functions.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
MapObject._ParseAJAXLayers(json["getlayer"]);
4545
MapObject._ParseAJAXGeo(json["getgeo"]);
4646
MapObject._ParseAJAXSettings(json["startup"]);
47+
OverlayObject._ParseAJAXSettings(json["startup"]);
4748
}
4849
};
4950
getonce.open("GET", "/getonce", true);

Lora-Map/resources/js/map.js

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,26 +67,30 @@
6767
},
6868
_GenerateFightBoxes: function (fightdedection) {
6969
for (var cameraid in fightdedection) {
70-
this._FightDedection[cameraid] = L.polygon(fightdedection[cameraid], { color: 'black', weight: 1 }).addTo(this.Map);
71-
this._FightDedection[cameraid].bindPopup("Fightdedection für Kamera: " + cameraid);
70+
this._FightDedection[cameraid] = {};
71+
this._FightDedection[cameraid].Box = L.polygon(fightdedection[cameraid].Polygon, { color: 'black', weight: 1 }).addTo(this.Map);
72+
this._FightDedection[cameraid].Box.bindPopup("Fightdedection " + fightdedection[cameraid].Alias);
73+
this._FightDedection[cameraid].Level = fightdedection[cameraid].Level;
7274
}
7375
},
7476
_ParseAJAXFightDedection: function (json) {
7577
for (var cameraid in json) {
7678
if (this._FightDedection.hasOwnProperty(cameraid)) {
7779
var fight = json[cameraid];
78-
var box = this._FightDedection[cameraid];
80+
var box = this._FightDedection[cameraid].Box;
7981
var diff = FunctionsObject.TimeCalculation(fight["LastUpdate"], "diffraw");
80-
if (diff <= 10 && box.options.color === "black") {
81-
box.setStyle({ color: 'rgb(' + fight["FightProbability"] * 255 + ',0,0)' });
82-
} else if (diff <= 10 && box.options.color !== "black") {
83-
if (diff % 2 === 0) {
82+
if (fight["FightProbability"] > this._FightDedection[cameraid].Level) {
83+
if (diff <= 10 && box.options.color === "black") {
8484
box.setStyle({ color: 'rgb(' + fight["FightProbability"] * 255 + ',0,0)' });
85-
} else {
86-
box.setStyle({ color: 'green' });
85+
} else if (diff <= 10 && box.options.color !== "black") {
86+
if (diff % 2 === 0) {
87+
box.setStyle({ color: 'rgb(' + fight["FightProbability"] * 255 + ',0,0)' });
88+
} else {
89+
box.setStyle({ color: 'green' });
90+
}
91+
} else if (diff > 10 && box.options.color !== "black") {
92+
box.setStyle({ color: 'black' });
8793
}
88-
} else if (diff > 10 && box.options.color !== "black") {
89-
box.setStyle({ color: 'black' });
9094
}
9195
}
9296
}

Lora-Map/resources/js/overlays.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
var OverlayObject = {
2+
_DensitySettings: {},
23
Start: function () {
34
return this;
45
},
@@ -22,14 +23,19 @@
2223
var densystext = "";
2324
for (var densyid in cameradensy) {
2425
if (cameradensy.hasOwnProperty(densyid)) {
25-
var densy = cameradensy[densyid];
26-
var densytext = "<div class='camera'>";
27-
densytext += "<span class='name'>" + densyid + "</span>";
28-
densytext += "<span class='count'>" + densy["DensityCount"] + "</span>";
29-
densytext += "</div>";
30-
densystext += densytext;
26+
if (this._DensitySettings.hasOwnProperty(densyid)) {
27+
var densy = cameradensy[densyid];
28+
var densytext = "<div class='camera'>";
29+
densytext += "<span class='name'>" + this._DensitySettings[densyid].Alias + "</span>";
30+
densytext += "<span class='count'>" + densy["DensityCount"] + "</span>";
31+
densytext += "</div>";
32+
densystext += densytext;
33+
}
3134
}
3235
}
3336
document.getElementById("crwoddensy").innerHTML = densystext;
37+
},
38+
_ParseAJAXSettings: function (json) {
39+
this._DensitySettings = json["DensityArea"];
3440
}
3541
}.Start();

0 commit comments

Comments
 (0)