From 076e31b8c8f435fc953ad472bbfc83e259251907 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Tue, 8 Oct 2024 00:31:18 +0200 Subject: [PATCH] Arrow/Parquet: use recommended item names for GeoArrow [multi]line, [multi]polygon, multipoint --- .../arrow_common/ograrrowwriterlayer.hpp | 55 ++++++++++++++----- 1 file changed, 42 insertions(+), 13 deletions(-) diff --git a/ogr/ogrsf_frmts/arrow_common/ograrrowwriterlayer.hpp b/ogr/ogrsf_frmts/arrow_common/ograrrowwriterlayer.hpp index 2a30a8e71dc0..ca60ff3d5e6a 100644 --- a/ogr/ogrsf_frmts/arrow_common/ograrrowwriterlayer.hpp +++ b/ogr/ogrsf_frmts/arrow_common/ograrrowwriterlayer.hpp @@ -319,6 +319,30 @@ inline void OGRArrowWriterLayer::CreateSchemaCommon() arrow::field("m", arrow::float64(), false)); auto pointStructType(arrow::struct_(std::move(pointFields))); + const auto getListOfVertices = [&getFixedSizeListOfPoint]() + { + return arrow::list(std::make_shared( + "vertices", getFixedSizeListOfPoint())); + }; + + const auto getListOfRings = [&getListOfVertices]() + { + return arrow::list( + std::make_shared("rings", getListOfVertices())); + }; + + const auto getListOfVerticesStruct = [&pointStructType]() + { + return arrow::list( + std::make_shared("vertices", pointStructType)); + }; + + const auto getListOfRingsStruct = [&getListOfVerticesStruct]() + { + return arrow::list(std::make_shared( + "rings", getListOfVerticesStruct())); + }; + std::shared_ptr dt; switch (m_aeGeomEncoding[i]) { @@ -340,24 +364,26 @@ inline void OGRArrowWriterLayer::CreateSchemaCommon() break; case OGRArrowGeomEncoding::GEOARROW_FSL_LINESTRING: - dt = arrow::list(getFixedSizeListOfPoint()); + dt = getListOfVertices(); break; case OGRArrowGeomEncoding::GEOARROW_FSL_POLYGON: - dt = arrow::list(arrow::list(getFixedSizeListOfPoint())); + dt = getListOfRings(); break; case OGRArrowGeomEncoding::GEOARROW_FSL_MULTIPOINT: - dt = arrow::list(getFixedSizeListOfPoint()); + dt = arrow::list(std::make_shared( + "points", getFixedSizeListOfPoint())); break; case OGRArrowGeomEncoding::GEOARROW_FSL_MULTILINESTRING: - dt = arrow::list(arrow::list(getFixedSizeListOfPoint())); + dt = arrow::list(std::make_shared( + "linestrings", getListOfVertices())); break; case OGRArrowGeomEncoding::GEOARROW_FSL_MULTIPOLYGON: - dt = arrow::list( - arrow::list(arrow::list(getFixedSizeListOfPoint()))); + dt = arrow::list(std::make_shared( + "polygons", getListOfRings())); break; case OGRArrowGeomEncoding::GEOARROW_STRUCT_POINT: @@ -365,23 +391,26 @@ inline void OGRArrowWriterLayer::CreateSchemaCommon() break; case OGRArrowGeomEncoding::GEOARROW_STRUCT_LINESTRING: - dt = arrow::list(pointStructType); + dt = getListOfVerticesStruct(); break; case OGRArrowGeomEncoding::GEOARROW_STRUCT_POLYGON: - dt = arrow::list(arrow::list(pointStructType)); + dt = getListOfRingsStruct(); break; case OGRArrowGeomEncoding::GEOARROW_STRUCT_MULTIPOINT: - dt = arrow::list(pointStructType); + dt = arrow::list( + std::make_shared("points", pointStructType)); break; - case OGRArrowGeomEncoding::GEOARROW_STRUCT_MULTILINESTRING: - dt = arrow::list(arrow::list(pointStructType)); + case OGRArrowGeomEncoding::GEOARROW_FSL_MULTILINESTRING: + dt = arrow::list(std::make_shared( + "linestrings", getListOfVerticesStruct())); break; - case OGRArrowGeomEncoding::GEOARROW_STRUCT_MULTIPOLYGON: - dt = arrow::list(arrow::list(arrow::list(pointStructType))); + case OGRArrowGeomEncoding::GEOARROW_FSL_MULTIPOLYGON: + dt = arrow::list(std::make_shared( + "polygons", getListOfRingsStruct())); break; }