示例#1
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("");
        }
        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); }
            }
        }