示例#1
1
 /// <summary>
 /// Default constructor.
 /// </summary>
 public Index()
 {
     this.row = -1;
     this.col = -1;
     this.dem = null;
     this.alt = null;
 }
示例#2
1
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="row">Row index.</param>
 /// <param name="col">Column index.</param>
 /// <param name="nDem">DEM list index.</param>
 public Index(int row, int col, Dem dem)
 {
     this.col = col;
     this.row = row;
     this.dem = dem;
     this.alt = null;
 }
示例#3
0
 /// <summary>
 /// Default constructor.
 /// </summary>
 public Index()
 {
     this.row = -1;
     this.col = -1;
     this.dem = null;
     this.alt = null;
 }
示例#4
0
		//---------------------------------------------------------------------
		/// <summary>
		/// Sets a working area and a precision in order to use it during the 
		/// whole mission. When requesting a point outside this area, all
		/// features will return always null.
		/// </summary>
		/// <param name="bottomLeft">
		/// A <see cref="Point"/> as the bottom left corner of the working 
		/// area.
		/// </param>
		/// <param name="topRight"></para>
		/// A <see cref="Point"/> as the bottom left corner of the working 
		/// area.
		/// </param>
		/// <param name="precision">
		/// A <see cref="Dem.Precision"/> as the selected DEM precision.
		/// </param>
		public Features(Point bottomLeft, Point topRight, Dem.Precision precision)
        {
			this.precision = precision;
            this.demList = new DemList(bottomLeft, topRight, precision);
			this.isWorkingAreaSet = true;
			this.SetWorkingArea(bottomLeft, topRight, precision);
        }
示例#5
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="row">Row index</param>
 /// <param name="col">Column index</param>
 public Index(int row, int col)
 {
     this.row = row;
     this.col = col;
     this.dem = null;
     this.alt = null;
 }
示例#6
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="row">Row index.</param>
 /// <param name="col">Column index.</param>
 /// <param name="alt">Altitude.</param>
 /// <param name="nDem">DEM list index.</param>
 public Index(int row, int col, double alt, Dem dem)
 {
     this.row = row;
     this.col = col;
     this.dem = dem;
     this.alt = alt;
 }
示例#7
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="row">Row index.</param>
 /// <param name="col">Column index.</param>
 /// <param name="alt">Altitude.</param>
 public Index(int row, int col, double alt)
 {
     this.row = row;
     this.col = col;
     this.alt = alt;
     this.dem = null;
 }
示例#8
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="row">Row index.</param>
 /// <param name="col">Column index.</param>
 /// <param name="nDem">DEM list index.</param>
 public Index(int row, int col, Dem dem)
 {
     this.col = col;
     this.row = row;
     this.dem = dem;
     this.alt = null;
 }
示例#9
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="row">Row index</param>
 /// <param name="col">Column index</param>
 public Index(int row, int col)
 {
     this.row = row;
     this.col = col;
     this.dem = null;
     this.alt = null;
 }
示例#10
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="row">Row index.</param>
 /// <param name="col">Column index.</param>
 /// <param name="alt">Altitude.</param>
 public Index(int row, int col, double alt)
 {
     this.row = row; 
     this.col = col;
     this.alt = alt;
     this.dem = null;
 }
示例#11
0
 //---------------------------------------------------------------------
 /// <summary>
 ///
 /// </summary>
 /// <param name="bottomLeft">
 /// </param>
 /// <param name="topRight">
 /// </param>
 /// <param name="dem">
 /// </param>
 /// <param name="precision">
 /// </param>
 /// <returns>
 /// </returns>
 //---------------------------------------------------------------------
 public bool areIncluded(Point bottomLeft, Point topRight,
                         out Dem dem, Dem.Precision precision)
 {
     if (isIncluded(bottomLeft, out dem, precision) &&
         isIncluded(topRight, out dem, precision))
     {
         return(true);
     }
     dem = null;
     return(false);
 }
示例#12
0
 //---------------------------------------------------------------------
 /// <summary>
 /// Checks the avalaible DEM data for a specific waypoint depending on
 /// the cell size.
 /// </summary>
 /// <param name="p">
 /// The specific waypoint
 /// </param>
 /// <param name="dem">
 /// The dem where the waypoint is included.
 /// </param>
 /// <param name="cellSize">
 /// The preferred DEM cell size
 /// </param>
 /// <returns>
 /// </returns>
 //---------------------------------------------------------------------
 public bool isIncluded(Point p, out Dem dem,
                        Dem.Precision precision)
 {
     foreach (Dem d in demList)
     {
         if (d.precision == precision)
         {
             if (d.isIncluded(p))
             {
                 dem = d;
                 return(true);
             }
         }
     }
     dem = null;
     return(false);
 }
示例#13
0
 //---------------------------------------------------------------------
 /// <summary>
 /// Add a DEM object depending on the cellsize and the point that have 
 /// to be included.
 /// </summary>
 /// <param name="p">
 /// The included waypoint.
 /// </param>
 /// <param name="cellSize">
 /// The cell size.
 /// </param>
 //---------------------------------------------------------------------
 private Dem addDem(Point p, Dem.Precision precision)
 {
     int count = this.demList.Count;
     Dem dem;
     if (!isIncluded(p, out dem, precision))
     {
         if (!this.isWorkingAreaSet)
         {
             dem = DemFactory.createDem(p, precision, this.demList);
             this.demList.Add(dem);
         }
         else
         {
             return null;
         }
     }
     return dem;
 }
示例#14
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;
 }
示例#15
0
        public double getAltitude(Point p, Dem.Precision precision)
        {
            Dem dem = null;

            if (isIncluded(p, out dem, precision))
            {
                return(dem.getAltitudeFromCoords(p));
            }
            else
            {
                dem = this.addDem(p, precision);
                if (dem != null)
                {
                    return(dem.getAltitudeFromCoords(p));
                }
                else
                {
                    return(0.0);
                }
            }
        }
示例#16
0
        //---------------------------------------------------------------------
        /// <summary>
        /// Returns a
        /// </summary>
        /// <param name="bottomLeft">
        /// </param>
        /// <param name="topRight">
        /// </param>
        /// <param name="precision">
        /// </param>
        /// <returns></returns>
        //---------------------------------------------------------------------
        public Dem getSelection(Point bottomLeft, Point topRight,
                                Dem.Precision precision)
        {
            if (bottomLeft.getLatitude() > topRight.getLatitude())
            {
                if (bottomLeft.getLongitude() > topRight.getLongitude())
                {
                    Point aux = bottomLeft;
                    bottomLeft = topRight;
                    topRight   = aux;
                }
                else
                {
                    WgsPoint aux  = bottomLeft.toWgs();
                    WgsPoint aux2 = topRight.toWgs();
                    bottomLeft = new WgsPoint(aux2.getLatitude(),
                                              aux.getLongitude(), aux.getAltitude());
                    topRight = new WgsPoint(aux.getLatitude(),
                                            aux2.getLongitude(), aux2.getAltitude());
                }
            }
            else
            {
                if (bottomLeft.getLongitude() > topRight.getLongitude())
                {
                    WgsPoint aux  = bottomLeft.toWgs();
                    WgsPoint aux2 = topRight.toWgs();
                    bottomLeft = new WgsPoint(aux.getLatitude(),
                                              aux2.getLongitude(), aux.getAltitude());
                    topRight = new WgsPoint(aux2.getLatitude(),
                                            aux.getLongitude(), aux2.getAltitude());
                }
            }
            Dem dem = this.addDem(bottomLeft, topRight, precision);

            return(dem.getSelection(bottomLeft, topRight));
        }
示例#17
0
 public DemList(Point bottomLeft, Point topRight, Dem.Precision precision)
 {
     this.demList = new List<Dem>();
     this.demList.Add(DemFactory.createDem(bottomLeft, topRight, this.demList, precision));
     this.isWorkingAreaSet = true;
 }
示例#18
0
 public void SetWorkingArea(Point bottomLeft, Point topRight, Dem.Precision precision)
 {
     demList.getSelection(bottomLeft, topRight, precision);
 }
示例#19
0
 public double getAltitude(Point p, Dem.Precision precision)
 {
     return demList.getAltitude(p, precision);
 }
示例#20
0
 //---------------------------------------------------------------------
 /// <summary>
 /// Returns a
 /// </summary>
 /// <param name="bottomLeft">
 /// </param>
 /// <param name="topRight">
 /// </param>
 /// <param name="precision">
 /// </param>
 /// <returns></returns>
 //---------------------------------------------------------------------
 public Dem getSelection(Point bottomLeft, Point topRight,
     Dem.Precision precision)
 {
     if (bottomLeft.getLatitude() > topRight.getLatitude())
     {
         if (bottomLeft.getLongitude() > topRight.getLongitude())
         {
             Point aux = bottomLeft;
             bottomLeft = topRight;
             topRight = aux;
         }
         else
         {
             WgsPoint aux = bottomLeft.toWgs();
             WgsPoint aux2 = topRight.toWgs();
             bottomLeft = new WgsPoint(aux2.getLatitude(),
                 aux.getLongitude(), aux.getAltitude());
             topRight = new WgsPoint(aux.getLatitude(),
                 aux2.getLongitude(), aux2.getAltitude());
         }
     }
     else
     {
         if (bottomLeft.getLongitude() > topRight.getLongitude())
         {
             WgsPoint aux = bottomLeft.toWgs();
             WgsPoint aux2 = topRight.toWgs();
             bottomLeft = new WgsPoint(aux.getLatitude(),
                 aux2.getLongitude(), aux.getAltitude());
             topRight = new WgsPoint(aux2.getLatitude(),
                 aux.getLongitude(), aux2.getAltitude());
         }
     }
     Dem dem = this.addDem(bottomLeft, topRight, precision);
     return dem.getSelection(bottomLeft, topRight);
 }
示例#21
0
 //---------------------------------------------------------------------
 /// <summary>
 /// Selects the DEM generator depending on the cell size.
 /// </summary>
 /// <param name="p">
 /// The included waypoint.
 /// </param>
 /// <param name="cellSize">
 /// The preferred cellsize.
 /// </param>
 /// <returns>
 /// A DEM type.
 /// </returns>
 //---------------------------------------------------------------------
 private static DemType selectDemGenerator(Dem.Precision precision)
 {
     if (precision == Dem.Precision.low)
         return DemType.Srtm30;
     else if (precision == Dem.Precision.medium)
         return DemType.Srtm3;
     else
         return DemType.Icc;
 }
示例#22
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;
        }
示例#23
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;
        }
示例#24
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);
            }
        }
示例#25
0
 //---------------------------------------------------------------------
 /// <summary>
 /// Adds a DEM that complies with the input parametres unless it has
 /// been added before.
 /// </summary>
 /// <param name="bottomLeft">
 /// A <see cref="Point"/> representing the bottom left corner 
 /// coordinates of the specified DEM.
 /// </param>
 /// <param name="topRight">
 /// A <see cref="Point"/> representing the top right corner coordiantes
 /// of the specified DEM.
 /// </param>
 /// <param name="precision">
 /// A <see cref="Dem.Precision"/>.
 /// </param>
 /// <returns>
 /// A DEM that complies with the input parametres.
 /// </returns>
 //---------------------------------------------------------------------
 private Dem addDem(Point bottomLeft, Point topRight,
     Dem.Precision precision)
 {
     int count = this.demList.Count;
     Dem dem;
     if (!areIncluded(bottomLeft, topRight, out dem, precision))
     {
         if (!this.isWorkingAreaSet)
         {
             dem =
                 DemFactory.createDem(
                     bottomLeft, topRight, this.demList, precision);
             this.demList.Add(dem);
         }
         else
         {
             return null;
         }
     }
     return dem;
 }
示例#26
0
 //---------------------------------------------------------------------
 /// <summary>
 /// Checks the avalaible DEM data for a specific waypoint depending on 
 /// the cell size.
 /// </summary>
 /// <param name="p">
 /// The specific waypoint
 /// </param>
 /// <param name="dem">
 /// The dem where the waypoint is included.
 /// </param>
 /// <param name="cellSize">
 /// The preferred DEM cell size
 /// </param>
 /// <returns>
 /// </returns>
 //---------------------------------------------------------------------
 public bool isIncluded(Point p, out Dem dem,
     Dem.Precision precision)
 {
     foreach (Dem d in demList)
     {
         if (d.precision == precision)
         {
             if (d.isIncluded(p))
             {
                 dem = d;
                 return true;
             }
         }
     }
     dem = null;
     return false;
 }
示例#27
0
 //---------------------------------------------------------------------
 /// <summary>
 /// 
 /// </summary>
 /// <param name="bottomLeft">
 /// </param>
 /// <param name="topRight">
 /// </param>
 /// <param name="dem">
 /// </param>
 /// <param name="precision">
 /// </param>
 /// <returns>
 /// </returns>
 //---------------------------------------------------------------------
 public bool areIncluded(Point bottomLeft, Point topRight,
     out Dem dem, Dem.Precision precision)
 {
     if (isIncluded(bottomLeft, out dem, precision) &&
         isIncluded(topRight, out dem, precision))
         return true;
     dem = null;
     return false;
 }
示例#28
0
        public double getAltitude(Point p, Dem.Precision precision)
        {
            Dem dem = null;
            if (isIncluded(p, out dem, precision))
                return dem.getAltitudeFromCoords(p);
            else
            {
                dem = this.addDem(p, precision);
                if (dem != null)
                    return dem.getAltitudeFromCoords(p);
                else
                    return 0.0;

            }
        }
示例#29
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="row">Row index.</param>
 /// <param name="col">Column index.</param>
 /// <param name="alt">Altitude.</param>
 /// <param name="nDem">DEM list index.</param>
 public Index(int row, int col, double alt, Dem dem)
 {
     this.row = row;
     this.col = col;
     this.dem = dem;
     this.alt = alt;
 }
示例#30
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);
        }