mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
Use C# 7
This commit is contained in:
parent
d6f16782ff
commit
3ffb613f80
|
|
@ -23,9 +23,7 @@ namespace MapControl
|
|||
return new Point();
|
||||
}
|
||||
|
||||
double azimuth, distance;
|
||||
|
||||
GetAzimuthDistance(Center, location, out azimuth, out distance);
|
||||
GetAzimuthDistance(Center, location, out double azimuth, out double distance);
|
||||
|
||||
var mapDistance = distance * Wgs84EquatorialRadius;
|
||||
|
||||
|
|
|
|||
|
|
@ -86,9 +86,8 @@ namespace MapControl
|
|||
{
|
||||
var zoomMin = metadata.Element(ns + "ZoomMin")?.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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,9 +26,7 @@ namespace MapControl
|
|||
return new Point();
|
||||
}
|
||||
|
||||
double azimuth, distance;
|
||||
|
||||
GetAzimuthDistance(Center, location, out azimuth, out distance);
|
||||
GetAzimuthDistance(Center, location, out double azimuth, out double distance);
|
||||
|
||||
var mapDistance = distance < Math.PI / 2d
|
||||
? Math.Tan(distance) * Wgs84EquatorialRadius
|
||||
|
|
|
|||
|
|
@ -33,11 +33,10 @@ namespace MapControl
|
|||
while (!string.IsNullOrEmpty(text))
|
||||
{
|
||||
var match = regex.Match(text);
|
||||
Uri uri;
|
||||
|
||||
if (match.Success &&
|
||||
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) });
|
||||
text = text.Substring(match.Index + match.Length);
|
||||
|
|
|
|||
|
|
@ -81,10 +81,9 @@ namespace MapControl
|
|||
{
|
||||
if (responseMessage.IsSuccessStatusCode)
|
||||
{
|
||||
IEnumerable<string> tileInfo;
|
||||
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"))
|
||||
{
|
||||
buffer = await responseMessage.Content.ReadAsByteArrayAsync().ConfigureAwait(continueOnCapturedContext);
|
||||
|
|
|
|||
|
|
@ -26,9 +26,7 @@ namespace MapControl
|
|||
return new Point();
|
||||
}
|
||||
|
||||
double azimuth, distance;
|
||||
|
||||
GetAzimuthDistance(Center, location, out azimuth, out distance);
|
||||
GetAzimuthDistance(Center, location, out double azimuth, out double distance);
|
||||
|
||||
var mapDistance = Math.Tan(distance / 2d) * 2d * Wgs84EquatorialRadius;
|
||||
|
||||
|
|
|
|||
|
|
@ -89,16 +89,16 @@ namespace MapControl
|
|||
{
|
||||
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()
|
||||
{
|
||||
Tile tile;
|
||||
|
||||
while (tileQueue.TryDequeue(out tile))
|
||||
while (tileQueue.TryDequeue(out Tile tile))
|
||||
{
|
||||
tile.Pending = false;
|
||||
|
||||
|
|
|
|||
|
|
@ -174,52 +174,49 @@ namespace MapControl
|
|||
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;
|
||||
|
||||
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 + "\".");
|
||||
}
|
||||
|
||||
valueString = tileMatrixElement.Element(ns + "TopLeftCorner")?.Value;
|
||||
string[] topLeftCornerStrings;
|
||||
|
||||
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))
|
||||
!double.TryParse(topLeftCornerStrings[0], NumberStyles.Float, CultureInfo.InvariantCulture, out double left) ||
|
||||
!double.TryParse(topLeftCornerStrings[1], NumberStyles.Float, CultureInfo.InvariantCulture, out double top))
|
||||
{
|
||||
throw new ArgumentException("No TopLeftCorner element found in TileMatrix \"" + identifier + "\".");
|
||||
}
|
||||
|
||||
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 + "\".");
|
||||
}
|
||||
|
||||
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 + "\".");
|
||||
}
|
||||
|
||||
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 + "\".");
|
||||
}
|
||||
|
||||
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 + "\".");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -85,10 +85,8 @@ namespace MapControl
|
|||
{
|
||||
UpdateTimer.Stop();
|
||||
|
||||
WmtsTileMatrixSet tileMatrixSet;
|
||||
|
||||
if (ParentMap == null ||
|
||||
!TileMatrixSets.TryGetValue(ParentMap.MapProjection.CrsId, out tileMatrixSet))
|
||||
!TileMatrixSets.TryGetValue(ParentMap.MapProjection.CrsId, out WmtsTileMatrixSet tileMatrixSet))
|
||||
{
|
||||
Children.Clear();
|
||||
UpdateTiles(null);
|
||||
|
|
|
|||
Loading…
Reference in a new issue