Esempio n. 1
0
        /// <summary>
        /// Creates a Bitmap image with size width,height.
        /// From the area (x1,y2) to (x2,y2) where x1,y1,x2,y2 are
        /// geological coordinates.
        /// </summary>
        public Bitmap GetTile(double x1, double y1, double x2, double y2, int width, int height)
        {
            Bitmap tile      = new Bitmap(width, height);
            int    zoomLevel = GetZoomLevel(x1, x2, width);
            BBox   box       = new BBox(x1, y1, x2, y2);

            // Make searchbox wider dependent on zoomlevel.
            // Explanation at summary of getSearchBBox.
            BBox searchBox = getSearchBBox(box, zoomLevel);

            // Clears image with grey backgroundcolor.
            Graphics.FromImage(tile).Clear(Color.FromArgb(230, 230, 230));

            // Draww all seperate elements in following order:
            // Land -> Buildings -> Streets -> extra locations (Busstations, parking signs)
            drawLandCurves(box, tile, graph.GetLandsInBBox(searchBox));
            drawBuildingCurves(box, tile, graph.GetBuildingsInBBox(searchBox));
            drawStreetCurves(box, tile, graph.GetWaysInBBox(searchBox), zoomLevel);
            drawExtras(box, tile, graph.GetExtrasInBBox(BBox.getResizedBBox(box, 2)), zoomLevel);
            //drawAdditionalCurves(box, tile, graph.GetExtrasinBBOX(searchBox), zoomLevel);

            //used for debugging
            //Graphics.FromImage(tile).DrawLines(Pens.LightGray, new Point[] { Point.Empty, new Point(0, height), new Point(width, height), new Point(width, 0), Point.Empty });
            return(tile);
        }
Esempio n. 2
0
 /// <summary>
 /// Resizes the BBox box if zoomlevel is very low.
 /// This is because when curves pass through a tile but no nodes
 /// of that curve are in that tile the curve won't be drawn in that tile.
 /// So on very low zoomlevels, we need to search wider to draw all
 /// curves in a tile.
 /// </summary>
 private BBox getSearchBBox(BBox box, int zoomLevel)
 {
     if (zoomLevel == 1)
     {
         return(BBox.getResizedBBox(box, 3));
     }
     if (zoomLevel == 0)
     {
         return(BBox.getResizedBBox(box, 7));
     }
     return(box);
 }