示例#1
0
        public static bool Check1W(string mapnumber1W)
        {
            if (string.IsNullOrEmpty(mapnumber1W) || !mapnumber1W.Contains("-") || !mapnumber1W.Contains("(") || !mapnumber1W.Contains(")"))
            {
                return(false);
            }
            string[] split = mapnumber1W.Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries);
            if (split.Length != 4)
            {
                return(false);
            }
            string o10W = split[0] + "-" + split[1] + "-" + split[2];

            if (!Check10W(o10W))
            {
                return(false);
            }
            string k = split[3];

            string[] subSplit = k.Split(new char[] { '(', ')' }, StringSplitOptions.RemoveEmptyEntries);
            if (subSplit.Length != 1)
            {
                return(false);
            }
            string sub = subSplit[0];
            int    sum = OldMapnumber.SumCount(OldMapnumberDefine.MaxCount1W);

            string[] strs = OldMapnumber.AllAllowedNums(sum);
            return(MapnumberCommon.Contain(strs, sub));
        }
示例#2
0
        public static bool Check25W(string mapnumber25W)
        {
            if (string.IsNullOrEmpty(mapnumber25W) || !mapnumber25W.Contains("-") || !mapnumber25W.Contains("[") || !mapnumber25W.Contains("]"))
            {
                return(false);
            }
            string[] split = mapnumber25W.Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries);
            if (split.Length != 3 || !Mapnumber100W.ValidateRowNum(split[0]) || !Mapnumber100W.ValidateColumnNum(split[1]))
            {
                return(false);
            }
            string k = split[2];

            string[] subSplit = k.Split(new char[] { '[', ']' }, StringSplitOptions.RemoveEmptyEntries);
            int      len      = subSplit.Length;

            if (len != 1)
            {
                return(false);
            }
            int sum = OldMapnumber.SumCount(OldMapnumberDefine.MaxCount25W);

            string[] strs = OldMapnumber.AllAllowedNums(sum);
            return(MapnumberCommon.Contain(strs, subSplit[0]));
        }
示例#3
0
        public static string ToNewMapnumber50W(string oldMapnumber50W)
        {
            if (!OldMapnumberCheck.Check50W(oldMapnumber50W))
            {
                return("");
            }
            var temp   = oldMapnumber50W.Split('-');
            var new100 = temp[0] + temp[1].PadLeft(2, '0');
            var chrStr = temp[2];

            if (chrStr.Length != 1)
            {
                return("");
            }
            var x = OldMapnumber.ChangeABCDabcdTo1234(chrStr[0]);

            if (x <= 0)
            {
                return("");
            }
            var new50R = ToNew50WRow(x);
            var new50C = ToNew50WColumn(x);

            return(new100 + "B" + new50R.ToString().PadLeft(3, '0') + new50C.ToString().PadLeft(3, '0'));
        }
示例#4
0
        public static string ToNewMapnumber2_5W(string oldMapnumber2_5W)
        {
            if (!OldMapnumberCheck.Check2_5W(oldMapnumber2_5W))
            {
                return("");
            }
            var temp   = oldMapnumber2_5W.Split('-');
            var new100 = temp[0] + temp[1].PadLeft(2, '0');
            var sub10W = temp[2];

            if (!int.TryParse(sub10W, out int x))
            {
                return("");
            }
            var new10R = ToNew10WRow(x);
            var new10C = ToNew10WColumn(x);
            var chrStr = temp[3];

            if (chrStr.Length != 1)
            {
                return("");
            }
            var sub5W   = OldMapnumber.ChangeABCDabcdTo1234(chrStr[0]);
            var new5R   = ToNew5WRow(sub5W, new10R);
            var new5C   = ToNew5WColumn(sub5W, new10C);
            var sub2_5W = int.Parse(temp[4]);
            var new2_5R = ToNew2_5WRow(sub2_5W, new5R);
            var new2_5C = ToNew2_5WColumn(sub2_5W, new5C);
            var new2    = new100 + "F" + new2_5R.ToString().PadLeft(3, '0') + new2_5C.ToString().PadLeft(3, '0');

            return(new2);
        }
示例#5
0
        public static string ToOldMapnumber5K(string oldMapnumber5K)
        {
            if (string.IsNullOrEmpty(oldMapnumber5K))
            {
                return("");
            }

            if (OldMapnumberCheck.Check5K(oldMapnumber5K))
            {
                return(oldMapnumber5K);
            }

            oldMapnumber5K = ChangeOldMapnumberChar(oldMapnumber5K);
            if (!oldMapnumber5K.Contains("-"))
            {
                return("");
            }

            var split  = oldMapnumber5K.Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries);
            var length = split.Length;

            if (length != 5)
            {
                return("");
            }

            var x1 = split[0] + "-" + split[1] + "-" + split[2] + "-(" + split[3] + ")";
            var s1 = ToOldMapnumber1W(x1);

            if (string.IsNullOrEmpty(s1) || !int.TryParse(split[4], out int x0_5))
            {
                return("");
            }

            var s0_5 = OldMapnumber.Change1234Toabcd(x0_5);

            oldMapnumber5K = s1 + "-" + s0_5;
            if (OldMapnumberCheck.Check5K(oldMapnumber5K))
            {
                return(oldMapnumber5K);
            }

            return("");
        }
示例#6
0
        public static string ToOldMapnumber5W(string oldMapnumber5W)
        {
            if (string.IsNullOrEmpty(oldMapnumber5W))
            {
                return("");
            }
            if (OldMapnumberCheck.Check5W(oldMapnumber5W))
            {
                return(oldMapnumber5W);
            }

            oldMapnumber5W = ChangeOldMapnumberChar(oldMapnumber5W);
            if (!oldMapnumber5W.Contains("-"))
            {
                return("");
            }
            var split  = oldMapnumber5W.Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries);
            int length = split.Length;

            if (length != 4)
            {
                return("");
            }
            var x10 = split[0] + "-" + split[1] + "-" + split[2];
            var s10 = ToOldMapnumber10W(x10);

            if (string.IsNullOrEmpty(s10) || !int.TryParse(split[3], out int x5))
            {
                return("");
            }

            var s5 = OldMapnumber.Change1234ToABCD(x5);

            oldMapnumber5W = s10 + "-" + s5;
            if (OldMapnumberCheck.Check5W(oldMapnumber5W))
            {
                return(oldMapnumber5W);
            }
            return("");
        }
示例#7
0
        public static string ToNewMapnumber5K(string oldMapnumber5K)
        {
            if (!OldMapnumberCheck.Check5K(oldMapnumber5K))
            {
                return("");
            }
            var temp   = oldMapnumber5K.Split('-');
            var new100 = temp[0] + temp[1].PadLeft(2, '0');
            var sub10W = temp[2];

            if (!int.TryParse(sub10W, out int x))
            {
                return("");
            }
            var new10R  = ToNew10WRow(x);
            var new10C  = ToNew10WColumn(x);
            var sub1W   = temp[3];
            var subTemp = sub1W.Split(new char[] { '(', ')' }, StringSplitOptions.RemoveEmptyEntries);

            if (!int.TryParse(subTemp[0], out int k))
            {
                return("");
            }
            var new1R   = ToNew1WRow(k, new10R);
            var new1C   = ToNew1WColumn(k, new10C);
            var sub0_5W = temp[4];
            var chrStr  = temp[4];

            if (chrStr.Length != 1)
            {
                return("");
            }
            var l       = OldMapnumber.ChangeABCDabcdTo1234(chrStr[0]);
            var new0_5R = ToNew5KRow(l, new1R);
            var new0_5C = ToNew5KColumn(l, new1C);

            return(new100 + "H" + new0_5R.ToString().PadLeft(3, '0') + new0_5C.ToString().PadLeft(3, '0'));
        }
        public static string ToOldMapnumber(string mapnumber)
        {
            if (!NewMapnumberCheck.Check(mapnumber))
            {
                return("");
            }
            NewMapnumber.GetInfo(mapnumber, out bool success, out string m100WRow, out string m100WColumn, out string scale, out string row, out string column);
            if (!success)
            {
                return("");
            }

            if (scale.Length != 1)
            {
                throw new Exception();
            }
            var scaleChr    = scale[0];
            var scaleNumber = NewMapnumber.NewMapnumberGetScaleDenominatorNumberByScaleStr(scaleChr);

            switch (scaleNumber)
            {
            case 1000000: { return(ToOldMapnumber100W(m100WRow, m100WColumn)); }

            case 500000: {
                var o100W   = ToOldMapnumber100W(m100WRow, m100WColumn);
                var o50W    = ToOld50WNum(row, column);
                var o50WStr = OldMapnumber.Change1234ToABCD(o50W);
                if (string.IsNullOrEmpty(o50WStr))
                {
                    return("");
                }
                return(o100W + "-" + o50WStr);
            }

            case 250000: {
                var o100W = ToOldMapnumber100W(m100WRow, m100WColumn);
                var o25W  = ToOld25WNum(row, column);
                if (o25W <= 0 || o25W > 16)
                {
                    return("");
                }
                return(o100W + "-[" + o25W.ToString("00") + "]");
            }

            case 100000: {
                var o100W = ToOldMapnumber100W(m100WRow, m100WColumn);
                var o10W  = ToOld10WNum(row, column);
                if (o10W <= 0 || o10W > 144)
                {
                    return("");
                }
                return(o100W + "-" + o10W.ToString("000"));
            }

            case 50000: {
                var o100W  = ToOldMapnumber100W(m100WRow, m100WColumn);
                var o5W    = ToOld5WNum(row, column);
                var o5WStr = OldMapnumber.Change1234ToABCD(o5W);
                if (string.IsNullOrEmpty(o5WStr))
                {
                    return("");
                }
                var n10WR = New5WRCToNew10WRC(int.Parse(row));
                var n10WC = New5WRCToNew10WRC(int.Parse(column));
                var o10W  = ToOld10WNum(n10WR.ToString(), n10WC.ToString());
                if (o10W <= 0 || o10W > 144)
                {
                    return("");
                }
                return(o100W + "-" + o10W.ToString("000") + "-" + o5WStr);
            }

            case 25000: {
                var o100W = ToOldMapnumber100W(m100WRow, m100WColumn);
                var o2_5W = ToOld2_5WNum(row, column);
                if (o2_5W <= 0 || o2_5W > 4)
                {
                    return("");
                }
                var n5WR   = New2_5WRCToNew5WRC(int.Parse(row));
                var n5WC   = New2_5WRCToNew5WRC(int.Parse(column));
                var o5W    = ToOld5WNum(n5WR.ToString(), n5WC.ToString());
                var o5WStr = OldMapnumber.Change1234ToABCD(o5W);
                if (string.IsNullOrEmpty(o5WStr))
                {
                    return("");
                }
                var n10WR = New5WRCToNew10WRC(n5WR);
                var n10WC = New5WRCToNew10WRC(n5WC);
                var o10W  = ToOld10WNum(n10WR.ToString(), n10WC.ToString());
                if (o10W <= 0 || o10W > 144)
                {
                    return("");
                }
                return(o100W + "-" + o10W.ToString("000") + "-" + o5WStr + "-" + o2_5W.ToString());
            }

            case 10000: {
                var o100W = ToOldMapnumber100W(m100WRow, m100WColumn);
                var o1W   = ToOld1WNum(row, column);
                if (o1W <= 0 || o1W > 64)
                {
                    return("");
                }
                var n10WR = New1WRCToNew10WRC(int.Parse(row));
                var n10WC = New1WRCToNew10WRC(int.Parse(column));
                var o10W  = ToOld10WNum(n10WR.ToString(), n10WC.ToString());
                if (o10W <= 0 || o10W > 144)
                {
                    return("");
                }
                return(o100W + "-" + o10W.ToString("000") + "-(" + o1W.ToString("00") + ")");
            }

            case 5000: {
                var o100W    = ToOldMapnumber100W(m100WRow, m100WColumn);
                var o0_5W    = ToOld5KNum(row, column);
                var o0_5WStr = OldMapnumber.Change1234Toabcd(o0_5W);
                if (string.IsNullOrEmpty(o0_5WStr))
                {
                    return("");
                }
                var n1WR = New5KRCToNew1WRC(int.Parse(row));
                var n1WC = New5KRCToNew1WRC(int.Parse(column));
                var o1W  = ToOld1WNum(n1WR.ToString(), n1WC.ToString());
                if (o1W <= 0 || o1W > 64)
                {
                    return("");
                }
                var n10WR = New1WRCToNew10WRC(n1WR);
                var n10WC = New1WRCToNew10WRC(n1WC);
                var o10W  = ToOld10WNum(n10WR.ToString(), n10WC.ToString());
                if (o10W <= 0 || o10W > 144)
                {
                    return("");
                }
                return(o100W + "-" + o10W.ToString("000") + "-(" + o1W.ToString("00") + ")-" + o0_5WStr);
            }

            default: { return(null); }
            }
        }