mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
Updated WmtsTileMatrixSet
This commit is contained in:
parent
65c20c76b2
commit
d09832988c
|
|
@ -19,13 +19,21 @@ namespace MapControl
|
||||||
public static WmtsTileMatrixSet CreateOpenStreetMapTileMatrixSet(
|
public static WmtsTileMatrixSet CreateOpenStreetMapTileMatrixSet(
|
||||||
string uriTemplate, int minZoomLevel = 0, int maxZoomLevel = 19)
|
string uriTemplate, int minZoomLevel = 0, int maxZoomLevel = 19)
|
||||||
{
|
{
|
||||||
const int tileSize = 256;
|
static WmtsTileMatrix CreateWmtsTileMatrix(int zoomLevel)
|
||||||
const double baseScale = tileSize / (360d * MapProjection.Wgs84MeterPerDegree);
|
{
|
||||||
|
const int tileSize = 256;
|
||||||
|
const double origin = 180d * MapProjection.Wgs84MeterPerDegree;
|
||||||
|
|
||||||
Point mapTopLeft = new(-180d * MapProjection.Wgs84MeterPerDegree,
|
var matrixSize = 1 << zoomLevel;
|
||||||
180d * MapProjection.Wgs84MeterPerDegree);
|
var scale = matrixSize * tileSize / (2d * origin);
|
||||||
|
|
||||||
return new WmtsTileMatrixSet(null,
|
return new WmtsTileMatrix(
|
||||||
|
zoomLevel.ToString(), scale, new Point(-origin, origin),
|
||||||
|
tileSize, tileSize, matrixSize, matrixSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new WmtsTileMatrixSet(
|
||||||
|
null,
|
||||||
WebMercatorProjection.DefaultCrsId,
|
WebMercatorProjection.DefaultCrsId,
|
||||||
uriTemplate
|
uriTemplate
|
||||||
.Replace("{z}", "{0}")
|
.Replace("{z}", "{0}")
|
||||||
|
|
@ -33,11 +41,7 @@ namespace MapControl
|
||||||
.Replace("{y}", "{2}"),
|
.Replace("{y}", "{2}"),
|
||||||
Enumerable
|
Enumerable
|
||||||
.Range(minZoomLevel, maxZoomLevel - minZoomLevel + 1)
|
.Range(minZoomLevel, maxZoomLevel - minZoomLevel + 1)
|
||||||
.Select<int, (int zoomLevel, int matrixSize)>(z => (z, 1 << z))
|
.Select(CreateWmtsTileMatrix));
|
||||||
.Select(t => new WmtsTileMatrix(
|
|
||||||
t.zoomLevel.ToString(),
|
|
||||||
t.matrixSize * baseScale, mapTopLeft,
|
|
||||||
tileSize, tileSize, t.matrixSize, t.matrixSize)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue