MCPcopy Create free account
hub / github.com/PDAL/PDAL / unwrap

Method unwrap

tools/nitfwrap/NitfWrap.cpp:105–165  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

103
104
105void NitfWrap::unwrap()
106{
107 // Use the NITF reader to get the offset and length
108 uint64_t offset, length;
109 NitfFileReader reader(m_inputFile);
110 reader.open();
111 reader.getLasOffset(offset, length);
112 reader.close();
113
114 // Open file file and seek to the beginning of the location.
115 std::istream *in = FileUtils::openFile(m_inputFile);
116 if (!in)
117 {
118 std::ostringstream oss;
119
120 oss << "Couldn't open input file '" << m_inputFile << "'.";
121 throw error(oss.str());
122 }
123 in->seekg(offset, std::istream::beg);
124
125 // Find out if this is a LAS or BPF file and make the output filename.
126 bool compressed;
127 BOX3D bounds;
128 ILeStream leIn(in);
129 IStreamMarker mark(leIn);
130 if (verifyLas(leIn, bounds, compressed))
131 {
132 if (m_outputFile.empty())
133 {
134 m_outputFile = FileUtils::stem(m_inputFile);
135 m_outputFile += (compressed ? ".laz" : ".las");
136 }
137 }
138 else
139 {
140 mark.rewind();
141 if (verifyBpf(leIn, bounds))
142 {
143 if (m_outputFile.empty())
144 m_outputFile = FileUtils::stem(m_inputFile) + ".bpf";
145 }
146 else
147 {
148 std::cerr << "Wrapped file isn't BPF or LAS.\n";
149 return;
150 }
151 }
152
153 uint64_t bufsize = 16;
154 std::vector<char> buf(bufsize);
155 std::ostream *out = FileUtils::createFile(m_outputFile);
156 in->seekg(offset, std::istream::beg);
157 while (length)
158 {
159 size_t size = (std::min)(length, bufsize);
160 in->read(buf.data(), size);
161 out->write(buf.data(), size);
162 length -= size;

Callers

nothing calls this directly

Calls 14

stemFunction · 0.85
getLasOffsetMethod · 0.80
strMethod · 0.80
errorClass · 0.70
openFileFunction · 0.50
createFileFunction · 0.50
closeFileFunction · 0.50
openMethod · 0.45
closeMethod · 0.45
emptyMethod · 0.45
rewindMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected