mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-06 06:55:04 +00:00
Updated WMTS implementation
This commit is contained in:
parent
375c5d0b58
commit
209d06adf5
6 changed files with 243 additions and 205 deletions
|
|
@ -2,9 +2,6 @@
|
|||
// © 2020 Clemens Fischer
|
||||
// Licensed under the Microsoft Public License (Ms-PL)
|
||||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Xml.Linq;
|
||||
#if !WINDOWS_UWP
|
||||
using System.Windows;
|
||||
#endif
|
||||
|
|
@ -32,71 +29,5 @@ namespace MapControl
|
|||
MatrixWidth = matrixWidth;
|
||||
MatrixHeight = matrixHeight;
|
||||
}
|
||||
|
||||
public static WmtsTileMatrix Create(XElement tileMatrixElement)
|
||||
{
|
||||
XNamespace ns = tileMatrixElement.Name.Namespace;
|
||||
XNamespace ows = "http://www.opengis.net/ows/1.1";
|
||||
|
||||
var identifier = tileMatrixElement.Element(ows + "Identifier")?.Value;
|
||||
|
||||
if (string.IsNullOrEmpty(identifier))
|
||||
{
|
||||
throw new ArgumentException("ows:Identifier element not found in TileMatrix.");
|
||||
}
|
||||
|
||||
string[] topLeftCornerStrings;
|
||||
double scaleDenominator, top, left;
|
||||
int tileWidth, tileHeight, matrixWidth, matrixHeight;
|
||||
|
||||
var valueString = tileMatrixElement.Element(ns + "ScaleDenominator")?.Value;
|
||||
|
||||
if (string.IsNullOrEmpty(valueString) ||
|
||||
!double.TryParse(valueString, NumberStyles.Float, CultureInfo.InvariantCulture, out scaleDenominator))
|
||||
{
|
||||
throw new ArgumentException("ScaleDenominator element not found in TileMatrix \"" + identifier + "\".");
|
||||
}
|
||||
|
||||
valueString = tileMatrixElement.Element(ns + "TopLeftCorner")?.Value;
|
||||
|
||||
if (string.IsNullOrEmpty(valueString) ||
|
||||
(topLeftCornerStrings = valueString.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)).Length < 2 ||
|
||||
!double.TryParse(topLeftCornerStrings[0], NumberStyles.Float, CultureInfo.InvariantCulture, out left) ||
|
||||
!double.TryParse(topLeftCornerStrings[1], NumberStyles.Float, CultureInfo.InvariantCulture, out top))
|
||||
{
|
||||
throw new ArgumentException("TopLeftCorner element not found in TileMatrix \"" + identifier + "\".");
|
||||
}
|
||||
|
||||
valueString = tileMatrixElement.Element(ns + "TileWidth")?.Value;
|
||||
|
||||
if (string.IsNullOrEmpty(valueString) || !int.TryParse(valueString, out tileWidth))
|
||||
{
|
||||
throw new ArgumentException("TileWidth element not found in TileMatrix \"" + identifier + "\".");
|
||||
}
|
||||
|
||||
valueString = tileMatrixElement.Element(ns + "TileHeight")?.Value;
|
||||
|
||||
if (string.IsNullOrEmpty(valueString) || !int.TryParse(valueString, out tileHeight))
|
||||
{
|
||||
throw new ArgumentException("TileHeight element not found in TileMatrix \"" + identifier + "\".");
|
||||
}
|
||||
|
||||
valueString = tileMatrixElement.Element(ns + "MatrixWidth")?.Value;
|
||||
|
||||
if (string.IsNullOrEmpty(valueString) || !int.TryParse(valueString, out matrixWidth))
|
||||
{
|
||||
throw new ArgumentException("MatrixWidth element not found in TileMatrix \"" + identifier + "\".");
|
||||
}
|
||||
|
||||
valueString = tileMatrixElement.Element(ns + "MatrixHeight")?.Value;
|
||||
|
||||
if (string.IsNullOrEmpty(valueString) || !int.TryParse(valueString, out matrixHeight))
|
||||
{
|
||||
throw new ArgumentException("MatrixHeight element not found in TileMatrix \"" + identifier + "\".");
|
||||
}
|
||||
|
||||
return new WmtsTileMatrix(
|
||||
identifier, scaleDenominator, new Point(left, top), tileWidth, tileHeight, matrixWidth, matrixHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue