Exemple #1
0
        public void hhhhh()
        {
            // LASReader lasreader = new LASReader(@"c:\las\sample_our2.las");
            LASReader lasreader = new LASReader(@"C:\las\data\TO_core_last_clip.las");

            LASPoint laspoint;

            //laspoint = lasreader.GetPointAt(0);
            //Console.WriteLine(laspoint.X + "," + laspoint.Y + "," + laspoint.Z + "  " + laspoint.Intensity );

            LASHeader lasheader = lasreader.GetHeader();

            LASWriter laswriter = new LASWriter(@"c:\las\sample_our.las", lasheader, LASReadWriteMode.LASModeWrite);

            //LASReader lasreader = new LASReader(@"C:\las\data\TO_core_last_clip.las");
            //LASPoint laspoint = new LASPoint();

            laspoint = lasreader.GetPointAt(0);
            //laspoint.X = 23.0;
            //Assert.AreEqual(laspoint.X, 23.0);
            //byte gg = laspoint.Classification;
            //bool d = lasreader.GetNextPoint();
            ////d = lasreader.GetNextPoint();
            //LASPoint point = lasreader.GetPointAt(1);
            //Assert.LessOrEqual(Math.Abs(point.X - 630262.30), 0.0001);
            //Assert.LessOrEqual(Math.Abs(point.Y - 4834500.0), 0.0001);
            //Assert.LessOrEqual(Math.Abs(point.Z - 51.53), 0.0001);
            Assert.AreEqual(laspoint.Intensity, 670);
            // Assert.AreEqual(laspoint.Classification,(byte) 1);

            //Assert.AreEqual(point.ScanAngleRank, 0);
            //Assert.AreEqual(point.UserData, 3);
            //Assert.AreEqual(point.ScanFlags, 9);
            //Assert.LessOrEqual(Math.Abs(point.Time - 413665.23360000004), 0.0001);
        }
Exemple #2
0
    static void Main(string[] args)
    {
        try
        {
            LASReader lasreader = new LASReader(@"c:\las\sample_our2.las");

            LASPoint laspoint;

            LASHeader lasheader = lasreader.GetHeader();
            Console.WriteLine(lasheader.SoftwareId);//
            lasheader.VersionMinor = 0;
            LASWriter laswriter = new LASWriter(@"c:\las\sample_our.las", lasheader, LASReadWriteMode.LASModeWrite);

            Console.WriteLine("Number of points in file= {0}", lasheader.PointRecordsCount);

            while (lasreader.GetNextPoint())
            {
                laspoint   = lasreader.GetPoint();
                laspoint.X = laspoint.X + 3;

                //Console.WriteLine(laspoint.X + "," + laspoint.Y + "," + laspoint.Z);

                laswriter.WritePoint(laspoint);
            }
        }
        catch (LASException e)
        {
            Console.WriteLine("\nLASException! Msg: {0}", e.Message);
        }
        catch (SystemException e)
        {
            Console.WriteLine("\nException! Msg: {0}", e.Message);
        }
        catch
        {
            Console.WriteLine("Unknown exception caught");
        }
        finally
        {
            Console.WriteLine("Do i need something to do?");
        }
        Console.WriteLine("End of file");
        Console.Read();
    }
Exemple #3
0
    static void Main(string[] args)
    {
        try
        {
            string    filename  = @"..\..\..\..\..\test\data\TO_core_last_zoom.las";
            LASReader lasreader = new LASReader(filename);
            LASHeader h         = lasreader.GetHeader();
            Console.WriteLine("Version  : " + lasreader.GetVersion());
            Console.WriteLine("Signature: : " + h.FileSignature);
            Console.WriteLine("Format   : " + h.DataFormatId);
            Console.WriteLine("Project  : " + h.ProjectId);
            Console.WriteLine("Points count: " + h.PointRecordsCount);
            Console.WriteLine("VLRecords count: " + h.VariableLengthRecordsCount);
            int counter = 0;
            while (lasreader.GetNextPoint())
            {
                LASPoint laspoint = lasreader.GetPoint();
                counter += 1;
            }

            if (lasreader.GetHeader().PointRecordsCount != counter)
            {
                throw new LASException("read incorrect number of point records");
            }
        }
        catch (LASException e)
        {
            Console.WriteLine("\nLASException! Msg: {0}", e.Message);
        }
        catch (SystemException e)
        {
            Console.WriteLine("\nException! Msg: {0}", e.Message);
        }
        catch
        {
            Console.WriteLine("Unknown exception caught");
        }

        Console.WriteLine("End of file");
        Console.Read();
    }
Exemple #4
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;
        }