7
7
#include < fstream>
8
8
9
9
#include " liblas\liblas.hpp"
10
+ #include < boost/algorithm/string/predicate.hpp>
10
11
11
12
#include " AABB.h"
12
13
#include " PointWriter.hpp"
13
14
14
15
using std::string;
15
16
using std::fstream;
16
17
using std::ios;
18
+ using boost::algorithm::iends_with;
17
19
18
20
class LASPointWriter : public PointWriter {
19
21
@@ -35,9 +37,14 @@ class LASPointWriter : public PointWriter{
35
37
header->SetMin (aabb.min .x , aabb.min .y , aabb.min .z );
36
38
header->SetMax (aabb.max .x , aabb.max .y , aabb.max .z );
37
39
header->SetScale (0.01 , 0.01 , 0.01 );
40
+ header->SetPointRecordsCount (53 );
41
+
42
+ if (iends_with (file, " .laz" )){
43
+ header->SetCompressed (true );
44
+ }
38
45
39
46
stream = new fstream (file, ios::out | ios::binary);
40
- writer = new liblas::Writer (*stream, *header);
47
+ writer = new liblas::Writer (*stream, *header);
41
48
42
49
43
50
// LASheader header;
@@ -63,16 +70,22 @@ class LASPointWriter : public PointWriter{
63
70
void write (const Point &point);
64
71
65
72
void close (){
66
- header->SetPointRecordsCount (numPoints);
67
-
68
- writer->SetHeader (*header);
69
- writer->WriteHeader ();
70
73
71
- stream-> close ();
74
+ // close stream
72
75
delete writer;
76
+ stream->close ();
73
77
delete stream;
74
78
writer = NULL ;
75
79
stream = NULL ;
80
+
81
+ // update point count
82
+ stream = new fstream (file, ios::out | ios::binary | ios::in );
83
+ stream->seekp (107 );
84
+ stream->write (reinterpret_cast <const char *>(&numPoints), 4 );
85
+ stream->close ();
86
+ delete stream;
87
+ stream = NULL ;
88
+
76
89
}
77
90
78
91
};
0 commit comments