コード例 #1
0
ファイル: NewMapnumber.cs プロジェクト: tanghaojie/JT.Net
        public static void GetInfo(string mapnumber, out bool succcess, out string m100WRow, out string m100WColumn, out string scale, out string rownum, out string columnnum)
        {
            m100WRow    = null;
            m100WColumn = null;
            scale       = null;
            rownum      = null;
            columnnum   = null;
            if (!NewMapnumberCheck.Check(mapnumber))
            {
                succcess = false;
                return;
            }
            int length = mapnumber.Length;

            m100WRow    = mapnumber.Substring(0, 1);
            m100WColumn = mapnumber.Substring(1, 2);
            if (length > 3)
            {
                scale = mapnumber.Substring(3, 1);
                if (length == 10)
                {
                    rownum    = mapnumber.Substring(4, 3);
                    columnnum = mapnumber.Substring(7, 3);
                }
                else
                {
                    rownum    = mapnumber.Substring(4, 4);
                    columnnum = mapnumber.Substring(8, 4);
                }
            }
            succcess = true;
        }
コード例 #2
0
 public static string ToNewMapnumber(string mapnumber)
 {
     if (NewMapnumberCheck.Check(mapnumber))
     {
         return(mapnumber);
     }
     mapnumber = mapnumber.ToUpper();
     if (NewMapnumberCheck.Check(mapnumber))
     {
         return(mapnumber);
     }
     return("");
 }
コード例 #3
0
        public static string NewMapnumber100WFromLongitudeLatitude(decimal longitude, decimal latitude)
        {
            var rNum  = (int)(latitude / LongitudeLatitudeDifferent.MAPNUMBER_100W_LATITUDE_DIFFERENT) + 1;
            var cNum  = (int)(longitude / LongitudeLatitudeDifferent.MAPNUMBER_100W_LONGITUDE_DIFFERENT) + 31;
            var rStr  = Mapnumber100W.RowDigitalToString(rNum);
            var n100W = rStr + cNum.ToString("00");

            if (!NewMapnumberCheck.Check(n100W))
            {
                return(null);
            }
            return(n100W);
        }
コード例 #4
0
        public static string OldMapnumberFromLongitudeLatitude(decimal longitude, decimal latitude, int scaleDenominator)
        {
            string n100W = NewMapnumber100WFromLongitudeLatitude(longitude, latitude);

            if (string.IsNullOrEmpty(n100W))
            {
                return(null);
            }
            LongitudeLatitudeDifferent.LongitudeLatitudeDifferenceByScaleDenominator(scaleDenominator, out bool success, out decimal JC, out decimal WC);

            NewMapnumberRowColumnNumIn100WFromLongitudeLatitude(longitude, latitude, JC, WC, out int row, out int column);
            string scaleStr = NewMapnumber.ScaleString(scaleDenominator);

            if (scaleDenominator == 200000)
            {
                return(OldMapnumber20WFromLongitudeLatitude(longitude, latitude));
            }
            else
            {
                string r = "";
                string c = "";
                if (scaleStr == "J" || scaleStr == "K")
                {
                    r = row.ToString("0000");
                    c = column.ToString("0000");
                }
                else
                {
                    r = row.ToString("000");
                    c = column.ToString("000");
                }
                if (string.IsNullOrEmpty(scaleStr))
                {
                    scaleStr = "";
                    r        = "";
                    c        = "";
                }
                string newMapnumber = n100W + scaleStr + r + c;
                if (NewMapnumberCheck.Check(newMapnumber))
                {
                    string oldMapnumber = NewMapnumberToMapnumber.ToOldMapnumber(newMapnumber);
                    if (OldMapnumberCheck.Check(oldMapnumber))
                    {
                        return(oldMapnumber);
                    }
                }
                return(null);
            }
        }
コード例 #5
0
        public static string NewMapnumber25WFromLongitudeLatitude(decimal longitude, decimal latitude)
        {
            var n100W = NewMapnumber100WFromLongitudeLatitude(longitude, latitude);

            if (string.IsNullOrEmpty(n100W))
            {
                return(null);
            }
            NewMapnumberRowColumnNumIn100WFromLongitudeLatitude(longitude, latitude, LongitudeLatitudeDifferent.MAPNUMBER_25W_LONGITUDE_DIFFERENT, LongitudeLatitudeDifferent.MAPNUMBER_25W_LATITUDE_DIFFERENT, out int row, out int column);
            var r    = row.ToString("000");
            var c    = column.ToString("000");
            var n25W = n100W + "C" + r + c;

            if (!NewMapnumberCheck.Check(n25W))
            {
                return(null);
            }
            return(n25W);
        }
コード例 #6
0
        public static string NewMapnumberFromLongitudeLatitude(decimal longitude, decimal latitude, int scaleDenominator)
        {
            var newMapnumber_100W = NewMapnumber100WFromLongitudeLatitude(longitude, latitude);

            if (string.IsNullOrEmpty(newMapnumber_100W))
            {
                return(null);
            }
            LongitudeLatitudeDifferent.LongitudeLatitudeDifferenceByScaleDenominator(scaleDenominator, out bool success, out decimal longitudeDifference, out decimal latitudeDifference);
            if (!success)
            {
                throw new Exception();
            }

            NewMapnumberRowColumnNumIn100WFromLongitudeLatitude(longitude, latitude, longitudeDifference, latitudeDifference, out int row, out int column);
            string scaleStr = NewMapnumber.ScaleString(scaleDenominator);
            string r        = "";
            string c        = "";

            if (scaleStr == "J" || scaleStr == "K")
            {
                r = row.ToString("0000");
                c = column.ToString("0000");
            }
            else
            {
                r = row.ToString("000");
                c = column.ToString("000");
            }
            if (string.IsNullOrEmpty(scaleStr))
            {
                scaleStr = "";
                r        = "";
                c        = "";
            }
            string newMapnumber = newMapnumber_100W + scaleStr + r + c;

            if (!NewMapnumberCheck.Check(newMapnumber))
            {
                return(null);
            }
            return(newMapnumber);
        }
コード例 #7
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); }
            }
        }