private bool SetTileMatrix() { var tileMatrixZoomLevel = (int)Math.Floor(ParentMap.ZoomLevel + 0.001); // avoid rounding issues var tileMatrixScale = ViewTransform.ZoomLevelToScale(tileMatrixZoomLevel); // bounds in tile pixels from view size // var bounds = ParentMap.ViewTransform.GetTileMatrixBounds(tileMatrixScale, MapTopLeft, ParentMap.RenderSize); // tile column and row index bounds // var xMin = (int)Math.Floor(bounds.X / TileSize); var yMin = (int)Math.Floor(bounds.Y / TileSize); var xMax = (int)Math.Floor((bounds.X + bounds.Width) / TileSize); var yMax = (int)Math.Floor((bounds.Y + bounds.Height) / TileSize); if (TileMatrix != null && TileMatrix.ZoomLevel == tileMatrixZoomLevel && TileMatrix.XMin == xMin && TileMatrix.YMin == yMin && TileMatrix.XMax == xMax && TileMatrix.YMax == yMax) { return(false); } TileMatrix = new TileMatrix(tileMatrixZoomLevel, xMin, yMin, xMax, yMax); return(true); }
public bool SetBounds(ViewTransform viewTransform, Size viewSize) { // bounds in tile pixels from view size // var bounds = viewTransform.GetTileMatrixBounds(TileMatrix.Scale, TileMatrix.TopLeft, viewSize); // tile column and row index bounds // var xMin = (int)Math.Floor(bounds.X / TileMatrix.TileWidth); var yMin = (int)Math.Floor(bounds.Y / TileMatrix.TileHeight); var xMax = (int)Math.Floor((bounds.X + bounds.Width) / TileMatrix.TileWidth); var yMax = (int)Math.Floor((bounds.Y + bounds.Height) / TileMatrix.TileHeight); xMin = Math.Max(xMin, 0); yMin = Math.Max(yMin, 0); xMax = Math.Min(Math.Max(xMax, 0), TileMatrix.MatrixWidth - 1); yMax = Math.Min(Math.Max(yMax, 0), TileMatrix.MatrixHeight - 1); if (XMin == xMin && YMin == yMin && XMax == xMax && YMax == yMax) { return(false); } XMin = xMin; YMin = yMin; XMax = xMax; YMax = yMax; return(true); }
public void SetRenderTransform(ViewTransform viewTransform) { // tile matrix origin in pixels // var tileMatrixOrigin = new Point(TileMatrix.TileWidth * XMin, TileMatrix.TileHeight * YMin); ((MatrixTransform)RenderTransform).Matrix = viewTransform.GetTileLayerTransform(TileMatrix.Scale, TileMatrix.TopLeft, tileMatrixOrigin); }
protected override void SetRenderTransform() { // tile matrix origin in pixels // var tileMatrixOrigin = new Point(TileSize * TileMatrix.XMin, TileSize * TileMatrix.YMin); var tileMatrixScale = ViewTransform.ZoomLevelToScale(TileMatrix.ZoomLevel); ((MatrixTransform)RenderTransform).Matrix = ParentMap.ViewTransform.GetTileLayerTransform(tileMatrixScale, MapTopLeft, tileMatrixOrigin); }