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

            pointTypeRegistrations.Add(ruleName, reg);
            return(reg);
        }
Beispiel #2
0
        public PointTypeRegistration RegisterNewPointType(string ruleName)
        {
            int id = customPointNextTypeId++;

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

            PointTypeRegistration reg = new PointTypeRegistration(id, ruleName);

            pointTypeRegistrations.Add(ruleName, reg);
            return(reg);
        }
Beispiel #3
0
        private static void WritePointTypeDefinition(
            MapMakerSettings mapMakerSettings,
            CGpsMapperGeneralFileWriter file,
            PointTypeRegistration registration)
        {
            // constant labels are placed on type definitions instead of each individual map element
            if (registration.TypeName != null)
            {
                file.AddFormat("string1=4,{0}", registration.TypeName);
            }
            else if (registration.Label != null && registration.Label.IsConstant)
            {
                file.AddFormat("string1=4,{0}", registration.Label.BuildLabel(mapMakerSettings, null, null));
            }

            file.AddFormat(
                "xpm=\"{0} {1} {2} {3}\"",
                registration.Pattern.Width,
                registration.Pattern.Height,
                registration.Pattern.ColorsCount + 1, // first color is transparent
                registration.Pattern.ColorsCount >= 128 ? 2 : 1);

            file.AddFormat("\"0 c none\"");

            foreach (KeyValuePair <string, string> pair in registration.Pattern.EnumerateColorDictionary())
            {
                file.AddFormat("\"{0} c #{1}\"", pair.Key, pair.Value);
            }

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

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

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