Esempio n. 1
0
/// Get a dimension type list for the storage schema.
/// \return  Storage dimension types.
DimTypeList DbWriter::dbDimTypes() const
{
    using namespace Dimension;

    DimTypeList dimTypes;
    for (auto di = m_dimTypes.begin(); di != m_dimTypes.end(); ++di)
        dimTypes.push_back(DimType(di->m_id, di->m_type, XForm()));

    if (!m_locationScaling)
        return dimTypes;

    //ONLY for location scaling...
    for (auto di = dimTypes.begin(); di != dimTypes.end(); ++di)
    {
        if (di->m_id == Id::X)
        {
            di->m_xform = m_xXform;
            di->m_type = Type::Signed32;
        }
        if (di->m_id == Id::Y)
        {
            di->m_xform = m_yXform;
            di->m_type = Type::Signed32;
        }
        if (di->m_id == Id::Z)
        {
            di->m_xform = m_zXform;
            di->m_type = Type::Signed32;
        }
    }
    return dimTypes;
}
Esempio n. 2
0
DimTypeList XMLSchema::dimTypes() const
{
    DimTypeList dimTypes;

    for (auto di = m_dims.begin(); di != m_dims.end(); ++di)
        dimTypes.push_back(di->m_dimType);
    return dimTypes;
}
DimTypeList DbReader::dbDimTypes() const
{
    DimTypeList dimTypes;

    for (auto di = m_dims.begin(); di != m_dims.end(); ++di)
        dimTypes.push_back(di->m_dimType);
    return dimTypes;
}
Esempio n. 4
0
DimTypeList PointLayout::dimTypes() const
{
    DimTypeList dimTypes;

    const Dimension::IdList& ids = dims();
    for (auto ii = ids.begin(); ii != ids.end(); ++ii)
        dimTypes.push_back(DimType(*ii, dimType(*ii)));
    return dimTypes;
}
Esempio n. 5
0
TEST(Compression, types)
{
    using namespace Dimension;
    Type types[] = {
        Type::Unsigned8, Type::Unsigned16, Type::Unsigned32, Type::Unsigned64,
        Type::Signed8, Type::Signed16, Type::Signed32, Type::Signed64,
        Type::Float, Type::Double
    };
    // Size is 42.

    std::default_random_engine generator;
    std::uniform_int_distribution<int> dist(std::numeric_limits<int>::min());
    char pts[3][42];

    // Fill three "points" with some random data.
    char *c = &pts[0][0];
    for (size_t i = 0; i < 3 * 42; ++i)
    {
        int v = dist(generator);
        memcpy(c++, &v, sizeof(char));
    }

    DimTypeList dimTypes;
    for (auto ti = std::begin(types); ti != std::end(types); ++ti)
        dimTypes.push_back(DimType(Dimension::Id::Unknown, *ti));

    std::vector<unsigned char> rawBuf;
    LazPerfBuf b(rawBuf);
    LazPerfCompressor<LazPerfBuf> compressor(b, dimTypes);
    for (size_t i = 0; i < 50; i++)
    {
        compressor.compress(pts[0], 42);
        compressor.compress(pts[1], 42);
        compressor.compress(pts[2], 42);
    }
    compressor.done();

    LazPerfBuf b2(rawBuf);

    LazPerfDecompressor<LazPerfBuf> decompressor(b2, dimTypes);
    char oPts[3][42];
    for (size_t i = 0; i < 50; ++i)
    {
        decompressor.decompress(oPts[0], 42);
        decompressor.decompress(oPts[1], 42);
        decompressor.decompress(oPts[2], 42);
        EXPECT_EQ(memcmp(pts[0], oPts[0], 42), 0);
        EXPECT_EQ(memcmp(pts[1], oPts[1], 42), 0);
        EXPECT_EQ(memcmp(pts[2], oPts[2], 42), 0);
        memset(oPts[0], 0, 42);
        memset(oPts[1], 0, 42);
        memset(oPts[2], 0, 42);
    }
}
Esempio n. 6
0
DimTypeList DbWriter::dimTypes(PointTableRef table)
{
    using namespace Dimension;

    PointLayoutPtr layout = table.layout();

    if (m_outputDims.empty())
        return layout->dimTypes();

    DimTypeList dims;
    for (std::string& s : m_outputDims)
    {
        DimType dt = layout->findDimType(s);
        if (dt.m_id == Id::Unknown)
        {
            std::ostringstream oss;
            oss << "Invalid dimension '" << s << "' specified for "
                "'output_dims' option.";
            throw pdal_error(oss.str());
        }
        dims.push_back(dt);
    }
    return dims;
}
Esempio n. 7
0
TEST(Compression, types)
{
    using namespace Dimension;
    Type types[] = {
        Type::Unsigned8, Type::Unsigned16, Type::Unsigned32, Type::Unsigned64,
        Type::Signed8, Type::Signed16, Type::Signed32, Type::Signed64,
        Type::Float, Type::Double
    };
    // Size is 42.

    std::default_random_engine generator;
    std::uniform_int_distribution<int> dist((std::numeric_limits<int>::min)());
    char pts[3][42];

    // Fill three "points" with some random data.
    char *c = &pts[0][0];
    for (size_t i = 0; i < 3 * 42; ++i)
    {
        int v = dist(generator);
        memcpy(c++, &v, sizeof(char));
    }

    DimTypeList dimTypes;
    for (auto ti = std::begin(types); ti != std::end(types); ++ti)
        dimTypes.push_back(DimType(Dimension::Id::Unknown, *ti));

    std::vector<unsigned char> rawBuf;
    auto cb = [&rawBuf](char *buf, size_t bufsize)
    {
        unsigned char *ubuf = reinterpret_cast<unsigned char *>(buf);
        rawBuf.insert(rawBuf.begin(), ubuf, ubuf + bufsize);
    };

    LazPerfCompressor compressor(cb, dimTypes);
    for (size_t i = 0; i < 50; i++)
    {
        compressor.compress(pts[0], 42);
        compressor.compress(pts[1], 42);
        compressor.compress(pts[2], 42);
    }
    compressor.done();

    char oPts[3][42];
    PointId id = 0;
    auto cb2 = [&pts, &oPts, &id](char *buf, size_t bufsize)
    {
        memcpy(oPts[id++], buf, bufsize);
        if (id == 3)
        {
            EXPECT_EQ(memcmp(pts[0], oPts[0], 42), 0);
            EXPECT_EQ(memcmp(pts[0], oPts[0], 42), 0);
            EXPECT_EQ(memcmp(pts[2], oPts[2], 42), 0);
            memset(oPts[0], 0, 42);
            memset(oPts[1], 0, 42);
            memset(oPts[2], 0, 42);
            id = 0;
        }
    };
    LazPerfDecompressor(cb2, dimTypes, 50 * 3).
           decompress(reinterpret_cast<const char *>(rawBuf.data()),
                       rawBuf.size());
}