Skip to content

Commit

Permalink
Handle metadata. Remove interpretationName for actual types.
Browse files Browse the repository at this point in the history
  • Loading branch information
abellgithub committed Jan 2, 2025
1 parent ad26a0d commit 7ad50c9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 71 deletions.
63 changes: 0 additions & 63 deletions pdal/DimUtil.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,69 +139,6 @@ inline std::string interpretationName(Type dimtype)
return "unknown";
}

template <typename T>
std::string interpretationName();

template<>
inline std::string interpretationName<int8_t>()
{
return "int8_t";
}

template<>
inline std::string interpretationName<int16_t>()
{
return "int16_t";
}

template<>
inline std::string interpretationName<int32_t>()
{
return "int32_t";
}

template<>
inline std::string interpretationName<int64_t>()
{
return "int64_t";
}

template<>
inline std::string interpretationName<uint8_t>()
{
return "uint8_t";
}

template<>
inline std::string interpretationName<uint16_t>()
{
return "uint16_t";
}

template<>
inline std::string interpretationName<uint32_t>()
{
return "uint32_t";
}

template<>
inline std::string interpretationName<uint64_t>()
{
return "uint64_t";
}

template<>
inline std::string interpretationName<float>()
{
return "float";
}

template<>
inline std::string interpretationName<double>()
{
return "double";
}

/// Get the type corresponding to a type name.
/// \param s Name of type.
/// \return Corresponding type enumeration value.
Expand Down
20 changes: 12 additions & 8 deletions plugins/arrow/io/ArrowWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class DimHandler : public BaseDimHandler
NL::json metadata {
{ "name", m_name },
{ "description", Dimension::description(m_id) },
{ "interpretation", Dimension::interpretationName<DT>() },
{ "interpretation", Dimension::interpretationName(Dimension::type<DT>()) },
{ "size", sizeof(DT) }
};

Expand Down Expand Up @@ -133,8 +133,9 @@ class DimHandler : public BaseDimHandler
class XyzHandler : public BaseDimHandler
{
public:
XyzHandler(arrow::MemoryPool *pool, const std::string& dimName) :
m_dimName(dimName),
XyzHandler(arrow::MemoryPool *pool, const std::string& dimName,
const std::string& pipelineMetadata) :
m_dimName(dimName), m_pipelineMetadata(pipelineMetadata),
m_doubleBuilder(std::make_shared<arrow::DoubleBuilder>(pool)),
m_builder(pool, m_doubleBuilder, 3)
{
Expand All @@ -150,10 +151,8 @@ class XyzHandler : public BaseDimHandler
};

auto kvMetadata = std::make_shared<arrow::KeyValueMetadata>();
/**
if (m_writePipelineMetadata)
kvMetadata->Append("PDAL:pipeline:metadata", Utils::toJSON(table.metadata());
**/
if (m_pipelineMetadata.size())
kvMetadata->Append("PDAL:pipeline:metadata", m_pipelineMetadata);
kvMetadata->Append("PDAL:dimension:metadata", metadata.dump(-1));

return arrow::field("xyz", arrow::fixed_size_list(arrow::float64(), 3), kvMetadata);
Expand All @@ -180,6 +179,7 @@ class XyzHandler : public BaseDimHandler

private:
std::string m_dimName;
std::string m_pipelineMetadata;
std::shared_ptr<arrow::DoubleBuilder> m_doubleBuilder;
arrow::FixedSizeListBuilder m_builder;
};
Expand Down Expand Up @@ -331,7 +331,11 @@ void ArrowWriter::prepared(PointTableRef table)
m_dimHandlers.reserve(table.layout()->dims().size());

//Always do XYZ.
m_dimHandlers.push_back(std::make_unique<XyzHandler>(m_pool, m_geoArrowDimensionName));
std::string pipelineMetadata;
if (m_writePipelineMetadata)
pipelineMetadata = Utils::toJSON(table.metadata());
m_dimHandlers.push_back(std::make_unique<XyzHandler>(m_pool, m_geoArrowDimensionName,
pipelineMetadata));
if (m_formatType == arrowsupport::Parquet)
m_dimHandlers.push_back(std::make_unique<WkbHandler>(m_pool));
for (Id id : table.layout()->dims())
Expand Down

0 comments on commit 7ad50c9

Please sign in to comment.