mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-06 06:55:04 +00:00
Version 4.17.0: Added support for WMTS
This commit is contained in:
parent
b687487be2
commit
e06e910126
4 changed files with 204 additions and 173 deletions
|
|
@ -5,11 +5,16 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace MapControl
|
||||
{
|
||||
public class WmtsTileMatrixSet
|
||||
{
|
||||
public string Identifier { get; }
|
||||
public string SupportedCrs { get; }
|
||||
public IList<WmtsTileMatrix> TileMatrixes { get; }
|
||||
|
||||
public WmtsTileMatrixSet(string identifier, string supportedCrs, IEnumerable<WmtsTileMatrix> tileMatrixes)
|
||||
{
|
||||
if (string.IsNullOrEmpty(identifier))
|
||||
|
|
@ -32,8 +37,38 @@ namespace MapControl
|
|||
TileMatrixes = tileMatrixes.OrderBy(m => m.Scale).ToList();
|
||||
}
|
||||
|
||||
public string Identifier { get; }
|
||||
public string SupportedCrs { get; }
|
||||
public IList<WmtsTileMatrix> TileMatrixes { get; }
|
||||
public static WmtsTileMatrixSet Create(XElement tileMatrixSetElement)
|
||||
{
|
||||
XNamespace ns = tileMatrixSetElement.Name.Namespace;
|
||||
XNamespace ows = "http://www.opengis.net/ows/1.1";
|
||||
|
||||
var identifier = tileMatrixSetElement.Element(ows + "Identifier")?.Value;
|
||||
|
||||
if (string.IsNullOrEmpty(identifier))
|
||||
{
|
||||
throw new ArgumentException("ows:Identifier element not found in TileMatrixSet.");
|
||||
}
|
||||
|
||||
var supportedCrs = tileMatrixSetElement.Element(ows + "SupportedCRS")?.Value;
|
||||
|
||||
if (string.IsNullOrEmpty(supportedCrs))
|
||||
{
|
||||
throw new ArgumentException("ows:SupportedCRS element not found in TileMatrixSet \"" + identifier + "\".");
|
||||
}
|
||||
|
||||
var tileMatrixes = new List<WmtsTileMatrix>();
|
||||
|
||||
foreach (var tileMatrixElement in tileMatrixSetElement.Descendants(ns + "TileMatrix"))
|
||||
{
|
||||
tileMatrixes.Add(WmtsTileMatrix.Create(tileMatrixElement));
|
||||
}
|
||||
|
||||
if (tileMatrixes.Count <= 0)
|
||||
{
|
||||
throw new ArgumentException("No TileMatrix elements found in TileMatrixSet \"" + identifier + "\".");
|
||||
}
|
||||
|
||||
return new WmtsTileMatrixSet(identifier, supportedCrs, tileMatrixes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue