mirror of
https://github.com/azaion/satellite-provider.git
synced 2026-04-22 09:06:38 +00:00
geo fences - wip
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Dapper;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Npgsql;
|
||||
using SatelliteProvider.DataAccess.Models;
|
||||
|
||||
@@ -7,10 +8,12 @@ namespace SatelliteProvider.DataAccess.Repositories;
|
||||
public class TileRepository : ITileRepository
|
||||
{
|
||||
private readonly string _connectionString;
|
||||
private readonly ILogger<TileRepository> _logger;
|
||||
|
||||
public TileRepository(string connectionString)
|
||||
public TileRepository(string connectionString, ILogger<TileRepository> logger)
|
||||
{
|
||||
_connectionString = connectionString;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public async Task<TileEntity?> GetByIdAsync(Guid id)
|
||||
@@ -24,7 +27,15 @@ public class TileRepository : ITileRepository
|
||||
FROM tiles
|
||||
WHERE id = @Id";
|
||||
|
||||
return await connection.QuerySingleOrDefaultAsync<TileEntity>(sql, new { Id = id });
|
||||
var tile = await connection.QuerySingleOrDefaultAsync<TileEntity>(sql, new { Id = id });
|
||||
|
||||
if (tile != null)
|
||||
{
|
||||
_logger.LogInformation("TileRepository - Read tile {TileId} from DB: Lat={Lat:F12}, Lon={Lon:F12}, Zoom={Zoom}",
|
||||
id, tile.Latitude, tile.Longitude, tile.ZoomLevel);
|
||||
}
|
||||
|
||||
return tile;
|
||||
}
|
||||
|
||||
public async Task<TileEntity?> FindExistingTileAsync(double latitude, double longitude, double tileSizeMeters, int zoomLevel, int version)
|
||||
@@ -105,6 +116,9 @@ public class TileRepository : ITileRepository
|
||||
updated_at = EXCLUDED.updated_at
|
||||
RETURNING id";
|
||||
|
||||
_logger.LogInformation("TileRepository - Inserting tile {TileId} to DB: Lat={Lat:F12}, Lon={Lon:F12}, Zoom={Zoom}",
|
||||
tile.Id, tile.Latitude, tile.Longitude, tile.ZoomLevel);
|
||||
|
||||
return await connection.ExecuteScalarAsync<Guid>(sql, tile);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user