mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 19:56:31 +00:00
fix throttle ext
fix configs fix build scripts
This commit is contained in:
@@ -104,51 +104,6 @@ public class SatelliteDownloader(
|
||||
await Task.Run(() => Parallel.ForEach(cropTasks, action => action()), token);
|
||||
}
|
||||
|
||||
private async Task SplitToTiles_OLD(Image<Rgba32> image, DownloadTilesResult bounds, CancellationToken token = default)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(image);
|
||||
ArgumentNullException.ThrowIfNull(bounds);
|
||||
|
||||
if (bounds.LatMax <= bounds.LatMin || bounds.LonMax <= bounds.LonMin || image.Width <= 0 || image.Height <= 0)
|
||||
throw new ArgumentException("Invalid coordinate bounds (LatMax <= LatMin or LonMax <= LonMin) or image dimensions (Width/Height <= 0).");
|
||||
|
||||
var latRange = bounds.LatMax - bounds.LatMin;
|
||||
var lonRange = bounds.LonMax - bounds.LonMin;
|
||||
var degreesPerPixelLat = latRange / image.Height;
|
||||
var degreesPerPixelLon = lonRange / image.Width;
|
||||
|
||||
var rowIndex = 0;
|
||||
for (int top = 0; top <= image.Height - CROP_HEIGHT; top += STEP_Y)
|
||||
{
|
||||
token.ThrowIfCancellationRequested();
|
||||
int colIndex = 0;
|
||||
for (int left = 0; left <= image.Width - CROP_WIDTH; left += STEP_X)
|
||||
{
|
||||
token.ThrowIfCancellationRequested();
|
||||
|
||||
var cropBox = new Rectangle(left, top, CROP_WIDTH, CROP_HEIGHT);
|
||||
|
||||
using (var croppedImage = image.Clone(ctx => ctx.Crop(cropBox)))
|
||||
{
|
||||
var cropTlLat = bounds.LatMax - (top * degreesPerPixelLat);
|
||||
var cropTlLon = bounds.LonMin + (left * degreesPerPixelLon);
|
||||
var cropBrLat = cropTlLat - (CROP_HEIGHT * degreesPerPixelLat);
|
||||
var cropBrLon = cropTlLon + (CROP_WIDTH * degreesPerPixelLon);
|
||||
|
||||
var outputFilename = Path.Combine(_satDirectory,
|
||||
$"map_{rowIndex:D4}_{colIndex:D4}_tl_{cropTlLat:F6}_{cropTlLon:F6}_br_{cropBrLat:F6}_{cropBrLon:F6}.tif"
|
||||
);
|
||||
|
||||
using (var resizedImage = croppedImage.Clone(ctx => ctx.Resize(OUTPUT_TILE_SIZE, OUTPUT_TILE_SIZE, KnownResamplers.Lanczos3)))
|
||||
await resizedImage.SaveAsTiffAsync(outputFilename, token);
|
||||
}
|
||||
colIndex++;
|
||||
}
|
||||
rowIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private async Task<Image<Rgba32>?> ComposeTiles(ConcurrentDictionary<(int x, int y), byte[]> downloadedTiles, CancellationToken token = default)
|
||||
{
|
||||
if (downloadedTiles.IsEmpty)
|
||||
|
||||
Reference in New Issue
Block a user