首页 > 其他 > 详细

使用liblas文件将数据存储为las却打不开问题的原因

时间:2017-01-19 12:43:52      阅读:709      评论:0      收藏:0      [点我收藏+]

liblas是一个通用的las库,用来对las文件进行读写操作。今天使用时,明明数据写入的很正确很成功,但是使用多个点云浏览软件测试,都打开,最后发现了问题所在,再次Mark一下,以供参考。

主要代码如下:

     // 设置文件头,点数、格式、缩放因子、偏移量
        liblas::Header header;
        header.SetVersionMajor(1);
        header.SetVersionMinor(2);
        header.SetDataFormatId(liblas::PointFormatName::ePointFormat3);
        header.SetScale(0.001, 0.001, 0.001);
        header.SetOffset(int(tempPt.GetX()), int(tempPt.GetY()), 0);
     // 建立存储文件
        ofstream outPt(newOutPath.c_str(), ios::out | ios::binary);
        if (!outPt.is_open())
        {
            return 1;
        }

        liblas::Writer writer(outPt, header);
        liblas::Point point(&header);

        double minPt[3] = {9999999, 9999999, 9999999};
        double maxPt[3] = {0, 0, 0};
        double pt[3] = {0};
    
     // 中间是写入点云及记录点的个数      header.SetPointRecordsCount(point_count); header.SetPointRecordsByReturnCount(
0, point_count); header.SetMax(maxPt[0], maxPt[1], maxPt[2]); header.SetMin(minPt[0], minPt[1], minPt[2]); writer.SetHeader(header);
    
     // 注意此处有问题
     outPt.close();

这是很一般的写法,应该是没有问题的,实际上保存的las文件打不开。原因竟然是“outPt.close()”,在这里,将这句注释掉就对了,我暂时也不清楚为什么。

使用liblas文件将数据存储为las却打不开问题的原因

原文:http://www.cnblogs.com/xingzhensun/p/6305802.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!