Пример #1
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);
 }
Пример #2
0
        public object FunctionCall(String id, object[] parameters)
        {
            if (!isDemPrecisionSet && id != "SetPrecision")
            {
                Console.WriteLine("WARNING: DemPrecision is not set. DemManagerService will use default precisions.");
            }
            switch (id)
            {
            case "SetWorkingArea":
                WgsPoint bottomLeft = this.convertUsalPosToWgsPoint((USAL.Position)parameters[0]);
                WgsPoint topRight   = this.convertUsalPosToWgsPoint((USAL.Position)parameters[1]);
                f.SetWorkingArea(bottomLeft, topRight, demPrecision);
                break;

            case "SetPrecision":
                demPrecision      = (Dem.Precision)parameters[0];
                isDemPrecisionSet = true;
                Console.WriteLine("DemPrecision set to " + demPrecision);
                break;

            case "GetAltitude":
                WgsPoint pWgs = this.convertUsalPosToWgsPoint((USAL.Position)parameters[0]);
                double   alt  = f.getAltitude(pWgs, demPrecision);
                return(alt);
            }
            return(null);
        }
Пример #3
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);
            }
        }
Пример #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>
 ///
 /// </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);
 }
Пример #6
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);
     }
 }
Пример #7
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);
 }
Пример #8
0
        public void ReadXML(XmlTextReader xmltextreader, string endName)
        {
            bool   done    = false;
            string element = "";

            while (xmltextreader.Read() && !done)
            {
                if (xmltextreader.NodeType == XmlNodeType.Element)
                {
                    element = xmltextreader.Name;
                }
                else if (xmltextreader.NodeType == XmlNodeType.Text)
                {
                    switch (element)
                    {
                    case "demPrecision":
                        if (xmltextreader.Value == "low")
                        {
                            demPrecision = Dem.Precision.low;
                        }
                        else if (xmltextreader.Value == "medium")
                        {
                            demPrecision = Dem.Precision.medium;
                        }
                        else if (xmltextreader.Value == "high")
                        {
                            demPrecision = Dem.Precision.high;
                        }
                        break;

                    case "localGeoidHeight":
                        localGeoidHeight = float.Parse(xmltextreader.Value, NumberStyles.Float, CultureInfo.InvariantCulture);
                        break;
                    }
                }
                else if (xmltextreader.NodeType == XmlNodeType.EndElement)
                {
                    if (xmltextreader.Name == endName)
                    {
                        done = true;
                    }
                }
            }
        }
Пример #9
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);
        }
Пример #10
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);
                }
            }
        }
Пример #11
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);
        }
Пример #12
0
 public object FunctionCall(String id, object[] parameters)
 {
     if (!isDemPrecisionSet && id != "SetPrecision")
         Console.WriteLine("WARNING: DemPrecision is not set. DemManagerService will use default precisions.");
     switch (id)
     {
         case "SetWorkingArea":
             WgsPoint bottomLeft = this.convertUsalPosToWgsPoint((USAL.Position)parameters[0]);
             WgsPoint topRight = this.convertUsalPosToWgsPoint((USAL.Position)parameters[1]);
             f.SetWorkingArea(bottomLeft, topRight, demPrecision);
             break;
         case "SetPrecision":
             demPrecision = (Dem.Precision)parameters[0];
             isDemPrecisionSet = true;
             Console.WriteLine("DemPrecision set to " + demPrecision);
             break;
         case "GetAltitude":
             WgsPoint pWgs = this.convertUsalPosToWgsPoint((USAL.Position)parameters[0]);
             double alt = f.getAltitude(pWgs, demPrecision);
             return alt;
     }
     return null;
 }
Пример #13
0
        public void ReadXML(XmlTextReader xmltextreader, string endName)
        {
            bool done = false;
            string element = "";

            while (xmltextreader.Read() && !done)
            {
                if (xmltextreader.NodeType == XmlNodeType.Element)
                {
                    element = xmltextreader.Name;
                }
                else if (xmltextreader.NodeType == XmlNodeType.Text)
                {
                    switch (element)
                    {
                        case "demPrecision":
                            if (xmltextreader.Value == "low")
                                demPrecision = Dem.Precision.low;
                            else if (xmltextreader.Value == "medium")
                                demPrecision = Dem.Precision.medium;
                            else if (xmltextreader.Value == "high")
                                demPrecision = Dem.Precision.high;
                            break;
                        case "localGeoidHeight":
                            localGeoidHeight = float.Parse(xmltextreader.Value, NumberStyles.Float, CultureInfo.InvariantCulture);
                            break;
                    }
                }
                else if (xmltextreader.NodeType == XmlNodeType.EndElement)
                {
                    if (xmltextreader.Name == endName)
                    {
                        done = true;
                    }
                }
            }
        }
Пример #14
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));
        }
Пример #15
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;
 }
Пример #16
0
        public float localGeoidHeight;      // WGS84 geoid height in the area to scan

        public TerrainModelSettings()
        {
            demPrecision = Dem.Precision.medium;
            localGeoidHeight = 0;
        }
Пример #17
0
 public void SetWorkingArea(Point bottomLeft, Point topRight, Dem.Precision precision)
 {
     demList.getSelection(bottomLeft, topRight, precision);
 }
Пример #18
0
 public double getAltitude(Point p, Dem.Precision precision)
 {
     return(demList.getAltitude(p, precision));
 }
Пример #19
0
        public float localGeoidHeight;      // WGS84 geoid height in the area to scan

        public TerrainModelSettings()
        {
            demPrecision     = Dem.Precision.medium;
            localGeoidHeight = 0;
        }
Пример #20
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);
        }