Hi Simo,
I figured that the WmsLayer is hard-coded to swallow exceptions and display an error message on the map. As a result, the exception is never thrown, which is why DrawExceptionCore is not being called. This behavior appears to be specific to WmsLayer.
You can work around this by overriding the DrawAsyncCore method (see my code below) in your CustomWmsAsyncLayer (derived from WmsAsyncLayer). By removing the hard-coded exception handling, the exception will be raised properly and DrawExceptionCore will be invoked.
Thank you for reporting this issue. We plan to fix it in the upcoming v14.3 release.
Thanks,
Ben
protected override async Task DrawAsyncCore(GeoCanvas canvas, Collection<SimpleCandidate> labelsInAllLayers)
{
ValidatorHelper.CheckObjectIsNotNull(canvas, "view");
ValidatorHelper.CheckLayerIsOpened(IsOpen);
ValidatorHelper.CheckGeoCanvasIsInDrawing(canvas.IsDrawing);
var wmsRequestExtent = canvas.CurrentWorldExtent;
// Apply projection if need
if (ProjectionConverter != null)
wmsRequestExtent = ProjectionConverter.ConvertToInternalProjection(canvas.CurrentWorldExtent);
GeoImage tempImage = null;
try
{
PointShape centerPointShape = canvas.CurrentWorldExtent.GetCenterPoint();
int canvasWidth = (int)(canvas.Width * canvas.ScaleFactor);
int canvasHeight = (int)(canvas.Height * canvas.ScaleFactor);
var imageBytes = await DownloadImageAsync(canvasWidth, canvasHeight, 1,
wmsRequestExtent, canvas.MapUnit, canvas.CancellationToken);
if (canvas.CancellationToken.IsCancellationRequested || imageBytes == null)
return;
tempImage = new GeoImage(imageBytes);
// Check if the image needs to be projected
if (ProjectionConverter != null && tempImage != null)
{
// Project the downloaded image to the external projection
RasterProjectionResult projectedResult = ProjectionConverter.ConvertToExternalProjection(tempImage, wmsRequestExtent);
if (canvas.CancellationToken.IsCancellationRequested) { return; }
// Dispose the original image and use the projected one
tempImage.Dispose();
tempImage = projectedResult.Image;
}
if (tempImage != null)
{
if (Math.Abs(canvas.ScaleFactor - 1.0) < double.Epsilon)
canvas.DrawWorldImageWithoutScaling(tempImage, centerPointShape.X, centerPointShape.Y, DrawingLevel.LevelOne);
else
canvas.DrawWorldImage(tempImage, centerPointShape.X, centerPointShape.Y, (tempImage.Width / canvas.ScaleFactor), (tempImage.Height / canvas.ScaleFactor), DrawingLevel.LevelOne);
}
}
finally
{
tempImage?.Dispose();
}
}