Exemplo n.º 1
0
void Diff::checkPoints(const PointBuffer& source_data,
    const PointBuffer& candidate_data, ptree& errors)
{
    uint32_t i(0);
    uint32_t MAX_BADBYTES(20);
    uint32_t badbytes(0);

    // Both schemas have already been determined to be equal, so are the
    // same size and in the same order.
    Dimension::IdList const& sourceDims = source_data.dims();
    Dimension::IdList const& candidateDims = candidate_data.dims();

    char sbuf[8];
    char cbuf[8];
    for (PointId idx = 0; idx < source_data.size(); ++idx)
    {
        for (size_t d = 0; d < sourceDims.size(); ++d)
        {
            Dimension::Id::Enum sd = sourceDims[d];
            Dimension::Id::Enum cd = candidateDims[d];

            source_data.getRawField(sd, idx, (void *)sbuf);
            candidate_data.getRawField(cd, idx, (void *)cbuf);
            Dimension::Type::Enum t = Dimension::defaultType(cd);
            size_t size = Dimension::size(t);
            if (memcmp(sbuf, cbuf, size))
            {
                std::ostringstream oss;

                oss << "Point " << idx << " differs for dimension \"" <<
                    Dimension::name(sd) << "\" for source and candidate";
                errors.put<std::string>("data.error", oss.str());
                badbytes++;
            }
        }
        if (badbytes > MAX_BADBYTES )
            break;
    }
}
Exemplo n.º 2
0
Arquivo: Diff.cpp Projeto: SCUSIT/PDAL
void Diff::checkPoints(  StageSequentialIterator* source_iter,
                         PointBuffer& source_data,
                         StageSequentialIterator* candidate_iter,
                         PointBuffer& candidate_data,
                         ptree& errors)
{

    boost::uint32_t i(0);
    boost::uint32_t chunk(0);
    boost::uint32_t MAX_BADBYTES(20);
    boost::uint32_t badbytes(0);
    while (!source_iter->atEnd())
    {
        const boost::uint32_t numSrcRead = source_iter->read(source_data);
        const boost::uint32_t numCandidateRead = candidate_iter->read(candidate_data);
        if (numSrcRead != numCandidateRead)
        {
            std::ostringstream oss;

            oss << "Unable to read same number of points for chunk number";
            errors.put<std::string>("points.error", oss.str());
            errors.put<boost::uint32_t>("points.candidate" , numCandidateRead);
            errors.put<boost::uint32_t>("points.source" , numSrcRead);
        }

        chunk++;

        pdal::pointbuffer::PointBufferByteSize source_byte_length(0);
        pdal::pointbuffer::PointBufferByteSize candidate_byte_length(0);
        source_byte_length =  static_cast<pdal::pointbuffer::PointBufferByteSize>(source_data.getSchema().getByteSize()) *
                              static_cast<pdal::pointbuffer::PointBufferByteSize>(source_data.getNumPoints());

        candidate_byte_length =  static_cast<pdal::pointbuffer::PointBufferByteSize>(candidate_data.getSchema().getByteSize()) *
                                 static_cast<pdal::pointbuffer::PointBufferByteSize>(candidate_data.getNumPoints());

        if (source_byte_length != candidate_byte_length)
        {
            std::ostringstream oss;

            oss << "Source byte length != candidate byte length";
            errors.put<std::string>("buffer.error", oss.str());
            errors.put<boost::uint32_t>("buffer.candidate" , candidate_byte_length);
            errors.put<boost::uint32_t>("buffer.source" , source_byte_length);
        }
        boost::uint8_t* s = source_data.getData(0);
        boost::uint8_t* c = candidate_data.getData(0);

        for (boost::uint32_t p = 0; p < std::min(source_byte_length, candidate_byte_length); ++p)
        {
            if (s[p] != c[p])
            {
                std::ostringstream oss;

                oss << "Byte number " << p << " is not equal for source and candidate";
                errors.put<std::string>("data.error", oss.str());
                badbytes++;
            }

        }

        if (badbytes > MAX_BADBYTES )
            break;

    }

}