Skip to content

Commit

Permalink
filter lat lng = 0 in staticmapcservice
Browse files Browse the repository at this point in the history
  • Loading branch information
bassmaster187 committed Jun 28, 2024
1 parent 0b94386 commit 40cb921
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
24 changes: 13 additions & 11 deletions TeslaLogger/StaticMapService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -237,17 +237,19 @@ private static DataTable TripToCoords(TripRequest request)
if (CarID != int.MinValue && CarID > 0)
{
using (MySqlDataAdapter da = new MySqlDataAdapter(@"
SELECT
lat,
lng
FROM
pos
WHERE
CarID = @CarID
AND id >= @startID
AND id <= @endID
ORDER BY
Datum", DBHelper.DBConnectionstring))
SELECT
lat,
lng
FROM
pos
WHERE
CarID = @CarID
AND id >= @startID
AND id <= @endID
AND lat <> 0
AND lng <> 0
ORDER BY
Datum", DBHelper.DBConnectionstring))
{
da.SelectCommand.Parameters.AddWithValue("@CarID", CarID);
da.SelectCommand.Parameters.AddWithValue("@startID", request.StartPosID);
Expand Down
7 changes: 6 additions & 1 deletion TeslaLogger/WebServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1749,6 +1749,7 @@ private static void GetStaticMap(HttpListenerRequest request, HttpListenerRespon
int endPosID = 0;
int width = 240;
int height = 0;
int carid = 1;
StaticMapProvider.MapMode mode = StaticMapProvider.MapMode.Regular;
if (request.QueryString.HasKeys())
{
Expand Down Expand Up @@ -1777,6 +1778,10 @@ private static void GetStaticMap(HttpListenerRequest request, HttpListenerRespon
case "type":
// TODO
break;
case "carid":
_ = int.TryParse(request.QueryString.GetValues(key)[0], out carid);
break;

default:
break;
}
Expand Down Expand Up @@ -1806,7 +1811,7 @@ private static void GetStaticMap(HttpListenerRequest request, HttpListenerRespon
else
{
// order static map generation
StaticMapService.GetSingleton().Enqueue(1, startPosID, endPosID, width, height, mode, StaticMapProvider.MapSpecial.None);
StaticMapService.GetSingleton().Enqueue(carid, startPosID, endPosID, width, height, mode, StaticMapProvider.MapSpecial.None);
// wait
for (int i = 0; i < 30; i++)
{
Expand Down

0 comments on commit 40cb921

Please sign in to comment.