//---------------------------------------------------------------------
        /// <summary>
        /// Loads DEM data depending on the cell size and the avaliable data.
        /// </summary>
        /// <param name="p">
        /// The waypoint that must be included in the DEM.
        /// </param>
        /// <param name="cellSize">
        /// The preferred cell size.
        /// </param>
        /// <param name="demList">
        /// The DEM List where loaded DEMs will added.
        /// </param>
        /// <returns>
        /// The DEM List with the new DEMs included.
        /// </returns>
        //---------------------------------------------------------------------
        public static Dem createDem(Point p, Dem.Precision precision,
                                    List <Dem> demList)
        {
            DemType demType = selectDemGenerator(precision);
            Dem     dem;
            string  path = buildPath(p, demType);

            if (existsPath(demType, path, demList))
            {
                if (demType == DemType.Icc)
                {
                    dem = new Icc(path);
                }
                else if (demType == DemType.Srtm3)
                {
                    dem = new Srtm3(path);
                }
                else
                {
                    dem = new Srtm30(
                        path, string.Format(path.Split('.')[0] + ".HDR"));
                }
                return(dem);
            }
            else
            {
                return(null);
            }
        }
Exemple #2
0
 //---------------------------------------------------------------------
 /// <summary>
 /// Loads DEM data depending on the cell size and the avaliable data.
 /// </summary>
 /// <param name="p">
 /// The waypoint that must be included in the DEM.
 /// </param>
 /// <param name="cellSize">
 /// The preferred cell size.
 /// </param>
 /// <param name="demList">
 /// The DEM List where loaded DEMs will added.
 /// </param>
 /// <returns>
 /// The DEM List with the new DEMs included.
 /// </returns>
 //---------------------------------------------------------------------
 public static Dem createDem(Point p, Dem.Precision precision, 
     List<Dem> demList)
 {
     DemType demType = selectDemGenerator(precision);
     Dem dem;
     string path = buildPath(p, demType);
     if (existsPath(demType, path, demList))
     {
         if (demType == DemType.Icc)
             dem = new Icc(path);
         else if (demType == DemType.Srtm3)
             dem = new Srtm3(path);
         else
             dem = new Srtm30(
                     path, string.Format(path.Split('.')[0] + ".HDR"));
         return dem;
     }
     else
         return null;
 }
Exemple #3
0
        //---------------------------------------------------------------------
        /// <summary>
        /// STATIC: Creates the DEM that complies with the input parametres.
        /// </summary>
        /// <param name="bottomLeft">
        /// A <see cref="Point"/> representing the bottom left corner 
        /// coordinates
        /// </param>
        /// <param name="topRight">
        /// A <see cref="Point"/> representing the top right corner coordinates
        /// </param>
        /// <param name="demList">
        /// A List of <see cref="Dem"/>.
        /// </param>
        /// <param name="precision">
        /// A <see cref="Dem.Precision"/>.
        /// </param>
        /// <returns>
        /// The created <see cref="Dem"/>.
        /// </returns>
        //---------------------------------------------------------------------
        public static Dem createDem(Point bottomLeft, 
            Point topRight,List<Dem> demList, Dem.Precision precision)
        {
            Dem dem = null;
            DemType demType = selectDemGenerator(precision);
            if (demType == DemType.Icc)
            {
                if (!couldBeICCInfo(bottomLeft) || !couldBeICCInfo(topRight))
                {
                    return null;
                }
                else
                {
                    bottomLeft = new HayPoint(bottomLeft.toWgs());
                    topRight = new HayPoint(topRight.toWgs());
                    string path1 = buildPath(bottomLeft, demType);
                    string path2 = buildPath(topRight, demType);
                    if (path1 != path2)
                    {
                        Icc icc1 = new Icc(path1);
                        Icc icc2 = new Icc(path2);
                        dem = Dem.concatenate(icc1, icc2);

                    }
                    else
                    {
                        dem = new Icc(path1);
                    }
                    return dem;
                }
            }
            else if (demType == DemType.Srtm3)
            {
                List<Dem> aux = new List<Dem>();
                bottomLeft = bottomLeft.toWgs();
                topRight = topRight.toWgs();
                int latBL = 
                    Convert.ToInt32(Math.Floor(bottomLeft.getLatitude()));
                int lonBL = 
                    Convert.ToInt32(Math.Floor(bottomLeft.getLongitude()));
                int latTR = 
                    Convert.ToInt32(Math.Floor(topRight.getLatitude()));
                int lonTR = 
                    Convert.ToInt32(Math.Floor(topRight.getLongitude()));
                List<string> paths = new List<string>();
                for (int i = latBL; i <= latTR; i++)
                {
                    for (int j = lonBL; j <= lonTR; j++)
                    {
                        Point p = new WgsPoint(i, j, null);
                        paths.Add(buildPath(p, demType));
                    }
                }
                bool ok = false;
                foreach (string path in paths)
                {
                    foreach (Dem d in demList)
                    {
                        if (d.getPath() == path)
                        {
                            ok = true;
                            aux.Add(d);
                        }
                    }
                    if (!ok && existsPath(demType, path, demList))
                    {
                        aux.Add(new Srtm3(path));
                    }
                    ok = false;
                }
                dem = aux[0];
                List<Dem> aux2 = new List<Dem>();
                int count = 0;
                for (int i = latBL; i <= (latTR); i++)
                {
                    for (double j = lonBL; j <= (lonTR - 1); j++)
                    {
                        count++;
                        dem = Dem.concatenate(dem, aux[count]);
                    }
                    aux2.Add(dem);
                    count++;
                    if (count < aux.Count)
                        dem = aux[count];
                }
                dem = aux2[0];
                for (int i = 1; i < aux2.Count; i++)
                    dem = Dem.concatenate(dem, aux2[i]);
            }
            else if (demType == DemType.Srtm30)
            {
                List<Dem> aux = new List<Dem>();
                bottomLeft = bottomLeft.toWgs();
                topRight = topRight.toWgs();
                int latBL = 
                    Convert.ToInt32(Math.Floor(bottomLeft.getLatitude()));
                int lonBL = 
                    Convert.ToInt32(Math.Floor(bottomLeft.getLongitude()));
                int latTR =
                    Convert.ToInt32(Math.Floor(topRight.getLatitude()));
                int lonTR = 
                    Convert.ToInt32(Math.Floor(topRight.getLongitude()));
                List<string> paths = new List<string>();
                for (double i = latBL; i <= latTR; i = i + 60)
                {
                    for (double j = lonBL; j <= lonTR; j = j + 40)
                    {
                        Point p = new WgsPoint(i, j, null);
                        paths.Add(buildPath(p, demType));
                    }
                }
                bool ok = false;
                foreach (string path in paths)
                {
                    foreach (Dem d in demList)
                    {
                        if (d.getPath() == path)
                        {
                            ok = true;
                            aux.Add(d);
                        }
                    }
                  
                    if (!ok && existsPath(demType, path, demList))
                    {
                        aux.Add(
                            new Srtm30(
                                path, string.Format(
                                    path.Split('.')[0] + ".HDR")));
                    }
                    ok = false;
                }
                dem = aux[0];
                List<Dem> aux2 = new List<Dem>();
                int count = 0;
                bool isFirst = true;
                for (double i = latBL; isFirst || i <= latTR; i = i + 60)
                {
                    for (double j = lonBL; j <= (lonTR - 40); j = j + 40)
                    {
                        count++;
                        dem = Dem.concatenate(dem, aux[count]);
                    }
                    aux2.Add(dem);
                    count++;
                    if(count < aux.Count)
                        dem = aux[count];
                    isFirst = false;
                }
                dem = aux2[0];
                for (int i = 1; i < aux2.Count; i++)
                    dem = Dem.concatenate(dem, aux2[i]);
            }
            return dem;
        }
        //---------------------------------------------------------------------
        /// <summary>
        /// STATIC: Creates the DEM that complies with the input parametres.
        /// </summary>
        /// <param name="bottomLeft">
        /// A <see cref="Point"/> representing the bottom left corner
        /// coordinates
        /// </param>
        /// <param name="topRight">
        /// A <see cref="Point"/> representing the top right corner coordinates
        /// </param>
        /// <param name="demList">
        /// A List of <see cref="Dem"/>.
        /// </param>
        /// <param name="precision">
        /// A <see cref="Dem.Precision"/>.
        /// </param>
        /// <returns>
        /// The created <see cref="Dem"/>.
        /// </returns>
        //---------------------------------------------------------------------
        public static Dem createDem(Point bottomLeft,
                                    Point topRight, List <Dem> demList, Dem.Precision precision)
        {
            Dem     dem     = null;
            DemType demType = selectDemGenerator(precision);

            if (demType == DemType.Icc)
            {
                if (!couldBeICCInfo(bottomLeft) || !couldBeICCInfo(topRight))
                {
                    return(null);
                }
                else
                {
                    bottomLeft = new HayPoint(bottomLeft.toWgs());
                    topRight   = new HayPoint(topRight.toWgs());
                    string path1 = buildPath(bottomLeft, demType);
                    string path2 = buildPath(topRight, demType);
                    if (path1 != path2)
                    {
                        Icc icc1 = new Icc(path1);
                        Icc icc2 = new Icc(path2);
                        dem = Dem.concatenate(icc1, icc2);
                    }
                    else
                    {
                        dem = new Icc(path1);
                    }
                    return(dem);
                }
            }
            else if (demType == DemType.Srtm3)
            {
                List <Dem> aux = new List <Dem>();
                bottomLeft = bottomLeft.toWgs();
                topRight   = topRight.toWgs();
                int latBL =
                    Convert.ToInt32(Math.Floor(bottomLeft.getLatitude()));
                int lonBL =
                    Convert.ToInt32(Math.Floor(bottomLeft.getLongitude()));
                int latTR =
                    Convert.ToInt32(Math.Floor(topRight.getLatitude()));
                int lonTR =
                    Convert.ToInt32(Math.Floor(topRight.getLongitude()));
                List <string> paths = new List <string>();
                for (int i = latBL; i <= latTR; i++)
                {
                    for (int j = lonBL; j <= lonTR; j++)
                    {
                        Point p = new WgsPoint(i, j, null);
                        paths.Add(buildPath(p, demType));
                    }
                }
                bool ok = false;
                foreach (string path in paths)
                {
                    foreach (Dem d in demList)
                    {
                        if (d.getPath() == path)
                        {
                            ok = true;
                            aux.Add(d);
                        }
                    }
                    if (!ok && existsPath(demType, path, demList))
                    {
                        aux.Add(new Srtm3(path));
                    }
                    ok = false;
                }
                dem = aux[0];
                List <Dem> aux2  = new List <Dem>();
                int        count = 0;
                for (int i = latBL; i <= (latTR); i++)
                {
                    for (double j = lonBL; j <= (lonTR - 1); j++)
                    {
                        count++;
                        dem = Dem.concatenate(dem, aux[count]);
                    }
                    aux2.Add(dem);
                    count++;
                    if (count < aux.Count)
                    {
                        dem = aux[count];
                    }
                }
                dem = aux2[0];
                for (int i = 1; i < aux2.Count; i++)
                {
                    dem = Dem.concatenate(dem, aux2[i]);
                }
            }
            else if (demType == DemType.Srtm30)
            {
                List <Dem> aux = new List <Dem>();
                bottomLeft = bottomLeft.toWgs();
                topRight   = topRight.toWgs();
                int latBL =
                    Convert.ToInt32(Math.Floor(bottomLeft.getLatitude()));
                int lonBL =
                    Convert.ToInt32(Math.Floor(bottomLeft.getLongitude()));
                int latTR =
                    Convert.ToInt32(Math.Floor(topRight.getLatitude()));
                int lonTR =
                    Convert.ToInt32(Math.Floor(topRight.getLongitude()));
                List <string> paths = new List <string>();
                for (double i = latBL; i <= latTR; i = i + 60)
                {
                    for (double j = lonBL; j <= lonTR; j = j + 40)
                    {
                        Point p = new WgsPoint(i, j, null);
                        paths.Add(buildPath(p, demType));
                    }
                }
                bool ok = false;
                foreach (string path in paths)
                {
                    foreach (Dem d in demList)
                    {
                        if (d.getPath() == path)
                        {
                            ok = true;
                            aux.Add(d);
                        }
                    }

                    if (!ok && existsPath(demType, path, demList))
                    {
                        aux.Add(
                            new Srtm30(
                                path, string.Format(
                                    path.Split('.')[0] + ".HDR")));
                    }
                    ok = false;
                }
                dem = aux[0];
                List <Dem> aux2    = new List <Dem>();
                int        count   = 0;
                bool       isFirst = true;
                for (double i = latBL; isFirst || i <= latTR; i = i + 60)
                {
                    for (double j = lonBL; j <= (lonTR - 40); j = j + 40)
                    {
                        count++;
                        dem = Dem.concatenate(dem, aux[count]);
                    }
                    aux2.Add(dem);
                    count++;
                    if (count < aux.Count)
                    {
                        dem = aux[count];
                    }
                    isFirst = false;
                }
                dem = aux2[0];
                for (int i = 1; i < aux2.Count; i++)
                {
                    dem = Dem.concatenate(dem, aux2[i]);
                }
            }
            return(dem);
        }