Beispiel #1
0
        public PointCloudTileSource Process(ProgressManager progressManager)
        {
            progressManager.Log("<= {0}", m_inputHandler.FilePath);

            PerformanceManager.Start(m_inputHandler.FilePath);

            // check for existing tile source
            LoadFromCache(progressManager);

            if (m_tileSource == null)
            {
                using (var process = progressManager.StartProcess("ProcessSet"))
                {
                    m_binarySource = m_inputHandler.GenerateBinarySource(progressManager);
                    m_tiledHandler = LASFile.Create(m_tiledHandler.FilePath, m_binarySource);

                    using (var segmentBuffer = BufferManager.AcquireBuffer(m_id, (int)PROPERTY_SEGMENT_SIZE.Value, true))
                    {
                        var tileManager = new PointCloudTileManager(m_binarySource);
                        m_tileSource = tileManager.TilePointFileIndex(m_tiledHandler, segmentBuffer, progressManager);
                    }

#warning this was for xyz, but I have not yet re-implemented that anyway
                    //if (m_binarySource.FilePath != m_inputHandler.FilePath)
                    //    File.Delete(m_binarySource.FilePath);

                    if (m_tileSource.IsDirty)
                    {
                        m_tileSource.Close();
                        File.Delete(m_tileSource.FilePath);
                        m_tileSource = null;

                        process.LogTime("=> Processing Cancelled");
                    }
                    else
                    {
                        process.LogTime("=> Processing Completed");
                    }
                }

                GC.Collect();
            }

            TransferRate averageReadSpeed  = PerformanceManager.GetReadSpeed();
            TransferRate averageWriteSpeed = PerformanceManager.GetWriteSpeed();

            Context.WriteLine("IO Read Speed: {0}", averageReadSpeed);
            Context.WriteLine("IO Write Speed: {0}", averageWriteSpeed);

            //{
            //    // test
            //    Stopwatch stopwatch = new Stopwatch();
            //    stopwatch.Start();

            //    PointCloudTile tempTile = m_tileSource.TileSet[0, 0];
            //    Grid<float> grid = new Grid<float>(tempTile.Extent, 540, (float)m_tileSource.Extent.MinZ - 1.0f, true);
            //    Grid<uint> quantizedGrid = new Grid<uint>(grid.SizeX, grid.SizeY, m_tileSource.Extent, true);

            //    using (GridTileSource<float> gridSource = new GridTileSource<float>(m_tiledPath + ".grid", grid.SizeX, grid.SizeY, m_tileSource.TileSet.Cols, m_tileSource.TileSet.Rows))
            //    {
            //        int tempBufferSize = (int)(m_tileSource.TileSet.Max(t => t.PointCount));
            //        byte[] tempBuffer = new byte[tempBufferSize * m_tileSource.PointSizeBytes];

            //        foreach (PointCloudTile tile in m_tileSource)
            //        {
            //            m_tileSource.LoadTileGrid(tile, tempBuffer, grid, quantizedGrid);
            //            gridSource.WriteTile(tile.Col, tile.Row, grid.Data);

            //            if (!progressManager.Update((float)tile.Index / m_tileSource.TileSet.TileCount))
            //                break;
            //        }

            //        //gridSource.ReadTile(tempTile.Col, tempTile.Row, grid.Data);
            //    }
            //    m_tileSource.Close();

            //    progressManager.Log(stopwatch, "Generated GRID");
            //}

            return(m_tileSource);
        }