fetch data using arbiter to get a char vector
| 191 | |
| 192 | // fetch data using arbiter to get a char vector |
| 193 | std::vector<char> SlpkInterface::fetchBinary(std::string url, std::string attNum, |
| 194 | std::string ext) const |
| 195 | { |
| 196 | std::vector<char> output; |
| 197 | |
| 198 | url += attNum + ext; |
| 199 | |
| 200 | auto li = m_locMap.find(url); |
| 201 | if (li != m_locMap.end()) |
| 202 | { |
| 203 | const Location& loc = li->second; |
| 204 | |
| 205 | const char *c = reinterpret_cast<const char *>(m_ctx.addr()) + loc.m_pos; |
| 206 | if (FileUtils::extension(url) != ".gz") |
| 207 | output.assign(c, c + loc.m_length); |
| 208 | else |
| 209 | { |
| 210 | GzipDecompressor decomp( |
| 211 | [&output](char *buf, size_t bufsize) |
| 212 | {output.insert(output.end(), buf, buf + bufsize);}); |
| 213 | decomp.decompress(c, loc.m_length); |
| 214 | decomp.done(); |
| 215 | } |
| 216 | } |
| 217 | return output; |
| 218 | } |
| 219 | |
| 220 | } //namespace pdal |