コード例 #1
0
        public LASFile(string filename, int pointsToStore)
        {
            IsLoaded = false;

            using (LASReader reader = new LASReader(filename))
                using (LASHeader header = reader.GetHeader()) {
                    ProjectID = header.ProjectId;
                    Signature = header.FileSignature;
                    NumPoints = header.PointRecordsCount;
                    XOffset   = header.GetMinX();
                    YOffset   = header.GetMinY();
                    ZOffset   = header.GetMinZ();
                    XExtent   = header.MaxX() - XOffset;
                    YExtent   = header.GetMaxY() - YOffset;
                    ZExtent   = header.GetMaxZ() - ZOffset;
                    chunks    = new List <LASChunk>((int)(NumPoints / LASChunk.ChunkSize + 1));

                    LASChunk curChunk = new LASChunk(0);
                    long     curOffset = 0, stored = 0;
                    long     pointSkip = NumPoints / pointsToStore;
                    if (pointSkip <= 0)
                    {
                        pointSkip = 1;
                    }

                    while (reader.GetNextPoint())
                    {
                        curOffset++;

                        if (curOffset % pointSkip == 0)
                        {
                            LASPoint point = reader.GetPoint();
                            if (point.ReturnNumber > 1)
                            {
                                curOffset--;
                                continue;
                            }

                            curChunk.Points.Add(
                                new LPoint()
                            {
                                X         = (float)(point.X - XOffset),
                                Y         = (float)(point.Y - YOffset),
                                Z         = (float)(point.Z - ZOffset),
                                Intensity = (float)point.Intensity
                            }
                                );
                            stored++;

                            if (curChunk.Points.Count >= LASChunk.ChunkSize)
                            {
                                chunks.Add(curChunk);
                                curChunk = new LASChunk(curOffset);
                            }
                        }
                    }

                    if (curChunk.Points.Count > 0)
                    {
                        chunks.Add(curChunk);
                    }

                    StoredPoints = stored;
                }

            Filename = filename;
            IsLoaded = true;
        }
コード例 #2
0
 public LPoint this[long index] {
     get {
         LASChunk chunk = chunks[(int)(index / LASChunk.ChunkSize)];
         return(chunk.Points[(int)(index % LASChunk.ChunkSize)]);
     }
 }