Exemplo n.º 1
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);
            }
        }
Exemplo n.º 2
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);
        }