parent
d0a4430d0e
commit
a2b3f2c5da
@ -2,11 +2,13 @@
|
|||||||
|
|
||||||
## 1.2.9
|
## 1.2.9
|
||||||
### New Features
|
### New Features
|
||||||
|
* Add setting model to code
|
||||||
|
* #19 grid automatisch generieren
|
||||||
### Bugfixes
|
### Bugfixes
|
||||||
### Changes
|
### Changes
|
||||||
* Refactoring of all JS
|
* Refactoring of all JS
|
||||||
* Make only one request per second instead of four per AJAX
|
* Make only one request per second instead of four per AJAX
|
||||||
* Refactoring Adminpannel and add settings.json
|
* Refactoring adminpannel and add settings.json
|
||||||
|
|
||||||
## 1.2.8
|
## 1.2.8
|
||||||
### New Features
|
### New Features
|
||||||
|
@ -51,6 +51,7 @@
|
|||||||
<Compile Include="Model\Crowd.cs" />
|
<Compile Include="Model\Crowd.cs" />
|
||||||
<Compile Include="Model\Marker.cs" />
|
<Compile Include="Model\Marker.cs" />
|
||||||
<Compile Include="Model\AlarmItem.cs" />
|
<Compile Include="Model\AlarmItem.cs" />
|
||||||
|
<Compile Include="Model\Settings.cs" />
|
||||||
<Compile Include="Model\UTMData.cs" />
|
<Compile Include="Model\UTMData.cs" />
|
||||||
<Compile Include="Server.cs" />
|
<Compile Include="Server.cs" />
|
||||||
<Compile Include="Model\PositionItem.cs" />
|
<Compile Include="Model\PositionItem.cs" />
|
||||||
|
121
Lora-Map/Model/Settings.cs
Normal file
121
Lora-Map/Model/Settings.cs
Normal file
@ -0,0 +1,121 @@
|
|||||||
|
using CoordinateSharp;
|
||||||
|
using LitJson;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace Fraunhofer.Fit.IoT.LoraMap.Model {
|
||||||
|
public class Settings {
|
||||||
|
private readonly List<Int32> weatherCellIDs = new List<Int32>();
|
||||||
|
private Int32 gridradius;
|
||||||
|
|
||||||
|
public Double Startloclat { get; private set; }
|
||||||
|
public Double Startloclon { get; private set; }
|
||||||
|
public Dictionary<String, List<Dictionary<String, List<Double>>>> Grid { get; private set; }
|
||||||
|
|
||||||
|
public Settings() => this.ParseJson();
|
||||||
|
|
||||||
|
public void AdminModelUpdateSettings(Object sender, EventArgs e) => this.ParseJson();
|
||||||
|
|
||||||
|
private void ParseJson() {
|
||||||
|
JsonData json = JsonMapper.ToObject(File.ReadAllText("json/settings.json"));
|
||||||
|
if(json.ContainsKey("StartPos") && json["StartPos"].IsObject &&
|
||||||
|
json["StartPos"].ContainsKey("lat") && json["StartPos"]["lat"].IsDouble &&
|
||||||
|
json["StartPos"].ContainsKey("lon") && json["StartPos"]["lon"].IsDouble) {
|
||||||
|
this.Startloclat = (Double)json["StartPos"]["lat"];
|
||||||
|
this.Startloclon = (Double)json["StartPos"]["lon"];
|
||||||
|
} else {
|
||||||
|
this.Startloclat = 0;
|
||||||
|
this.Startloclon = 0;
|
||||||
|
}
|
||||||
|
this.weatherCellIDs.Clear();
|
||||||
|
if (json.ContainsKey("CellIds") && json["CellIds"].IsArray && json["CellIds"].Count > 0) {
|
||||||
|
foreach (JsonData item in json["CellIds"]) {
|
||||||
|
if(Int32.TryParse(item.ToString(), out Int32 cellid)) {
|
||||||
|
this.weatherCellIDs.Add(cellid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.gridradius = json.ContainsKey("GridRadius") && json["GridRadius"].IsInt && this.Startloclat != 0 && this.Startloclon != 0 ? (Int32)json["GridRadius"] : 0;
|
||||||
|
this.GenerateGrid();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void GenerateGrid() {
|
||||||
|
if(this.Startloclat == 0 || this.Startloclon == 0 || this.gridradius == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
MilitaryGridReferenceSystem start = new Coordinate(this.Startloclat, this.Startloclon).MGRS;
|
||||||
|
|
||||||
|
Double left = start.Easting - this.gridradius - ((start.Easting - this.gridradius) % 100);
|
||||||
|
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<String, List<Dictionary<String, List<Double>>>> {
|
||||||
|
{ "Major", new List<Dictionary<String, List<Double>>>() },
|
||||||
|
{ "Minor", new List<Dictionary<String, List<Double>>>() }
|
||||||
|
};
|
||||||
|
for (Double i = left; i <= right; i = 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));
|
||||||
|
if(i%100 == 0) {
|
||||||
|
this.Grid["Major"].Add(new Dictionary<String, List<Double>> {
|
||||||
|
{ "from", new List<Double> {
|
||||||
|
TopLeft.Latitude.DecimalDegree,
|
||||||
|
TopLeft.Longitude.DecimalDegree
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ "to", new List<Double> {
|
||||||
|
BottomLeft.Latitude.DecimalDegree,
|
||||||
|
BottomLeft.Longitude.DecimalDegree
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.Grid["Minor"].Add(new Dictionary<String, List<Double>> {
|
||||||
|
{ "from", new List<Double> {
|
||||||
|
TopLeft.Latitude.DecimalDegree,
|
||||||
|
TopLeft.Longitude.DecimalDegree
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ "to", new List<Double> {
|
||||||
|
BottomLeft.Latitude.DecimalDegree,
|
||||||
|
BottomLeft.Longitude.DecimalDegree
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (Double i = bottom; i <= top; i = i + 50) {
|
||||||
|
Coordinate BottomLeft = MilitaryGridReferenceSystem.MGRStoLatLong(new MilitaryGridReferenceSystem(start.LatZone, start.LongZone, start.Digraph, left, i));
|
||||||
|
Coordinate BottomRight = MilitaryGridReferenceSystem.MGRStoLatLong(new MilitaryGridReferenceSystem(start.LatZone, start.LongZone, start.Digraph, right, i));
|
||||||
|
if (i % 100 == 0) {
|
||||||
|
this.Grid["Major"].Add(new Dictionary<String, List<Double>> {
|
||||||
|
{ "from", new List<Double> {
|
||||||
|
BottomLeft.Latitude.DecimalDegree,
|
||||||
|
BottomLeft.Longitude.DecimalDegree
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ "to", new List<Double> {
|
||||||
|
BottomRight.Latitude.DecimalDegree,
|
||||||
|
BottomRight.Longitude.DecimalDegree
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.Grid["Minor"].Add(new Dictionary<String, List<Double>> {
|
||||||
|
{ "from", new List<Double> {
|
||||||
|
BottomLeft.Latitude.DecimalDegree,
|
||||||
|
BottomLeft.Longitude.DecimalDegree
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ "to", new List<Double> {
|
||||||
|
BottomRight.Latitude.DecimalDegree,
|
||||||
|
BottomRight.Longitude.DecimalDegree
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -18,6 +18,7 @@ namespace Fraunhofer.Fit.IoT.LoraMap {
|
|||||||
private readonly SortedDictionary<String, Camera> cameras = new SortedDictionary<String, Camera>();
|
private readonly SortedDictionary<String, Camera> cameras = new SortedDictionary<String, Camera>();
|
||||||
private readonly SortedDictionary<String, Crowd> crowds = new SortedDictionary<String, Crowd>();
|
private readonly SortedDictionary<String, Crowd> crowds = new SortedDictionary<String, Crowd>();
|
||||||
private JsonData marker;
|
private JsonData marker;
|
||||||
|
private Settings settings;
|
||||||
private readonly Dictionary<String, Marker> markertable = new Dictionary<String, Marker>();
|
private readonly Dictionary<String, Marker> markertable = new Dictionary<String, Marker>();
|
||||||
private readonly AdminModel admin;
|
private readonly AdminModel admin;
|
||||||
private readonly Object lockData = new Object();
|
private readonly Object lockData = new Object();
|
||||||
@ -29,6 +30,8 @@ namespace Fraunhofer.Fit.IoT.LoraMap {
|
|||||||
this.admin = new AdminModel(settings);
|
this.admin = new AdminModel(settings);
|
||||||
this.marker = JsonMapper.ToObject(File.ReadAllText("json/names.json"));
|
this.marker = JsonMapper.ToObject(File.ReadAllText("json/names.json"));
|
||||||
this.admin.NamesUpdate += this.AdminModelUpdateNames;
|
this.admin.NamesUpdate += this.AdminModelUpdateNames;
|
||||||
|
this.settings = new Settings();
|
||||||
|
this.admin.SettingsUpdate += this.settings.AdminModelUpdateSettings;
|
||||||
this.StartListen();
|
this.StartListen();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,7 +126,8 @@ namespace Fraunhofer.Fit.IoT.LoraMap {
|
|||||||
} else if (cont.Request.Url.PathAndQuery.StartsWith("/getonce")) {
|
} else if (cont.Request.Url.PathAndQuery.StartsWith("/getonce")) {
|
||||||
return SendJsonResponse(new Dictionary<String, Object>() {
|
return SendJsonResponse(new Dictionary<String, Object>() {
|
||||||
{ "getlayer", this.FindMapLayer(cont.Request) },
|
{ "getlayer", this.FindMapLayer(cont.Request) },
|
||||||
{ "getgeo", JsonMapper.ToObject(File.ReadAllText("json/geo.json")) }
|
{ "getgeo", JsonMapper.ToObject(File.ReadAllText("json/geo.json")) },
|
||||||
|
{ "startup", this.settings }
|
||||||
}, cont);
|
}, cont);
|
||||||
} else if (cont.Request.Url.PathAndQuery.StartsWith("/icons/marker/Marker.svg") && cont.Request.Url.PathAndQuery.Contains("?")) {
|
} else if (cont.Request.Url.PathAndQuery.StartsWith("/icons/marker/Marker.svg") && cont.Request.Url.PathAndQuery.Contains("?")) {
|
||||||
String hash = cont.Request.Url.PathAndQuery.Substring(cont.Request.Url.PathAndQuery.IndexOf('?') + 1);
|
String hash = cont.Request.Url.PathAndQuery.Substring(cont.Request.Url.PathAndQuery.IndexOf('?') + 1);
|
||||||
|
@ -122,6 +122,7 @@
|
|||||||
|
|
||||||
#content #settingseditor .startloc,
|
#content #settingseditor .startloc,
|
||||||
#content #settingseditor .wetterwarnings,
|
#content #settingseditor .wetterwarnings,
|
||||||
#content #settingseditor .savesettings {
|
#content #settingseditor .savesettings,
|
||||||
|
#content #settingseditor .gridradius {
|
||||||
margin-left: 15px;
|
margin-left: 15px;
|
||||||
}
|
}
|
@ -343,8 +343,9 @@ var NamesEditor = {
|
|||||||
var Settings = {
|
var Settings = {
|
||||||
ParseJson: function (jsonsettings) {
|
ParseJson: function (jsonsettings) {
|
||||||
var html = "<div id='settingseditor'><div class='title'>Einstellungen</div>";
|
var html = "<div id='settingseditor'><div class='title'>Einstellungen</div>";
|
||||||
html += "<div class='startloc'>Startlocation: <input value='" + jsonsettings.StartPos.lat + "' id='startlat'> Lat, <input value='" + jsonsettings.StartPos.lon + "' id='startlon'> Lon</div>";
|
html += "<div class='startloc'>Startpunkt: <input value='" + jsonsettings.StartPos.lat + "' id='startlat'> Lat, <input value='" + jsonsettings.StartPos.lon + "' id='startlon'> Lon</div>";
|
||||||
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>";
|
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>";
|
||||||
|
html += "<div class='gridradius'>Radius für das Grid um den Startpunkt: <input value='" + jsonsettings.GridRadius + "' id='gridrad'>m</div>";
|
||||||
html += "<div class='savesettings'><img src='../icons/general/save.png' onclick='Settings.Save()' class='pointer'></div>";
|
html += "<div class='savesettings'><img src='../icons/general/save.png' onclick='Settings.Save()' class='pointer'></div>";
|
||||||
document.getElementById("content").innerHTML = html + "</div>";
|
document.getElementById("content").innerHTML = html + "</div>";
|
||||||
},
|
},
|
||||||
@ -354,6 +355,7 @@ var Settings = {
|
|||||||
ret.StartPos.lat = parseFloat(document.getElementById("startlat").value.replace(",", "."));
|
ret.StartPos.lat = parseFloat(document.getElementById("startlat").value.replace(",", "."));
|
||||||
ret.StartPos.lon = parseFloat(document.getElementById("startlon").value.replace(",", "."));
|
ret.StartPos.lon = parseFloat(document.getElementById("startlon").value.replace(",", "."));
|
||||||
ret.CellIds = document.getElementById("wetterids").value.split(";");
|
ret.CellIds = document.getElementById("wetterids").value.split(";");
|
||||||
|
ret.GridRadius = parseInt(document.getElementById("gridrad").value);
|
||||||
|
|
||||||
var savesettings = new XMLHttpRequest();
|
var savesettings = new XMLHttpRequest();
|
||||||
savesettings.onreadystatechange = function () {
|
savesettings.onreadystatechange = function () {
|
||||||
|
Loading…
Reference in New Issue
Block a user