public SkiaSharp.SKPoint PlaceInfoToSKPoint(PraxisCore.StandaloneDbTables.PlaceInfo2 pi, ImageStats imgstats) { SkiaSharp.SKPoint point = new SkiaSharp.SKPoint(); point.X = (float)((pi.lonCenter - imgstats.area.WestLongitude) * (1 / imgstats.degreesPerPixelX)); point.Y = (float)((pi.latCenter - imgstats.area.SouthLatitude) * (1 / imgstats.degreesPerPixelY)); return(point); }
public Rectangle PlaceInfoToRect(PraxisCore.StandaloneDbTables.PlaceInfo2 pi, ImageStats info) { //TODO test this. Rectangle r = new Rectangle(); float heightMod = (float)pi.height / 2; float widthMod = (float)pi.width / 2; r.Width = (int)(pi.width * info.pixelsPerDegreeX); r.Height = (int)(pi.height * info.pixelsPerDegreeY); r.X = (int)(pi.lonCenter * info.pixelsPerDegreeX); r.Y = (int)(pi.latCenter * info.pixelsPerDegreeY); return(r); }
/// <summary> /// Converts the offline-standalone PlaceInfo entries into SKRects for drawing on a SlippyMap. Used to visualize the offline mode beahvior of areas. /// </summary> /// <param name="pi">PlaceInfo object to convert</param> /// <param name="info">ImageStats for the resulting map tile</param> /// <returns>The SKRect representing the standaloneDb size of the PlaceInfo</returns> public SkiaSharp.SKRect PlaceInfoToRect(PraxisCore.StandaloneDbTables.PlaceInfo2 pi, ImageStats info) { SkiaSharp.SKRect r = new SkiaSharp.SKRect(); float heightMod = (float)pi.height / 2; float widthMod = (float)pi.width / 2; r.Left = (float)pi.lonCenter - widthMod; r.Left = (float)(r.Left - info.area.WestLongitude) * (float)(1 / info.degreesPerPixelX); r.Right = (float)pi.lonCenter + widthMod; r.Right = (float)(r.Right - info.area.WestLongitude) * (float)(1 / info.degreesPerPixelX); r.Top = (float)pi.latCenter + heightMod; r.Top = (float)(r.Top - info.area.SouthLatitude) * (float)(1 / info.degreesPerPixelY); r.Bottom = (float)pi.latCenter - heightMod; r.Bottom = (float)(r.Bottom - info.area.SouthLatitude) * (float)(1 / info.degreesPerPixelY); return(r); }
public SkiaSharp.SKPoint[] PlaceInfoToSKPoints(PraxisCore.StandaloneDbTables.PlaceInfo2 pi, ImageStats info) { float heightMod = (float)pi.height / 2; float widthMod = (float)pi.width / 2; var points = new SkiaSharp.SKPoint[5]; points[0] = new SkiaSharp.SKPoint((float)(pi.lonCenter + widthMod), (float)(pi.latCenter + heightMod)); //upper right corner points[1] = new SkiaSharp.SKPoint((float)(pi.lonCenter + widthMod), (float)(pi.latCenter - heightMod)); //lower right points[2] = new SkiaSharp.SKPoint((float)(pi.lonCenter - widthMod), (float)(pi.latCenter - heightMod)); //lower left points[3] = new SkiaSharp.SKPoint((float)(pi.lonCenter - widthMod), (float)(pi.latCenter + heightMod)); //upper left points[4] = new SkiaSharp.SKPoint((float)(pi.lonCenter + widthMod), (float)(pi.latCenter + heightMod)); //upper right corner again for a closed shape. //points is now a geometric area. Convert to image area points = points.Select(p => new SkiaSharp.SKPoint((float)((p.X - info.area.WestLongitude) * (1 / info.degreesPerPixelX)), (float)((p.Y - info.area.SouthLatitude) * (1 / info.degreesPerPixelY)))).ToArray(); return(points); }