MCPcopy Create free account
hub / github.com/LASzip/LASzip / read

Method read

src/lasquadtree.cpp:578–670  ·  view source on GitHub ↗

read from file

Source from the content-addressed store, hash-verified

576
577// read from file
578BOOL LASquadtree::read(ByteStreamIn* stream)
579{
580 // read data in the following order
581 // U32 levels 4 bytes
582 // U32 level_index 4 bytes (default 0)
583 // U32 implicit_levels 4 bytes (only used when level_index != 0))
584 // F32 min_x 4 bytes
585 // F32 max_x 4 bytes
586 // F32 min_y 4 bytes
587 // F32 max_y 4 bytes
588 // which totals 28 bytes
589
590 char signature[4];
591 try { stream->getBytes((U8*)signature, 4); } catch(...)
592 {
593 laserror("(LASquadtree): reading LASspatial signature");
594 return FALSE;
595 }
596 if (strncmp(signature, "LASS", 4) != 0)
597 {
598 laserror("(LASquadtree): wrong LASspatial signature %4s instead of 'LASS'", signature);
599 return FALSE;
600 }
601 U32 type;
602 try { stream->getBytes((U8*)&type, 4); } catch(...)
603 {
604 laserror("(LASquadtree): reading LASspatial type");
605 return 0;
606 }
607 if (type != LAS_SPATIAL_QUAD_TREE)
608 {
609 laserror("(LASquadtree): unknown LASspatial type %u", type);
610 return 0;
611 }
612 try { stream->getBytes((U8*)signature, 4); } catch(...)
613 {
614 laserror("(LASquadtree): reading signature");
615 return FALSE;
616 }
617 if (strncmp(signature, "LASQ", 4) != 0)
618 {
619// laserror("(LASquadtree): wrong signature %4s instead of 'LASV'", signature);
620// return FALSE;
621 levels = ((U32*)signature)[0];
622 }
623 else
624 {
625 U32 version;
626 try { stream->get32bitsLE((U8*)&version); } catch(...)
627 {
628 laserror("(LASquadtree): reading version");
629 return FALSE;
630 }
631 try { stream->get32bitsLE((U8*)&levels); } catch(...)
632 {
633 laserror("(LASquadtree): reading levels");
634 return FALSE;
635 }

Callers

nothing calls this directly

Calls 3

laserrorFunction · 0.85
getBytesMethod · 0.45
get32bitsLEMethod · 0.45

Tested by

no test coverage detected