Ejemplo n.º 1
0
        //-----------------------------------------------------------------------------

        /// <summary>
        /// Open function to produce a list of grid files.
        /// </summary>
        /// <param name="prmInput">Input las file</param>
        /// <param name="prmGridTypes">List of grid types</param>
        /// <param name="prmGridSizes">List of grid sizes</param>
        public void Grid(String prmInput, IEnumerable <TeGriddingType> prmGridTypes, IEnumerable <Int32> prmGridSizes)
        {
            List <TcGridObject> gridObjects = new List <TcGridObject>(prmGridTypes.Count() + prmGridSizes.Count());
            String xmlFile = String.Format(@"{0}\{1}.xml", Path.GetDirectoryName(prmInput), Path.GetFileNameWithoutExtension(prmInput));

            m_Info = TcTileUtils.GetTileBlocks(xmlFile);

            // Type defined las tiling.
            foreach (TeGriddingType type in prmGridTypes)
            {
                String outputFile = String.Format(@"{0}\{1}_{2}.tor"
                                                  , m_OutputDirectory
                                                  , Path.GetFileNameWithoutExtension(prmInput)
                                                  , TcEnums.ShortName(type));
                gridObjects.Add(new TcGridObject(outputFile, type, m_Info));
            }

            // Type defined las tiling.
            foreach (Int32 size in prmGridSizes.Distinct())
            {
                String outputFile = String.Format(@"{0}\{1}_m{2}.tor"
                                                  , m_OutputDirectory
                                                  , Path.GetFileNameWithoutExtension(prmInput)
                                                  , size);

                gridObjects.Add(new TcGridObject(outputFile, size, m_Info));
            }

            Grid(prmInput, gridObjects);
        }
Ejemplo n.º 2
0
        //-----------------------------------------------------------------------------

        private void Initialize(String prmFile, TcTileBlockInfoCollection prmInfo)
        {
            OutputFile         = prmFile;
            Info               = prmInfo;
            GridCount          = (Int32)Math.Ceiling(TileSize * 1.0 / GridSize);
            MinZ               = Double.MaxValue;
            MaxZ               = Double.MinValue;
            MaxRowsInGridBlock = (Int32)Math.Floor(TcConstants.MaxBytesToLoadInTorBlock * 1.0 / (Info.TileInfo.Col * GridCount * sizeof(Single)));
            NumberOfGridBlocks = (Int32)Math.Ceiling(Info.TileInfo.Row * GridCount * 1.0 / MaxRowsInGridBlock);
            TorBlocks          = new List <TcTorBlock32>();

            Int32 rowsProcessed = 0;

            for (int gc = 0; gc < NumberOfGridBlocks; gc++)
            {
                Int32        rowsInGrid = Math.Min(MaxRowsInGridBlock, Info.TileInfo.Row * GridCount - rowsProcessed);
                TcTorBlock32 block      = new TcTorBlock32(gc, rowsInGrid, prmInfo.TileInfo.Col * GridCount);
                for (int r = 0; r < rowsInGrid; r++)
                {
                    for (int c = 0; c < prmInfo.TileInfo.Col * GridCount; c++)
                    {
                        block.Points[r, c] = TcConstants.TorNullValue32Bit;
                    }
                }
                TorBlocks.Add(block);
            }
        }
Ejemplo n.º 3
0
        //-----------------------------------------------------------------------------

        public LasPoint2[] GetPointsByTile(String prmInput, Int32 prmRow, Int32 prmCol)
        {
            String blockFile = String.Format(@"{0}\{1}.xml", Path.GetDirectoryName(prmInput), Path.GetFileNameWithoutExtension(prmInput));
            TcTileBlockInfoCollection tileInfoCollection = TcTileUtils.GetTileBlocks(blockFile);

            IEnumerable <TcTileBlockInfo> blocks = tileInfoCollection.TileBlocks.Where(iter => iter.Row == prmRow && iter.Col == prmCol);
            Int32 numberOfPoints = blocks.Aggregate(0, (result, iter) => result += iter.NoOfPoints);

            using (TcLasReader reader = new TcLasReader(prmInput))
            {
                LasHeader   header     = reader.GetHeaderOld();
                LasPoint2[] points     = new LasPoint2[numberOfPoints];
                Int32       arrayStart = 0;
                foreach (TcTileBlockInfo info in blocks)
                {
                    if (reader.GetLasBlock(ref points, arrayStart, info.StartPoint, info.NoOfPoints, header))
                    {
                        arrayStart += info.NoOfPoints;
                    }
                    else
                    {
                        throw new Exception(String.Format("Couldn't read the las tile ({0},{1})", prmRow, prmCol));
                    }
                }
                return(points);
            }
        }
Ejemplo n.º 4
0
 public TcLasTiler(Int32 prmTileSize = 1000, Int32 prmTileBlockSize = 1000, Int32 prmFactor = 1)
 {
     m_TileSize                = prmTileSize;
     m_TileBlockSize           = prmTileBlockSize;
     m_Factor                  = prmFactor;
     m_TileBlocks              = new Dictionary <Int32, LasPoint2[]>();
     m_BlockPointCount         = new Dictionary <Int32, Int32>();
     m_TileBlockInfoCollection = null;
 }
Ejemplo n.º 5
0
        //-----------------------------------------------------------------------------

#warning Vicky: It can be removed if it didn't affect other projects.
        private void UpdateTileCounts(ref TiLasHeader prmHeader, Int32 prmSize)
        {
            prmHeader.MinX = (prmHeader.MinX + XAdjustment) - ((prmHeader.MinX + XAdjustment) % (prmSize * Factor));
            prmHeader.MinY = (prmHeader.MinY + YAdjustment) - ((prmHeader.MinY + YAdjustment) % (prmSize * Factor));
            prmHeader.MaxX = (prmHeader.MaxX + XAdjustment) - ((prmHeader.MaxX + XAdjustment) % (prmSize * Factor)) + (prmSize * Factor);
            prmHeader.MaxY = (prmHeader.MaxY + YAdjustment) - ((prmHeader.MaxY + YAdjustment) % (prmSize * Factor)) + (prmSize * Factor);

            m_RevisedEast             = (Int32)prmHeader.MinX;
            m_RevisedNorth            = (Int32)prmHeader.MaxY;
            m_TileColumns             = (Int32)(prmHeader.MaxX - prmHeader.MinX) / (prmSize * Factor);
            m_TileRows                = (Int32)(prmHeader.MaxY - prmHeader.MinY) / (prmSize * Factor);
            m_TileBlockInfoCollection = new TcTileBlockInfoCollection(prmSize, m_TileRows, m_TileColumns);
        }
Ejemplo n.º 6
0
        //-----------------------------------------------------------------------------

        private void UpdateTileCounts(LasHeader prmHeader, Int32 prmSize)
        {
            prmHeader.MinX = prmHeader.MinX - (prmHeader.MinX % (prmSize * m_Factor));
            prmHeader.MinY = prmHeader.MinY - (prmHeader.MinY % (prmSize * m_Factor));
            prmHeader.MaxX = prmHeader.MaxX - (prmHeader.MaxX % (prmSize * m_Factor)) + (prmSize * m_Factor);
            prmHeader.MaxY = prmHeader.MaxY - (prmHeader.MaxY % (prmSize * m_Factor)) + (prmSize * m_Factor);

            m_RevisedEast  = (Int32)prmHeader.MinX;
            m_RevisedNorth = (Int32)prmHeader.MaxY;
            m_TileColumns  = (Int32)(prmHeader.MaxX - prmHeader.MinX) / (prmSize * m_Factor);
            m_TileRows     = (Int32)(prmHeader.MaxY - prmHeader.MinY) / (prmSize * m_Factor);

            m_TileBlockInfoCollection = new TcTileBlockInfoCollection(prmSize, m_TileRows, m_TileColumns);
        }
Ejemplo n.º 7
0
        //-----------------------------------------------------------------------------

        /// <summary>
        /// Open function to produce a single grid file with a given type.
        /// </summary>
        /// <param name="prmInput">Input las file</param>
        /// <param name="prmOutputFileName">Output tor file name</param>
        /// <param name="prmGridSize">Size of the grid</param>
        public void Grid(String prmInput, String prmOutputFileName, Int32 prmGridSize)
        {
            // Start of the actual function.
            String blockFile = String.Format(@"{0}\{1}.xml", Path.GetDirectoryName(prmInput), Path.GetFileNameWithoutExtension(prmInput));

            m_Info = TcTileUtils.GetTileBlocks(blockFile);

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

            Grid(prmInput, new List <TcGridObject>(1)
            {
                new TcGridObject(outputFile, prmGridSize, m_Info)
            });
        }
Ejemplo n.º 8
0
        public TcLasIndexMaker()
        {
            m_BlockPointCount         = new Dictionary <Int32, Int32>();
            m_TileBlockInfoCollection = null;

            ProgressFrequency = 5;
            TileSize          = 200;
            PointBlockSize    = 20000;
            Factor            = 1;
            XAdjustment       = 0.0;
            YAdjustment       = 0.0;
            ZAdjustment       = 0.0;
            MinClampZ         = Double.MinValue;
            MaxClampZ         = Double.MaxValue;
        }
Ejemplo n.º 9
0
        //-----------------------------------------------------------------------------

        static public void SaveTileBlocks(TcTileBlockInfoCollection prmInfo, String prmFile)
        {
            using (XmlWriter xmlWriter = XmlWriter.Create(prmFile))
            {
                try
                {
                    XmlSerializer serializer = new XmlSerializer(typeof(TcTileBlockInfoCollection));
                    serializer.Serialize(xmlWriter, prmInfo);
                }
                finally
                {
                    xmlWriter.Flush();
                    xmlWriter.Close();
                }
            }
        }
Ejemplo n.º 10
0
        //-----------------------------------------------------------------------------

        public TcGridObject(String prmFile, Int32 prmGridSize, TcTileBlockInfoCollection prmInfo)
        {
            Type     = TeGriddingType.Unknown;
            GridSize = prmGridSize;
            Initialize(prmFile, prmInfo);
        }
Ejemplo n.º 11
0
 public TcGridObject(String prmFile, TeGriddingType prmType, TcTileBlockInfoCollection prmInfo)
 {
     Type     = prmType;
     GridSize = GetGridSize(prmType);
     Initialize(prmFile, prmInfo);
 }
Ejemplo n.º 12
0
 public TcTileLasReader(String prmInput, TcTileBlockInfoCollection prmTileInfo)
     : base(prmInput)
 {
     m_TileInfo = prmTileInfo;
 }
Ejemplo n.º 13
0
        private TiLasHeader UpdateTileCounts <T>(TiLasHeader prmTileHeader, Int32 prmSize) where T : TiLasPoint
        {
            if (prmTileHeader is TsLasHeader12)
            {
                TsLasHeader12 tileHeader = (TsLasHeader12)prmTileHeader;
                tileHeader.MinX = (tileHeader.MinX + XAdjustment) - ((tileHeader.MinX + XAdjustment) % (prmSize * Factor));
                tileHeader.MinY = (tileHeader.MinY + YAdjustment) - ((tileHeader.MinY + YAdjustment) % (prmSize * Factor));
                tileHeader.MaxX = (tileHeader.MaxX + XAdjustment) - ((tileHeader.MaxX + XAdjustment) % (prmSize * Factor)) + (prmSize * Factor);
                tileHeader.MaxY = (tileHeader.MaxY + YAdjustment) - ((tileHeader.MaxY + YAdjustment) % (prmSize * Factor)) + (prmSize * Factor);
                tileHeader.NumberOfPointRecords    = 0;
                tileHeader.NumberofPointsByReturn1 = 0;
                tileHeader.NumberofPointsByReturn2 = 0;
                tileHeader.NumberofPointsByReturn3 = 0;
                tileHeader.NumberofPointsByReturn4 = 0;
                tileHeader.NumberofPointsByReturn5 = 0;

                m_RevisedEast             = (Int32)tileHeader.MinX;
                m_RevisedNorth            = (Int32)tileHeader.MaxY;
                m_TileColumns             = (Int32)(tileHeader.MaxX - tileHeader.MinX) / (prmSize * Factor);
                m_TileRows                = (Int32)(tileHeader.MaxY - tileHeader.MinY) / (prmSize * Factor);
                m_TileBlockInfoCollection = new TcTileBlockInfoCollection(prmSize, m_TileRows, m_TileColumns);

                return(tileHeader);
            }
            else if (prmTileHeader is TsLasHeader13)
            {
                TsLasHeader13 tileHeader = (TsLasHeader13)prmTileHeader;
                tileHeader.MinX = (tileHeader.MinX + XAdjustment) - ((tileHeader.MinX + XAdjustment) % (prmSize * Factor));
                tileHeader.MinY = (tileHeader.MinY + YAdjustment) - ((tileHeader.MinY + YAdjustment) % (prmSize * Factor));
                tileHeader.MaxX = (tileHeader.MaxX + XAdjustment) - ((tileHeader.MaxX + XAdjustment) % (prmSize * Factor)) + (prmSize * Factor);
                tileHeader.MaxY = (tileHeader.MaxY + YAdjustment) - ((tileHeader.MaxY + YAdjustment) % (prmSize * Factor)) + (prmSize * Factor);
                tileHeader.NumberOfPointRecords    = 0;
                tileHeader.NumberofPointsByReturn1 = 0;
                tileHeader.NumberofPointsByReturn2 = 0;
                tileHeader.NumberofPointsByReturn3 = 0;
                tileHeader.NumberofPointsByReturn4 = 0;
                tileHeader.NumberofPointsByReturn5 = 0;

                m_RevisedEast             = (Int32)tileHeader.MinX;
                m_RevisedNorth            = (Int32)tileHeader.MaxY;
                m_TileColumns             = (Int32)(tileHeader.MaxX - tileHeader.MinX) / (prmSize * Factor);
                m_TileRows                = (Int32)(tileHeader.MaxY - tileHeader.MinY) / (prmSize * Factor);
                m_TileBlockInfoCollection = new TcTileBlockInfoCollection(prmSize, m_TileRows, m_TileColumns);

                return(tileHeader);
            }
            else if (prmTileHeader is TsLasHeader14)
            {
                TsLasHeader14 tileHeader = (TsLasHeader14)prmTileHeader;
                tileHeader.MinX = (tileHeader.MinX + XAdjustment) - ((tileHeader.MinX + XAdjustment) % (prmSize * Factor));
                tileHeader.MinY = (tileHeader.MinY + YAdjustment) - ((tileHeader.MinY + YAdjustment) % (prmSize * Factor));
                tileHeader.MaxX = (tileHeader.MaxX + XAdjustment) - ((tileHeader.MaxX + XAdjustment) % (prmSize * Factor)) + (prmSize * Factor);
                tileHeader.MaxY = (tileHeader.MaxY + YAdjustment) - ((tileHeader.MaxY + YAdjustment) % (prmSize * Factor)) + (prmSize * Factor);
                tileHeader.NumberOfPointRecords       = 0;
                tileHeader.NumberofPointsByReturn1    = 0;
                tileHeader.NumberofPointsByReturn2    = 0;
                tileHeader.NumberofPointsByReturn3    = 0;
                tileHeader.NumberofPointsByReturn4    = 0;
                tileHeader.NumberofPointsByReturn5    = 0;
                tileHeader.NumberofPointsByReturn6    = 0;
                tileHeader.NumberofPointsByReturn7    = 0;
                tileHeader.NumberofPointsByReturn8    = 0;
                tileHeader.NumberofPointsByReturn9    = 0;
                tileHeader.NumberofPointsByReturn10   = 0;
                tileHeader.NumberofPointsByReturn11   = 0;
                tileHeader.NumberofPointsByReturn12   = 0;
                tileHeader.NumberofPointsByReturn13   = 0;
                tileHeader.NumberofPointsByReturn14   = 0;
                tileHeader.NumberofPointsByReturn15   = 0;
                tileHeader.LegNumberofPointsByReturn1 = 0;
                tileHeader.LegNumberofPointsByReturn2 = 0;
                tileHeader.LegNumberofPointsByReturn3 = 0;
                tileHeader.LegNumberofPointsByReturn4 = 0;
                tileHeader.LegNumberofPointsByReturn5 = 0;

                m_RevisedEast             = (Int32)tileHeader.MinX;
                m_RevisedNorth            = (Int32)tileHeader.MaxY;
                m_TileColumns             = (Int32)(tileHeader.MaxX - tileHeader.MinX) / (prmSize * Factor);
                m_TileRows                = (Int32)(tileHeader.MaxY - tileHeader.MinY) / (prmSize * Factor);
                m_TileBlockInfoCollection = new TcTileBlockInfoCollection(prmSize, m_TileRows, m_TileColumns);
                return(tileHeader);
            }

            throw new InvalidDataException("Couldn't update the Tile Header. Invalid data format.");
        }