mirror of
https://github.com/azaion/satellite-provider.git
synced 2026-06-21 08:41:13 +00:00
[AZ-375] [AZ-377] HashSet tile lookup + consolidate Earth constants
Batch 24 of 03-code-quality-refactoring run; closes the run. AZ-375 (C22): GoogleMapsDownloaderV2.DownloadTilesGridAsync now builds a HashSet<(int X, int Y, int Z)> once from existingTiles and tests Contains((x, y, zoomLevel)) per cell. Removes the per-cell FirstOrDefault tolerance scan and the unused _processingConfig .LatLonTolerance reference at this site. AZ-377 (C24): promote Earth + tile-pixel constants to a single home. GeoUtils now exposes EarthRadiusMeters, EarthEquatorial CircumferenceMeters, MetersPerDegreeLatitude as public const. MapConfig adds DefaultTileSizePixels (const) wired as the TileSizePixels property default. TileRepository and Google MapsDownloaderV2 read those constants instead of duplicating the literals 6378137, 40075016.686, 111000.0, and 256. Tests: +6 new (DownloaderRefactorTests, extended GeoUtils RefactorTests). 200/200 unit tests pass. Cumulative K=3 review (batches 22-24): PASS_WITH_WARNINGS, 4 Low findings only — see _docs/03_implementation/reviews/cumulative_review_22-24.md. Tooling fix: scripts/run-tests.sh --unit-only path now restores before testing (was failing on SixLabors resolution in clean container). Stripped stray BOM from MapConfig.cs to satisfy the .editorconfig charset gate. Updates _dependencies_table.md to reflect all 27 03-code-quality- refactoring tasks done; updates _autodev_state.md to refactor phase 5 (test-sync). Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -2,6 +2,8 @@ using System.Diagnostics;
|
||||
using Dapper;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Npgsql;
|
||||
using SatelliteProvider.Common.Configs;
|
||||
using SatelliteProvider.Common.Utils;
|
||||
using SatelliteProvider.DataAccess.Models;
|
||||
|
||||
namespace SatelliteProvider.DataAccess.Repositories;
|
||||
@@ -53,16 +55,14 @@ public class TileRepository : ITileRepository
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString);
|
||||
|
||||
const double EARTH_CIRCUMFERENCE_METERS = 40075016.686;
|
||||
const int TILE_SIZE_PIXELS = 256;
|
||||
var latRad = latitude * Math.PI / 180.0;
|
||||
var metersPerPixel = (EARTH_CIRCUMFERENCE_METERS * Math.Cos(latRad)) / (Math.Pow(2, zoomLevel) * TILE_SIZE_PIXELS);
|
||||
var tileSizeMeters = metersPerPixel * TILE_SIZE_PIXELS;
|
||||
var metersPerPixel = (GeoUtils.EarthEquatorialCircumferenceMeters * Math.Cos(latRad)) / (Math.Pow(2, zoomLevel) * MapConfig.DefaultTileSizePixels);
|
||||
var tileSizeMeters = metersPerPixel * MapConfig.DefaultTileSizePixels;
|
||||
|
||||
var expandedSizeMeters = sizeMeters + (tileSizeMeters * 2);
|
||||
|
||||
var latRange = expandedSizeMeters / 111000.0;
|
||||
var lonRange = expandedSizeMeters / (111000.0 * Math.Cos(latitude * Math.PI / 180.0));
|
||||
var latRange = expandedSizeMeters / GeoUtils.MetersPerDegreeLatitude;
|
||||
var lonRange = expandedSizeMeters / (GeoUtils.MetersPerDegreeLatitude * Math.Cos(latitude * Math.PI / 180.0));
|
||||
|
||||
const string sql = $@"
|
||||
SELECT {ColumnList}
|
||||
|
||||
Reference in New Issue
Block a user