MCPcopy Create free account
hub / github.com/LAStools/LAStools / write

Method write

LASzip/src/laswriteitemcompressed_v1.cpp:134–258  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

132}
133
134inline BOOL LASwriteItemCompressed_POINT10_v1::write(const U8* item, U32& context)
135{
136 // find median difference for x and y from 3 preceding differences
137 I32 median_x;
138 if (last_x_diff[0] < last_x_diff[1])
139 {
140 if (last_x_diff[1] < last_x_diff[2])
141 median_x = last_x_diff[1];
142 else if (last_x_diff[0] < last_x_diff[2])
143 median_x = last_x_diff[2];
144 else
145 median_x = last_x_diff[0];
146 }
147 else
148 {
149 if (last_x_diff[0] < last_x_diff[2])
150 median_x = last_x_diff[0];
151 else if (last_x_diff[1] < last_x_diff[2])
152 median_x = last_x_diff[2];
153 else
154 median_x = last_x_diff[1];
155 }
156
157 I32 median_y;
158 if (last_y_diff[0] < last_y_diff[1])
159 {
160 if (last_y_diff[1] < last_y_diff[2])
161 median_y = last_y_diff[1];
162 else if (last_y_diff[0] < last_y_diff[2])
163 median_y = last_y_diff[2];
164 else
165 median_y = last_y_diff[0];
166 }
167 else
168 {
169 if (last_y_diff[0] < last_y_diff[2])
170 median_y = last_y_diff[0];
171 else if (last_y_diff[1] < last_y_diff[2])
172 median_y = last_y_diff[2];
173 else
174 median_y = last_y_diff[1];
175 }
176
177 // compress x y z coordinates
178 I32 x_diff = ((const LASpoint10*)item)->x - ((LASpoint10*)last_item)->x;
179 I32 y_diff = ((const LASpoint10*)item)->y - ((LASpoint10*)last_item)->y;
180
181 ic_dx->compress(median_x, x_diff);
182 // we use the number k of bits corrector bits to switch contexts
183 U32 k_bits = ic_dx->getK();
184 ic_dy->compress(median_y, y_diff, (k_bits < 19 ? k_bits : 19));
185 k_bits = (k_bits + ic_dy->getK()) / 2;
186 ic_z->compress(((LASpoint10*)last_item)->z, ((const LASpoint10*)item)->z, (k_bits < 19 ? k_bits : 19));
187
188 // compress which other values have changed
189 I32 changed_values = ((((LASpoint10*)last_item)->intensity != ((const LASpoint10*)item)->intensity) << 5) |
190 ((last_item[14] != item[14]) << 4) | // bit_byte
191 ((last_item[15] != item[15]) << 3) | // classification

Callers

nothing calls this directly

Calls 6

compressMethod · 0.80
getKMethod · 0.80
encodeSymbolMethod · 0.45
createSymbolModelMethod · 0.45
initSymbolModelMethod · 0.45
writeInt64Method · 0.45

Tested by

no test coverage detected