ThinkGeo.com    |     Blog    |     Wiki    |     Support

WMS version=1.1.1 not displaying due to bounding box fail in WmsRasterLayer.DrawCore

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));
        }
    }

Hi Jonathan,

Could you please show us the server or capability XML so we can see where it parse incorrect?

a. View the code I found it looks both the CRS and SRS had been parsed. So I think more detail information is helpful. I want to make sure what’s the first place check fail means.

b. I also don’t make sure what’s check is removed. I compare the code you modified with the DrawCore of WMSLayer, I found they are nearly the same.

Only the gray part is different.

Is that the change you did and what’s target this change want to solve here?

Any more information should be helpful.

Regards,

Ethan

Hi Ethan,

bsky.xml (3.5 KB)

I have attached the capability XML, hopefully that will be helpful.

The difference you highlighted is the change that made it work. The if statement was returning false as the GetBoundingBox() was returning lat/long values but the CurrentWorldExtent is in OS-GB Easting and Northing.

Regards,
Jonathan

Hi Jonathan,

Thanks for your information, we will check this issue based on your capability XML, our developer is on the vacation, we will reply the result to your next Monday. Please keep eyes on this post.

Thanks
Mark

Hi Jonathan,

We research your capability XML.

a. We handle the CRS and SRS correct, and our layer parse the capability succeed.

b. It looks your layer contains a sub layer here:

<Layer>
<Title>GeoWebCache WMS</Title>
<Abstract>
Note that not all GeoWebCache instances provide a full WMS service.
</Abstract>
<LatLonBoundingBox minx="-180.0" miny="-90.0" maxx="180.0" maxy="90.0"/>
<Layer queryable="1">
<Name>UK_AerialPhoto_2018</Name>
<Title>UK_AerialPhoto_2018</Title>
<Abstract/>
<SRS>EPSG:27700</SRS>
<BoundingBox SRS="EPSG:27700" minx="-2631.181480109517" miny="4133.303818128188" maxx="662338.237607193" maxy="1334072.1419927329"/>
</Layer>
</Layer>

If your node contains the LatLonBoundingBox, this bouding box will be used as the layer’s bounding box.

Your modify is OK, it only remove the adjust which works for improve effect, the WMS still render correct.

And if possible you can modify the server setting to remove the LatLonBoundingBox value, and the sub layer’s bouding box will works.

Regards,

Ethan

Ethan,

Thank you for the update, it was very helpful. I will pass on the information about the capability document to the layer provider as they may want to make some changes.

Sorry but I’m not 100% sure what, “… works for improve effect,” means. Would that mean improve the appearance in some way? or precision of location of image on canvas? or maybe the speed of rendering?

Regards,
Jonathan

Hi Jonathan,

I am glad to hear that’s helpful.

It looks my description make you confused, in fact that means improve performance. I used incorrect word here. In our logic, if the bouding box is not in current extent, the layer won’t be rendered, after remove it, all added layer will be rendered. So it only works when you make sure the layer is needed.

Regards,

Ethan

Ethan,

Thanks, the extra explanation makes things perfectly clear and I understand now. Hopefully the service provider will modify their Capability Document so we can go back to using the standard ThinkGEO implementation, but not too big a problem if not.

Regards,
Jonathan

Hi Jonathan,

Thanks to let us know it.

Regards,

Ethan