Class names in Debug output

This commit is contained in:
ClemensFischer 2024-08-31 16:39:49 +02:00
parent 84cd6e2f9a
commit aa6018cf0e
18 changed files with 64 additions and 66 deletions

View file

@ -39,7 +39,7 @@ namespace MapControl.Caching
try try
{ {
fileDb.Open(path); fileDb.Open(path);
Debug.WriteLine($"FileDbCache: Opened database {path}"); Debug.WriteLine($"{nameof(FileDbCache)}: Opened database {path}");
Clean(); Clean();
} }
@ -61,7 +61,7 @@ namespace MapControl.Caching
new Field(expiresField, DataTypeEnum.DateTime) new Field(expiresField, DataTypeEnum.DateTime)
}); });
Debug.WriteLine($"FileDbCache: Created database {path}"); Debug.WriteLine($"{nameof(FileDbCache)}: Created database {path}");
} }
} }
@ -94,7 +94,7 @@ namespace MapControl.Caching
} }
catch (Exception ex) catch (Exception ex)
{ {
Debug.WriteLine($"FileDbCache.Get({key}): {ex.Message}"); Debug.WriteLine($"{nameof(FileDbCache)}.Get({key}): {ex.Message}");
} }
return value; return value;
@ -143,7 +143,7 @@ namespace MapControl.Caching
} }
catch (Exception ex) catch (Exception ex)
{ {
Debug.WriteLine($"FileDbCache.Set({key}): {ex.Message}"); Debug.WriteLine($"{nameof(FileDbCache)}.Set({key}): {ex.Message}");
} }
} }
@ -161,7 +161,7 @@ namespace MapControl.Caching
} }
catch (Exception ex) catch (Exception ex)
{ {
Debug.WriteLine($"FileDbCache.Remove({key}): {ex.Message}"); Debug.WriteLine($"{nameof(FileDbCache)}.Remove({key}): {ex.Message}");
} }
} }
@ -171,7 +171,7 @@ namespace MapControl.Caching
if (deleted > 0) if (deleted > 0)
{ {
Debug.WriteLine($"FileDbCache: Deleted {deleted} expired items"); Debug.WriteLine($"{nameof(FileDbCache)}: Deleted {deleted} expired items");
fileDb.Clean(); fileDb.Clean();
} }
} }

View file

@ -40,7 +40,7 @@ namespace MapControl.Caching
command.ExecuteNonQuery(); command.ExecuteNonQuery();
} }
Debug.WriteLine($"SQLiteCache: Opened database {path}"); Debug.WriteLine($"{nameof(SQLiteCache)}: Opened database {path}");
Clean(); Clean();
} }
@ -70,7 +70,7 @@ namespace MapControl.Caching
} }
catch (Exception ex) catch (Exception ex)
{ {
Debug.WriteLine($"SQLiteCache.Get({key}): {ex.Message}"); Debug.WriteLine($"{nameof(SQLiteCache)}.Get({key}): {ex.Message}");
} }
return value; return value;
@ -96,7 +96,7 @@ namespace MapControl.Caching
} }
catch (Exception ex) catch (Exception ex)
{ {
Debug.WriteLine($"SQLiteCache.GetAsync({key}): {ex.Message}"); Debug.WriteLine($"{nameof(SQLiteCache)}.GetAsync({key}): {ex.Message}");
} }
return value; return value;
@ -115,7 +115,7 @@ namespace MapControl.Caching
} }
catch (Exception ex) catch (Exception ex)
{ {
Debug.WriteLine($"SQLiteCache.Set({key}): {ex.Message}"); Debug.WriteLine($"{nameof(SQLiteCache)}.Set({key}): {ex.Message}");
} }
} }
@ -132,7 +132,7 @@ namespace MapControl.Caching
} }
catch (Exception ex) catch (Exception ex)
{ {
Debug.WriteLine($"SQLiteCache.SetAsync({key}): {ex.Message}"); Debug.WriteLine($"{nameof(SQLiteCache)}.SetAsync({key}): {ex.Message}");
} }
} }
@ -158,7 +158,7 @@ namespace MapControl.Caching
} }
catch (Exception ex) catch (Exception ex)
{ {
Debug.WriteLine($"SQLiteCache.Remove({key}): {ex.Message}"); Debug.WriteLine($"{nameof(SQLiteCache)}.Remove({key}): {ex.Message}");
} }
} }
@ -175,7 +175,7 @@ namespace MapControl.Caching
} }
catch (Exception ex) catch (Exception ex)
{ {
Debug.WriteLine($"SQLiteCache.RemoveAsync({key}): {ex.Message}"); Debug.WriteLine($"{nameof(SQLiteCache)}.RemoveAsync({key}): {ex.Message}");
} }
} }
@ -192,7 +192,7 @@ namespace MapControl.Caching
var deleted = (long)command.ExecuteScalar(); var deleted = (long)command.ExecuteScalar();
if (deleted > 0) if (deleted > 0)
{ {
Debug.WriteLine($"SQLiteCache: Deleted {deleted} expired items"); Debug.WriteLine($"{nameof(SQLiteCache)}: Deleted {deleted} expired items");
} }
} }
#endif #endif
@ -211,7 +211,7 @@ namespace MapControl.Caching
var deleted = (long)await command.ExecuteScalarAsync(); var deleted = (long)await command.ExecuteScalarAsync();
if (deleted > 0) if (deleted > 0)
{ {
Debug.WriteLine($"SQLiteCache: Deleted {deleted} expired items"); Debug.WriteLine($"{nameof(SQLiteCache)}: Deleted {deleted} expired items");
} }
} }
#endif #endif

View file

@ -91,7 +91,7 @@ namespace MapControl.MBTiles
} }
catch (Exception ex) catch (Exception ex)
{ {
Debug.WriteLine($"MBTileLayer: {ex.Message}"); Debug.WriteLine($"{nameof(MBTileLayer)}: {ex.Message}");
} }
} }
} }

View file

@ -106,7 +106,7 @@ namespace MapControl.MBTiles
} }
catch (Exception ex) catch (Exception ex)
{ {
Debug.WriteLine($"MBTileSource: {ex.Message}"); Debug.WriteLine($"{nameof(MBTileSource)}: {ex.Message}");
} }
return image; return image;

View file

@ -59,12 +59,12 @@ namespace MapControl
} }
catch (Exception ex) catch (Exception ex)
{ {
Debug.WriteLine($"BingMapsTileLayer: {metadataUri}: {ex.Message}"); Debug.WriteLine($"{nameof(BingMapsTileLayer)}: {metadataUri}: {ex.Message}");
} }
} }
else else
{ {
Debug.WriteLine("BingMapsTileLayer requires a Bing Maps API Key"); Debug.WriteLine($"{nameof(BingMapsTileLayer)} requires a Bing Maps API Key");
} }
} }

View file

@ -65,7 +65,7 @@ namespace MapControl
} }
catch (Exception ex) catch (Exception ex)
{ {
Debug.WriteLine($"GeoImage: {ex.Message}"); Debug.WriteLine($"{nameof(GeoImage)}: {sourcePath}: {ex.Message}");
} }
} }
} }
@ -138,13 +138,11 @@ namespace MapControl
private static async Task<GeoBitmap> ReadWorldFileImageAsync(string sourcePath, string worldFilePath) private static async Task<GeoBitmap> ReadWorldFileImageAsync(string sourcePath, string worldFilePath)
{ {
var geoBitmap = new GeoBitmap(); return new GeoBitmap
{
geoBitmap.Bitmap = (BitmapSource)await ImageLoader.LoadImageAsync(sourcePath); Bitmap = (BitmapSource)await ImageLoader.LoadImageAsync(sourcePath),
Transform = await Task.Run(() => ReadWorldFileMatrix(worldFilePath))
geoBitmap.Transform = await Task.Run(() => ReadWorldFileMatrix(worldFilePath)); };
return geoBitmap;
} }
private static Matrix ReadWorldFileMatrix(string worldFilePath) private static Matrix ReadWorldFileMatrix(string worldFilePath)
@ -170,7 +168,7 @@ namespace MapControl
parameters[5]); // line 6: F or OffsetY parameters[5]); // line 6: F or OffsetY
} }
private static MapProjection GetProjection(string sourcePath, short[] geoKeyDirectory) private static MapProjection GetProjection(short[] geoKeyDirectory)
{ {
MapProjection projection = null; MapProjection projection = null;
@ -181,7 +179,7 @@ namespace MapControl
int epsgCode = geoKeyDirectory[i + 3]; int epsgCode = geoKeyDirectory[i + 3];
projection = MapProjectionFactory.Instance.GetProjection(epsgCode) ?? projection = MapProjectionFactory.Instance.GetProjection(epsgCode) ??
throw new ArgumentException($"Can not create projection EPSG:{epsgCode} in {sourcePath}."); throw new ArgumentException($"Can not create projection EPSG:{epsgCode}.");
break; break;
} }

View file

@ -86,7 +86,7 @@ namespace MapControl
} }
catch (Exception ex) catch (Exception ex)
{ {
Debug.WriteLine($"GroundOverlayPanel: {sourcePath}: {ex.Message}"); Debug.WriteLine($"{nameof(GroundOverlay)}: {sourcePath}: {ex.Message}");
} }
} }

View file

@ -34,7 +34,7 @@ namespace MapControl.Caching
rootPath = path; rootPath = path;
Debug.WriteLine($"ImageFileCache: {rootPath}"); Debug.WriteLine($"{nameof(ImageFileCache)}: {rootPath}");
ThreadPool.QueueUserWorkItem(o => Clean()); ThreadPool.QueueUserWorkItem(o => Clean());
} }
@ -61,7 +61,7 @@ namespace MapControl.Caching
} }
catch (Exception ex) catch (Exception ex)
{ {
Debug.WriteLine($"ImageFileCache: Failed reading {path}: {ex.Message}"); Debug.WriteLine($"{nameof(ImageFileCache)}: Failed reading {path}: {ex.Message}");
} }
} }
@ -101,7 +101,7 @@ namespace MapControl.Caching
} }
catch (Exception ex) catch (Exception ex)
{ {
Debug.WriteLine($"ImageFileCache: Failed reading {path}: {ex.Message}"); Debug.WriteLine($"{nameof(ImageFileCache)}: Failed reading {path}: {ex.Message}");
} }
} }
@ -134,7 +134,7 @@ namespace MapControl.Caching
} }
catch (Exception ex) catch (Exception ex)
{ {
Debug.WriteLine($"ImageFileCache: Failed writing {path}: {ex.Message}"); Debug.WriteLine($"{nameof(ImageFileCache)}: Failed writing {path}: {ex.Message}");
} }
} }
} }
@ -166,7 +166,7 @@ namespace MapControl.Caching
} }
catch (Exception ex) catch (Exception ex)
{ {
Debug.WriteLine($"ImageFileCache: Failed writing {path}: {ex.Message}"); Debug.WriteLine($"{nameof(ImageFileCache)}: Failed writing {path}: {ex.Message}");
} }
} }
@ -195,7 +195,7 @@ namespace MapControl.Caching
} }
catch (Exception ex) catch (Exception ex)
{ {
Debug.WriteLine($"ImageFileCache: Failed deleting {path}: {ex.Message}"); Debug.WriteLine($"{nameof(ImageFileCache)}: Failed deleting {path}: {ex.Message}");
} }
} }
@ -214,7 +214,7 @@ namespace MapControl.Caching
} }
catch (Exception ex) catch (Exception ex)
{ {
Debug.WriteLine($"ImageFileCache: Failed deleting {path}: {ex.Message}"); Debug.WriteLine($"{nameof(ImageFileCache)}: Failed deleting {path}: {ex.Message}");
} }
} }
@ -224,7 +224,7 @@ namespace MapControl.Caching
if (deletedFileCount > 0) if (deletedFileCount > 0)
{ {
Debug.WriteLine($"ImageFileCache: Deleted {deletedFileCount} expired files."); Debug.WriteLine($"{nameof(ImageFileCache)}: Deleted {deletedFileCount} expired files.");
} }
} }
@ -241,7 +241,7 @@ namespace MapControl.Caching
} }
catch (Exception ex) catch (Exception ex)
{ {
Debug.WriteLine($"ImageFileCache: Invalid key {key}: {ex.Message}"); Debug.WriteLine($"{nameof(ImageFileCache)}: Invalid key {key}: {ex.Message}");
} }
return null; return null;
@ -264,7 +264,7 @@ namespace MapControl.Caching
} }
catch (Exception ex) catch (Exception ex)
{ {
Debug.WriteLine($"ImageFileCache: Failed cleaning {directory.FullName}: {ex.Message}"); Debug.WriteLine($"{nameof(ImageFileCache)}: Failed cleaning {directory.FullName}: {ex.Message}");
} }
return deletedFileCount; return deletedFileCount;
@ -299,7 +299,7 @@ namespace MapControl.Caching
} }
catch (Exception ex) catch (Exception ex)
{ {
Debug.WriteLine($"ImageFileCache: Failed cleaning {file.FullName}: {ex.Message}"); Debug.WriteLine($"{nameof(ImageFileCache)}: Failed cleaning {file.FullName}: {ex.Message}");
} }
} }

View file

@ -60,7 +60,7 @@ namespace MapControl
} }
catch (Exception ex) catch (Exception ex)
{ {
Debug.WriteLine($"ImageLoader: {uri}: {ex.Message}"); Debug.WriteLine($"{nameof(ImageLoader)}: {uri}: {ex.Message}");
} }
progress?.Report(1d); progress?.Report(1d);
@ -121,13 +121,13 @@ namespace MapControl
} }
else else
{ {
Debug.WriteLine($"ImageLoader: {uri}: {(int)responseMessage.StatusCode} {responseMessage.ReasonPhrase}"); Debug.WriteLine($"{nameof(ImageLoader)}: {uri}: {(int)responseMessage.StatusCode} {responseMessage.ReasonPhrase}");
} }
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
Debug.WriteLine($"ImageLoader: {uri}: {ex.Message}"); Debug.WriteLine($"{nameof(ImageLoader)}: {uri}: {ex.Message}");
} }
return response; return response;

View file

@ -195,7 +195,7 @@ namespace MapControl
} }
catch (Exception ex) catch (Exception ex)
{ {
Debug.WriteLine($"MapImageLayer: {ex.Message}"); Debug.WriteLine($"{nameof(MapImageLayer)}: {ex.Message}");
} }
} }

View file

@ -123,7 +123,7 @@ namespace MapControl
} }
catch (Exception ex) catch (Exception ex)
{ {
Debug.WriteLine($"MapOverlaysControl: {sourcePath}: {ex.Message}"); Debug.WriteLine($"{nameof(MapOverlaysPanel)}: {sourcePath}: {ex.Message}");
overlay = new MapPanel(); overlay = new MapPanel();
} }

View file

@ -179,7 +179,7 @@ namespace MapControl
} }
catch (Exception ex) catch (Exception ex)
{ {
Debug.WriteLine($"MapPanel.ArrangeOverride: {element}: {ex.Message}"); Debug.WriteLine($"{nameof(MapPanel)}.{nameof(ArrangeOverride)}: {element}: {ex.Message}");
} }
} }
} }

View file

@ -127,7 +127,7 @@ namespace MapControl
} }
catch (Exception ex) catch (Exception ex)
{ {
Debug.WriteLine($"TileImageLoader: {tile.ZoomLevel}/{tile.Column}/{tile.Row}: {ex.Message}"); Debug.WriteLine($"{nameof(TileImageLoader)}: {tile.ZoomLevel}/{tile.Column}/{tile.Row}: {ex.Message}");
} }
} }
@ -170,7 +170,7 @@ namespace MapControl
} }
catch (Exception ex) catch (Exception ex)
{ {
Debug.WriteLine($"TileImageLoader.Cache.GetAsync: {cacheKey}: {ex.Message}"); Debug.WriteLine($"{nameof(TileImageLoader)}.{nameof(Cache)}.{nameof(Cache.GetAsync)}: {cacheKey}: {ex.Message}");
return null; return null;
} }
@ -195,7 +195,7 @@ namespace MapControl
} }
catch (Exception ex) catch (Exception ex)
{ {
Debug.WriteLine($"TileImageLoader.Cache.SetAsync: {cacheKey}: {ex.Message}"); Debug.WriteLine($"{nameof(TileImageLoader)}.{nameof(Cache)}.{nameof(Cache.SetAsync)}: {cacheKey}: {ex.Message}");
} }
} }
} }

View file

@ -117,7 +117,7 @@ namespace MapControl
} }
catch (Exception ex) catch (Exception ex)
{ {
Debug.WriteLine($"WmsImageLayer: {uri}: {ex.Message}"); Debug.WriteLine($"{nameof(WmsImageLayer)}: {uri}: {ex.Message}");
} }
} }
} }
@ -147,7 +147,7 @@ namespace MapControl
} }
catch (Exception ex) catch (Exception ex)
{ {
Debug.WriteLine($"WmsImageLayer: {uri}: {ex.Message}"); Debug.WriteLine($"{nameof(WmsImageLayer)}: {uri}: {ex.Message}");
} }
} }
} }
@ -334,7 +334,7 @@ namespace MapControl
} }
catch (Exception ex) catch (Exception ex)
{ {
Debug.WriteLine($"WmsImageLayer: {uri}: {ex.Message}"); Debug.WriteLine($"{nameof(WmsImageLayer)}: {uri}: {ex.Message}");
} }
} }

View file

@ -210,7 +210,7 @@ namespace MapControl
} }
catch (Exception ex) catch (Exception ex)
{ {
Debug.WriteLine($"WmtsTileLayer: {CapabilitiesUri}: {ex.Message}"); Debug.WriteLine($"{nameof(WmtsTileLayer)}: {CapabilitiesUri}: {ex.Message}");
} }
} }
} }

View file

@ -32,7 +32,7 @@ namespace MapControl.Caching
{ {
rootFolder = folder ?? throw new ArgumentException($"The {nameof(folder)} argument must not be null or empty.", nameof(folder)); rootFolder = folder ?? throw new ArgumentException($"The {nameof(folder)} argument must not be null or empty.", nameof(folder));
Debug.WriteLine($"ImageFileCache: {rootFolder.Path}"); Debug.WriteLine($"{nameof(ImageFileCache)}: {rootFolder.Path}");
_ = Task.Factory.StartNew(CleanAsync, TaskCreationOptions.LongRunning); _ = Task.Factory.StartNew(CleanAsync, TaskCreationOptions.LongRunning);
} }
@ -89,7 +89,7 @@ namespace MapControl.Caching
} }
catch (Exception ex) catch (Exception ex)
{ {
Debug.WriteLine($"ImageFileCache: Failed reading {key}: {ex.Message}"); Debug.WriteLine($"{nameof(ImageFileCache)}: Failed reading {key}: {ex.Message}");
} }
} }
@ -126,7 +126,7 @@ namespace MapControl.Caching
} }
catch (Exception ex) catch (Exception ex)
{ {
Debug.WriteLine($"ImageFileCache: Failed writing {key}: {ex.Message}"); Debug.WriteLine($"{nameof(ImageFileCache)}: Failed writing {key}: {ex.Message}");
} }
} }
} }
@ -137,7 +137,7 @@ namespace MapControl.Caching
if (deletedFileCount > 0) if (deletedFileCount > 0)
{ {
Debug.WriteLine($"ImageFileCache: Deleted {deletedFileCount} expired files."); Debug.WriteLine($"{nameof(ImageFileCache)}: Deleted {deletedFileCount} expired files.");
} }
} }
@ -164,7 +164,7 @@ namespace MapControl.Caching
} }
catch (Exception ex) catch (Exception ex)
{ {
Debug.WriteLine($"ImageFileCache: Failed cleaning {folder.Path}: {ex.Message}"); Debug.WriteLine($"{nameof(ImageFileCache)}: Failed cleaning {folder.Path}: {ex.Message}");
} }
return deletedFileCount; return deletedFileCount;
@ -200,7 +200,7 @@ namespace MapControl.Caching
} }
catch (Exception ex) catch (Exception ex)
{ {
Debug.WriteLine($"ImageFileCache: Failed cleaning {file.Path}: {ex.Message}"); Debug.WriteLine($"{nameof(ImageFileCache)}: Failed cleaning {file.Path}: {ex.Message}");
} }
} }

View file

@ -13,9 +13,9 @@ namespace MapControl
{ {
public partial class GeoImage public partial class GeoImage
{ {
private static async Task<GeoBitmap> ReadGeoTiffAsync(string sourcePath) private static Task<GeoBitmap> ReadGeoTiffAsync(string sourcePath)
{ {
return await Task.Run(() => return Task.Run(() =>
{ {
var geoBitmap = new GeoBitmap(); var geoBitmap = new GeoBitmap();
@ -42,12 +42,12 @@ namespace MapControl
} }
else else
{ {
throw new ArgumentException($"No coordinate transformation found in {sourcePath}."); throw new ArgumentException("No coordinate transformation found.");
} }
if (metadata.GetQuery(QueryString(GeoKeyDirectoryTag)) is short[] geoKeyDirectory) if (metadata.GetQuery(QueryString(GeoKeyDirectoryTag)) is short[] geoKeyDirectory)
{ {
geoBitmap.Projection = GetProjection(sourcePath, geoKeyDirectory); geoBitmap.Projection = GetProjection(geoKeyDirectory);
} }
if (metadata.GetQuery(QueryString(NoDataTag)) is string noData && if (metadata.GetQuery(QueryString(NoDataTag)) is string noData &&

View file

@ -54,13 +54,13 @@ namespace MapControl
} }
else else
{ {
throw new ArgumentException($"No coordinate transformation found in {sourcePath}."); throw new ArgumentException("No coordinate transformation found.");
} }
if (metadata.TryGetValue(geoKeyDirectoryQuery, out BitmapTypedValue geoKeyDirValue) && if (metadata.TryGetValue(geoKeyDirectoryQuery, out BitmapTypedValue geoKeyDirValue) &&
geoKeyDirValue.Value is short[] geoKeyDirectory) geoKeyDirValue.Value is short[] geoKeyDirectory)
{ {
geoBitmap.Projection = GetProjection(sourcePath, geoKeyDirectory); geoBitmap.Projection = GetProjection(geoKeyDirectory);
} }
return geoBitmap; return geoBitmap;