boost::uint32_t ByteSwap::processBuffer(PointBuffer& dstData, const PointBuffer& srcData) const { const Schema& dstSchema = dstData.getSchema(); schema::index_by_index const& dstDims = dstSchema.getDimensions().get<schema::index>(); dstData.setSpatialBounds(srcData.getSpatialBounds()); dstData.copyPointsFast(0, 0, srcData, srcData.getNumPoints()); dstData.setNumPoints(srcData.getNumPoints()); for (boost::uint32_t i = 0; i != dstData.getNumPoints(); ++i) { boost::uint8_t* data = dstData.getData(i); std::size_t position = 0; for (boost::uint32_t n = 0; n < dstDims.size(); ++n) { const Dimension& d = dstSchema.getDimension(n); std::size_t size = d.getByteSize(); boost::uint8_t* pos = data + position; SWAP_ENDIANNESS_N(*pos, size); position = position + size; } } return dstData.getNumPoints(); }
boost::uint32_t Mosaic::readBufferImpl(PointBuffer& destData) { boost::uint32_t totalNumPointsToRead = destData.getCapacity(); boost::uint32_t totalNumPointsRead = 0; boost::uint32_t destPointIndex = 0; // for each stage, we read as many points as we can while (totalNumPointsRead < totalNumPointsToRead) { assert(m_iteratorIndex < m_prevIterators.size()); m_prevIterator = m_prevIterators[m_iteratorIndex]; // read as much as we can into temp buffer PointBuffer tmp(destData.getSchema(), totalNumPointsToRead-totalNumPointsRead); boost::uint32_t numRead = m_prevIterator->read(tmp); totalNumPointsRead += numRead; // concat the temp buffer on to end of real dest buffer destData.copyPointsFast(destPointIndex, 0, tmp, numRead); destPointIndex += numRead; destData.setNumPoints(destData.getNumPoints() + numRead); if (m_prevIterator->atEnd()) { ++m_iteratorIndex; } if (m_iteratorIndex == m_prevIterators.size()) { break; } } return totalNumPointsRead; }
void Cache::addToCache(boost::uint64_t pointIndex, const PointBuffer& data) const { PointBuffer* block = new PointBuffer(data.getSchema(), m_cacheBlockSize); block->copyPointsFast(0, 0, data, m_cacheBlockSize); m_cache->insert(pointIndex, block); return; }
boost::uint32_t Predicate::processBuffer(PointBuffer& data, pdal::plang::BufferedInvocation& python) const { python.resetArguments(); python.beginChunk(data); python.execute(); if (!python.hasOutputVariable("Mask")) { throw python_error("Mask variable not set in predicate filter function"); } boost::uint8_t* mask = new boost::uint8_t[data.getNumPoints()]; PointBuffer dstData(data.getSchema(), data.getCapacity()); python.extractResult("Mask", (boost::uint8_t*)mask, data.getNumPoints(), 1, pdal::dimension::RawByte, 1); boost::uint8_t* dst = dstData.getData(0); boost::uint8_t* src = data.getData(0); const Schema& schema = dstData.getSchema(); boost::uint32_t numBytes = schema.getByteSize(); assert(numBytes == data.getSchema().getByteSize()); boost::uint32_t numSrcPoints = data.getNumPoints(); boost::uint32_t count = 0; for (boost::uint32_t srcIndex=0; srcIndex<numSrcPoints; srcIndex++) { if (mask[srcIndex]) { memcpy(dst, src, numBytes); dst += numBytes; ++count; dstData.setNumPoints(count); } src += numBytes; } data.copyPointsFast(0, 0, dstData, count); data.setNumPoints(count); delete[] mask; return count; }