internal static void RunTest(MapFile mapFile) { int tileX = MercatorProjection.LongitudeToTileX(0, ZOOM_LEVEL); int tileY = MercatorProjection.LatitudeToTileY(0, ZOOM_LEVEL); Tile tile = new Tile(tileX, tileY, ZOOM_LEVEL, 256); MapReadResult mapReadResult = mapFile.ReadMapData(tile); mapFile.Close(); Assert.AreEqual(mapReadResult.PointOfInterests.Count, 0); Assert.AreEqual(1, mapReadResult.Ways.Count); LatLong latLong1 = new LatLong(0.0, 0.0, true); LatLong latLong2 = new LatLong(0.0, 0.1, true); LatLong latLong3 = new LatLong(-0.1, 0.1, true); LatLong latLong4 = new LatLong(-0.1, 0.0, true); LatLong[][] latLongsExpected = new LatLong[][] { new LatLong[] { latLong1, latLong2, latLong3, latLong4, latLong1 } }; Way way = mapReadResult.Ways[0]; // TODO: Was ArrayEquals() Assert.AreEqual(latLongsExpected, way.LatLongs); }
private void AdjustFrameBufferMatrix(MapPosition mapPositionFrameBuffer, Dimension mapViewDimension, double scaleFactor, LatLong pivot) { MapPosition mapViewPosition = this.model.mapViewPosition.MapPosition; long mapSize = MercatorProjection.GetMapSize(mapPositionFrameBuffer.ZoomLevel, model.displayModel.TileSize); Point pointFrameBuffer = MercatorProjection.GetPixel(mapPositionFrameBuffer.LatLong, mapSize); Point pointMapPosition = MercatorProjection.GetPixel(mapViewPosition.LatLong, mapSize); double diffX = pointFrameBuffer.X - pointMapPosition.X; double diffY = pointFrameBuffer.Y - pointMapPosition.Y; // we need to compute the pivot distance from the map center // as we will need to find the pivot point for the // frame buffer (which generally has not the same size as the // map view). double pivotDistanceX = 0d; double pivotDistanceY = 0d; if (pivot != null) { Point pivotXY = MercatorProjection.GetPixel(pivot, mapSize); pivotDistanceX = pivotXY.X - pointFrameBuffer.X; pivotDistanceY = pivotXY.Y - pointFrameBuffer.Y; } float currentScaleFactor = (float)(scaleFactor / Math.Pow(2, mapPositionFrameBuffer.ZoomLevel)); this.frameBuffer.AdjustMatrix((float)diffX, (float)diffY, currentScaleFactor, mapViewDimension, (float)pivotDistanceX, (float)pivotDistanceY); }
public override void Draw(BoundingBox boundingBox, sbyte zoomLevel, ICanvas canvas, Point topLeftPoint) { long tileLeft = MercatorProjection.LongitudeToTileX(boundingBox.MinLongitude, zoomLevel); long tileTop = MercatorProjection.LatitudeToTileY(boundingBox.MaxLatitude, zoomLevel); long tileRight = MercatorProjection.LongitudeToTileX(boundingBox.MaxLongitude, zoomLevel); long tileBottom = MercatorProjection.LatitudeToTileY(boundingBox.MinLatitude, zoomLevel); int tileSize = this.displayModel.TileSize; int pixelX1 = (int)(MercatorProjection.TileToPixel(tileLeft, tileSize) - topLeftPoint.X); int pixelY1 = (int)(MercatorProjection.TileToPixel(tileTop, tileSize) - topLeftPoint.Y); int pixelX2 = (int)(MercatorProjection.TileToPixel(tileRight, tileSize) - topLeftPoint.X + tileSize); int pixelY2 = (int)(MercatorProjection.TileToPixel(tileBottom, tileSize) - topLeftPoint.Y + tileSize); for (int lineX = pixelX1; lineX <= pixelX2 + 1; lineX += tileSize) { canvas.DrawLine(lineX, pixelY1, lineX, pixelY2, this.paintBack); } for (int lineY = pixelY1; lineY <= pixelY2 + 1; lineY += tileSize) { canvas.DrawLine(pixelX1, lineY, pixelX2, lineY, this.paintBack); } for (int lineX = pixelX1; lineX <= pixelX2 + 1; lineX += tileSize) { canvas.DrawLine(lineX, pixelY1, lineX, pixelY2, this.paintFront); } for (int lineY = pixelY1; lineY <= pixelY2 + 1; lineY += tileSize) { canvas.DrawLine(pixelX1, lineY, pixelX2, lineY, this.paintFront); } }
public void RenderPointOfInterestCircle(RenderContext renderContext, float radius, IPaint fill, IPaint stroke, int level, PointOfInterest poi) { Point poiPosition = MercatorProjection.GetPixelRelativeToTile(poi.Position, renderContext.rendererJob.tile); renderContext.AddToCurrentDrawingLayer(level, new ShapePaintContainer(new CircleContainer(poiPosition, radius), stroke)); renderContext.AddToCurrentDrawingLayer(level, new ShapePaintContainer(new CircleContainer(poiPosition, radius), fill)); }
public virtual void ExecuteQueryTest() { MapFile mapFile = new MapFile(MAP_FILE); MapFileInfo mapFileInfo = mapFile.MapFileInfo; Assert.True(mapFileInfo.DebugFile); for (sbyte zoomLevel = ZOOM_LEVEL_MIN; zoomLevel <= ZOOM_LEVEL_MAX; ++zoomLevel) { int tileX = MercatorProjection.LongitudeToTileX(0.04, zoomLevel); int tileY = MercatorProjection.LatitudeToTileY(0.04, zoomLevel); Tile tile = new Tile(tileX, tileY, zoomLevel, 256); MapReadResult mapReadResult = mapFile.ReadMapData(tile); Assert.AreEqual(1, mapReadResult.PointOfInterests.Count); Assert.AreEqual(1, mapReadResult.Ways.Count); CheckPointOfInterest(mapReadResult.PointOfInterests[0]); CheckWay(mapReadResult.Ways[0]); } mapFile.Close(); }
/// <summary> /// Converts geographic coordinates to view x/y coordinates in the map view. /// </summary> /// <param name="in"> /// the geographic coordinates </param> /// <returns> x/y view coordinates for the given location </returns> public virtual Point ToPixels(LatLong @in) { if (@in == null || this.mapView.Width <= 0 || this.mapView.Height <= 0) { return(null); } MapPosition mapPosition = this.mapView.Model.mapViewPosition.MapPosition; // this means somehow the mapview is not yet properly set up, see issue #308. if (mapPosition == null) { return(null); } // calculate the pixel coordinates of the top left corner LatLong latLong = mapPosition.LatLong; long mapSize = MercatorProjection.GetMapSize(mapPosition.ZoomLevel, this.mapView.Model.displayModel.TileSize); double pixelX = MercatorProjection.LongitudeToPixelX(latLong.Longitude, mapSize); double pixelY = MercatorProjection.LatitudeToPixelY(latLong.Latitude, mapSize); pixelX -= this.mapView.Width >> 1; pixelY -= this.mapView.Height >> 1; // create a new point and return it return(new Point((int)(MercatorProjection.LongitudeToPixelX(@in.Longitude, mapSize) - pixelX), (int)(MercatorProjection.LatitudeToPixelY(@in.Latitude, mapSize) - pixelY))); }
public override void Draw(BoundingBox boundingBox, sbyte zoomLevel, ICanvas canvas, Point topLeftPoint) { lock (this) { if (this.latLong == null || this.bitmap == null) { return; } long mapSize = MercatorProjection.GetMapSize(zoomLevel, this.displayModel.TileSize); double pixelX = MercatorProjection.LongitudeToPixelX(this.latLong.Longitude, mapSize); double pixelY = MercatorProjection.LatitudeToPixelY(this.latLong.Latitude, mapSize); int halfBitmapWidth = this.bitmap.Width / 2; int halfBitmapHeight = this.bitmap.Height / 2; int left = (int)(pixelX - topLeftPoint.X - halfBitmapWidth + this.horizontalOffset); int top = (int)(pixelY - topLeftPoint.Y - halfBitmapHeight + this.verticalOffset); int right = left + this.bitmap.Width; int bottom = top + this.bitmap.Height; Rectangle bitmapRectangle = new Rectangle(left, top, right, bottom); Rectangle canvasRectangle = new Rectangle(0, 0, canvas.Width, canvas.Height); if (!canvasRectangle.Intersects(bitmapRectangle)) { return; } canvas.DrawBitmap(this.bitmap, left, top); } }
/// <summary> /// The pivot point is the point the map zooms around. If the map zooms around its center null is returned, otherwise /// the zoom-specific x/y pixel coordinates for the MercatorProjection (note: not the x/y coordinates for the map /// view or the frame buffer, the MapViewPosition knows nothing about them). /// </summary> /// <param name="zoomLevel"> the zoomlevel to compute the x/y coordinates for </param> /// <returns> the x/y coordinates of the map pivot point if set or null otherwise. </returns> public virtual Point GetPivotXY(sbyte zoomLevel) { lock (this) { if (this.pivot != null) { return(MercatorProjection.GetPixel(this.pivot, MercatorProjection.GetMapSize(zoomLevel, displayModel.TileSize))); } return(null); } }
public static Point GetTopLeftPoint(MapPosition mapPosition, Dimension canvasDimension, int tileSize) { LatLong centerPoint = mapPosition.LatLong; int halfCanvasWidth = canvasDimension.Width / 2; int halfCanvasHeight = canvasDimension.Height / 2; long mapSize = MercatorProjection.GetMapSize(mapPosition.ZoomLevel, tileSize); double pixelX = Math.Round(MercatorProjection.LongitudeToPixelX(centerPoint.Longitude, mapSize)); double pixelY = Math.Round(MercatorProjection.LatitudeToPixelY(centerPoint.Latitude, mapSize)); return(new Point((int)pixelX - halfCanvasWidth, (int)pixelY - halfCanvasHeight)); }
public override void Draw(BoundingBox boundingBox, sbyte zoomLevel, ICanvas canvas, Point topLeftPoint) { lock (this) { if (this.latLongs.Count < 2 || (this.paintStroke == null && this.paintFill == null)) { return; } IEnumerator <LatLong> iterator = this.latLongs.GetEnumerator(); IPath path = this.graphicFactory.CreatePath(); LatLong latLong = iterator.Current; long mapSize = MercatorProjection.GetMapSize(zoomLevel, displayModel.TileSize); float x = (float)(MercatorProjection.LongitudeToPixelX(latLong.Longitude, mapSize) - topLeftPoint.X); float y = (float)(MercatorProjection.LatitudeToPixelY(latLong.Latitude, mapSize) - topLeftPoint.Y); path.MoveTo(x, y); while (iterator.MoveNext()) { latLong = iterator.Current; x = (float)(MercatorProjection.LongitudeToPixelX(latLong.Longitude, mapSize) - topLeftPoint.X); y = (float)(MercatorProjection.LatitudeToPixelY(latLong.Latitude, mapSize) - topLeftPoint.Y); path.LineTo(x, y); } if (this.paintStroke != null) { if (this.keepAligned) { this.paintStroke.SetBitmapShaderShift = topLeftPoint; } canvas.DrawPath(path, this.paintStroke); } if (this.paintFill != null) { if (this.keepAligned) { this.paintFill.SetBitmapShaderShift = topLeftPoint; } canvas.DrawPath(path, this.paintFill); } } }
public virtual void ExecuteQueryTest() { MapFile mapFile = new MapFile(MAP_FILE); for (sbyte zoomLevel = 0; zoomLevel <= ZOOM_LEVEL_MAX; ++zoomLevel) { int tileX = MercatorProjection.LongitudeToTileX(1, zoomLevel); int tileY = MercatorProjection.LatitudeToTileY(1, zoomLevel); Tile tile = new Tile(tileX, tileY, zoomLevel, 256); MapReadResult mapReadResult = mapFile.ReadMapData(tile); Assert.AreEqual(0, mapReadResult.PointOfInterests.Count); Assert.AreEqual(0, mapReadResult.Ways.Count); } mapFile.Close(); }
/// <summary> /// Moves the center position of the map by the given amount of pixels. /// </summary> /// <param name="moveHorizontal"> /// the amount of pixels to move this MapViewPosition horizontally. </param> /// <param name="moveVertical"> /// the amount of pixels to move this MapViewPosition vertically. </param> /// <param name="zoomLevelDiff"> /// the difference in desired zoom level. </param> /// <param name="animated"> /// whether the move should be animated. </param> public virtual void MoveCenterAndZoom(double moveHorizontal, double moveVertical, sbyte zoomLevelDiff, bool animated) { lock (this) { long mapSize = MercatorProjection.GetMapSize(this.zoomLevel, this.displayModel.TileSize); double pixelX = MercatorProjection.LongitudeToPixelX(this.longitude, mapSize) - moveHorizontal; double pixelY = MercatorProjection.LatitudeToPixelY(this.latitude, mapSize) - moveVertical; pixelX = Math.Min(Math.Max(0, pixelX), mapSize); pixelY = Math.Min(Math.Max(0, pixelY), mapSize); double newLatitude = MercatorProjection.PixelYToLatitude(pixelY, mapSize); double newLongitude = MercatorProjection.PixelXToLongitude(pixelX, mapSize); setCenterInternal(newLatitude, newLongitude); setZoomLevelInternal(this.zoomLevel + zoomLevelDiff, animated); } NotifyObservers(); }
public static ISet <Tile> GetTiles(BoundingBox boundingBox, sbyte zoomLevel, int tileSize) { int tileLeft = MercatorProjection.LongitudeToTileX(boundingBox.MinLongitude, zoomLevel); int tileTop = MercatorProjection.LatitudeToTileY(boundingBox.MaxLatitude, zoomLevel); int tileRight = MercatorProjection.LongitudeToTileX(boundingBox.MaxLongitude, zoomLevel); int tileBottom = MercatorProjection.LatitudeToTileY(boundingBox.MinLatitude, zoomLevel); ISet <Tile> tiles = new HashSet <Tile>(); for (int tileY = tileTop; tileY <= tileBottom; ++tileY) { for (int tileX = tileLeft; tileX <= tileRight; ++tileX) { tiles.Add(new Tile(tileX, tileY, zoomLevel, tileSize)); } } return(tiles); }
public static BoundingBox GetBoundingBox(MapPosition mapPosition, Dimension canvasDimension, int tileSize) { long mapSize = MercatorProjection.GetMapSize(mapPosition.ZoomLevel, tileSize); double pixelX = MercatorProjection.LongitudeToPixelX(mapPosition.LatLong.Longitude, mapSize); double pixelY = MercatorProjection.LatitudeToPixelY(mapPosition.LatLong.Latitude, mapSize); int halfCanvasWidth = canvasDimension.Width / 2; int halfCanvasHeight = canvasDimension.Height / 2; double pixelXMin = Math.Max(0, pixelX - halfCanvasWidth); double pixelYMin = Math.Max(0, pixelY - halfCanvasHeight); double pixelXMax = Math.Min(mapSize, pixelX + halfCanvasWidth); double pixelYMax = Math.Min(mapSize, pixelY + halfCanvasHeight); double minLatitude = MercatorProjection.PixelYToLatitude(pixelYMax, mapSize); double minLongitude = MercatorProjection.PixelXToLongitude(pixelXMin, mapSize); double maxLatitude = MercatorProjection.PixelYToLatitude(pixelYMin, mapSize); double maxLongitude = MercatorProjection.PixelXToLongitude(pixelXMax, mapSize); return(new BoundingBox(minLatitude, minLongitude, maxLatitude, maxLongitude)); }
public override void Draw(BoundingBox boundingBox, sbyte zoomLevel, ICanvas canvas, Point topLeftPoint) { lock (this) { if (this.latLong == null || (this.paintStroke == null && this.paintFill == null)) { return; } double latitude = this.latLong.Latitude; double longitude = this.latLong.Longitude; long mapSize = MercatorProjection.GetMapSize(zoomLevel, displayModel.TileSize); int pixelX = (int)(MercatorProjection.LongitudeToPixelX(longitude, mapSize) - topLeftPoint.X); int pixelY = (int)(MercatorProjection.LatitudeToPixelY(latitude, mapSize) - topLeftPoint.Y); int radiusInPixel = GetRadiusInPixels(latitude, zoomLevel); Rectangle canvasRectangle = new Rectangle(0, 0, canvas.Width, canvas.Height); if (!canvasRectangle.IntersectsCircle(pixelX, pixelY, radiusInPixel)) { return; } if (this.paintStroke != null) { if (this.keepAligned) { this.paintStroke.SetBitmapShaderShift = topLeftPoint; } canvas.DrawCircle(pixelX, pixelY, radiusInPixel, this.paintStroke); } if (this.paintFill != null) { if (this.keepAligned) { this.paintFill.SetBitmapShaderShift = topLeftPoint; } canvas.DrawCircle(pixelX, pixelY, radiusInPixel, this.paintFill); } } }
/// <summary> /// Calculates the required length and value of the scalebar /// </summary> /// <param name="unitAdapter"> /// the DistanceUnitAdapter to calculate for </param> /// <returns> a <seealso cref="ScaleBarLengthAndValue"/> object containing the required scaleBarLength and scaleBarValue </returns> protected internal virtual ScaleBarLengthAndValue CalculateScaleBarLengthAndValue(DistanceUnitAdapter unitAdapter) { this.prevMapPosition = this.mapViewPosition.MapPosition; double groundResolution = MercatorProjection.CalculateGroundResolution(this.prevMapPosition.LatLong.Latitude, MercatorProjection.GetMapSize(this.prevMapPosition.ZoomLevel, this.displayModel.TileSize)); groundResolution = groundResolution / unitAdapter.MeterRatio; int[] scaleBarValues = unitAdapter.ScaleBarValues; int scaleBarLength = 0; int mapScaleValue = 0; for (int i = 0; i < scaleBarValues.Length; ++i) { mapScaleValue = scaleBarValues[i]; scaleBarLength = (int)(mapScaleValue / groundResolution); if (scaleBarLength < (this.mapScaleBitmap.Width - 10)) { break; } } return(new ScaleBarLengthAndValue(scaleBarLength, mapScaleValue)); }
public static IList <TilePosition> GetTilePositions(BoundingBox boundingBox, sbyte zoomLevel, Point topLeftPoint, int tileSize) { int tileLeft = MercatorProjection.LongitudeToTileX(boundingBox.MinLongitude, zoomLevel); int tileTop = MercatorProjection.LatitudeToTileY(boundingBox.MaxLatitude, zoomLevel); int tileRight = MercatorProjection.LongitudeToTileX(boundingBox.MaxLongitude, zoomLevel); int tileBottom = MercatorProjection.LatitudeToTileY(boundingBox.MinLatitude, zoomLevel); int initialCapacity = (tileRight - tileLeft + 1) * (tileBottom - tileTop + 1); IList <TilePosition> tilePositions = new List <TilePosition>(initialCapacity); for (int tileY = tileTop; tileY <= tileBottom; ++tileY) { for (int tileX = tileLeft; tileX <= tileRight; ++tileX) { double pixelX = MercatorProjection.TileToPixel(tileX, tileSize) - topLeftPoint.X; double pixelY = MercatorProjection.TileToPixel(tileY, tileSize) - topLeftPoint.Y; tilePositions.Add(new TilePosition(new Tile(tileX, tileY, zoomLevel, tileSize), new Point(pixelX, pixelY))); } } return(tilePositions); }
/// <summary> /// Start animating the map towards the given point. /// </summary> public virtual void AnimateTo(LatLong pos) { new Task(async() => { int totalSteps = 25; // Define the Step Number int signX = 1; // Define the Sign for Horizontal Movement int signY = 1; // Define the Sign for Vertical Movement long mapSize = MercatorProjection.GetMapSize(ZoomLevel, displayModel.TileSize); double targetPixelX = MercatorProjection.LongitudeToPixelX(pos.Longitude, mapSize); double targetPixelY = MercatorProjection.LatitudeToPixelY(pos.Latitude, mapSize); double currentPixelX = MercatorProjection.LongitudeToPixelX(longitude, mapSize); double currentPixelY = MercatorProjection.LatitudeToPixelY(latitude, mapSize); double stepSizeX = Math.Abs(targetPixelX - currentPixelX) / totalSteps; double stepSizeY = Math.Abs(targetPixelY - currentPixelY) / totalSteps; /* Check the Signs */ if (currentPixelX < targetPixelX) { signX = -1; } if (currentPixelY < targetPixelY) { signY = -1; } /* Compute Scroll */ for (int i = 0; i < totalSteps; i++) { MoveCenter(stepSizeX * signX, stepSizeY * signY); await Task.Delay(10); } }).Start(); }
/// <summary> /// Computes the geographic coordinates of a screen point. /// </summary> /// <returns> the coordinates of the x/y point </returns> public virtual LatLong FromPixels(double x, double y) { if (this.mapView.Width <= 0 || this.mapView.Height <= 0) { return(null); } // this uses the framebuffer position, the mapview position can be out of sync with // what the user sees on the screen if an animation is in progress MapPosition mapPosition = this.mapView.Model.frameBufferModel.MapPosition; // this means somehow the mapview is not yet properly set up, see issue #308. if (mapPosition == null) { return(null); } // calculate the pixel coordinates of the top left corner LatLong latLong = mapPosition.LatLong; long mapSize = MercatorProjection.GetMapSize(mapPosition.ZoomLevel, this.mapView.Model.displayModel.TileSize); double pixelX = MercatorProjection.LongitudeToPixelX(latLong.Longitude, mapSize); double pixelY = MercatorProjection.LatitudeToPixelY(latLong.Latitude, mapSize); pixelX -= this.mapView.Width >> 1; pixelY -= this.mapView.Height >> 1; // catch outer map limits try { // convert the pixel coordinates to a LatLong and return it return(new LatLong(MercatorProjection.PixelYToLatitude(pixelY + y, mapSize), MercatorProjection.PixelXToLongitude(pixelX + x, mapSize))); } catch (Exception) { return(null); } }
/// <returns> the non-negative radius of this circle in pixels. </returns> protected internal virtual int GetRadiusInPixels(double latitude, sbyte zoomLevel) { return((int)MercatorProjection.MetersToPixels(this.radius, latitude, MercatorProjection.GetMapSize(zoomLevel, displayModel.TileSize))); }
public virtual bool AnimationInProgress() { return(this.scaleFactor != MercatorProjection.ZoomLevelToScaleFactor(this.zoomLevel)); }
public override void Draw(BoundingBox boundingBox, sbyte zoomLevel, ICanvas canvas, Point topLeftPoint) { if (spacingConfig.ContainsKey(zoomLevel)) { double spacing = spacingConfig[zoomLevel].Value; double minLongitude = spacing * (Math.Floor(boundingBox.MinLongitude / spacing)); double maxLongitude = spacing * (Math.Ceiling(boundingBox.MaxLongitude / spacing)); double minLatitude = spacing * (Math.Floor(boundingBox.MinLatitude / spacing)); double maxLatitude = spacing * (Math.Ceiling(boundingBox.MaxLatitude / spacing)); long mapSize = MercatorProjection.GetMapSize(zoomLevel, this.displayModel.TileSize); int bottom = (int)(MercatorProjection.LatitudeToPixelY(minLatitude, mapSize) - topLeftPoint.Y); int top = (int)(MercatorProjection.LatitudeToPixelY(maxLatitude, mapSize) - topLeftPoint.Y); int left = (int)(MercatorProjection.LongitudeToPixelX(minLongitude, mapSize) - topLeftPoint.X); int right = (int)(MercatorProjection.LongitudeToPixelX(maxLongitude, mapSize) - topLeftPoint.X); for (double latitude = minLatitude; latitude <= maxLatitude; latitude += spacing) { int pixelY = (int)(MercatorProjection.LatitudeToPixelY(latitude, mapSize) - topLeftPoint.Y); canvas.DrawLine(left, pixelY, right, pixelY, this.lineBack); } for (double longitude = minLongitude; longitude <= maxLongitude; longitude += spacing) { int pixelX = (int)(MercatorProjection.LongitudeToPixelX(longitude, mapSize) - topLeftPoint.X); canvas.DrawLine(pixelX, bottom, pixelX, top, this.lineBack); } for (double latitude = minLatitude; latitude <= maxLatitude; latitude += spacing) { int pixelY = (int)(MercatorProjection.LatitudeToPixelY(latitude, mapSize) - topLeftPoint.Y); canvas.DrawLine(left, pixelY, right, pixelY, this.lineFront); } for (double longitude = minLongitude; longitude <= maxLongitude; longitude += spacing) { int pixelX = (int)(MercatorProjection.LongitudeToPixelX(longitude, mapSize) - topLeftPoint.X); canvas.DrawLine(pixelX, bottom, pixelX, top, this.lineFront); } for (double latitude = minLatitude; latitude <= maxLatitude; latitude += spacing) { string text = ConvertCoordinate(latitude); int pixelX = (canvas.Width - this.textFront.GetTextWidth(text)) / 2; int pixelY = (int)(MercatorProjection.LatitudeToPixelY(latitude, mapSize) - topLeftPoint.Y) + this.textFront.GetTextHeight(text) / 2; canvas.DrawText(text, pixelX, pixelY, this.textBack); canvas.DrawText(text, pixelX, pixelY, this.textFront); } for (double longitude = minLongitude; longitude <= maxLongitude; longitude += spacing) { string text = ConvertCoordinate(longitude); int pixelX = (int)(MercatorProjection.LongitudeToPixelX(longitude, mapSize) - topLeftPoint.X) - this.textFront.GetTextWidth(text) / 2; int pixelY = (canvas.Height + this.textFront.GetTextHeight(text)) / 2; canvas.DrawText(text, pixelX, pixelY, this.textBack); canvas.DrawText(text, pixelX, pixelY, this.textFront); } } }
public void RenderPointOfInterestSymbol(RenderContext renderContext, Display display, int priority, IBitmap symbol, PointOfInterest poi) { Point poiPosition = MercatorProjection.GetPixelAbsolute(poi.Position, renderContext.rendererJob.tile.MapSize); renderContext.labels.Add(new SymbolContainer(poiPosition, display, priority, symbol)); }
public void RenderPointOfInterestCaption(RenderContext renderContext, Display display, int priority, string caption, float horizontalOffset, float verticalOffset, IPaint fill, IPaint stroke, Position position, int maxTextWidth, PointOfInterest poi) { Point poiPosition = MercatorProjection.GetPixelAbsolute(poi.Position, renderContext.rendererJob.tile.MapSize); renderContext.labels.Add(this.graphicFactory.CreatePointTextContainer(poiPosition.Offset(horizontalOffset, verticalOffset), display, priority, caption, fill, stroke, null, position, maxTextWidth)); }