Beispiel #1
0
 /// <summary>
 /// A rasterizer.
 /// </summary>
 /// <remarks>
 /// For more info see http://www.codeproject.com/KB/graphics/bresenham_revisited.aspx
 /// </remarks>
 /// <param name="begin">The index of the begin of the line.</param>
 /// <param name="end">The index of the begin of the line.</param>
 /// <param name="dem">A list of dems.</param>
 /// <returns>A list with the rastered indexs</returns>
 private static List<Index> rasterizeLineOrig(Index begin, Index end, double scaleFactor)
 {
     List<Index> retIndex = new List<Index>();
     double totalDistance = Math.Sqrt(Math.Pow((begin.getRow() - end.getRow()), 2) + Math.Pow((begin.getCol() - end.getCol()), 2));
     double totalHeight = (double)(end.getAlt() - begin.getAlt())/scaleFactor;
     double angle = Math.Atan2(totalHeight,totalDistance);
     int deltaX = end.getCol() - begin.getCol();
     int deltaY = (int)Math.Abs(begin.getRow() - end.getRow());
     int error = (int)(deltaX / 2.0);
     int yStep = 1;
     if (end.getRow() < begin.getRow())
         yStep = -1;
     else if (end.getRow() == begin.getRow())
         yStep = 0;
     int indX = begin.getCol();
     int indY = begin.getRow();
     retIndex.Add(begin);
     while (indX < end.getCol())
     {
         indX++;
         error -= deltaY;
         if (error < 0)
         {
             indY += yStep;
             error += deltaX;
         }
         double d = Math.Sqrt(Math.Pow((begin.getRow() - indY), 2) + Math.Pow((begin.getCol() - indX), 2));
         double alt = (double)begin.getAlt() + d * Math.Tan(angle) * scaleFactor;
         retIndex.Add(new Index(indY, indX, alt));
     }
     return retIndex;
 }
Beispiel #2
0
        //---------------------------------------------------------------------
        /// <summary>
        /// Return the terrain altitude from the specified indexs.
        /// </summary>
        /// <param name="index">
        /// The specified indexs.
        /// </param>
        /// <returns>
        /// The terrain altitude.
        /// </returns>
        //---------------------------------------------------------------------
        public override WgsPoint indexToPoint(Index index)
        {
            double utmY = this.bottomLeft.getUtmY() + this.cellSize *
                          (this.rows - index.getRow());
            double utmX = this.bottomLeft.getUtmX() + this.cellSize *
                          index.getCol();

            if (this.bottomLeft.getLatitude() < 0)
            {
                return(new WgsPoint(utmX, utmY, index.getAlt(),
                                    this.bottomLeft.getTimeZone(), 'S'));
            }
            else
            {
                return(new WgsPoint(utmX, utmY, index.getAlt(),
                                    this.bottomLeft.getTimeZone(), 'N'));
            }
        }
Beispiel #3
0
        //---------------------------------------------------------------------
        /// <summary>
        /// Returns the correspoding waypoint from the specified indexs.
        /// </summary>
        /// <param name="index">
        /// The specified indexs.
        /// </param>
        /// <returns>
        /// The corresponding waypoint.
        /// </returns>
        //---------------------------------------------------------------------
        public override WgsPoint indexToPoint(Index index)
        {
            double latitude = this.bottomLeft.getLatitude() +
                              this.cellSize * (this.rows - index.getRow());
            double longitude = this.bottomLeft.getLongitude() +
                               this.cellSize * index.getCol();

            return(new WgsPoint(latitude, longitude, index.getAlt()));
        }
Beispiel #4
0
        /// <summary>
        /// A rasterizer.
        /// </summary>
        /// <remarks>
        /// For more info see http://www.codeproject.com/KB/graphics/bresenham_revisited.aspx
        /// </remarks>
        /// <param name="begin">The index of the begin of the line.</param>
        /// <param name="end">The index of the begin of the line.</param>
        /// <param name="dem">A list of dems.</param>
        /// <returns>A list with the rastered indexs</returns>
        private static List <Index> rasterizeLineOrig(Index begin, Index end, double scaleFactor)
        {
            List <Index> retIndex      = new List <Index>();
            double       totalDistance = Math.Sqrt(Math.Pow((begin.getRow() - end.getRow()), 2) + Math.Pow((begin.getCol() - end.getCol()), 2));
            double       totalHeight   = (double)(end.getAlt() - begin.getAlt()) / scaleFactor;
            double       angle         = Math.Atan2(totalHeight, totalDistance);
            int          deltaX        = end.getCol() - begin.getCol();
            int          deltaY        = (int)Math.Abs(begin.getRow() - end.getRow());
            int          error         = (int)(deltaX / 2.0);
            int          yStep         = 1;

            if (end.getRow() < begin.getRow())
            {
                yStep = -1;
            }
            else if (end.getRow() == begin.getRow())
            {
                yStep = 0;
            }
            int indX = begin.getCol();
            int indY = begin.getRow();

            retIndex.Add(begin);
            while (indX < end.getCol())
            {
                indX++;
                error -= deltaY;
                if (error < 0)
                {
                    indY  += yStep;
                    error += deltaX;
                }
                double d   = Math.Sqrt(Math.Pow((begin.getRow() - indY), 2) + Math.Pow((begin.getCol() - indX), 2));
                double alt = (double)begin.getAlt() + d * Math.Tan(angle) * scaleFactor;
                retIndex.Add(new Index(indY, indX, alt));
            }
            return(retIndex);
        }
Beispiel #5
0
        //---------------------------------------------------------------------
        /// <summary>
        /// Return the terrain altitude from the specified indexs.
        /// </summary>
        /// <param name="index">
        /// The specified indexs.
        /// </param>
        /// <returns>
        /// The terrain altitude.
        /// </returns>
        //---------------------------------------------------------------------
        public override WgsPoint indexToPoint(Index index)
        {
            double utmY = this.bottomLeft.getUtmY() + this.cellSize * 
                (this.rows - index.getRow());
            double utmX = this.bottomLeft.getUtmX() + this.cellSize * 
                index.getCol();
            if (this.bottomLeft.getLatitude() < 0)
                return new WgsPoint(utmX, utmY, index.getAlt(),
                    this.bottomLeft.getTimeZone(), 'S');
            else
                return new WgsPoint(utmX, utmY, index.getAlt(),
                    this.bottomLeft.getTimeZone(), 'N');

        }
Beispiel #6
0
 //---------------------------------------------------------------------
 /// <summary>
 /// Returns the correspoding waypoint from the specified indexs.
 /// </summary>
 /// <param name="index">
 /// The specified indexs.
 /// </param>
 /// <returns>
 /// The corresponding waypoint.
 /// </returns>
 //---------------------------------------------------------------------
 public override WgsPoint indexToPoint(Index index)
 {
     double latitude = this.bottomLeft.getLatitude() + 
         this.cellSize * (this.rows - index.getRow());
     double longitude = this.bottomLeft.getLongitude() + 
         this.cellSize * index.getCol();
     return new WgsPoint(latitude, longitude, index.getAlt());
 }