mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-31 22:00:12 +01:00
Exception logging
This commit is contained in:
parent
6ca1496095
commit
65828c9c24
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
#if WPF
|
||||
|
|
@ -181,14 +180,7 @@ namespace MapControl
|
|||
|
||||
if (boundingBox != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
image = await GetImageAsync(boundingBox, loadingProgress);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine($"MapImageLayer.GetImageAsync: {ex.Message}");
|
||||
}
|
||||
image = await GetImageAsync(boundingBox, loadingProgress);
|
||||
}
|
||||
|
||||
SwapImages(image, boundingBox);
|
||||
|
|
|
|||
|
|
@ -169,14 +169,7 @@ namespace MapControl
|
|||
{
|
||||
foreach (var element in ChildElements)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArrangeChildElement(element, finalSize);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine($"MapPanel.ArrangeOverride: {element}: {ex.Message}");
|
||||
}
|
||||
ArrangeChildElement(element, finalSize);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -164,50 +164,57 @@ namespace MapControl
|
|||
{
|
||||
ImageSource image = null;
|
||||
|
||||
if (ServiceUri != null && ParentMap?.MapProjection != null)
|
||||
try
|
||||
{
|
||||
if (WmsLayers == null &&
|
||||
ServiceUri.ToString().IndexOf("LAYERS=", StringComparison.OrdinalIgnoreCase) < 0)
|
||||
if (ServiceUri != null && ParentMap?.MapProjection != null)
|
||||
{
|
||||
// Get first Layer from a GetCapabilities response.
|
||||
//
|
||||
WmsLayers = (await GetLayerNamesAsync())?.FirstOrDefault() ?? "";
|
||||
}
|
||||
|
||||
if (boundingBox.West >= -180d && boundingBox.East <= 180d ||
|
||||
ParentMap.MapProjection.Type > MapProjectionType.NormalCylindrical)
|
||||
{
|
||||
var uri = CreateUri(GetMapRequestUri(boundingBox));
|
||||
|
||||
if (uri != null)
|
||||
if (WmsLayers == null &&
|
||||
ServiceUri.ToString().IndexOf("LAYERS=", StringComparison.OrdinalIgnoreCase) < 0)
|
||||
{
|
||||
image = await ImageLoader.LoadImageAsync(uri, progress);
|
||||
// Get first Layer from a GetCapabilities response.
|
||||
//
|
||||
WmsLayers = (await GetLayerNamesAsync())?.FirstOrDefault() ?? "";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
BoundingBox bbox1, bbox2;
|
||||
|
||||
if (boundingBox.West < -180d)
|
||||
if (boundingBox.West >= -180d && boundingBox.East <= 180d ||
|
||||
ParentMap.MapProjection.Type > MapProjectionType.NormalCylindrical)
|
||||
{
|
||||
bbox1 = new BoundingBox(boundingBox.South, boundingBox.West + 360, boundingBox.North, 180d);
|
||||
bbox2 = new BoundingBox(boundingBox.South, -180d, boundingBox.North, boundingBox.East);
|
||||
var uri = GetMapRequestUri(boundingBox);
|
||||
|
||||
if (uri != null)
|
||||
{
|
||||
image = await ImageLoader.LoadImageAsync(new Uri(uri), progress);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bbox1 = new BoundingBox(boundingBox.South, boundingBox.West, boundingBox.North, 180d);
|
||||
bbox2 = new BoundingBox(boundingBox.South, -180d, boundingBox.North, boundingBox.East - 360d);
|
||||
}
|
||||
BoundingBox bbox1, bbox2;
|
||||
|
||||
var uri1 = CreateUri(GetMapRequestUri(bbox1));
|
||||
var uri2 = CreateUri(GetMapRequestUri(bbox2));
|
||||
if (boundingBox.West < -180d)
|
||||
{
|
||||
bbox1 = new BoundingBox(boundingBox.South, boundingBox.West + 360, boundingBox.North, 180d);
|
||||
bbox2 = new BoundingBox(boundingBox.South, -180d, boundingBox.North, boundingBox.East);
|
||||
}
|
||||
else
|
||||
{
|
||||
bbox1 = new BoundingBox(boundingBox.South, boundingBox.West, boundingBox.North, 180d);
|
||||
bbox2 = new BoundingBox(boundingBox.South, -180d, boundingBox.North, boundingBox.East - 360d);
|
||||
}
|
||||
|
||||
if (uri1 != null && uri2 != null)
|
||||
{
|
||||
image = await ImageLoader.LoadMergedImageAsync(uri1, uri2, progress);
|
||||
var uri1 = GetMapRequestUri(bbox1);
|
||||
var uri2 = GetMapRequestUri(bbox2);
|
||||
|
||||
if (uri1 != null && uri2 != null)
|
||||
{
|
||||
image = await ImageLoader.LoadMergedImageAsync(new Uri(uri1), new Uri(uri2), progress);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger?.LogError(ex, "GetImageAsync");
|
||||
}
|
||||
|
||||
return image;
|
||||
}
|
||||
|
|
@ -358,22 +365,5 @@ namespace MapControl
|
|||
|
||||
return uri.Replace(" ", "%20");
|
||||
}
|
||||
|
||||
private static Uri CreateUri(string uri)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(uri))
|
||||
{
|
||||
try
|
||||
{
|
||||
return new Uri(uri, UriKind.RelativeOrAbsolute);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger?.LogError(ex, "{uri}", uri);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue