コード例 #1
0
ファイル: DeltaKernel.cpp プロジェクト: jasonoverland/PDAL
int DeltaKernel::execute()
{
    PointTable srcTable;
    PointTable candTable;
    DimIndexMap dims;

    PointViewPtr srcView = loadSet(m_sourceFile, srcTable);
    PointViewPtr candView = loadSet(m_candidateFile, candTable);

    PointLayoutPtr srcLayout = srcTable.layout();
    PointLayoutPtr candLayout = candTable.layout();

    Dimension::IdList ids = srcLayout->dims();
    for (Dimension::Id dim : ids)
    {
        std::string name = srcLayout->dimName(dim);
        if (!m_allDims)
            if (name != "X" && name != "Y" && name != "Z")
                continue;
        DimIndex d;
        d.m_name = name;
        d.m_srcId = dim;
        dims[name] = d;
    }
    ids = candLayout->dims();
    for (Dimension::Id dim : ids)
    {
        std::string name = candLayout->dimName(dim);
        auto di = dims.find(name);
        if (di == dims.end())
            continue;
        DimIndex& d = di->second;
        d.m_candId = dim;
    }

    // Remove dimensions that aren't in both the source and candidate lists.
    for (auto di = dims.begin(); di != dims.end();)
    {
        DimIndex& d = di->second;
        if (d.m_candId == Dimension::Id::Unknown)
            dims.erase(di++);
        else
            ++di;
    }

    // Index the candidate data.
    KD3Index index(*candView);
    index.build();

    MetadataNode root;

    if (m_detail)
        root = dumpDetail(srcView, candView, index, dims);
    else
        root = dump(srcView, candView, index, dims);
    Utils::toJSON(root, std::cout);

    return 0;
}
コード例 #2
0
ファイル: PDALUtils.hpp プロジェクト: adam-erickson/PDAL
inline MetadataNode toMetadata(PointTableRef table)
{
    const PointLayoutPtr layout(table.layout());
    MetadataNode root;

    for (const auto& id : layout->dims())
    {
        MetadataNode dim("dimensions");
        dim.add("name", layout->dimName(id));
        Dimension::Type::Enum t = layout->dimType(id);
        dim.add("type", Dimension::toName(Dimension::base(t)));
        dim.add("size", layout->dimSize(id));
        root.addList(dim);
    }

    return root;
}
コード例 #3
0
ファイル: BpfWriter.cpp プロジェクト: adam-erickson/PDAL
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);
    }
}
コード例 #4
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);
    }
}
コード例 #5
0
ファイル: PointView.cpp プロジェクト: Rafaelaniemann/PDAL
void PointView::dump(std::ostream& ostr) const
{
    using std::endl;
    PointLayoutPtr layout = m_pointTable.layout();
    const Dimension::IdList& dims = layout->dims();

    point_count_t numPoints = size();
    ostr << "Contains " << numPoints << "  points" << endl;
    for (PointId idx = 0; idx < numPoints; idx++)
    {
        ostr << "Point: " << idx << endl;

        for (auto di = dims.begin(); di != dims.end(); ++di)
        {
            Dimension::Id d = *di;
            const Dimension::Detail *dd = layout->dimDetail(d);
            ostr << Dimension::name(d) << " (" <<
                Dimension::interpretationName(dd->type()) << ") : ";

            switch (dd->type())
            {
            case Dimension::Type::Signed8:
                {
                    ostr << (int)(getFieldInternal<int8_t>(d, idx));
                    break;
                }
            case Dimension::Type::Signed16:
                {
                    ostr << getFieldInternal<int16_t>(d, idx);
                    break;
                }
            case Dimension::Type::Signed32:
                {
                    ostr << getFieldInternal<int32_t>(d, idx);
                    break;
                }
            case Dimension::Type::Signed64:
                {
                    ostr << getFieldInternal<int64_t>(d, idx);
                    break;
                }
            case Dimension::Type::Unsigned8:
                {
                    ostr << (unsigned)(getFieldInternal<uint8_t>(d, idx));
                    break;
                }
            case Dimension::Type::Unsigned16:
                {
                    ostr << getFieldInternal<uint16_t>(d, idx);
                    break;
                }
            case Dimension::Type::Unsigned32:
                {
                    ostr << getFieldInternal<uint32_t>(d, idx);
                    break;
                }
            case Dimension::Type::Unsigned64:
                {
                    ostr << getFieldInternal<uint64_t>(d, idx);
                    break;
                }
            case Dimension::Type::Float:
                {
                    ostr << getFieldInternal<float>(d, idx);
                    break;
                }
            case Dimension::Type::Double:
                {
                    ostr << getFieldInternal<double>(d, idx);
                    break;
                }
            default:
                throw;
            }
            ostr << endl;
        }
    }
}