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

Method open

LASlib/src/laswritercompatible.cpp:37–318  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35#include "bytestreamin_array.hpp"
36
37BOOL LASwriterCompatibleDown::open(LASheader* header, LASwriteOpener* laswriteopener, BOOL moveCRSfromEVLRtoVLR, BOOL moveEVLRtoVLR)
38{
39 U32 i;
40 U8 version_minor_orig = header->version_minor;
41
42 if (header == 0)
43 {
44 return FALSE;
45 }
46 if (laswriteopener == 0)
47 {
48 return FALSE;
49 }
50 if (header->version_minor < 4) // makes only sense for LAS 1.4 input
51 {
52 return FALSE;
53 }
54 if (header->point_data_format <= 5) // but not for old point types 0, 1, 2, 3, 4, and 5
55 {
56 return FALSE;
57 }
58 else if (header->point_data_format > 10) // only the new point types 6, 7, 8, 9, and 10 are supported
59 {
60 return FALSE;
61 }
62 if (header->extended_number_of_point_records > U32_MAX) // only less than 2^32-1 points are supported
63 {
64 return FALSE;
65 }
66 this->header = header;
67
68 // downgrade it to LAS 1.2 or LAS 1.3
69 if (header->point_data_format <= 8)
70 {
71 if (header->version_minor >= 4) {
72 // LAS 1.2 header is 148 bytes less than LAS 1.4 header
73 header->header_size -= 148;
74 header->offset_to_point_data -= 148;
75 }
76 if (header->version_minor >= 5) {
77 // LAS 1.4 header is 18 bytes less than LAS 1.5 header
78 header->header_size -= 18;
79 header->offset_to_point_data -= 18;
80 }
81 header->version_minor = 2;
82 }
83 else
84 {
85 if (header->version_minor >= 4) {
86 // LAS 1.3 header is 140 bytes less than LAS 1.4 header
87 header->header_size -= 140;
88 header->offset_to_point_data -= 140;
89 }
90 if (header->version_minor >= 5) {
91 // LAS 1.4 header is 18 bytes less than LAS 1.5 header
92 header->header_size -= 18;
93 header->offset_to_point_data -= 18;
94 }

Callers

nothing calls this directly

Calls 11

LASMessageFunction · 0.85
laserrorFunction · 0.85
takeDataMethod · 0.80
put16bitsLEMethod · 0.45
put32bitsLEMethod · 0.45
put64bitsLEMethod · 0.45
add_attributeMethod · 0.45
initMethod · 0.45
get16bitsLEMethod · 0.45
get32bitsLEMethod · 0.45
get64bitsLEMethod · 0.45

Tested by

no test coverage detected