private Matrix <double> GetPictureDrawMatrix(SKPicture picture, Position gpsPosition, Size pixelSize) { Size platformPixelsSize = pixelSize * PlatformPixelScale; Matrix <double> matrix = Matrix <double> .Build.DenseIdentity(3, 3); Point mercatorPosition = gpsPosition.ToMercator(); SKRect sourceRect = picture.CullRect; SKMapSpan drawSpan = PixelsToMapSpanAtScale(platformPixelsSize, gpsPosition, _ScaleFactor); double xScale = platformPixelsSize.Width / sourceRect.Width; double yScale = platformPixelsSize.Height / sourceRect.Height; SKPoint canvasPoint; if (drawSpan.Crosses180thMeridianRight() && _MercatorRenderArea.Left < SKMapExtensions.MercatorCenterOffset) { // We cross the 180th meridian to the right and are drawing to a tile on the left side of the map, so wrap around mercatorPosition.X -= SKMapExtensions.MercatorMapSize; } if (drawSpan.Crosses180thMeridianLeft() && _MercatorRenderArea.Right > SKMapExtensions.MercatorCenterOffset) { // We cross the 180th meridian to the right and are drawing to a tile on the left side of the map, so wrap around mercatorPosition.X += SKMapExtensions.MercatorMapSize; } canvasPoint = ApplyMatrix(mercatorPosition); matrix *= Matrix <double> .Build.Translation(canvasPoint.X, canvasPoint.Y); matrix *= Matrix <double> .Build.Scale(xScale, yScale); matrix *= Matrix <double> .Build.Translation(sourceRect.Width * -0.5, sourceRect.Height * -0.5); return(matrix); }
public static bool Crosses180thMeridian(this SKMapSpan self) { return(self.Crosses180thMeridianRight() || self.Crosses180thMeridianLeft()); }