void GeoWaveWriter::ready(PointTableRef table) { // get a list of all the dimensions & their types Dimension::IdList all = table.layout()->dims(); for (auto di = all.begin(); di != all.end(); ++di) if (!Utils::contains(m_dims, *di)) m_dims.push_back(*di); }
void SbetWriter::write(const PointViewPtr view) { Dimension::IdList dims = fileDimensions(); for (PointId idx = 0; idx < view->size(); ++idx) { for (auto di = dims.begin(); di != dims.end(); ++di) { // If a dimension doesn't exist, write 0. Dimension::Id dim = *di; *m_stream << (view->hasDim(dim) ? view->getFieldAs<double>(dim, idx) : 0.0); } } }
void BpfWriter::loadBpfDimensions(PointLayoutPtr layout) { // Verify that we have X, Y and Z and that they're the first three // dimensions. Dimension::IdList dims = layout->dims(); std::sort(dims.begin(), dims.end()); if (dims.size() < 3 || dims[0] != Dimension::Id::X || dims[1] != Dimension::Id::Y || dims[2] != Dimension::Id::Z) { throw pdal_error("Missing one of dimensions X, Y or Z. " "Can't write BPF."); } for (auto id : dims) { BpfDimension dim; dim.m_id = id; dim.m_label = layout->dimName(id); m_dims.push_back(dim); } }
void BpfWriter::loadBpfDimensions(PointLayoutPtr layout) { Dimension::IdList dims; if (m_outputDims.size()) { for (std::string& s : m_outputDims) { Dimension::Id::Enum id = layout->findDim(s); if (id == Dimension::Id::Unknown) { std::ostringstream oss; oss << "Invalid dimension '" << s << "' specified for " "'output_dims' option."; throw pdal_error(oss.str()); } dims.push_back(id); } } else dims = layout->dims(); // Verify that we have X, Y and Z and that they're the first three // dimensions. std::sort(dims.begin(), dims.end()); if (dims.size() < 3 || dims[0] != Dimension::Id::X || dims[1] != Dimension::Id::Y || dims[2] != Dimension::Id::Z) { throw pdal_error("Missing one of dimensions X, Y or Z. " "Can't write BPF."); } for (auto id : dims) { BpfDimension dim; dim.m_id = id; dim.m_label = layout->dimName(id); m_dims.push_back(dim); } }
QuickInfo LasReader::inspect() { QuickInfo qi; std::unique_ptr<PointLayout> layout(new PointLayout()); addDimensions(layout.get()); initialize(); Dimension::IdList dims = layout->dims(); for (auto di = dims.begin(); di != dims.end(); ++di) qi.m_dimNames.push_back(layout->dimName(*di)); qi.m_pointCount = Utils::saturation_cast<point_count_t>(m_lasHeader.pointCount()); qi.m_bounds = m_lasHeader.getBounds(); qi.m_srs = getSrsFromVlrs(); qi.m_valid = true; PointTable table; done(table); return qi; }
QuickInfo LasReader::inspect() { QuickInfo qi; std::unique_ptr<PointLayout> layout(new PointLayout()); PointTable table; initialize(table); addDimensions(layout.get()); Dimension::IdList dims = layout->dims(); for (auto di = dims.begin(); di != dims.end(); ++di) qi.m_dimNames.push_back(layout->dimName(*di)); if (!Utils::numericCast(m_lasHeader.pointCount(), qi.m_pointCount)) qi.m_pointCount = std::numeric_limits<point_count_t>::max(); qi.m_bounds = m_lasHeader.getBounds(); qi.m_srs = getSpatialReference(); qi.m_valid = true; done(table); return qi; }
point_count_t SbetReader::read(PointBuffer& buf, point_count_t count) { PointId nextId = buf.size(); PointId idx = m_index; point_count_t numRead = 0; seek(idx); Dimension::IdList dims = getDefaultDimensions(); while (numRead < count && idx < m_numPts) { for (auto di = dims.begin(); di != dims.end(); ++di) { double d; *m_stream >> d; Dimension::Id::Enum dim = *di; buf.setField(dim, nextId, d); } idx++; nextId++; numRead++; } m_index = idx; return numRead; }
void TextWriter::ready(PointTableRef table) { m_stream->precision(m_precision); *m_stream << std::fixed; typedef boost::tokenizer<boost::char_separator<char>> tokenizer; // Find the dimensions listed and put them on the id list. boost::char_separator<char> separator(","); boost::erase_all(m_dimOrder, " "); // Wipe off spaces tokenizer sdims(m_dimOrder, separator); for (tokenizer::iterator ti = sdims.begin(); ti != sdims.end(); ++ti) { Dimension::Id::Enum d = table.layout()->findDim(*ti); if (d == Dimension::Id::Unknown) { std::ostringstream oss; oss << "Dimension not found with name '" << *ti <<"'"; throw pdal::dimension_not_found(oss.str()); } m_dims.push_back(d); } // Add the rest of the dimensions to the list if we're doing that. // Yes, this isn't efficient when, but it's simple. if (m_dimOrder.empty() || m_writeAllDims) { Dimension::IdList all = table.layout()->dims(); for (auto di = all.begin(); di != all.end(); ++di) if (!contains(m_dims, *di)) m_dims.push_back(*di); } if (!m_writeHeader) log()->get(LogLevel::Debug) << "Not writing header" << std::endl; else writeHeader(table); }
void TextWriter::ready(PointTableRef table) { m_stream->precision(m_precision); *m_stream << std::fixed; // Find the dimensions listed and put them on the id list. StringList dimNames = Utils::split2(m_dimOrder, ','); for (std::string dim : dimNames) { Utils::trim(dim); Dimension::Id d = table.layout()->findDim(dim); if (d == Dimension::Id::Unknown) { std::ostringstream oss; oss << getName() << ": Dimension not found with name '" << dim << "'."; throw pdal_error(oss.str()); } m_dims.push_back(d); } // Add the rest of the dimensions to the list if we're doing that. // Yes, this isn't efficient when, but it's simple. if (m_dimOrder.empty() || m_writeAllDims) { Dimension::IdList all = table.layout()->dims(); for (auto di = all.begin(); di != all.end(); ++di) if (!Utils::contains(m_dims, *di)) m_dims.push_back(*di); } if (!m_writeHeader) log()->get(LogLevel::Debug) << "Not writing header" << std::endl; else writeHeader(table); }
point_count_t IcebridgeReader::read(PointViewPtr view, point_count_t count) { //All data we read for icebridge is currently 4 bytes wide, so // just allocate once and forget it. //This could be a huge allocation. Perhaps we should do something // in the icebridge handler? PointId startId = view->size(); point_count_t remaining = m_hdf5Handler.getNumPoints() - m_index; count = std::min(count, remaining); std::unique_ptr<unsigned char> rawData(new unsigned char[count * sizeof(float)]); //Not loving the position-linked data, but fine for now. Dimension::IdList dims = getDefaultDimensions(); auto di = dims.begin(); for (auto ci = hdf5Columns.begin(); ci != hdf5Columns.end(); ++ci, ++di) { PointId nextId = startId; PointId idx = m_index; const hdf5::Hdf5ColumnData& column = *ci; try { m_hdf5Handler.getColumnEntries(rawData.get(), column.name, count, m_index); void *p = (void *)rawData.get(); // This is ugly but avoids a test in a tight loop. if (column.predType == H5::PredType::NATIVE_FLOAT) { // Offset time is in ms but icebridge stores in seconds. if (*di == Dimension::Id::OffsetTime) { float *fval = (float *)p; for (PointId i = 0; i < count; ++i) { view->setField(*di, nextId++, *fval * 1000); fval++; } } else { float *fval = (float *)p; for (PointId i = 0; i < count; ++i) view->setField(*di, nextId++, *fval++); } } else if (column.predType == H5::PredType::NATIVE_INT) { int32_t *ival = (int32_t *)p; for (PointId i = 0; i < count; ++i) view->setField(*di, nextId++, *ival++); } } catch(...) { throw icebridge_error("Error fetching column data"); } } return count; }