mirror of
https://github.com/azaion/satellite-provider.git
synced 2026-06-23 15:51:14 +00:00
Add TileProvision configuration and gRPC service for tile delivery
- Introduced new TileProvision settings in appsettings.json, including MaxTilesPerBatch and ProgressEmitIntervalSeconds. - Configured TileProvisionConfig in Program.cs to bind the new settings. - Added gRPC service for RouteTileDelivery in Program.cs to handle tile delivery requests. - Updated SatelliteProvider.Api.csproj to include Grpc.AspNetCore package and added protobuf file for tile provision. - Enhanced AuthenticationServiceCollectionExtensions to handle JWT token extraction from the Authorization header. - Registered additional services in RouteManagementServiceCollectionExtensions for tile processing. These changes enhance the API's capability to manage tile provisioning and delivery efficiently.
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
namespace SatelliteProvider.Services.RouteManagement.TileProvision;
|
||||
|
||||
public sealed record ClientTileSnapshot(
|
||||
int Z,
|
||||
int X,
|
||||
int Y,
|
||||
double ResolutionMetersPerPx,
|
||||
DateTime CapturedAtUtc,
|
||||
byte[]? ContentSha256);
|
||||
|
||||
public static class ClientTileCatalog
|
||||
{
|
||||
public static Dictionary<(int Z, int X, int Y), ClientTileSnapshot> IndexByZxy(
|
||||
IEnumerable<ClientTileSnapshot> clientTiles)
|
||||
{
|
||||
var index = new Dictionary<(int Z, int X, int Y), ClientTileSnapshot>();
|
||||
foreach (var tile in clientTiles)
|
||||
{
|
||||
index[(tile.Z, tile.X, tile.Y)] = tile;
|
||||
}
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
public static bool ShouldSkipForClient(
|
||||
ClientTileSnapshot? client,
|
||||
ServerTileProspect server)
|
||||
{
|
||||
if (client is null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (client.ContentSha256 is { Length: 32 } clientHash
|
||||
&& server.ContentSha256 is { Length: 32 } serverHash
|
||||
&& clientHash.AsSpan().SequenceEqual(serverHash))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (client.ResolutionMetersPerPx <= server.ResolutionMetersPerPx
|
||||
&& client.CapturedAtUtc >= server.CapturedAtUtc)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user