Changed IMapLayer interface

This commit is contained in:
ClemensFischer 2026-04-09 20:40:14 +02:00
parent 57ee896f8a
commit 1d4c5a4b90
8 changed files with 28 additions and 32 deletions

View file

@ -73,6 +73,11 @@ namespace MapControl
/// </summary>
public IReadOnlyCollection<string> AvailableLayers { get; private set; }
/// <summary>
/// Gets a collection of all CRSs supported by a WMS.
/// </summary>
public IReadOnlyCollection<string> SupportedCrsIds { get; private set; }
private bool HasLayer =>
RequestLayers != null ||
AvailableLayers?.Count > 0 ||
@ -113,17 +118,17 @@ namespace MapControl
var ns = capabilities.Name.Namespace;
var capability = capabilities.Element(ns + "Capability");
SupportedCrsIds = capability
.Descendants(ns + "Layer")
.Descendants(ns + "CRS")
.Select(e => e.Value)
.ToList();
AvailableLayers = capability
.Descendants(ns + "Layer")
.Select(e => e.Element(ns + "Name")?.Value)
.Where(n => !string.IsNullOrEmpty(n))
.ToList();
SupportedCrsIds = capability
.Descendants(ns + "Layer")
.Descendants(ns + "CRS")
.Select(e => e.Value)
.ToList();
}
}
@ -161,7 +166,8 @@ namespace MapControl
string response = null;
if (ServiceUri != null && HasLayer &&
ParentMap != null && ParentMap.InsideViewBounds(position))
ParentMap != null && ParentMap.InsideViewBounds(position) &&
(SupportedCrsIds == null || SupportedCrsIds.Contains(ParentMap.MapProjection.CrsId)))
{
var uri = GetFeatureInfoRequestUri(position, format);
@ -185,7 +191,8 @@ namespace MapControl
{
ImageSource image = null;
if (ServiceUri != null && HasLayer)
if (ServiceUri != null && HasLayer &&
(SupportedCrsIds == null || SupportedCrsIds.Contains(ParentMap.MapProjection.CrsId)))
{
var xMin = -180d * MapProjection.Wgs84MeterPerDegree;
var xMax = 180d * MapProjection.Wgs84MeterPerDegree;