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

Method write

LASzip/src/laswriteitemcompressed_v3.cpp:478–759  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

476}
477
478inline BOOL LASwriteItemCompressed_POINT14_v3::write(const U8* item, U32& context)
479{
480 // get last
481
482 U8* last_item = contexts[current_context].last_item;
483
484 ////////////////////////////////////////
485 // compress returns_XY layer
486 ////////////////////////////////////////
487
488 // create single (3) / first (1) / last (2) / intermediate (0) context from last point return
489
490 I32 lpr = (((LASpoint14*)last_item)->return_number == 1 ? 1 : 0); // first?
491 lpr += (((LASpoint14*)last_item)->return_number >= ((LASpoint14*)last_item)->number_of_returns ? 2 : 0); // last?
492
493 // add info whether the GPS time changed in the last return to the context
494
495 lpr += (((LASpoint14*)last_item)->gps_time_change ? 4 : 0);
496
497 // get the (potentially new) context
498
499 U32 scanner_channel = ((const LASpoint14*)item)->scanner_channel;
500
501 // if context has changed (and the new context already exists) get last for new context
502
503 if (scanner_channel != current_context)
504 {
505 if (contexts[scanner_channel].unused == FALSE)
506 {
507 last_item = contexts[scanner_channel].last_item;
508 }
509 }
510
511 // determine changed attributes
512
513 BOOL point_source_change = (((const LASpoint14*)item)->point_source_ID != ((LASpoint14*)last_item)->point_source_ID);
514 BOOL gps_time_change = (((const LASpoint14*)item)->gps_time != ((LASpoint14*)last_item)->gps_time);
515 BOOL scan_angle_change = (((const LASpoint14*)item)->scan_angle != ((LASpoint14*)last_item)->scan_angle);
516
517 // get last and current return counts
518
519 U32 last_n = ((LASpoint14*)last_item)->number_of_returns;
520 U32 last_r = ((LASpoint14*)last_item)->return_number;
521
522 U32 n = ((const LASpoint14*)item)->number_of_returns;
523 U32 r = ((const LASpoint14*)item)->return_number;
524
525 // create the 7 bit mask that encodes various changes (its value ranges from 0 to 127)
526
527 I32 changed_values = ((scanner_channel != current_context) << 6) | // scanner channel compared to last point (same = 0 / different = 1)
528 (point_source_change << 5) | // point source ID compared to last point from *same* scanner channel (same = 0 / different = 1)
529 (gps_time_change << 4) | // GPS time stamp compared to last point from *same* scanner channel (same = 0 / different = 1)
530 (scan_angle_change << 3) | // scan angle compared to last point from *same* scanner channel (same = 0 / different = 1)
531 ((n != last_n) << 2); // number of returns compared to last point from *same* scanner channel (same = 0 / different = 1)
532
533 // return number compared to last point of *same* scanner channel (same = 0 / plus one mod 16 = 1 / minus one mod 16 = 2 / other difference = 3)
534
535 if (r != last_r)

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected