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