示例#1
0
文件: Dem.cs 项目: KAW0/Alter-Native
        //---------------------------------------------------------------------
        /// <summary>
        /// Concatenates a pair of <see cref="Dem"/>
        /// </summary>
        /// <param name="bigDem">
        /// The bigger <see cref="Dem"/>.
        /// </param>
        /// <param name="smallDem">
        /// The smaller <see cref="Dem"/>.
        /// </param>
        /// <returns>
        /// A <see cref="Dem"/>.
        /// </returns>
        //---------------------------------------------------------------------
        public static Dem concatenate(Dem bigDem, Dem smallDem)
        {
            if (bigDem.GetType() == smallDem.GetType())
            {
                int rows;
                int cols;
                Point bottomLeft;
                double[,] altitude;

                if (bigDem.bottomLeft.getLatitude() == 
                    smallDem.bottomLeft.getLatitude() && 
                    bigDem.rows == smallDem.rows || 
                    bigDem is Icc)
                {
                    rows = bigDem.rows;
                    cols = bigDem.cols + smallDem.cols;
                    altitude = new double[rows, cols];
                    if (bigDem.bottomLeft.getLongitude() < 
                        smallDem.bottomLeft.getLongitude())
                    {
                        bottomLeft = bigDem.bottomLeft;
                        for (int i = 0; i < bigDem.rows; i++)
                        {
                            for (int j = 0; j < bigDem.cols; j++)
                            {
                                altitude[i, j] = bigDem.altitude[i, j];
                                if(j < smallDem.cols)
                                    altitude[i, j + bigDem.cols] = 
                                        smallDem.altitude[i, j];
                            }
                        }
                    }
                    else
                    {
                        bottomLeft = smallDem.bottomLeft;
                        for (int i = 0; i < bigDem.rows; i++)
                        {
                            for (int j = 0; j < bigDem.cols; j++)
                            {
                                if(j < smallDem.cols)
                                    altitude[i, j] = smallDem.altitude[i, j];
                                altitude[i, j + bigDem.cols] = 
                                    bigDem.altitude[i, j];
                            }
                        }
                    }
                }
                else if (bigDem.bottomLeft.getLongitude() == 
                    smallDem.bottomLeft.getLongitude() && 
                    bigDem.cols == smallDem.cols)
                {
                    rows = bigDem.rows + smallDem.rows;
                    cols = bigDem.cols;
                    altitude = new double[rows, cols];
                    if (bigDem.bottomLeft.getLatitude() < 
                        smallDem.bottomLeft.getLatitude())
                    {
                        bottomLeft = bigDem.bottomLeft;
                        for (int i = 0; i < bigDem.rows; i++)
                        {
                            for (int j = 0; j < bigDem.cols; j++)
                            {
                                altitude[i + smallDem.rows, j] = 
                                    bigDem.altitude[i, j];
                                if (i < smallDem.rows)
                                    altitude[i, j] = smallDem.altitude[i, j];
                            }
                        }
                    }
                    else
                    {
                        bottomLeft = smallDem.bottomLeft;
                        for (int i = 0; i < bigDem.rows; i++)
                        {
                            for (int j = 0; j < bigDem.cols; j++)
                            {
                                if(i < smallDem.rows)
                                    altitude[i + bigDem.rows, j] = 
                                        smallDem.altitude[i, j];
                                altitude[i, j] = bigDem.altitude[i, j];
                            }
                        }
                    }
                }
                else
                    return null;
                if (bigDem is Icc)
                    return new Icc(rows, cols, bottomLeft, altitude);
                else if (bigDem is Srtm3)
                    return new Srtm3(rows, cols, bottomLeft.toWgs(), altitude);
                else
                    return new Srtm30(
                        rows, cols, bottomLeft.toWgs(), altitude);
            }
            else
                return null;
        }
示例#2
0
        //---------------------------------------------------------------------
        /// <summary>
        /// Concatenates a pair of <see cref="Dem"/>
        /// </summary>
        /// <param name="bigDem">
        /// The bigger <see cref="Dem"/>.
        /// </param>
        /// <param name="smallDem">
        /// The smaller <see cref="Dem"/>.
        /// </param>
        /// <returns>
        /// A <see cref="Dem"/>.
        /// </returns>
        //---------------------------------------------------------------------
        public static Dem concatenate(Dem bigDem, Dem smallDem)
        {
            if (bigDem.GetType() == smallDem.GetType())
            {
                int   rows;
                int   cols;
                Point bottomLeft;
                double[,] altitude;

                if (bigDem.bottomLeft.getLatitude() ==
                    smallDem.bottomLeft.getLatitude() &&
                    bigDem.rows == smallDem.rows ||
                    bigDem is Icc)
                {
                    rows     = bigDem.rows;
                    cols     = bigDem.cols + smallDem.cols;
                    altitude = new double[rows, cols];
                    if (bigDem.bottomLeft.getLongitude() <
                        smallDem.bottomLeft.getLongitude())
                    {
                        bottomLeft = bigDem.bottomLeft;
                        for (int i = 0; i < bigDem.rows; i++)
                        {
                            for (int j = 0; j < bigDem.cols; j++)
                            {
                                altitude[i, j] = bigDem.altitude[i, j];
                                if (j < smallDem.cols)
                                {
                                    altitude[i, j + bigDem.cols] =
                                        smallDem.altitude[i, j];
                                }
                            }
                        }
                    }
                    else
                    {
                        bottomLeft = smallDem.bottomLeft;
                        for (int i = 0; i < bigDem.rows; i++)
                        {
                            for (int j = 0; j < bigDem.cols; j++)
                            {
                                if (j < smallDem.cols)
                                {
                                    altitude[i, j] = smallDem.altitude[i, j];
                                }
                                altitude[i, j + bigDem.cols] =
                                    bigDem.altitude[i, j];
                            }
                        }
                    }
                }
                else if (bigDem.bottomLeft.getLongitude() ==
                         smallDem.bottomLeft.getLongitude() &&
                         bigDem.cols == smallDem.cols)
                {
                    rows     = bigDem.rows + smallDem.rows;
                    cols     = bigDem.cols;
                    altitude = new double[rows, cols];
                    if (bigDem.bottomLeft.getLatitude() <
                        smallDem.bottomLeft.getLatitude())
                    {
                        bottomLeft = bigDem.bottomLeft;
                        for (int i = 0; i < bigDem.rows; i++)
                        {
                            for (int j = 0; j < bigDem.cols; j++)
                            {
                                altitude[i + smallDem.rows, j] =
                                    bigDem.altitude[i, j];
                                if (i < smallDem.rows)
                                {
                                    altitude[i, j] = smallDem.altitude[i, j];
                                }
                            }
                        }
                    }
                    else
                    {
                        bottomLeft = smallDem.bottomLeft;
                        for (int i = 0; i < bigDem.rows; i++)
                        {
                            for (int j = 0; j < bigDem.cols; j++)
                            {
                                if (i < smallDem.rows)
                                {
                                    altitude[i + bigDem.rows, j] =
                                        smallDem.altitude[i, j];
                                }
                                altitude[i, j] = bigDem.altitude[i, j];
                            }
                        }
                    }
                }
                else
                {
                    return(null);
                }
                if (bigDem is Icc)
                {
                    return(new Icc(rows, cols, bottomLeft, altitude));
                }
                else if (bigDem is Srtm3)
                {
                    return(new Srtm3(rows, cols, bottomLeft.toWgs(), altitude));
                }
                else
                {
                    return(new Srtm30(
                               rows, cols, bottomLeft.toWgs(), altitude));
                }
            }
            else
            {
                return(null);
            }
        }