void GreyhoundReader::addDimensions(PointLayoutPtr layout)
{
    // Get Greyhound schema.
    exchanges::GetSchema schemaExchange(m_sessionId);
    m_wsClient.exchange(schemaExchange);

    std::vector<exchanges::DimData> dimData = schemaExchange.schema();

    for (const auto& dim : dimData)
    {
        layout->registerDim(dim.id, dim.type);
    }

    m_layout = layout;
}
Exemple #2
0
void PtsReader::addDimensions(PointLayoutPtr layout)
{
    // Dimensions are fixed in PTS

    m_dims.push_back(Dimension::Id::X);
    m_dims.push_back(Dimension::Id::Y);
    m_dims.push_back(Dimension::Id::Z);
    m_dims.push_back(Dimension::Id::Intensity);
    m_dims.push_back(Dimension::Id::Red);
    m_dims.push_back(Dimension::Id::Green);
    m_dims.push_back(Dimension::Id::Blue);

    for (auto d: m_dims)
    {
        layout->registerDim(d);
    }

}
Exemple #3
0
TEST(KDIndex, radius2D)
{
    PointTable table;
    PointLayoutPtr layout = table.layout();
    PointView view(table);

    layout->registerDim(Dimension::Id::X);
    layout->registerDim(Dimension::Id::Y);

    view.setField(Dimension::Id::X, 0, 0);
    view.setField(Dimension::Id::Y, 0, 0);
    
    view.setField(Dimension::Id::X, 1, 1);
    view.setField(Dimension::Id::Y, 1, 1);
    
    view.setField(Dimension::Id::X, 2, 3);
    view.setField(Dimension::Id::Y, 2, 3);
    
    view.setField(Dimension::Id::X, 3, 6);
    view.setField(Dimension::Id::Y, 3, 6);
    
    view.setField(Dimension::Id::X, 4, 10);
    view.setField(Dimension::Id::Y, 4, 10);
    
    KD2Index index(view);
    index.build();

    std::vector<PointId> ids;
    ids = index.radius(0, 0, 4.25);
    
    EXPECT_EQ(ids.size(), 3u);
    EXPECT_EQ(ids[0], 0u);
    EXPECT_EQ(ids[1], 1u);
    EXPECT_EQ(ids[2], 2u);

    ids = index.radius(3.1, 3.1, 10);
    EXPECT_EQ(ids.size(), 5u);
    EXPECT_EQ(ids[0], 2u);
    EXPECT_EQ(ids[1], 1u);
    EXPECT_EQ(ids[2], 3u);
    EXPECT_EQ(ids[3], 0u);
    EXPECT_EQ(ids[4], 4u);
}
Exemple #4
0
void Ilvis2Reader::addDimensions(PointLayoutPtr layout)
{
    layout->registerDim(Dimension::Id::LvisLfid);
    layout->registerDim(Dimension::Id::ShotNumber);
    layout->registerDim(Dimension::Id::GpsTime);
    layout->registerDim(Dimension::Id::LongitudeCentroid);
    layout->registerDim(Dimension::Id::LatitudeCentroid);
    layout->registerDim(Dimension::Id::ElevationCentroid);
    layout->registerDim(Dimension::Id::LongitudeLow);
    layout->registerDim(Dimension::Id::LatitudeLow);
    layout->registerDim(Dimension::Id::ElevationLow);
    layout->registerDim(Dimension::Id::LongitudeHigh);
    layout->registerDim(Dimension::Id::LatitudeHigh);
    layout->registerDim(Dimension::Id::ElevationHigh);
    layout->registerDim(Dimension::Id::X);
    layout->registerDim(Dimension::Id::Y);
    layout->registerDim(Dimension::Id::Z);
}
void TerrasolidReader::addDimensions(PointLayoutPtr layout)
{
    m_size = 0;
    layout->registerDim(Dimension::Id::Classification);
    layout->registerDim(Dimension::Id::PointSourceId);
    layout->registerDim(Dimension::Id::Intensity);
    layout->registerDim(Dimension::Id::X);
    layout->registerDim(Dimension::Id::Y);
    layout->registerDim(Dimension::Id::Z);
    layout->registerDim(Dimension::Id::ReturnNumber);
    layout->registerDim(Dimension::Id::NumberOfReturns);
    if (m_format == TERRASOLID_Format_2)
    {
        layout->registerDim(Dimension::Id::Flag);
        layout->registerDim(Dimension::Id::Mark);
    }
    if (m_format == TERRASOLID_Format_1)
        m_size = 16;
    else if (m_format == TERRASOLID_Format_2)
        m_size = 20;

    if (m_haveTime)
    {
        layout->registerDim(Dimension::Id::OffsetTime);
        m_size += 4;
    }

    if (m_haveColor)
    {
        layout->registerDim(Dimension::Id::Red);
        layout->registerDim(Dimension::Id::Green);
        layout->registerDim(Dimension::Id::Blue);
        layout->registerDim(Dimension::Id::Alpha);
        m_size += 4;
    }
}
Exemple #6
0
TEST(KDIndex, neighbors3D)
{
    PointTable table;
    PointLayoutPtr layout = table.layout();
    PointView view(table);

    layout->registerDim(Dimension::Id::X);
    layout->registerDim(Dimension::Id::Y);
    layout->registerDim(Dimension::Id::Z);

    view.setField(Dimension::Id::X, 0, 0);
    view.setField(Dimension::Id::Y, 0, 0);
    view.setField(Dimension::Id::Z, 0, 0);
    
    view.setField(Dimension::Id::X, 1, 1);
    view.setField(Dimension::Id::Y, 1, 1);
    view.setField(Dimension::Id::Z, 1, 1);
    
    view.setField(Dimension::Id::X, 2, 3);
    view.setField(Dimension::Id::Y, 2, 3);
    view.setField(Dimension::Id::Z, 2, 3);
    
    view.setField(Dimension::Id::X, 3, 6);
    view.setField(Dimension::Id::Y, 3, 6);
    view.setField(Dimension::Id::Z, 3, 6);
    
    view.setField(Dimension::Id::X, 4, 10);
    view.setField(Dimension::Id::Y, 4, 10);
    view.setField(Dimension::Id::Z, 4, 10);
    
    KD3Index index(view);
    index.build();

    EXPECT_EQ(index.neighbor(0, 0, 0), 0u);
    EXPECT_EQ(index.neighbor(1.1, 1.1, 1.1), 1u);
    EXPECT_EQ(index.neighbor(3.3, 3.3, 3.3), 2u);
    EXPECT_EQ(index.neighbor(6.1, 6.1, 6.1), 3u);
    EXPECT_EQ(index.neighbor(15, 15, 15), 4u);

    std::vector<PointId> ids;
    ids = index.neighbors(0, 0, 0, 5);
    EXPECT_EQ(ids.size(), 5u);
    EXPECT_EQ(ids[0], 0u);
    EXPECT_EQ(ids[1], 1u);
    EXPECT_EQ(ids[2], 2u);
    EXPECT_EQ(ids[3], 3u);
    EXPECT_EQ(ids[4], 4u);

    ids = index.neighbors(0, 0, 0, 25);
    EXPECT_EQ(ids.size(), 5u);
    EXPECT_EQ(ids[0], 0u);
    EXPECT_EQ(ids[1], 1u);
    EXPECT_EQ(ids[2], 2u);
    EXPECT_EQ(ids[3], 3u);
    EXPECT_EQ(ids[4], 4u);

    ids = index.neighbors(3.1, 3.1, 3.1, 5);
    EXPECT_EQ(ids.size(), 5u);
    EXPECT_EQ(ids[0], 2u);
    EXPECT_EQ(ids[1], 1u);
    EXPECT_EQ(ids[2], 3u);
    EXPECT_EQ(ids[3], 0u);
    EXPECT_EQ(ids[4], 4u);
}
void RadiusOutlierFilter::addDimensions(PointLayoutPtr layout)
{
    layout->registerDim(Dimension::Id::Classification);
}
Exemple #8
0
void GreyhoundReader::addDimensions(PointLayoutPtr layout)
{
    std::map<std::string, const Json::Value*> remote;
    for (const auto& d : m_info["schema"])
        remote[d["name"].asString()] = &d;

    // The dimensions we will query are determined in the following order, the
    // first of which is present taking precedence:
    //  - The `dims` PDAL option on this stage.
    //  - A `schema` query parameter parsed from the `url` option.
    //  - Finally, fall back to the full `info.schema`.
    if (m_args.dims.isNull())
    {
        // If no dimensions are explicitly listed, only include the indexed
        // schema - omitting any appended dimensions.  Those must be explicitly
        // specified if desired.
        Json::Value nativeSchema;
        for (const Json::Value d : m_info["schema"])
            if (!d["addon"].asBool())
                nativeSchema.append(d);

        const Json::Value& readSchema = m_params["schema"].isNull() ?
            nativeSchema : m_params["schema"];

        for (const auto& d : readSchema)
        {
            m_args.dims.append(d["name"].asString());
        }
    }

    auto isXyz([](const std::string& name)
    {
        return name == "X" || name == "Y" || name == "Z";
    });

    // Build the request layout from the specified `dims`.
    for (const auto& n : m_args.dims)
    {
        const auto name(n.asString());

        if (!remote.count(name))
            throw pdal_error(name + " does not exist in the remote schema");

        const auto& d(*remote.at(name));

        const int baseType(
                Utils::toNative(Dimension::fromName(d["type"].asString())));

        const int size(d["size"].asInt());

        const Dimension::Type type(
                isXyz(name) ?
                    Dimension::Type::Double :
                    static_cast<Dimension::Type>(baseType | size));

        layout->registerOrAssignDim(name, type);
        m_readLayout.registerOrAssignDim(name, type);
    }

    if (!m_params.obounds().isNull())
    {
        layout->registerDim(Dimension::Id::Omit);
    }

    // We'll keep track of the point ordering here in case any intermediate
    // filters reorder them.  We need to write them with a 1:1 mapping to the
    // original query.
    layout->registerDim(Dimension::Id::PointId);

    m_params["schema"] = layoutToSchema(m_readLayout);

    log()->get(LogLevel::Debug) << "Schema: " << m_params["schema"] <<
        std::endl;
}
Exemple #9
0
void TIndexReader::addDimensions(PointLayoutPtr layout)
{
    layout->registerDim(pdal::Dimension::Id::X);
    layout->registerDim(pdal::Dimension::Id::Y);
    layout->registerDim(pdal::Dimension::Id::Z);
}
Exemple #10
0
void QfitReader::addDimensions(PointLayoutPtr layout)
{
    using namespace Dimension;

    m_size = 0;
    layout->registerDim(Id::OffsetTime);
    layout->registerDim(Id::Y);
    layout->registerDim(Id::X);
    layout->registerDim(Id::Z);
    layout->registerDim(Id::StartPulse);
    layout->registerDim(Id::ReflectedPulse);
    layout->registerDim(Id::ScanAngleRank);
    layout->registerDim(Id::Pitch);
    layout->registerDim(Id::Roll);
    m_size += 36;

    if (m_format == QFIT_Format_12)
    {
        layout->registerDim(Id::Pdop);
        layout->registerDim(Id::PulseWidth);
        m_size += 8;
    }
    else if (m_format == QFIT_Format_14)
    {
        layout->registerDim(Id::PassiveSignal);
        layout->registerDim(Id::PassiveY);
        layout->registerDim(Id::PassiveX);
        layout->registerDim(Id::PassiveZ);
        m_size += 16;
    }
    m_size += 4;  // For the GPS time that we currently discard.
}
Exemple #11
0
void PMFFilter::addDimensions(PointLayoutPtr layout)
{
    layout->registerDim(Dimension::Id::Classification);
}
Exemple #12
0
void NumpyReader::addDimensions(PointLayoutPtr layout)
{
    using namespace Dimension;

    wakeUpNumpyArray();
    createFields(layout);

    m_storeXYZ = true;
    // If we already have an X dimension, we're done.
    for (const Field& field : m_fields)
        if (field.m_id == Id::X || field.m_id == Id::Y || field.m_id == Id::Z)
        {
            m_storeXYZ = false;
            return;
        }

    // We're storing a calculated XYZ, so register the dims.
    layout->registerDim(Id::X, Type::Signed32);
    if (m_ndims > 1)
    {
        layout->registerDim(Id::Y, Type::Signed32);
        if (m_ndims > 2)
            layout->registerDim(Id::Z, Type::Signed32);
    }
    if (m_order == Order::Row)
    {
        m_xIter = m_shape[m_ndims - 1];
        m_xDiv = 1;
        if (m_ndims > 1)
        {
            m_yDiv = 1;
            m_xDiv = m_xIter;
            m_xIter *= m_shape[m_ndims - 2];
            m_yIter = m_shape[m_ndims - 1];
            if (m_ndims > 2)
            {
                m_xDiv = m_xIter;
                m_yDiv = m_yIter;
                m_zDiv = 1;
                m_xIter *= m_shape[m_ndims - 3];
                m_yIter *= m_shape[m_ndims - 2];
                m_zIter = m_shape[m_ndims - 1];
            }
        }
    }
    else
    {
        m_xIter = m_shape[0];
        m_xDiv = 1;
        if (m_ndims > 1)
        {
            m_yIter = m_shape[0] * m_shape[1];
            m_yDiv = m_xIter;
            if (m_ndims > 2)
            {
                m_zIter = m_shape[0] * m_shape[1] * m_shape[2];
                m_zDiv = m_yIter;
            }
        }
    }
}
Exemple #13
0
void MyFilter::addDimensions(PointLayoutPtr layout)
{
    layout->registerDim(Dimension::Id::Intensity);
    m_myDimension = layout->registerOrAssignDim("MyDimension",
            Dimension::Type::Unsigned8);
}