//@Override public bool draw(BoundingBox boundingBox, byte zoomLevel, Canvas canvas, MapCore.Model.MapPoint canvasPosition) { if (this.GeoPoint == null || this.Shape == null) { return(false); } double latitude = this.GeoPoint.Latitude; double longitude = this.GeoPoint.Longitude; double pixelX = (MercatorProjection.longitudeToPixelX(longitude, zoomLevel) - canvasPosition.X); double pixelY = (MercatorProjection.latitudeToPixelY(latitude, zoomLevel) - canvasPosition.Y); Rect drawableBounds = this.Shape.GetPosition(); double left = pixelX + drawableBounds.Left; double top = pixelY + drawableBounds.Top; double right = pixelX + drawableBounds.Right; double bottom = pixelY + drawableBounds.Bottom; if (!intersect(canvas, left, top, right, bottom)) { return(false); } var clone = this.Shape.Clone(); canvas.Children.Add(clone); Canvas.SetTop(clone, pixelX); Canvas.SetLeft(clone, pixelY); return(true); }
/** * @param zoomLevel * the zoom level at which this {@code PolygonalChain} should draw itself. * @param canvasPosition * the top-left pixel position of the canvas on the world map at the given zoom level. * @param closeAutomatically * whether the generated path should always be closed. * @return a {@code Path} representing this {@code PolygonalChain} (may be null). */ public Path draw ( byte zoomLevel, MapPoint canvasPosition, bool closeAutomatically ) { lock (this.GeoPoints) { int numberOfGeoPoints = this.GeoPoints.Count; if (numberOfGeoPoints < 2) { return null; } Path path = new Path(); PathGeometry geometry = new PathGeometry(); PathFigure figure = new PathFigure(); for (int i = 0; i < numberOfGeoPoints; ++i) { GeoPoint GeoPoint = this.GeoPoints[i]; double latitude = GeoPoint.Latitude; double longitude = GeoPoint.Longitude; float pixelX = (float)(MercatorProjection.longitudeToPixelX(longitude, zoomLevel) - canvasPosition.X); float pixelY = (float)(MercatorProjection.latitudeToPixelY(latitude, zoomLevel) - canvasPosition.Y); if (i == 0) { figure.StartPoint = new Point(pixelX, pixelY); } else { var segment = new LineSegment(); segment.point = new Point(pixelX, pixelY); figure.Segments.Add(segment); } } if (closeAutomatically && !isClosed()) { var segment = new LineSegment(); segment.point = figure.StartPoint; figure.Segments.Add(segment); } return path; } }
//@Override public bool draw(BoundingBox boundingBox, byte zoomLevel, Canvas canvas, MapPoint canvasPosition) { if (this.GeoPoint == null || (this.paintStroke == null && this.paintFill == null)) { return(false); } double latitude = this.GeoPoint.Latitude; double longitude = this.GeoPoint.Longitude; float pixelX = (float)(MercatorProjection.longitudeToPixelX(longitude, zoomLevel) - canvasPosition.X); float pixelY = (float)(MercatorProjection.latitudeToPixelY(latitude, zoomLevel) - canvasPosition.Y); float radiusInPixel = (float)metersToPixels(latitude, this.radius, zoomLevel); var shape = new S.Ellipse(); shape.Width = radiusInPixel * 2; shape.Height = radiusInPixel * 2; OverlayUtils.SetShapeFormat(this.paintStroke, this.paintFill, shape); canvas.Children.Add(shape); Canvas.SetTop(shape, pixelY - radius); Canvas.SetLeft(shape, pixelX - radius); return(true); }
// Computes the amount of latitude degrees for a given distance in pixel at a given zoom level. private static double deltaLat(double deltaPixel, double lat, sbyte zoom, int tileSize) { long mapSize = MercatorProjection.getMapSize(zoom, tileSize); double pixelY = MercatorProjection.latitudeToPixelY(lat, mapSize); double lat2 = MercatorProjection.pixelYToLatitude(pixelY + deltaPixel, mapSize); return(Math.Abs(lat2 - lat)); }
/** * Converts the given GeoPoint into XY coordinates on the current tile. * * @param GeoPoint * the GeoPoint to convert. * @return the XY coordinates on the current tile. */ private MapPoint scaleGeoPoint(GeoPoint GeoPoint) { double pixelX = MercatorProjection.longitudeToPixelX(GeoPoint.Longitude, this.currentTile.ZoomFactor) - this.currentTile.PixelX; double pixelY = MercatorProjection.latitudeToPixelY(GeoPoint.Latitude, this.currentTile.ZoomFactor) - this.currentTile.PixelY; return(new MapPoint((float)pixelX, (float)pixelY)); }
//@Override public void draw(BoundingBox boundingBox, byte zoomLevel, Canvas canvas) { double canvasPixelLeft = MercatorProjection.longitudeToPixelX(boundingBox.MinLongitude, zoomLevel); double canvasPixelTop = MercatorProjection.latitudeToPixelY(boundingBox.MaxLatitude, zoomLevel); MapPoint canvasPosition = new MapPoint(canvasPixelLeft, canvasPixelTop); lock (this.overlayItems) { foreach (OverlayItem overlayItem in overlayItems) { overlayItem.draw(boundingBox, zoomLevel, canvas, canvasPosition); } } }