Beispiel #1
0
        public LineTypeRegistration RegisterStandardLineType(int typeId, string ruleName)
        {
            LineTypeRegistration reg = new LineTypeRegistration(typeId, ruleName);

            lineTypeRegistrations.Add(ruleName, reg);
            return(reg);
        }
Beispiel #2
0
        public LineTypeRegistration RegisterNewLineType(string ruleName)
        {
            int id = customLineNextTypeId++;

            if ((customLineNextTypeId & 0xff) == 20)
            {
                customLineNextTypeId += 0xe0;
            }

            LineTypeRegistration reg = new LineTypeRegistration(id, ruleName);

            lineTypeRegistrations.Add(ruleName, reg);
            return(reg);
        }
Beispiel #3
0
        private static void WritePolylineTypeDefinition(
            MapMakerSettings mapMakerSettings,
            CGpsMapperGeneralFileWriter file,
            LineTypeRegistration registration)
        {
            int colorsCount = registration.Pattern.ColorsCount;

            if (colorsCount == 0)
            {
                return;
            }

            bool bitmapUsed = registration.Pattern.Height > 0;

            file.AddSection("_line")
            .AddFormat(";rule={0}", registration.RuleName)
            .AddFormat("Type=0x{0:x}", registration.TypeId)
            ;

            if (false == bitmapUsed)
            {
                file.Add("LineWidth", registration.Width);
                file.Add("BorderWidth", registration.BorderWidth);
            }

            // constant labels are placed on type definitions instead of each individual map element
            if (registration.Label != null && registration.Label.IsConstant)
            {
                file.AddFormat("string1=4,{0}", registration.Label.BuildLabel(mapMakerSettings, null, null));
            }

            int patternWidth  = 0;
            int patternHeight = 0;

            if (bitmapUsed)
            {
                patternWidth  = 32;
                patternHeight = registration.Pattern.Height;
            }

            file.AddFormat(
                "xpm=\"{0} {1} {2} {3}\"",
                patternWidth,
                patternHeight,
                Math.Max(2, registration.Pattern.ColorsCount), 1);

            if (registration.Pattern.ColorsCount == 1)
            {
                file.AddFormat("\"1 c #{0}\"", registration.Pattern.GetColorByIndex(0))
                .AddFormat("\"0 c none\"");
            }
            else
            {
                for (int i = 0; i < registration.Pattern.ColorsCount; i++)
                {
                    file.AddFormat("\"{0} c #{1}\"", i, registration.Pattern.GetColorByIndex(i));
                }
            }

            for (int y = 0; y < registration.Pattern.Height; y++)
            {
                StringBuilder normalizedPatternLine = new StringBuilder();

                for (int x = 0; x < 32; x++)
                {
                    char patternChar =
                        registration.Pattern.PatternLines[y][x % registration.Pattern.Width];
                    normalizedPatternLine.Append(patternChar);
                }

                file.AddFormat("\"{0}\"", normalizedPatternLine);
            }
        }