예제 #1
0
파일: GeoWaveWriter.cpp 프로젝트: PDAL/PDAL
 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);
 }
예제 #2
0
Dimension::IdList FauxReader::getDefaultDimensions()
{
    Dimension::IdList ids;

    ids.push_back(Dimension::Id::X);
    ids.push_back(Dimension::Id::Y);
    ids.push_back(Dimension::Id::Z);
    ids.push_back(Dimension::Id::OffsetTime);
    return ids;
}
예제 #3
0
Dimension::IdList Ilvis2Reader::getDefaultDimensions()
{
    using namespace pdal::Dimension;
    Dimension::IdList ids;

    ids.push_back(Id::GpsTime);
    ids.push_back(Id::Y);
    ids.push_back(Id::X);
    ids.push_back(Id::Z);
    return ids;
}
예제 #4
0
파일: SbetWriter.cpp 프로젝트: chambbj/PDAL
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);
        }
    }
}
예제 #5
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);
    }
}
예제 #6
0
파일: BpfWriter.cpp 프로젝트: neteler/PDAL
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);
    }
}
예제 #7
0
Dimension::IdList OptechReader::getDefaultDimensions()
{
    Dimension::IdList dims;
    dims.push_back(Dimension::Id::X);
    dims.push_back(Dimension::Id::Y);
    dims.push_back(Dimension::Id::Z);
    dims.push_back(Dimension::Id::GpsTime);
    dims.push_back(Dimension::Id::ReturnNumber);
    dims.push_back(Dimension::Id::NumberOfReturns);
    dims.push_back(Dimension::Id::EchoRange);
    dims.push_back(Dimension::Id::Intensity);
    dims.push_back(Dimension::Id::ScanAngleRank);
    return dims;
}
예제 #8
0
파일: LasHeader.cpp 프로젝트: cugwhp/PDAL
Dimension::IdList LasHeader::usedDims() const
{
    using namespace Dimension;

    Dimension::Id::Enum dims[] = { Id::ReturnNumber, Id::NumberOfReturns,
        Id::X, Id::Y, Id::Z, Id::Intensity, Id::ScanChannel,
        Id::ScanDirectionFlag, Id::EdgeOfFlightLine, Id::Classification,
        Id::UserData, Id::ScanAngleRank, Id::PointSourceId };

    // This mess is because MSVC doesn't support initializer lists.
    Dimension::IdList ids;
    std::copy(std::begin(dims), std::end(dims), std::back_inserter(ids));

    if (hasTime())
        ids.push_back(Id::GpsTime);
    if (hasColor())
    {
        ids.push_back(Id::Red);
        ids.push_back(Id::Green);
        ids.push_back(Id::Blue);
    }
    if (hasInfrared())
        ids.push_back(Id::Infrared);

    return ids;
}
예제 #9
0
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;
}
예제 #10
0
파일: LasReader.cpp 프로젝트: davijo/PDAL
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;
}
예제 #11
0
파일: SbetReader.cpp 프로젝트: pramsey/PDAL
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;
}
예제 #12
0
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);
}
예제 #13
0
TEST_F(PgpointcloudWriterTest, writeXYZ)
{
    if (shouldSkipTests())
    {
        return;
    }

    Options ops = getDbOptions();
    ops.add("output_dims", "X,Y,Z");

    optionsWrite(ops);

    PointTable table;
    StageFactory factory;
    Stage* reader(factory.createStage("readers.pgpointcloud"));
    reader->setOptions(getDbOptions());

    reader->prepare(table);
    Dimension::IdList dims = table.layout()->dims();
    EXPECT_EQ(dims.size(), (size_t)3);
    EXPECT_TRUE(Utils::contains(dims, Dimension::Id::X));
    EXPECT_TRUE(Utils::contains(dims, Dimension::Id::Y));
    EXPECT_TRUE(Utils::contains(dims, Dimension::Id::Z));
}
예제 #14
0
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);
}
예제 #15
0
파일: Reader.cpp 프로젝트: simonsonc/PDAL
Dimension::IdList Reader::getDefaultDimensions()
{
    Dimension::IdList ids;

    using namespace Dimension;

    ids.push_back(Id::OffsetTime);
    ids.push_back(Id::Y);
    ids.push_back(Id::X);
    ids.push_back(Id::Z);
    ids.push_back(Id::StartPulse);
    ids.push_back(Id::ReflectedPulse);
    ids.push_back(Id::ScanAngleRank);
    ids.push_back(Id::Pitch);
    ids.push_back(Id::Roll);
    ids.push_back(Id::Pdop);
    ids.push_back(Id::PulseWidth);
    ids.push_back(Id::GpsTime);
    return ids;
}
예제 #16
0
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;
}
예제 #17
0
파일: QfitReader.cpp 프로젝트: pramsey/PDAL
Dimension::IdList QfitReader::getDefaultDimensions()
{
    Dimension::IdList ids;

    ids.push_back(Dimension::Id::OffsetTime);
    ids.push_back(Dimension::Id::Y);
    ids.push_back(Dimension::Id::X);
    ids.push_back(Dimension::Id::Z);
    ids.push_back(Dimension::Id::StartPulse);
    ids.push_back(Dimension::Id::ReflectedPulse);
    ids.push_back(Dimension::Id::ScanAngleRank);
    ids.push_back(Dimension::Id::Pitch);
    ids.push_back(Dimension::Id::Roll);
    ids.push_back(Dimension::Id::Pdop);
    ids.push_back(Dimension::Id::PulseWidth);
    ids.push_back(Dimension::Id::PassiveSignal);
    ids.push_back(Dimension::Id::PassiveY);
    ids.push_back(Dimension::Id::PassiveX);
    ids.push_back(Dimension::Id::PassiveZ);

    return ids;
}