Constants naming

This commit is contained in:
ClemensFischer 2025-12-05 15:07:01 +01:00
parent 107b8e0f90
commit 172a388841
2 changed files with 23 additions and 23 deletions

View file

@ -23,9 +23,9 @@ namespace MapControl.Caching
/// </summary> /// </summary>
public sealed class FileDbCache : IDistributedCache, IDisposable public sealed class FileDbCache : IDistributedCache, IDisposable
{ {
private const string keyField = "Key"; private const string KeyField = "Key";
private const string valueField = "Value"; private const string ValueField = "Value";
private const string expiresField = "Expires"; private const string ExpiresField = "Expires";
private readonly FileDb fileDb = new FileDb { AutoFlush = true }; private readonly FileDb fileDb = new FileDb { AutoFlush = true };
private readonly Timer timer; private readonly Timer timer;
@ -71,9 +71,9 @@ namespace MapControl.Caching
fileDb.Create(path, new Field[] fileDb.Create(path, new Field[]
{ {
new Field(keyField, DataTypeEnum.String) { IsPrimaryKey = true }, new Field(KeyField, DataTypeEnum.String) { IsPrimaryKey = true },
new Field(valueField, DataTypeEnum.Byte) { IsArray = true }, new Field(ValueField, DataTypeEnum.Byte) { IsArray = true },
new Field(expiresField, DataTypeEnum.DateTime) new Field(ExpiresField, DataTypeEnum.DateTime)
}); });
logger?.LogInformation("Created database {path}", path); logger?.LogInformation("Created database {path}", path);
@ -99,7 +99,7 @@ namespace MapControl.Caching
{ {
try try
{ {
var record = fileDb.GetRecordByKey(key, new string[] { valueField, expiresField }, false); var record = fileDb.GetRecordByKey(key, new string[] { ValueField, ExpiresField }, false);
if (record != null && (DateTime)record[1] > DateTime.UtcNow) if (record != null && (DateTime)record[1] > DateTime.UtcNow)
{ {
@ -130,8 +130,8 @@ namespace MapControl.Caching
var fieldValues = new FieldValues(3) var fieldValues = new FieldValues(3)
{ {
{ valueField, value }, { ValueField, value },
{ expiresField, expiration } { ExpiresField, expiration }
}; };
try try
@ -142,7 +142,7 @@ namespace MapControl.Caching
} }
else else
{ {
fieldValues.Add(keyField, key); fieldValues.Add(KeyField, key);
fileDb.AddRecord(fieldValues); fileDb.AddRecord(fieldValues);
} }
} }
@ -193,7 +193,7 @@ namespace MapControl.Caching
public void DeleteExpiredItems() public void DeleteExpiredItems()
{ {
var deletedItemsCount = fileDb.DeleteRecords(new FilterExpression(expiresField, DateTime.UtcNow, ComparisonOperatorEnum.LessThanOrEqual)); var deletedItemsCount = fileDb.DeleteRecords(new FilterExpression(ExpiresField, DateTime.UtcNow, ComparisonOperatorEnum.LessThanOrEqual));
if (deletedItemsCount > 0) if (deletedItemsCount > 0)
{ {

View file

@ -24,9 +24,9 @@ namespace MapControl
/// </summary> /// </summary>
public class MapTileLayer : TilePyramidLayer public class MapTileLayer : TilePyramidLayer
{ {
private const int tileSize = 256; private const int TileSize = 256;
private static readonly Point mapTopLeft = new Point(-180d * MapProjection.Wgs84MeterPerDegree, private static readonly Point MapTopLeft = new Point(-180d * MapProjection.Wgs84MeterPerDegree,
180d * MapProjection.Wgs84MeterPerDegree); 180d * MapProjection.Wgs84MeterPerDegree);
public static readonly DependencyProperty TileSourceProperty = public static readonly DependencyProperty TileSourceProperty =
@ -116,9 +116,9 @@ namespace MapControl
{ {
// Arrange tiles relative to TileMatrix.XMin/YMin. // Arrange tiles relative to TileMatrix.XMin/YMin.
// //
var tileSize = MapTileLayer.tileSize << (TileMatrix.ZoomLevel - tile.ZoomLevel); var tileSize = TileSize << (TileMatrix.ZoomLevel - tile.ZoomLevel);
var x = tileSize * tile.X - MapTileLayer.tileSize * TileMatrix.XMin; var x = tileSize * tile.X - TileSize * TileMatrix.XMin;
var y = tileSize * tile.Y - MapTileLayer.tileSize * TileMatrix.YMin; var y = tileSize * tile.Y - TileSize * TileMatrix.YMin;
tile.Image.Width = tileSize; tile.Image.Width = tileSize;
tile.Image.Height = tileSize; tile.Image.Height = tileSize;
@ -134,11 +134,11 @@ namespace MapControl
{ {
// Tile matrix origin in pixels. // Tile matrix origin in pixels.
// //
var tileMatrixOrigin = new Point(tileSize * TileMatrix.XMin, tileSize * TileMatrix.YMin); var tileMatrixOrigin = new Point(TileSize * TileMatrix.XMin, TileSize * TileMatrix.YMin);
var tileMatrixScale = MapBase.ZoomLevelToScale(TileMatrix.ZoomLevel); var tileMatrixScale = MapBase.ZoomLevelToScale(TileMatrix.ZoomLevel);
((MatrixTransform)RenderTransform).Matrix = ((MatrixTransform)RenderTransform).Matrix =
ParentMap.ViewTransform.GetTileLayerTransform(tileMatrixScale, mapTopLeft, tileMatrixOrigin); ParentMap.ViewTransform.GetTileLayerTransform(tileMatrixScale, MapTopLeft, tileMatrixOrigin);
} }
} }
@ -178,14 +178,14 @@ namespace MapControl
// Tile matrix bounds in pixels. // Tile matrix bounds in pixels.
// //
var bounds = ParentMap.ViewTransform.GetTileMatrixBounds(tileMatrixScale, mapTopLeft, ParentMap.ActualWidth, ParentMap.ActualHeight); var bounds = ParentMap.ViewTransform.GetTileMatrixBounds(tileMatrixScale, MapTopLeft, ParentMap.ActualWidth, ParentMap.ActualHeight);
// Tile X and Y bounds. // Tile X and Y bounds.
// //
var xMin = (int)Math.Floor(bounds.X / tileSize); var xMin = (int)Math.Floor(bounds.X / TileSize);
var yMin = (int)Math.Floor(bounds.Y / tileSize); var yMin = (int)Math.Floor(bounds.Y / TileSize);
var xMax = (int)Math.Floor((bounds.X + bounds.Width) / tileSize); var xMax = (int)Math.Floor((bounds.X + bounds.Width) / TileSize);
var yMax = (int)Math.Floor((bounds.Y + bounds.Height) / tileSize); var yMax = (int)Math.Floor((bounds.Y + bounds.Height) / TileSize);
if (TileMatrix != null && if (TileMatrix != null &&
TileMatrix.ZoomLevel == tileMatrixZoomLevel && TileMatrix.ZoomLevel == tileMatrixZoomLevel &&