mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-04 14:08:32 +00:00
Renamed TileSource.UriFormat, improved WmtsCapabilities
This commit is contained in:
parent
343888be5d
commit
916dc7d4af
13 changed files with 98 additions and 98 deletions
|
|
@ -106,7 +106,7 @@ namespace MapControl
|
||||||
|
|
||||||
TileSource = new BingMapsTileSource
|
TileSource = new BingMapsTileSource
|
||||||
{
|
{
|
||||||
UriFormat = imageUrl.Replace("{culture}", Culture),
|
UriTemplate = imageUrl.Replace("{culture}", Culture),
|
||||||
Subdomains = subdomains
|
Subdomains = subdomains
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,7 @@ namespace MapControl
|
||||||
{
|
{
|
||||||
Uri uri = null;
|
Uri uri = null;
|
||||||
|
|
||||||
if (UriFormat != null && Subdomains != null && Subdomains.Length > 0 &&
|
if (UriTemplate != null && Subdomains != null && Subdomains.Length > 0 && zoomLevel > 0)
|
||||||
x >= 0 && y >= 0 && zoomLevel > 0)
|
|
||||||
{
|
{
|
||||||
var subdomain = Subdomains[(x + y) % Subdomains.Length];
|
var subdomain = Subdomains[(x + y) % Subdomains.Length];
|
||||||
var quadkey = new char[zoomLevel];
|
var quadkey = new char[zoomLevel];
|
||||||
|
|
@ -23,7 +22,7 @@ namespace MapControl
|
||||||
quadkey[z] = (char)('0' + 2 * (y % 2) + (x % 2));
|
quadkey[z] = (char)('0' + 2 * (y % 2) + (x % 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
uri = new Uri(UriFormat
|
uri = new Uri(UriTemplate
|
||||||
.Replace("{subdomain}", subdomain)
|
.Replace("{subdomain}", subdomain)
|
||||||
.Replace("{quadkey}", new string(quadkey)));
|
.Replace("{quadkey}", new string(quadkey)));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ namespace MapControl
|
||||||
{
|
{
|
||||||
Uri uri = null;
|
Uri uri = null;
|
||||||
|
|
||||||
if (UriFormat != null)
|
if (UriTemplate != null)
|
||||||
{
|
{
|
||||||
var tileSize = 360d / (1 << zoomLevel); // tile width in degrees
|
var tileSize = 360d / (1 << zoomLevel); // tile width in degrees
|
||||||
var west = MapProjection.Wgs84MeterPerDegree * (x * tileSize - 180d);
|
var west = MapProjection.Wgs84MeterPerDegree * (x * tileSize - 180d);
|
||||||
|
|
@ -21,14 +21,14 @@ namespace MapControl
|
||||||
var south = MapProjection.Wgs84MeterPerDegree * (180d - (y + 1) * tileSize);
|
var south = MapProjection.Wgs84MeterPerDegree * (180d - (y + 1) * tileSize);
|
||||||
var north = MapProjection.Wgs84MeterPerDegree * (180d - y * tileSize);
|
var north = MapProjection.Wgs84MeterPerDegree * (180d - y * tileSize);
|
||||||
|
|
||||||
if (UriFormat.Contains("{bbox}"))
|
if (UriTemplate.Contains("{bbox}"))
|
||||||
{
|
{
|
||||||
uri = new Uri(UriFormat.Replace("{bbox}",
|
uri = new Uri(UriTemplate.Replace("{bbox}",
|
||||||
string.Format(CultureInfo.InvariantCulture, "{0:F2},{1:F2},{2:F2},{3:F2}", west, south, east, north)));
|
string.Format(CultureInfo.InvariantCulture, "{0:F2},{1:F2},{2:F2},{3:F2}", west, south, east, north)));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
uri = new Uri(UriFormat
|
uri = new Uri(UriTemplate
|
||||||
.Replace("{west}", west.ToString("F2", CultureInfo.InvariantCulture))
|
.Replace("{west}", west.ToString("F2", CultureInfo.InvariantCulture))
|
||||||
.Replace("{south}", south.ToString("F2", CultureInfo.InvariantCulture))
|
.Replace("{south}", south.ToString("F2", CultureInfo.InvariantCulture))
|
||||||
.Replace("{east}", east.ToString("F2", CultureInfo.InvariantCulture))
|
.Replace("{east}", east.ToString("F2", CultureInfo.InvariantCulture))
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ namespace MapControl
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static MapTileLayer OpenStreetMapTileLayer => new MapTileLayer
|
public static MapTileLayer OpenStreetMapTileLayer => new MapTileLayer
|
||||||
{
|
{
|
||||||
TileSource = new TileSource { UriFormat = "https://tile.openstreetmap.org/{z}/{x}/{y}.png" },
|
TileSource = new TileSource { UriTemplate = "https://tile.openstreetmap.org/{z}/{x}/{y}.png" },
|
||||||
SourceName = "OpenStreetMap",
|
SourceName = "OpenStreetMap",
|
||||||
Description = "© [OpenStreetMap Contributors](http://www.openstreetmap.org/copyright)"
|
Description = "© [OpenStreetMap Contributors](http://www.openstreetmap.org/copyright)"
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -105,7 +105,7 @@ namespace MapControl
|
||||||
Progress.Report(0d);
|
Progress.Report(0d);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Cache == null || tileSource.UriFormat == null || !tileSource.UriFormat.StartsWith("http"))
|
if (Cache == null || tileSource.UriTemplate == null || !tileSource.UriTemplate.StartsWith("http"))
|
||||||
{
|
{
|
||||||
cacheName = null; // no tile caching
|
cacheName = null; // no tile caching
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,19 +22,19 @@ namespace MapControl
|
||||||
#endif
|
#endif
|
||||||
public class TileSource
|
public class TileSource
|
||||||
{
|
{
|
||||||
private string uriFormat;
|
private string uriTemplate;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the format string to produce tile request Uris.
|
/// Gets or sets the template string for tile request Uris.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string UriFormat
|
public string UriTemplate
|
||||||
{
|
{
|
||||||
get => uriFormat;
|
get => uriTemplate;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
uriFormat = value;
|
uriTemplate = value;
|
||||||
|
|
||||||
if (Subdomains == null && uriFormat != null && uriFormat.Contains("{s}"))
|
if (Subdomains == null && uriTemplate != null && uriTemplate.Contains("{s}"))
|
||||||
{
|
{
|
||||||
Subdomains = new string[] { "a", "b", "c" }; // default OpenStreetMap subdomains
|
Subdomains = new string[] { "a", "b", "c" }; // default OpenStreetMap subdomains
|
||||||
}
|
}
|
||||||
|
|
@ -53,9 +53,9 @@ namespace MapControl
|
||||||
{
|
{
|
||||||
Uri uri = null;
|
Uri uri = null;
|
||||||
|
|
||||||
if (UriFormat != null && x >= 0 && y >= 0 && zoomLevel >= 0)
|
if (UriTemplate != null && x >= 0 && y >= 0 && zoomLevel >= 0)
|
||||||
{
|
{
|
||||||
var uriString = UriFormat
|
var uriString = UriTemplate
|
||||||
.Replace("{x}", x.ToString())
|
.Replace("{x}", x.ToString())
|
||||||
.Replace("{y}", y.ToString())
|
.Replace("{y}", y.ToString())
|
||||||
.Replace("{z}", zoomLevel.ToString());
|
.Replace("{z}", zoomLevel.ToString());
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ namespace MapControl
|
||||||
|
|
||||||
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
|
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
|
||||||
{
|
{
|
||||||
return new TileSource { UriFormat = (string)value };
|
return new TileSource { UriTemplate = (string)value };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -328,8 +328,6 @@ namespace MapControl
|
||||||
var uri = ServiceUri.GetLeftPart(UriPartial.Path) + "?"
|
var uri = ServiceUri.GetLeftPart(UriPartial.Path) + "?"
|
||||||
+ string.Join("&", queryParameters.Select(kv => kv.Key + "=" + kv.Value));
|
+ string.Join("&", queryParameters.Select(kv => kv.Key + "=" + kv.Value));
|
||||||
|
|
||||||
Debug.WriteLine(uri);
|
|
||||||
|
|
||||||
return uri.Replace(" ", "%20");
|
return uri.Replace(" ", "%20");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,8 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Xml.Linq;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Xml.Linq;
|
||||||
#if !WINUI && !UWP
|
#if !WINUI && !UWP
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -19,6 +19,10 @@ namespace MapControl
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class WmtsCapabilities
|
public class WmtsCapabilities
|
||||||
{
|
{
|
||||||
|
private static readonly XNamespace ows = "http://www.opengis.net/ows/1.1";
|
||||||
|
private static readonly XNamespace wmts = "http://www.opengis.net/wmts/1.0";
|
||||||
|
private static readonly XNamespace xlink = "http://www.w3.org/1999/xlink";
|
||||||
|
|
||||||
public string LayerIdentifier { get; private set; }
|
public string LayerIdentifier { get; private set; }
|
||||||
public WmtsTileSource TileSource { get; private set; }
|
public WmtsTileSource TileSource { get; private set; }
|
||||||
public List<WmtsTileMatrixSet> TileMatrixSets { get; private set; }
|
public List<WmtsTileMatrixSet> TileMatrixSets { get; private set; }
|
||||||
|
|
@ -44,10 +48,7 @@ namespace MapControl
|
||||||
|
|
||||||
public static WmtsCapabilities ReadCapabilities(XElement capabilitiesElement, string layerIdentifier, string capabilitiesUrl)
|
public static WmtsCapabilities ReadCapabilities(XElement capabilitiesElement, string layerIdentifier, string capabilitiesUrl)
|
||||||
{
|
{
|
||||||
XNamespace ns = capabilitiesElement.Name.Namespace;
|
var contentsElement = capabilitiesElement.Element(wmts + "Contents");
|
||||||
XNamespace ows = "http://www.opengis.net/ows/1.1";
|
|
||||||
|
|
||||||
var contentsElement = capabilitiesElement.Element(ns + "Contents");
|
|
||||||
|
|
||||||
if (contentsElement == null)
|
if (contentsElement == null)
|
||||||
{
|
{
|
||||||
|
|
@ -58,7 +59,7 @@ namespace MapControl
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(layerIdentifier))
|
if (!string.IsNullOrEmpty(layerIdentifier))
|
||||||
{
|
{
|
||||||
layerElement = contentsElement.Descendants(ns + "Layer")
|
layerElement = contentsElement.Elements(wmts + "Layer")
|
||||||
.FirstOrDefault(e => e.Element(ows + "Identifier")?.Value == layerIdentifier);
|
.FirstOrDefault(e => e.Element(ows + "Identifier")?.Value == layerIdentifier);
|
||||||
|
|
||||||
if (layerElement == null)
|
if (layerElement == null)
|
||||||
|
|
@ -68,7 +69,7 @@ namespace MapControl
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
layerElement = capabilitiesElement.Descendants(ns + "Layer").FirstOrDefault();
|
layerElement = contentsElement.Elements(wmts + "Layer").FirstOrDefault();
|
||||||
|
|
||||||
if (layerElement == null)
|
if (layerElement == null)
|
||||||
{
|
{
|
||||||
|
|
@ -78,34 +79,33 @@ namespace MapControl
|
||||||
layerIdentifier = layerElement.Element(ows + "Identifier")?.Value ?? "";
|
layerIdentifier = layerElement.Element(ows + "Identifier")?.Value ?? "";
|
||||||
}
|
}
|
||||||
|
|
||||||
var styleElement = layerElement.Descendants(ns + "Style")
|
var styleElement = layerElement.Elements(wmts + "Style")
|
||||||
.FirstOrDefault(e => e.Attribute("isDefault")?.Value == "true");
|
.FirstOrDefault(e => e.Attribute("isDefault")?.Value == "true");
|
||||||
|
|
||||||
if (styleElement == null)
|
if (styleElement == null)
|
||||||
{
|
{
|
||||||
styleElement = layerElement.Descendants(ns + "Style").FirstOrDefault();
|
styleElement = layerElement.Elements(wmts + "Style").FirstOrDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
var style = styleElement?.Element(ows + "Identifier")?.Value;
|
var styleIdentifier = styleElement?.Element(ows + "Identifier")?.Value;
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(style))
|
if (string.IsNullOrEmpty(styleIdentifier))
|
||||||
{
|
{
|
||||||
throw new ArgumentException($"No valid Style element found in Layer \"{layerIdentifier}\".");
|
throw new ArgumentException($"No Style element found in Layer \"{layerIdentifier}\".");
|
||||||
}
|
}
|
||||||
|
|
||||||
var urlTemplate = ReadUrlTemplate(layerElement, layerIdentifier, style, capabilitiesUrl);
|
var urlTemplate = ReadUrlTemplate(capabilitiesElement, layerElement, layerIdentifier, styleIdentifier, capabilitiesUrl);
|
||||||
|
|
||||||
var tileMatrixSetIds = layerElement
|
var tileMatrixSetIds = layerElement
|
||||||
.Descendants(ns + "TileMatrixSetLink")
|
.Elements(wmts + "TileMatrixSetLink")
|
||||||
.Select(e => e.Element(ns + "TileMatrixSet")?.Value)
|
.Select(e => e.Element(wmts + "TileMatrixSet")?.Value)
|
||||||
.Where(id => !string.IsNullOrEmpty(id))
|
.Where(id => !string.IsNullOrEmpty(id));
|
||||||
.ToList();
|
|
||||||
|
|
||||||
var tileMatrixSets = new List<WmtsTileMatrixSet>();
|
var tileMatrixSets = new List<WmtsTileMatrixSet>();
|
||||||
|
|
||||||
foreach (var tileMatrixSetId in tileMatrixSetIds)
|
foreach (var tileMatrixSetId in tileMatrixSetIds)
|
||||||
{
|
{
|
||||||
var tileMatrixSetElement = capabilitiesElement.Descendants(ns + "TileMatrixSet")
|
var tileMatrixSetElement = contentsElement.Elements(wmts + "TileMatrixSet")
|
||||||
.FirstOrDefault(e => e.Element(ows + "Identifier")?.Value == tileMatrixSetId);
|
.FirstOrDefault(e => e.Element(ows + "Identifier")?.Value == tileMatrixSetId);
|
||||||
|
|
||||||
if (tileMatrixSetElement == null)
|
if (tileMatrixSetElement == null)
|
||||||
|
|
@ -119,19 +119,18 @@ namespace MapControl
|
||||||
return new WmtsCapabilities
|
return new WmtsCapabilities
|
||||||
{
|
{
|
||||||
LayerIdentifier = layerIdentifier,
|
LayerIdentifier = layerIdentifier,
|
||||||
TileSource = new WmtsTileSource { UriFormat = urlTemplate },
|
TileSource = new WmtsTileSource { UriTemplate = urlTemplate },
|
||||||
TileMatrixSets = tileMatrixSets
|
TileMatrixSets = tileMatrixSets
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string ReadUrlTemplate(XElement layerElement, string layerIdentifier, string style, string capabilitiesUrl)
|
public static string ReadUrlTemplate(XElement capabilitiesElement, XElement layerElement, string layerIdentifier, string styleIdentifier, string capabilitiesUrl)
|
||||||
{
|
{
|
||||||
XNamespace ns = layerElement.Name.Namespace;
|
|
||||||
const string formatPng = "image/png";
|
const string formatPng = "image/png";
|
||||||
const string formatJpg = "image/jpeg";
|
const string formatJpg = "image/jpeg";
|
||||||
string urlTemplate = null;
|
string urlTemplate = null;
|
||||||
|
|
||||||
var resourceUrls = layerElement.Descendants(ns + "ResourceURL")
|
var resourceUrls = layerElement.Elements(wmts + "ResourceURL")
|
||||||
.ToLookup(e => e.Attribute("format")?.Value ?? "", e => e.Attribute("template")?.Value ?? "");
|
.ToLookup(e => e.Attribute("format")?.Value ?? "", e => e.Attribute("template")?.Value ?? "");
|
||||||
|
|
||||||
if (resourceUrls.Any())
|
if (resourceUrls.Any())
|
||||||
|
|
@ -140,39 +139,47 @@ namespace MapControl
|
||||||
: resourceUrls.Contains(formatJpg) ? resourceUrls[formatJpg]
|
: resourceUrls.Contains(formatJpg) ? resourceUrls[formatJpg]
|
||||||
: resourceUrls.First();
|
: resourceUrls.First();
|
||||||
|
|
||||||
urlTemplate = urlTemplates.First().Replace("{Style}", style);
|
urlTemplate = urlTemplates.First().Replace("{Style}", styleIdentifier);
|
||||||
}
|
}
|
||||||
else if (capabilitiesUrl != null &&
|
else
|
||||||
capabilitiesUrl.IndexOf("Request=GetCapabilities", StringComparison.OrdinalIgnoreCase) >= 0)
|
|
||||||
{
|
{
|
||||||
// no ResourceURL and GetCapabilities KVP request, use GetTile KVP request encoding
|
var requestUrl = capabilitiesElement
|
||||||
|
.Elements(ows + "OperationsMetadata")
|
||||||
|
.Elements(ows + "Operation").Where(e => e.Attribute("name")?.Value == "GetTile")
|
||||||
|
.Elements(ows + "DCP")
|
||||||
|
.Elements(ows + "HTTP")
|
||||||
|
.Elements(ows + "Get").Select(e => e.Attribute(xlink + "href")?.Value)
|
||||||
|
.FirstOrDefault();
|
||||||
|
|
||||||
var formats = layerElement.Descendants(ns + "Format").Select(e => e.Value).ToList();
|
if (requestUrl == null &&
|
||||||
var format = formatPng;
|
capabilitiesUrl != null &&
|
||||||
|
capabilitiesUrl.IndexOf("Request=GetCapabilities", StringComparison.OrdinalIgnoreCase) >= 0)
|
||||||
if (formats.Count > 0)
|
|
||||||
{
|
{
|
||||||
format = formats.Contains(formatPng) ? formatPng
|
requestUrl = capabilitiesUrl;
|
||||||
: formats.Contains(formatJpg) ? formatJpg
|
|
||||||
: formats[0];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
urlTemplate = capabilitiesUrl.Split('?')[0]
|
if (requestUrl != null)
|
||||||
+ "?Service=WMTS"
|
{
|
||||||
+ "&Request=GetTile"
|
var formats = layerElement.Elements(wmts + "Format").Select(e => e.Value);
|
||||||
+ "&Version=1.0.0"
|
var format = formats.Contains(formatPng) ? formatPng
|
||||||
+ "&Layer=" + layerIdentifier
|
: formats.Contains(formatJpg) ? formatJpg
|
||||||
+ "&Style=" + style
|
: formats.FirstOrDefault();
|
||||||
+ "&Format=" + format
|
|
||||||
+ "&TileMatrixSet={TileMatrixSet}"
|
if (string.IsNullOrEmpty(format))
|
||||||
+ "&TileMatrix={TileMatrix}"
|
{
|
||||||
+ "&TileRow={TileRow}"
|
format = formatPng;
|
||||||
+ "&TileCol={TileCol}";
|
}
|
||||||
|
|
||||||
|
urlTemplate = requestUrl.Split('?')[0]
|
||||||
|
+ "?Service=WMTS&Request=GetTile&Version=1.0.0"
|
||||||
|
+ "&Layer=" + layerIdentifier + "&Style=" + styleIdentifier + "&Format=" + format
|
||||||
|
+ "&TileMatrixSet={TileMatrixSet}&TileMatrix={TileMatrix}&TileRow={TileRow}&TileCol={TileCol}";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(urlTemplate))
|
if (string.IsNullOrEmpty(urlTemplate))
|
||||||
{
|
{
|
||||||
throw new ArgumentException($"No valid ResourceURL element found in Layer \"{layerIdentifier}\".");
|
throw new ArgumentException($"No ResourceURL element in Layer \"{layerIdentifier}\" and no GetTile KVP Operation Metadata found.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return urlTemplate;
|
return urlTemplate;
|
||||||
|
|
@ -180,21 +187,18 @@ namespace MapControl
|
||||||
|
|
||||||
public static WmtsTileMatrixSet ReadTileMatrixSet(XElement tileMatrixSetElement)
|
public static WmtsTileMatrixSet ReadTileMatrixSet(XElement tileMatrixSetElement)
|
||||||
{
|
{
|
||||||
XNamespace ns = tileMatrixSetElement.Name.Namespace;
|
|
||||||
XNamespace ows = "http://www.opengis.net/ows/1.1";
|
|
||||||
|
|
||||||
var identifier = tileMatrixSetElement.Element(ows + "Identifier")?.Value;
|
var identifier = tileMatrixSetElement.Element(ows + "Identifier")?.Value;
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(identifier))
|
if (string.IsNullOrEmpty(identifier))
|
||||||
{
|
{
|
||||||
throw new ArgumentException("No ows:Identifier element found in TileMatrixSet.");
|
throw new ArgumentException("No Identifier element found in TileMatrixSet.");
|
||||||
}
|
}
|
||||||
|
|
||||||
var supportedCrs = tileMatrixSetElement.Element(ows + "SupportedCRS")?.Value;
|
var supportedCrs = tileMatrixSetElement.Element(ows + "SupportedCRS")?.Value;
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(supportedCrs))
|
if (string.IsNullOrEmpty(supportedCrs))
|
||||||
{
|
{
|
||||||
throw new ArgumentException($"No ows:SupportedCRS element found in TileMatrixSet \"{identifier}\".");
|
throw new ArgumentException($"No SupportedCRS element found in TileMatrixSet \"{identifier}\".");
|
||||||
}
|
}
|
||||||
|
|
||||||
const string urnPrefix = "urn:ogc:def:crs:EPSG:";
|
const string urnPrefix = "urn:ogc:def:crs:EPSG:";
|
||||||
|
|
@ -211,7 +215,7 @@ namespace MapControl
|
||||||
|
|
||||||
var tileMatrixes = new List<WmtsTileMatrix>();
|
var tileMatrixes = new List<WmtsTileMatrix>();
|
||||||
|
|
||||||
foreach (var tileMatrixElement in tileMatrixSetElement.Descendants(ns + "TileMatrix"))
|
foreach (var tileMatrixElement in tileMatrixSetElement.Elements(wmts + "TileMatrix"))
|
||||||
{
|
{
|
||||||
tileMatrixes.Add(ReadTileMatrix(tileMatrixElement, supportedCrs));
|
tileMatrixes.Add(ReadTileMatrix(tileMatrixElement, supportedCrs));
|
||||||
}
|
}
|
||||||
|
|
@ -226,17 +230,14 @@ namespace MapControl
|
||||||
|
|
||||||
public static WmtsTileMatrix ReadTileMatrix(XElement tileMatrixElement, string supportedCrs)
|
public static WmtsTileMatrix ReadTileMatrix(XElement tileMatrixElement, string supportedCrs)
|
||||||
{
|
{
|
||||||
XNamespace ns = tileMatrixElement.Name.Namespace;
|
|
||||||
XNamespace ows = "http://www.opengis.net/ows/1.1";
|
|
||||||
|
|
||||||
var identifier = tileMatrixElement.Element(ows + "Identifier")?.Value;
|
var identifier = tileMatrixElement.Element(ows + "Identifier")?.Value;
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(identifier))
|
if (string.IsNullOrEmpty(identifier))
|
||||||
{
|
{
|
||||||
throw new ArgumentException("No ows:Identifier element found in TileMatrix.");
|
throw new ArgumentException("No Identifier element found in TileMatrix.");
|
||||||
}
|
}
|
||||||
|
|
||||||
var valueString = tileMatrixElement.Element(ns + "ScaleDenominator")?.Value;
|
var valueString = tileMatrixElement.Element(wmts + "ScaleDenominator")?.Value;
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(valueString) ||
|
if (string.IsNullOrEmpty(valueString) ||
|
||||||
!double.TryParse(valueString, NumberStyles.Float, CultureInfo.InvariantCulture, out double scaleDenominator))
|
!double.TryParse(valueString, NumberStyles.Float, CultureInfo.InvariantCulture, out double scaleDenominator))
|
||||||
|
|
@ -244,7 +245,7 @@ namespace MapControl
|
||||||
throw new ArgumentException($"No ScaleDenominator element found in TileMatrix \"{identifier}\".");
|
throw new ArgumentException($"No ScaleDenominator element found in TileMatrix \"{identifier}\".");
|
||||||
}
|
}
|
||||||
|
|
||||||
valueString = tileMatrixElement.Element(ns + "TopLeftCorner")?.Value;
|
valueString = tileMatrixElement.Element(wmts + "TopLeftCorner")?.Value;
|
||||||
string[] topLeftCornerStrings;
|
string[] topLeftCornerStrings;
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(valueString) ||
|
if (string.IsNullOrEmpty(valueString) ||
|
||||||
|
|
@ -255,28 +256,28 @@ namespace MapControl
|
||||||
throw new ArgumentException($"No TopLeftCorner element found in TileMatrix \"{identifier}\".");
|
throw new ArgumentException($"No TopLeftCorner element found in TileMatrix \"{identifier}\".");
|
||||||
}
|
}
|
||||||
|
|
||||||
valueString = tileMatrixElement.Element(ns + "TileWidth")?.Value;
|
valueString = tileMatrixElement.Element(wmts + "TileWidth")?.Value;
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(valueString) || !int.TryParse(valueString, out int tileWidth))
|
if (string.IsNullOrEmpty(valueString) || !int.TryParse(valueString, out int tileWidth))
|
||||||
{
|
{
|
||||||
throw new ArgumentException($"No TileWidth element found in TileMatrix \"{identifier}\".");
|
throw new ArgumentException($"No TileWidth element found in TileMatrix \"{identifier}\".");
|
||||||
}
|
}
|
||||||
|
|
||||||
valueString = tileMatrixElement.Element(ns + "TileHeight")?.Value;
|
valueString = tileMatrixElement.Element(wmts + "TileHeight")?.Value;
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(valueString) || !int.TryParse(valueString, out int tileHeight))
|
if (string.IsNullOrEmpty(valueString) || !int.TryParse(valueString, out int tileHeight))
|
||||||
{
|
{
|
||||||
throw new ArgumentException($"No TileHeight element found in TileMatrix \"{identifier}\".");
|
throw new ArgumentException($"No TileHeight element found in TileMatrix \"{identifier}\".");
|
||||||
}
|
}
|
||||||
|
|
||||||
valueString = tileMatrixElement.Element(ns + "MatrixWidth")?.Value;
|
valueString = tileMatrixElement.Element(wmts + "MatrixWidth")?.Value;
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(valueString) || !int.TryParse(valueString, out int matrixWidth))
|
if (string.IsNullOrEmpty(valueString) || !int.TryParse(valueString, out int matrixWidth))
|
||||||
{
|
{
|
||||||
throw new ArgumentException($"No MatrixWidth element found in TileMatrix \"{identifier}\".");
|
throw new ArgumentException($"No MatrixWidth element found in TileMatrix \"{identifier}\".");
|
||||||
}
|
}
|
||||||
|
|
||||||
valueString = tileMatrixElement.Element(ns + "MatrixHeight")?.Value;
|
valueString = tileMatrixElement.Element(wmts + "MatrixHeight")?.Value;
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(valueString) || !int.TryParse(valueString, out int matrixHeight))
|
if (string.IsNullOrEmpty(valueString) || !int.TryParse(valueString, out int matrixHeight))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -14,11 +14,11 @@ namespace MapControl
|
||||||
{
|
{
|
||||||
Uri uri = null;
|
Uri uri = null;
|
||||||
|
|
||||||
if (UriFormat != null &&
|
if (UriTemplate != null &&
|
||||||
TileMatrixSet != null && TileMatrixSet.TileMatrixes.Count > zoomLevel &&
|
TileMatrixSet != null && TileMatrixSet.TileMatrixes.Count > zoomLevel &&
|
||||||
x >= 0 && y >= 0 && zoomLevel >= 0)
|
x >= 0 && y >= 0 && zoomLevel >= 0)
|
||||||
{
|
{
|
||||||
uri = new Uri(UriFormat
|
uri = new Uri(UriTemplate
|
||||||
.Replace("{TileMatrixSet}", TileMatrixSet.Identifier)
|
.Replace("{TileMatrixSet}", TileMatrixSet.Identifier)
|
||||||
.Replace("{TileMatrix}", TileMatrixSet.TileMatrixes[zoomLevel].Identifier)
|
.Replace("{TileMatrix}", TileMatrixSet.TileMatrixes[zoomLevel].Identifier)
|
||||||
.Replace("{TileCol}", x.ToString())
|
.Replace("{TileCol}", x.ToString())
|
||||||
|
|
|
||||||
|
|
@ -148,7 +148,7 @@
|
||||||
SourceName="OpenStreetMap"
|
SourceName="OpenStreetMap"
|
||||||
Description="© [OpenStreetMap contributors](http://www.openstreetmap.org/copyright)">
|
Description="© [OpenStreetMap contributors](http://www.openstreetmap.org/copyright)">
|
||||||
<map:MapTileLayer.TileSource>
|
<map:MapTileLayer.TileSource>
|
||||||
<map:TileSource UriFormat="https://tile.openstreetmap.org/{z}/{x}/{y}.png"/>
|
<map:TileSource UriTemplate="https://tile.openstreetmap.org/{z}/{x}/{y}.png"/>
|
||||||
</map:MapTileLayer.TileSource>
|
</map:MapTileLayer.TileSource>
|
||||||
</map:MapTileLayer>
|
</map:MapTileLayer>
|
||||||
</tools:MapLayerItem>
|
</tools:MapLayerItem>
|
||||||
|
|
@ -157,7 +157,7 @@
|
||||||
SourceName="OpenStreetMap German"
|
SourceName="OpenStreetMap German"
|
||||||
Description="© [OpenStreetMap contributors](http://www.openstreetmap.org/copyright)">
|
Description="© [OpenStreetMap contributors](http://www.openstreetmap.org/copyright)">
|
||||||
<map:MapTileLayer.TileSource>
|
<map:MapTileLayer.TileSource>
|
||||||
<map:TileSource UriFormat="https://{s}.tile.openstreetmap.de/{z}/{x}/{y}.png"/>
|
<map:TileSource UriTemplate="https://{s}.tile.openstreetmap.de/{z}/{x}/{y}.png"/>
|
||||||
</map:MapTileLayer.TileSource>
|
</map:MapTileLayer.TileSource>
|
||||||
</map:MapTileLayer>
|
</map:MapTileLayer>
|
||||||
</tools:MapLayerItem>
|
</tools:MapLayerItem>
|
||||||
|
|
@ -166,7 +166,7 @@
|
||||||
SourceName="OpenStreetMap French"
|
SourceName="OpenStreetMap French"
|
||||||
Description="© [OpenStreetMap France](https://www.openstreetmap.fr/mentions-legales/) © [OpenStreetMap contributors](http://www.openstreetmap.org/copyright)">
|
Description="© [OpenStreetMap France](https://www.openstreetmap.fr/mentions-legales/) © [OpenStreetMap contributors](http://www.openstreetmap.org/copyright)">
|
||||||
<map:MapTileLayer.TileSource>
|
<map:MapTileLayer.TileSource>
|
||||||
<map:TileSource UriFormat="http://{s}.tile.openstreetmap.fr/osmfr/{z}/{x}/{y}.png"/>
|
<map:TileSource UriTemplate="http://{s}.tile.openstreetmap.fr/osmfr/{z}/{x}/{y}.png"/>
|
||||||
</map:MapTileLayer.TileSource>
|
</map:MapTileLayer.TileSource>
|
||||||
</map:MapTileLayer>
|
</map:MapTileLayer>
|
||||||
</tools:MapLayerItem>
|
</tools:MapLayerItem>
|
||||||
|
|
@ -175,7 +175,7 @@
|
||||||
SourceName="OpenTopoMap"
|
SourceName="OpenTopoMap"
|
||||||
Description="© [OpenTopoMap](https://opentopomap.org/) © [OpenStreetMap contributors](http://www.openstreetmap.org/copyright)">
|
Description="© [OpenTopoMap](https://opentopomap.org/) © [OpenStreetMap contributors](http://www.openstreetmap.org/copyright)">
|
||||||
<map:MapTileLayer.TileSource>
|
<map:MapTileLayer.TileSource>
|
||||||
<map:TileSource UriFormat="https://tile.opentopomap.org/{z}/{x}/{y}.png"/>
|
<map:TileSource UriTemplate="https://tile.opentopomap.org/{z}/{x}/{y}.png"/>
|
||||||
</map:MapTileLayer.TileSource>
|
</map:MapTileLayer.TileSource>
|
||||||
</map:MapTileLayer>
|
</map:MapTileLayer>
|
||||||
</tools:MapLayerItem>
|
</tools:MapLayerItem>
|
||||||
|
|
@ -206,7 +206,7 @@
|
||||||
<tools:MapLayerItem Text="Seamarks">
|
<tools:MapLayerItem Text="Seamarks">
|
||||||
<map:MapTileLayer SourceName="Seamarks" MinZoomLevel="9" MaxZoomLevel="18">
|
<map:MapTileLayer SourceName="Seamarks" MinZoomLevel="9" MaxZoomLevel="18">
|
||||||
<map:MapTileLayer.TileSource>
|
<map:MapTileLayer.TileSource>
|
||||||
<map:TileSource UriFormat="http://tiles.openseamap.org/seamark/{z}/{x}/{y}.png"/>
|
<map:TileSource UriTemplate="http://tiles.openseamap.org/seamark/{z}/{x}/{y}.png"/>
|
||||||
</map:MapTileLayer.TileSource>
|
</map:MapTileLayer.TileSource>
|
||||||
</map:MapTileLayer>
|
</map:MapTileLayer>
|
||||||
</tools:MapLayerItem>
|
</tools:MapLayerItem>
|
||||||
|
|
|
||||||
|
|
@ -143,7 +143,7 @@
|
||||||
</ProgressBar.Visibility>
|
</ProgressBar.Visibility>
|
||||||
</ProgressBar>
|
</ProgressBar>
|
||||||
|
|
||||||
<TextBlock Margin="4,2" FontSize="10" local:HyperlinkText.InlinesSource="{Binding Description}"/>
|
<TextBlock Margin="4,1,4,3" FontSize="10" local:HyperlinkText.InlinesSource="{Binding Description}"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
<StackPanel HorizontalAlignment="Left" VerticalAlignment="Top" Margin="6">
|
<StackPanel HorizontalAlignment="Left" VerticalAlignment="Top" Margin="6">
|
||||||
|
|
@ -155,7 +155,7 @@
|
||||||
SourceName="OpenStreetMap"
|
SourceName="OpenStreetMap"
|
||||||
Description="© [OpenStreetMap contributors](http://www.openstreetmap.org/copyright)">
|
Description="© [OpenStreetMap contributors](http://www.openstreetmap.org/copyright)">
|
||||||
<map:MapTileLayer.TileSource>
|
<map:MapTileLayer.TileSource>
|
||||||
<map:TileSource UriFormat="https://tile.openstreetmap.org/{z}/{x}/{y}.png"/>
|
<map:TileSource UriTemplate="https://tile.openstreetmap.org/{z}/{x}/{y}.png"/>
|
||||||
</map:MapTileLayer.TileSource>
|
</map:MapTileLayer.TileSource>
|
||||||
</map:MapTileLayer>
|
</map:MapTileLayer>
|
||||||
</tools:MapLayerItem>
|
</tools:MapLayerItem>
|
||||||
|
|
@ -164,7 +164,7 @@
|
||||||
SourceName="OpenStreetMap German"
|
SourceName="OpenStreetMap German"
|
||||||
Description="© [OpenStreetMap contributors](http://www.openstreetmap.org/copyright)">
|
Description="© [OpenStreetMap contributors](http://www.openstreetmap.org/copyright)">
|
||||||
<map:MapTileLayer.TileSource>
|
<map:MapTileLayer.TileSource>
|
||||||
<map:TileSource UriFormat="https://{s}.tile.openstreetmap.de/{z}/{x}/{y}.png"/>
|
<map:TileSource UriTemplate="https://{s}.tile.openstreetmap.de/{z}/{x}/{y}.png"/>
|
||||||
</map:MapTileLayer.TileSource>
|
</map:MapTileLayer.TileSource>
|
||||||
</map:MapTileLayer>
|
</map:MapTileLayer>
|
||||||
</tools:MapLayerItem>
|
</tools:MapLayerItem>
|
||||||
|
|
@ -173,7 +173,7 @@
|
||||||
SourceName="OpenStreetMap French"
|
SourceName="OpenStreetMap French"
|
||||||
Description="© [OpenStreetMap France](https://www.openstreetmap.fr/mentions-legales/) © [OpenStreetMap contributors](http://www.openstreetmap.org/copyright)">
|
Description="© [OpenStreetMap France](https://www.openstreetmap.fr/mentions-legales/) © [OpenStreetMap contributors](http://www.openstreetmap.org/copyright)">
|
||||||
<map:MapTileLayer.TileSource>
|
<map:MapTileLayer.TileSource>
|
||||||
<map:TileSource UriFormat="http://{s}.tile.openstreetmap.fr/osmfr/{z}/{x}/{y}.png"/>
|
<map:TileSource UriTemplate="http://{s}.tile.openstreetmap.fr/osmfr/{z}/{x}/{y}.png"/>
|
||||||
</map:MapTileLayer.TileSource>
|
</map:MapTileLayer.TileSource>
|
||||||
</map:MapTileLayer>
|
</map:MapTileLayer>
|
||||||
</tools:MapLayerItem>
|
</tools:MapLayerItem>
|
||||||
|
|
@ -182,7 +182,7 @@
|
||||||
SourceName="OpenTopoMap"
|
SourceName="OpenTopoMap"
|
||||||
Description="© [OpenTopoMap](https://opentopomap.org/) © [OpenStreetMap contributors](http://www.openstreetmap.org/copyright)">
|
Description="© [OpenTopoMap](https://opentopomap.org/) © [OpenStreetMap contributors](http://www.openstreetmap.org/copyright)">
|
||||||
<map:MapTileLayer.TileSource>
|
<map:MapTileLayer.TileSource>
|
||||||
<map:TileSource UriFormat="https://tile.opentopomap.org/{z}/{x}/{y}.png"/>
|
<map:TileSource UriTemplate="https://tile.opentopomap.org/{z}/{x}/{y}.png"/>
|
||||||
</map:MapTileLayer.TileSource>
|
</map:MapTileLayer.TileSource>
|
||||||
</map:MapTileLayer>
|
</map:MapTileLayer>
|
||||||
</tools:MapLayerItem>
|
</tools:MapLayerItem>
|
||||||
|
|
@ -190,12 +190,14 @@
|
||||||
<map:WmtsTileLayer
|
<map:WmtsTileLayer
|
||||||
SourceName="TopPlusOpen"
|
SourceName="TopPlusOpen"
|
||||||
Description="© [BKG](https://gdz.bkg.bund.de/index.php/default/webdienste/topplus-produkte/wmts-topplusopen-wmts-topplus-open.html)"
|
Description="© [BKG](https://gdz.bkg.bund.de/index.php/default/webdienste/topplus-produkte/wmts-topplusopen-wmts-topplus-open.html)"
|
||||||
CapabilitiesUri="https://sgx.geodatenzentrum.de/wmts_topplus_open/1.0.0/WMTSCapabilities.xml"/>
|
CapabilitiesUri="https://sgx.geodatenzentrum.de/wmts_topplus_open/1.0.0/WMTSCapabilities.xml"
|
||||||
|
LayerIdentifier="web_light_grau"/>
|
||||||
</tools:MapLayerItem>
|
</tools:MapLayerItem>
|
||||||
<tools:MapLayerItem Text="TopPlusOpen WMS">
|
<tools:MapLayerItem Text="TopPlusOpen WMS">
|
||||||
<map:WmsImageLayer
|
<map:WmsImageLayer
|
||||||
Description="© [BKG](https://gdz.bkg.bund.de/index.php/default/webdienste/topplus-produkte/wms-topplusopen-mit-layer-fur-normalausgabe-und-druck-wms-topplus-open.html)"
|
Description="© [BKG](https://gdz.bkg.bund.de/index.php/default/webdienste/topplus-produkte/wms-topplusopen-mit-layer-fur-normalausgabe-und-druck-wms-topplus-open.html)"
|
||||||
ServiceUri="https://sgx.geodatenzentrum.de/wms_topplus_open"/>
|
ServiceUri="https://sgx.geodatenzentrum.de/wms_topplus_open"
|
||||||
|
Layers="web_grau"/>
|
||||||
</tools:MapLayerItem>
|
</tools:MapLayerItem>
|
||||||
<tools:MapLayerItem Text="OpenStreetMap WMS">
|
<tools:MapLayerItem Text="OpenStreetMap WMS">
|
||||||
<map:WmsImageLayer
|
<map:WmsImageLayer
|
||||||
|
|
@ -213,7 +215,7 @@
|
||||||
<tools:MapLayerItem Text="Seamarks">
|
<tools:MapLayerItem Text="Seamarks">
|
||||||
<map:MapTileLayer SourceName="Seamarks" MinZoomLevel="9" MaxZoomLevel="18">
|
<map:MapTileLayer SourceName="Seamarks" MinZoomLevel="9" MaxZoomLevel="18">
|
||||||
<map:MapTileLayer.TileSource>
|
<map:MapTileLayer.TileSource>
|
||||||
<map:TileSource UriFormat="http://tiles.openseamap.org/seamark/{z}/{x}/{y}.png"/>
|
<map:TileSource UriTemplate="http://tiles.openseamap.org/seamark/{z}/{x}/{y}.png"/>
|
||||||
</map:MapTileLayer.TileSource>
|
</map:MapTileLayer.TileSource>
|
||||||
</map:MapTileLayer>
|
</map:MapTileLayer>
|
||||||
</tools:MapLayerItem>
|
</tools:MapLayerItem>
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
Description="© [OpenTopoMap](https://opentopomap.org/) © [OpenStreetMap contributors](http://www.openstreetmap.org/copyright)"/>
|
Description="© [OpenTopoMap](https://opentopomap.org/) © [OpenStreetMap contributors](http://www.openstreetmap.org/copyright)"/>
|
||||||
<map:MapTileLayer
|
<map:MapTileLayer
|
||||||
x:Key="Seamarks"
|
x:Key="Seamarks"
|
||||||
TileSource="http://tiles.openseamap.org/seamark/{z}/{x}/{y}.png"
|
TileSource="https://tiles.openseamap.org/seamark/{z}/{x}/{y}.png"
|
||||||
SourceName="Seamarks"
|
SourceName="Seamarks"
|
||||||
MinZoomLevel="9"
|
MinZoomLevel="9"
|
||||||
MaxZoomLevel="18"/>
|
MaxZoomLevel="18"/>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue