This commit is contained in:
ClemensF 2020-04-16 19:24:38 +02:00
parent d6f16782ff
commit 3ffb613f80
9 changed files with 19 additions and 33 deletions

View file

@ -23,9 +23,7 @@ namespace MapControl
return new Point(); return new Point();
} }
double azimuth, distance; GetAzimuthDistance(Center, location, out double azimuth, out double distance);
GetAzimuthDistance(Center, location, out azimuth, out distance);
var mapDistance = distance * Wgs84EquatorialRadius; var mapDistance = distance * Wgs84EquatorialRadius;

View file

@ -86,9 +86,8 @@ namespace MapControl
{ {
var zoomMin = metadata.Element(ns + "ZoomMin")?.Value; var zoomMin = metadata.Element(ns + "ZoomMin")?.Value;
var zoomMax = metadata.Element(ns + "ZoomMax")?.Value; var zoomMax = metadata.Element(ns + "ZoomMax")?.Value;
int zoomLevel;
if (zoomMin != null && int.TryParse(zoomMin, out zoomLevel) && MinZoomLevel < zoomLevel) if (zoomMin != null && int.TryParse(zoomMin, out int zoomLevel) && MinZoomLevel < zoomLevel)
{ {
MinZoomLevel = zoomLevel; MinZoomLevel = zoomLevel;
} }

View file

@ -26,9 +26,7 @@ namespace MapControl
return new Point(); return new Point();
} }
double azimuth, distance; GetAzimuthDistance(Center, location, out double azimuth, out double distance);
GetAzimuthDistance(Center, location, out azimuth, out distance);
var mapDistance = distance < Math.PI / 2d var mapDistance = distance < Math.PI / 2d
? Math.Tan(distance) * Wgs84EquatorialRadius ? Math.Tan(distance) * Wgs84EquatorialRadius

View file

@ -33,11 +33,10 @@ namespace MapControl
while (!string.IsNullOrEmpty(text)) while (!string.IsNullOrEmpty(text))
{ {
var match = regex.Match(text); var match = regex.Match(text);
Uri uri;
if (match.Success && if (match.Success &&
match.Groups.Count == 3 && match.Groups.Count == 3 &&
Uri.TryCreate(match.Groups[2].Value, UriKind.Absolute, out uri)) Uri.TryCreate(match.Groups[2].Value, UriKind.Absolute, out Uri uri))
{ {
inlines.Add(new Run { Text = text.Substring(0, match.Index) }); inlines.Add(new Run { Text = text.Substring(0, match.Index) });
text = text.Substring(match.Index + match.Length); text = text.Substring(match.Index + match.Length);

View file

@ -81,10 +81,9 @@ namespace MapControl
{ {
if (responseMessage.IsSuccessStatusCode) if (responseMessage.IsSuccessStatusCode)
{ {
IEnumerable<string> tileInfo;
byte[] buffer = null; byte[] buffer = null;
if (!responseMessage.Headers.TryGetValues("X-VE-Tile-Info", out tileInfo) || if (!responseMessage.Headers.TryGetValues("X-VE-Tile-Info", out IEnumerable<string> tileInfo) ||
!tileInfo.Contains("no-tile")) !tileInfo.Contains("no-tile"))
{ {
buffer = await responseMessage.Content.ReadAsByteArrayAsync().ConfigureAwait(continueOnCapturedContext); buffer = await responseMessage.Content.ReadAsByteArrayAsync().ConfigureAwait(continueOnCapturedContext);

View file

@ -26,9 +26,7 @@ namespace MapControl
return new Point(); return new Point();
} }
double azimuth, distance; GetAzimuthDistance(Center, location, out double azimuth, out double distance);
GetAzimuthDistance(Center, location, out azimuth, out distance);
var mapDistance = Math.Tan(distance / 2d) * 2d * Wgs84EquatorialRadius; var mapDistance = Math.Tan(distance / 2d) * 2d * Wgs84EquatorialRadius;

View file

@ -89,16 +89,16 @@ namespace MapControl
{ {
Interlocked.Add(ref taskCount, newTasks); Interlocked.Add(ref taskCount, newTasks);
await Task.WhenAll(Enumerable.Range(0, newTasks).Select(n => LoadTilesFromQueueAsync())).ConfigureAwait(false); var tasks = Enumerable.Range(0, newTasks).Select(n => LoadTilesFromQueueAsync());
await Task.WhenAll(tasks).ConfigureAwait(false);
} }
} }
} }
private async Task LoadTilesFromQueueAsync() private async Task LoadTilesFromQueueAsync()
{ {
Tile tile; while (tileQueue.TryDequeue(out Tile tile))
while (tileQueue.TryDequeue(out tile))
{ {
tile.Pending = false; tile.Pending = false;

View file

@ -174,52 +174,49 @@ namespace MapControl
throw new ArgumentException("No ows:Identifier element found in TileMatrix."); throw new ArgumentException("No ows:Identifier element found in TileMatrix.");
} }
string[] topLeftCornerStrings;
double scaleDenominator, top, left;
int tileWidth, tileHeight, matrixWidth, matrixHeight;
var valueString = tileMatrixElement.Element(ns + "ScaleDenominator")?.Value; var valueString = tileMatrixElement.Element(ns + "ScaleDenominator")?.Value;
if (string.IsNullOrEmpty(valueString) || if (string.IsNullOrEmpty(valueString) ||
!double.TryParse(valueString, NumberStyles.Float, CultureInfo.InvariantCulture, out scaleDenominator)) !double.TryParse(valueString, NumberStyles.Float, CultureInfo.InvariantCulture, out double scaleDenominator))
{ {
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(ns + "TopLeftCorner")?.Value;
string[] topLeftCornerStrings;
if (string.IsNullOrEmpty(valueString) || if (string.IsNullOrEmpty(valueString) ||
(topLeftCornerStrings = valueString.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)).Length < 2 || (topLeftCornerStrings = valueString.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)).Length < 2 ||
!double.TryParse(topLeftCornerStrings[0], NumberStyles.Float, CultureInfo.InvariantCulture, out left) || !double.TryParse(topLeftCornerStrings[0], NumberStyles.Float, CultureInfo.InvariantCulture, out double left) ||
!double.TryParse(topLeftCornerStrings[1], NumberStyles.Float, CultureInfo.InvariantCulture, out top)) !double.TryParse(topLeftCornerStrings[1], NumberStyles.Float, CultureInfo.InvariantCulture, out double top))
{ {
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(ns + "TileWidth")?.Value;
if (string.IsNullOrEmpty(valueString) || !int.TryParse(valueString, out 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(ns + "TileHeight")?.Value;
if (string.IsNullOrEmpty(valueString) || !int.TryParse(valueString, out 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(ns + "MatrixWidth")?.Value;
if (string.IsNullOrEmpty(valueString) || !int.TryParse(valueString, out 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(ns + "MatrixHeight")?.Value;
if (string.IsNullOrEmpty(valueString) || !int.TryParse(valueString, out matrixHeight)) if (string.IsNullOrEmpty(valueString) || !int.TryParse(valueString, out int matrixHeight))
{ {
throw new ArgumentException("No MatrixHeight element found in TileMatrix \"" + identifier + "\"."); throw new ArgumentException("No MatrixHeight element found in TileMatrix \"" + identifier + "\".");
} }

View file

@ -85,10 +85,8 @@ namespace MapControl
{ {
UpdateTimer.Stop(); UpdateTimer.Stop();
WmtsTileMatrixSet tileMatrixSet;
if (ParentMap == null || if (ParentMap == null ||
!TileMatrixSets.TryGetValue(ParentMap.MapProjection.CrsId, out tileMatrixSet)) !TileMatrixSets.TryGetValue(ParentMap.MapProjection.CrsId, out WmtsTileMatrixSet tileMatrixSet))
{ {
Children.Clear(); Children.Clear();
UpdateTiles(null); UpdateTiles(null);