Hi,
We use a number of WMS feeds, one of which is version 1.1.1 and the rest 1.3.0. The 1.3.0 ones appears to work OK but the 1.1.1 one is not displayed due to failing a bounding box validation check in WmsRasterLayer.DrawCore.
We already had an over ridden version of DrawCore that wrapped a call to Base.DrawCore in some exception handling specific for our application so further modified that to completely replace the standard version and removed the suspect check. So we were wondering:
(a) why might the check fail in the first place, might the capabilities document not being handled right for 1.1.1 (e.g. using SRS instead of CRS).
(b) does our modified code look OK? or are we missing something important by removing that check?
Regards,
Jonathan
// Call the base draw but handle exceptions more robustly
try
{
// var test = GetRequestUrlCore(canvas.CurrentWorldExtent, (int)canvas.Width, (int)canvas.Height);
if(this.GetServiceVersion() != "1.1.1") //If the service version is new, continue as normal
base.DrawCore(canvas, labelsInAllLayers);
else //else if version is old, perform a modified base.drawCore(Potentially a fix specific to blueskys)
{
ValidatorHelper.CheckObjectIsNotNull((object) canvas, nameof(canvas));
ValidatorHelper.CheckLayerIsOpened(this.IsOpen);
ValidatorHelper.CheckRasterSourceIsOpen(this.ImageSource.IsOpen);
ValidatorHelper.CheckGeoCanvasIsInDrawing(canvas.IsDrawing);
GeoImage image = (GeoImage) null;
try
{
int width = (int) canvas.Width;
int height = (int) canvas.Height;
if (!RasterLayer.IsExtentWithinThreshold(canvas.CurrentWorldExtent, this.UpperThreshold,
this.LowerThreshold, width, canvas.MapUnit, canvas.Dpi))
return;
PointShape centerPoint = canvas.CurrentWorldExtent.GetCenterPoint();
image = this.ImageSource.GetImage(canvas.CurrentWorldExtent, width, height);
if (image == null)
return;
if (Math.Abs(this.ScaleFactor - 1.0) < double.Epsilon)
canvas.DrawWorldImageWithoutScaling(image, centerPoint.X, centerPoint.Y,
DrawingLevel.LevelOne);
else
canvas.DrawWorldImage(image, centerPoint.X, centerPoint.Y,
(float) image.Width / (float) this.ScaleFactor,
(float) image.Height / (float) this.ScaleFactor, DrawingLevel.LevelOne);
}
finally
{
image?.Dispose();
}
}
}
catch (Exception ex)
{
// Update user on failure
PearMessageBox.Show(
PearMessageBox.mBoxType.errorNotification,
"Difficulty accessing WMS server",
PearMessageBox.FormattedString("Reported error: ", ex.Message));
// Stop layer updates by making not visible
ProjectHelper.SetLayerVisibility(record, false);
// Refresh stuff
messaging.Send(new InternalMessage(Cmd.Route.REFRESH_STATES));
messaging.Send(new InternalMessage(Cmd.Map.REFRESH_MAP_DEFERRED));
messaging.Send(new InternalMessage(Cmd.Map.CHECK_SELECTED));
messaging.Send(new InternalMessage(Cmd.Layer.REFRESH_LAYER_CONTROLS));
}
}