示例#1
0
        //-----------------------------------------------------------------------------

        /// <summary>
        /// Check whether a line intersect a rectangle or not.
        /// </summary>
        /// <param name="p1">TcPoint 1 of Line 1</param>
        /// <param name="p2">TcPoint 2 of Line 1</param>
        /// <param name="r">Rectangle</param>
        /// <returns>True if intersects and False otherwise</returns>
        static public Boolean LineIntersectRectangle(TcPoint p1, TcPoint p2, TcRectangle r)
        {
            return(LineIntersectsLine(p1, p2, new TcPoint(r.UpperLeftX, r.LowerRightY), new TcPoint(r.LowerRightX, r.LowerRightY)) ||
                   LineIntersectsLine(p1, p2, new TcPoint(r.LowerRightX, r.LowerRightY), new TcPoint(r.LowerRightX, r.UpperLeftY)) ||
                   LineIntersectsLine(p1, p2, new TcPoint(r.LowerRightX, r.UpperLeftY), new TcPoint(r.UpperLeftX, r.UpperLeftY)) ||
                   LineIntersectsLine(p1, p2, new TcPoint(r.UpperLeftX, r.UpperLeftY), new TcPoint(r.UpperLeftX, r.LowerRightY)) ||
                   (r.Contains(p1) && r.Contains(p2)));
        }
示例#2
0
        public TcTileAreaBlock(TcRectangle prmArea)
        {
            Area       = new TcTileGrid(prmArea.UpperLeftX, prmArea.UpperLeftY, prmArea.LowerRightX, prmArea.LowerRightY);
            FileBlocks = new HashSet <TcTileFileBlock>();

            Index      = -1;
            OutputFile = String.Empty;
        }
示例#3
0
        //-----------------------------------------------------------------------------

        public TcRectangle GetOverlappedArea(Double prmUpperLeftEast, Double prmUpperLeftNorth, Double prmLowerRightEast, Double prmLowerRightNorth)
        {
            Int32 upperLeftEast   = TileBlocks.Min(iter => iter.East);
            Int32 upperLeftNorth  = TileBlocks.Max(iter => iter.North);
            Int32 lowerRightEast  = TileBlocks.Max(iter => iter.East);
            Int32 lowerRightNorth = TileBlocks.Min(iter => iter.North);

            return(TcRectangle.OverlapArea(upperLeftEast, upperLeftNorth, lowerRightEast, lowerRightNorth, prmUpperLeftEast, prmUpperLeftNorth, prmLowerRightEast, prmLowerRightNorth));
        }
示例#4
0
        //-----------------------------------------------------------------------------

        public Boolean HasOverlap(Double prmUpperLeftEast, Double prmUpperLeftNorth, Double prmLowerRightEast, Double prmLowerRightNorth)
        {
            Int32 upperLeftEast   = TileBlocks.Min(iter => iter.East);
            Int32 upperLeftNorth  = TileBlocks.Max(iter => iter.North);
            Int32 lowerRightEast  = TileBlocks.Max(iter => iter.East);
            Int32 lowerRightNorth = TileBlocks.Min(iter => iter.North);

            return(TcRectangle.HasOverlap(upperLeftEast, upperLeftNorth, lowerRightEast, lowerRightNorth, prmUpperLeftEast, prmUpperLeftNorth, prmLowerRightEast, prmLowerRightNorth));
        }
示例#5
0
        //-----------------------------------------------------------------------------

        public List <TcTileBlockInfo> GetTileBlocks(TcRectangle prmRect)
        {
            List <TcTileBlockInfo> tileBlocks = new List <TcTileBlockInfo>();

            foreach (TcTileBlockInfo info in TileBlocks)
            {
                if (prmRect.HasOverlap(info.East, info.North, info.East + TileInfo.TileSize, info.North - TileInfo.TileSize))
                {
                    tileBlocks.Add(info);
                }
            }
            return(tileBlocks);
        }
示例#6
0
        //-----------------------------------------------------------------------------

        public List <Int32> GetTileIndices(TcRectangle prmArea)
        {
            HashSet <Int32> indices = new HashSet <Int32>();

            foreach (TcTileBlockInfo info in TileBlocks)
            {
                if (prmArea.HasOverlap(info.East, info.North, info.East + TileInfo.TileSize, info.North - TileInfo.TileSize))
                {
                    indices.Add(info.Row * TileInfo.Col + info.Col);
                }
            }
            return(indices.ToList());
        }
示例#7
0
        //-----------------------------------------------------------------------------

        public T[] FilterPointsByArea <T>(T[] prmPoints, TcRectangle prmArea) where T : TiLasPoint
        {
            List <T> filteredPoints = new List <T>();

            for (int i = 0; i < prmPoints.Length; i++)
            {
                if ((prmPoints[i].X >= prmArea.UpperLeftX && prmPoints[i].X <= prmArea.LowerRightX) &&
                    (prmPoints[i].Y <= prmArea.UpperLeftY && prmPoints[i].Y >= prmArea.LowerRightY))
                {
                    filteredPoints.Add(prmPoints[i]);
                }
            }
            return(filteredPoints.ToArray());
        }
示例#8
0
        //-----------------------------------------------------------------------------

        private void ProcessBlockSets(IEnumerable <String> prmFiles, TcRectangle prmTileArea, String prmOutputFileName)
        {
            TcTileAreaBlock areaBlock = new TcTileAreaBlock(prmTileArea)
            {
                Index = 0
            };

            areaBlock.OutputFile = String.Format(@"{0}\{1}", m_OutputDirectory, prmOutputFileName);

            ProcessBlockSets(prmFiles, new List <TcTileAreaBlock>(1)
            {
                areaBlock
            });
        }
示例#9
0
        //-----------------------------------------------------------------------------

        private void InitializeGrid(Double prmULE, Double prmULN, Double prmLRE, Double prmLRN)
        {
            m_FullArea = new TcRectangle
                         (
                prmULE - (prmULE % (TileSize * ScalingFactor)),
                prmULN + (TileSize * ScalingFactor - (prmULN % (TileSize * ScalingFactor))),
                prmLRE + (TileSize * ScalingFactor - (prmLRE % (TileSize * ScalingFactor))),
                prmLRN - (prmLRN % (TileSize * ScalingFactor))
                         );

            m_Rows    = (Int32)((m_FullArea.UpperLeftY - m_FullArea.LowerRightY) / TileSize);
            m_Columns = (Int32)((m_FullArea.LowerRightX - m_FullArea.UpperLeftX) / TileSize);
            m_TilesToProcessAtOnce = TilingMethod == TeTilingMethod.OneRowAtOnce ? m_Columns : (Int32)TilingMethod;

            // Create the polygons to be loaded.
            for (int i = 0; i < m_Rows; i++)
            {
                for (int j = 0; j < m_Columns; j++)
                {
                    m_TilePolygons.Add
                    (
                        new TcTileGrid
                        (
                            m_FullArea.UpperLeftX + j * TileSize - Buffer,
                            m_FullArea.UpperLeftY - i * TileSize + Buffer,
                            m_FullArea.UpperLeftX + (j + 1) * TileSize + Buffer,
                            m_FullArea.UpperLeftY - (i + 1) * TileSize - Buffer
                        )
                    {
                        Row = i, Col = j
                    }
                    );
                }
            }

            // Write the tiles into a coo file.
            using (StreamWriter write = new StreamWriter(new FileStream(String.Format(@"{0}\atlass_tiling_grid.coo", m_OutputDirectory), FileMode.Create)))
            {
                foreach (TcRectangle tile in m_TilePolygons)
                {
                    write.WriteLine(String.Format("{0:0.0000} {1:0.0000} 0.0", tile.UpperLeftX, tile.UpperLeftY));
                    write.WriteLine(String.Format("{0:0.0000} {1:0.0000} 0.0", tile.LowerRightX, tile.UpperLeftY));
                    write.WriteLine(String.Format("{0:0.0000} {1:0.0000} 0.0", tile.LowerRightX, tile.LowerRightY));
                    write.WriteLine(String.Format("{0:0.0000} {1:0.0000} 0.0", tile.UpperLeftX, tile.LowerRightY));
                    write.WriteLine(String.Format("{0:0.0000} {1:0.0000} 0.0", tile.UpperLeftX, tile.UpperLeftY));
                    write.WriteLine(String.Empty);
                }
            }
        }
示例#10
0
        //-----------------------------------------------------------------------------

        public void TrimTile(String prmInputFile, Double prmMetersToTrim, String prmOutputFileName)
        {
            // Function to update the list of tiles to be processed.
            UpdateCommonHeader(new List <String>(1)
            {
                prmInputFile
            });

            TcRectangle rectangle = new TcRectangle
                                    (
                m_AreaHeader.MinX + prmMetersToTrim,
                m_AreaHeader.MaxY - prmMetersToTrim,
                m_AreaHeader.MaxX - prmMetersToTrim,
                m_AreaHeader.MinY + prmMetersToTrim
                                    );

            // Process a set of blocks to be processed for the given tiles.
            ProcessBlockSets(new List <String>(1)
            {
                prmInputFile
            }, rectangle, prmOutputFileName);
        }
示例#11
0
        //-----------------------------------------------------------------------------

        public TcRectangle GetOverlappedArea(TcRectangle prmArea)
        {
            return(GetOverlappedArea(prmArea.UpperLeftX, prmArea.UpperLeftY, prmArea.LowerRightX, prmArea.LowerRightY));
        }
示例#12
0
        //-----------------------------------------------------------------------------

        public Boolean HasOverlap(TcRectangle prmRect)
        {
            return(HasOverlap(prmRect.UpperLeftX, prmRect.UpperLeftY, prmRect.LowerRightX, prmRect.LowerRightY));
        }
示例#13
0
        //-----------------------------------------------------------------------------

        public T[] GetPointsByArea <T>(TcRectangle prmArea) where T : TiLasPoint
        {
            return(GetPointsByTileBlocks <T>(m_TileInfo.GetTileBlocks(prmArea)));
        }
示例#14
0
        //-----------------------------------------------------------------------------

        public TcLasPointBase[] GetPointObjectsByArea <T>(TcRectangle prmArea, TiLasHeader prmHeader) where T : TiLasPoint
        {
            return(GetPointObjectsByTileBlocks <T>(m_TileInfo.GetTileBlocks(prmArea), prmHeader));
        }
示例#15
0
        //-----------------------------------------------------------------------------

        /// <summary>
        /// Compare whether two rectangles are equal or not.
        /// </summary>
        /// <param name="prmRect1">Rectangle 1</param>
        /// <param name="prmRect2">Rectangle 2</param>
        /// <returns>True if equal, and False otherwise</returns>
        static public Boolean RectangleEquals(TcRectangle prmRect1, TcRectangle prmRect2)
        {
            return(prmRect1.UpperLeftX == prmRect2.UpperLeftX && prmRect1.UpperLeftY == prmRect2.UpperLeftY &&
                   prmRect1.LowerRightX == prmRect2.LowerRightX && prmRect1.LowerRightY == prmRect2.LowerRightY);
        }