mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
Update WmtsCapabilities.cs
This commit is contained in:
parent
28b76ec73f
commit
4f7f7672a1
|
|
@ -75,8 +75,6 @@ namespace MapControl
|
||||||
layerIdentifier = layerElement.Element(ows + "Identifier")?.Value ?? "";
|
layerIdentifier = layerElement.Element(ows + "Identifier")?.Value ?? "";
|
||||||
}
|
}
|
||||||
|
|
||||||
var urlTemplate = ReadUrlTemplate(layerElement, layerIdentifier, capabilitiesUrl);
|
|
||||||
|
|
||||||
var styleElement = layerElement.Descendants(ns + "Style")
|
var styleElement = layerElement.Descendants(ns + "Style")
|
||||||
.FirstOrDefault(e => e.Attribute("isDefault")?.Value == "true");
|
.FirstOrDefault(e => e.Attribute("isDefault")?.Value == "true");
|
||||||
|
|
||||||
|
|
@ -92,6 +90,8 @@ namespace MapControl
|
||||||
throw new ArgumentException("No valid Style element found in Layer \"" + layerIdentifier + "\".");
|
throw new ArgumentException("No valid Style element found in Layer \"" + layerIdentifier + "\".");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var urlTemplate = ReadUrlTemplate(layerElement, layerIdentifier, style, capabilitiesUrl);
|
||||||
|
|
||||||
var tileMatrixSetIds = layerElement
|
var tileMatrixSetIds = layerElement
|
||||||
.Descendants(ns + "TileMatrixSetLink")
|
.Descendants(ns + "TileMatrixSetLink")
|
||||||
.Select(e => e.Element(ns + "TileMatrixSet")?.Value)
|
.Select(e => e.Element(ns + "TileMatrixSet")?.Value)
|
||||||
|
|
@ -110,20 +110,18 @@ namespace MapControl
|
||||||
throw new ArgumentException("Linked TileMatrixSet element not found in Layer \"" + layerIdentifier + "\".");
|
throw new ArgumentException("Linked TileMatrixSet element not found in Layer \"" + layerIdentifier + "\".");
|
||||||
}
|
}
|
||||||
|
|
||||||
var tileMatrixSet = ReadTileMatrixSet(tileMatrixSetElement);
|
tileMatrixSets.Add(ReadTileMatrixSet(tileMatrixSetElement));
|
||||||
|
|
||||||
tileMatrixSets.Add(tileMatrixSet);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return new WmtsCapabilities
|
return new WmtsCapabilities
|
||||||
{
|
{
|
||||||
LayerIdentifier = layerIdentifier,
|
LayerIdentifier = layerIdentifier,
|
||||||
TileSource = new WmtsTileSource { UriFormat = urlTemplate.Replace("{Style}", style) },
|
TileSource = new WmtsTileSource { UriFormat = urlTemplate },
|
||||||
TileMatrixSets = tileMatrixSets
|
TileMatrixSets = tileMatrixSets
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string ReadUrlTemplate(XElement layerElement, string layerIdentifier, string capabilitiesUrl)
|
public static string ReadUrlTemplate(XElement layerElement, string layerIdentifier, string style, string capabilitiesUrl)
|
||||||
{
|
{
|
||||||
XNamespace ns = layerElement.Name.Namespace;
|
XNamespace ns = layerElement.Name.Namespace;
|
||||||
const string formatPng = "image/png";
|
const string formatPng = "image/png";
|
||||||
|
|
@ -140,7 +138,7 @@ namespace MapControl
|
||||||
: resourceUrls.Contains(formatJpg) ? resourceUrls[formatJpg]
|
: resourceUrls.Contains(formatJpg) ? resourceUrls[formatJpg]
|
||||||
: resourceUrls.First();
|
: resourceUrls.First();
|
||||||
|
|
||||||
urlTemplate = urlTemplates.FirstOrDefault();
|
urlTemplate = urlTemplates.First().Replace("{Style}", style);
|
||||||
}
|
}
|
||||||
else if (capabilitiesUrl != null)
|
else if (capabilitiesUrl != null)
|
||||||
{
|
{
|
||||||
|
|
@ -166,7 +164,7 @@ namespace MapControl
|
||||||
+ "&Version=1.0.0"
|
+ "&Version=1.0.0"
|
||||||
+ "&Layer=" + layerIdentifier
|
+ "&Layer=" + layerIdentifier
|
||||||
+ "&Format=" + format
|
+ "&Format=" + format
|
||||||
+ "&Style={Style}"
|
+ "&Style=" + style
|
||||||
+ "&TileMatrixSet={TileMatrixSet}"
|
+ "&TileMatrixSet={TileMatrixSet}"
|
||||||
+ "&TileMatrix={TileMatrix}"
|
+ "&TileMatrix={TileMatrix}"
|
||||||
+ "&TileCol={TileCol}"
|
+ "&TileCol={TileCol}"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue