mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
Added LayerIdentifier to WmtsTileLayer cache path
This commit is contained in:
parent
181c9e5642
commit
0af0901ce8
|
|
@ -42,7 +42,7 @@ namespace MapControl.Caching
|
|||
{
|
||||
try
|
||||
{
|
||||
return Path.Combine(rootDirectory, Path.Combine(key.Split('/', ':', ';', ',')));
|
||||
return Path.Combine(rootDirectory, Path.Combine(key.Split('/')));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ namespace MapControl
|
|||
public WmtsTileSource TileSource { get; private set; }
|
||||
public List<WmtsTileMatrixSet> TileMatrixSets { get; private set; }
|
||||
|
||||
public static async Task<WmtsCapabilities> ReadCapabilities(Uri capabilitiesUri, string layerIdentifier)
|
||||
public static async Task<WmtsCapabilities> ReadCapabilitiesAsync(Uri capabilitiesUri, string layerIdentifier)
|
||||
{
|
||||
WmtsCapabilities capabilities;
|
||||
|
||||
|
|
@ -142,7 +142,8 @@ namespace MapControl
|
|||
}
|
||||
else if (capabilitiesUrl != null)
|
||||
{
|
||||
var requestIndex = capabilitiesUrl.IndexOf("Request=GetCapabilities", StringComparison.OrdinalIgnoreCase);
|
||||
const string requestParam = "Request=GetCapabilities";
|
||||
var requestIndex = capabilitiesUrl.IndexOf(requestParam, StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
if (requestIndex > 0)
|
||||
{
|
||||
|
|
@ -160,7 +161,7 @@ namespace MapControl
|
|||
|
||||
urlTemplate = capabilitiesUrl.Substring(0, requestIndex)
|
||||
+ "Request=GetTile"
|
||||
+ capabilitiesUrl.Substring(requestIndex + "Request=GetCapabilities".Length)
|
||||
+ capabilitiesUrl.Substring(requestIndex + requestParam.Length)
|
||||
+ "&Version=1.0.0"
|
||||
+ "&Layer=" + layerIdentifier
|
||||
+ "&Format=" + format
|
||||
|
|
@ -199,13 +200,15 @@ namespace MapControl
|
|||
throw new ArgumentException($"No ows:SupportedCRS element found in TileMatrixSet \"{identifier}\".");
|
||||
}
|
||||
|
||||
if (supportedCrs.StartsWith("urn:")) // e.g. "urn:ogc:def:crs:EPSG:6.18:3857")
|
||||
{
|
||||
var urn = supportedCrs.Split(':');
|
||||
const string urnPrefix = "urn:ogc:def:crs:EPSG:";
|
||||
|
||||
if (urn.Length == 7 && urn[3] == "crs" && urn[4] == "EPSG")
|
||||
if (supportedCrs.StartsWith(urnPrefix)) // e.g. "urn:ogc:def:crs:EPSG:6.18:3857")
|
||||
{
|
||||
var crs = supportedCrs.Substring(urnPrefix.Length).Split(':');
|
||||
|
||||
if (crs.Length > 1)
|
||||
{
|
||||
supportedCrs = "EPSG:" + urn[6];
|
||||
supportedCrs = "EPSG:" + crs[1];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -174,12 +174,12 @@ namespace MapControl
|
|||
|
||||
if (!string.IsNullOrEmpty(cacheName))
|
||||
{
|
||||
cacheName += "/" + tileMatrixSet.Identifier
|
||||
.Replace(':', '_')
|
||||
.Replace(';', '_')
|
||||
.Replace(',', '_')
|
||||
.Replace('/', '_')
|
||||
.Replace('\\', '_');
|
||||
if (!string.IsNullOrEmpty(LayerIdentifier))
|
||||
{
|
||||
cacheName += "/" + LayerIdentifier.Replace(':', '_');
|
||||
}
|
||||
|
||||
cacheName += "/" + tileMatrixSet.Identifier.Replace(':', '_');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -192,7 +192,7 @@ namespace MapControl
|
|||
{
|
||||
try
|
||||
{
|
||||
var capabilities = await WmtsCapabilities.ReadCapabilities(CapabilitiesUri, LayerIdentifier);
|
||||
var capabilities = await WmtsCapabilities.ReadCapabilitiesAsync(CapabilitiesUri, LayerIdentifier);
|
||||
|
||||
foreach (var tileMatrixSet in capabilities.TileMatrixSets
|
||||
.Where(s => !TileMatrixSets.ContainsKey(s.SupportedCrs)))
|
||||
|
|
|
|||
Loading…
Reference in a new issue