Beispiel #1
0
        private static IPen SetPenForGameTile(StylePaint tpe)
        {
            //These pens are saved with a fixed drawing width to match game tiles.
            int imgX = 0, imgY = 0;

            MapTileSupport.GetPlusCodeImagePixelSize("22334455", out imgX, out imgY);
            var info = new ImageStats(OpenLocationCode.DecodeValid("22334455"), imgX, imgY);

            var widthMod = resolutionCell11Lon * IMapTiles.GameTileScale;

            string htmlColor = tpe.HtmlColorCode;

            if (htmlColor.Length == 8)
            {
                htmlColor = htmlColor.Substring(2, 6) + htmlColor.Substring(0, 2);
            }

            Pen p;

            if (String.IsNullOrWhiteSpace(tpe.LinePattern) || tpe.LinePattern == "solid")
            {
                p = new Pen(Rgba32.ParseHex(htmlColor), tpe.LineWidthDegrees * (float)info.pixelsPerDegreeX);
            }
            else
            {
                float[] linesAndGaps = tpe.LinePattern.Split('|').Select(t => float.Parse(t)).ToArray();
                p = new Pen(Rgba32.ParseHex(htmlColor), tpe.LineWidthDegrees * (float)info.pixelsPerDegreeX, linesAndGaps);
            }

            return(p);
        }
Beispiel #2
0
        //Optional parameter allows you to pass in different stuff that the DB alone has, possibly for manual or one-off changes to styling
        //or other elements converted for maptile purposes.
        /// <summary>
        /// //This generic function takes the area to draw and creates an image for it. Can optionally be provided specific elements, a specific style set, and told to filter small areas out of the results.
        /// </summary>
        /// <param name="stats">Image information, including width and height.</param>
        /// <param name="drawnItems">the elments to draw</param>
        /// <param name="styleSet">the style rules to use when drawing</param>
        /// <param name="filterSmallAreas">if true, removes elements from the drawing that take up fewer than 8 pixels.</param>
        /// <returns></returns>
        public byte[] DrawAreaAtSize(ImageStats stats, List <DbTables.Place> drawnItems = null, string styleSet = "mapTiles", bool filterSmallAreas = true)
        {
            //This is the new core drawing function. Takes in an area, the items to draw, and the size of the image to draw.
            //The drawn items get their paint pulled from the TagParser's list. If I need multiple match lists, I'll need to make a way
            //to pick which list of tagparser rules to use.
            //This can work for user data by using the linked Places from the items in PlaceGameData.
            //I need a slightly different function for using AreaGameData, or another optional parameter here

            //This should just get the paint ops then call the core drawing function.
            double minimumSize = 0;

            if (filterSmallAreas)
            {
                minimumSize = stats.degreesPerPixelX * 8; //don't draw small elements. THis runs on perimeter/length
            }

            //Single points are excluded separately so that small areas or lines can still be drawn when points aren't.
            bool includePoints = true;

            if (stats.degreesPerPixelX > ConstantValues.zoom14DegPerPixelX)
            {
                includePoints = false;
            }

            if (drawnItems == null)
            {
                drawnItems = GetPlaces(stats.area, filterSize: minimumSize, includePoints: includePoints);
            }

            var paintOps = MapTileSupport.GetPaintOpsForStoredElements(drawnItems, styleSet, stats);

            return(DrawAreaAtSize(stats, paintOps));
        }