Skip to content

Commit

Permalink
[1.2.3] #9 display polygons and marker on the map
Browse files Browse the repository at this point in the history
  • Loading branch information
blubbfish committed Apr 24, 2019
1 parent 8e93886 commit 3ad491c
Show file tree
Hide file tree
Showing 9 changed files with 104 additions and 4,518 deletions.
5 changes: 4 additions & 1 deletion Lora-Map/Lora-Map.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@
<None Include="dpkg\postinst" />
<None Include="dpkg\preinst" />
<None Include="dpkg\prerm" />
<None Include="layer.json" />
<None Include="resources\icons\marker\din1451m.woff">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="resources\js\leaflet\leaflet-src.js.map" />
</ItemGroup>
<ItemGroup>
<Content Include="resources\admin\css\global.css">
Expand All @@ -88,6 +88,9 @@
<Content Include="resources\css\icons\admin-with-cogwheels.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="resources\css\icons\cctv.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="resources\css\icons\failtile.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
Expand Down
25 changes: 24 additions & 1 deletion Lora-Map/Model/Admin/Adminmodel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,23 @@ private Boolean GetJson(HttpListenerContext cont) {
return false;
}
File.WriteAllText("json/names.json", rawData);
Console.WriteLine("200 - Get names.json " + cont.Request.Url.PathAndQuery);
Console.WriteLine("200 - Post names.json " + cont.Request.Url.PathAndQuery);
this.NamesUpdate?.Invoke(this, new EventArgs());
return true;
} else if(cont.Request.Url.PathAndQuery == "/admin/set_json_geo") {
StreamReader reader = new StreamReader(cont.Request.InputStream, cont.Request.ContentEncoding);
String rawData = reader.ReadToEnd();
cont.Request.InputStream.Close();
reader.Close();
try {
JsonMapper.ToObject(rawData);
} catch(Exception) {
Helper.WriteError("501 - Error recieving geo.json " + cont.Request.Url.PathAndQuery);
cont.Response.StatusCode = 501;
return false;
}
File.WriteAllText("json/geo.json", rawData);
Console.WriteLine("200 - Post geo.json " + cont.Request.Url.PathAndQuery);
this.NamesUpdate?.Invoke(this, new EventArgs());
return true;
}
Expand All @@ -68,6 +84,13 @@ private Boolean SendJson(HttpListenerContext cont) {
cont.Response.OutputStream.Write(buf, 0, buf.Length);
Console.WriteLine("200 - Send names.json " + cont.Request.Url.PathAndQuery);
return true;
} else if(cont.Request.Url.PathAndQuery == "/admin/get_json_geo") {
String file = File.ReadAllText("json/geo.json");
Byte[] buf = Encoding.UTF8.GetBytes(file);
cont.Response.ContentLength64 = buf.Length;
cont.Response.OutputStream.Write(buf, 0, buf.Length);
Console.WriteLine("200 - Send geo.json " + cont.Request.Url.PathAndQuery);
return true;
}
Helper.WriteError("404 - Section in get_json not found " + cont.Request.Url.PathAndQuery + "!");
cont.Response.StatusCode = 404;
Expand Down
7 changes: 4 additions & 3 deletions Lora-Map/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Fraunhofer FIT")]
[assembly: AssemblyProduct("Lora-Map")]
[assembly: AssemblyCopyright("Copyright © 2018 - 22.04.2019")]
[assembly: AssemblyCopyright("Copyright © 2018 - 24.04.2019")]
[assembly: AssemblyTrademark("Fraunhofer FIT, BlubbFish")]
[assembly: AssemblyCulture("")]
[assembly: NeutralResourcesLanguage("de-DE")]
Expand All @@ -33,8 +33,8 @@
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
// übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.2.2")]
[assembly: AssemblyFileVersion("1.2.2")]
[assembly: AssemblyVersion("1.2.3")]
[assembly: AssemblyFileVersion("1.2.3")]

/*
* 1.1.1 Add Debian package config
Expand All @@ -47,4 +47,5 @@
* 1.2.0 #4 Possible to Ex and Import Setting
* 1.2.1 #6 Load the map from the Device
* 1.2.2 Bugfix, if only recieve panic packet with gps data, update the marker on the map also
* 1.2.3 #9 display polygons and marker on the map
*/
9 changes: 9 additions & 0 deletions Lora-Map/Server.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ private void CheckJsonFiles() {
if(!File.Exists("json/names.json")) {
File.WriteAllText("json/names.json", "{}");
}
if(!File.Exists("json/geo.json")) {
File.WriteAllText("json/geo.json", "{}");
}
}

protected override void Backend_MessageIncomming(Object sender, BackendEvent e) {
Expand Down Expand Up @@ -100,6 +103,12 @@ protected override Boolean SendWebserverResponse(HttpListenerContext cont) {
return SendJsonResponse(this.FindMapLayer(cont.Request), cont);
} else if(cont.Request.Url.PathAndQuery.StartsWith("/maps/")) {
return SendFileResponse(cont, "resources", false);
} else if(cont.Request.Url.PathAndQuery.StartsWith("/getgeo")) {
Byte[] buf = Encoding.UTF8.GetBytes(File.ReadAllText("json/geo.json"));
cont.Response.ContentLength64 = buf.Length;
cont.Response.OutputStream.Write(buf, 0, buf.Length);
Console.WriteLine("200 - " + cont.Request.Url.PathAndQuery);
return true;
}
} catch(Exception e) {
Helper.WriteError("500 - " + e.Message);
Expand Down
Loading

0 comments on commit 3ad491c

Please sign in to comment.