Skip to content

Commit

Permalink
Arrow/Parquet: use recommended item names for GeoArrow [multi]line, […
Browse files Browse the repository at this point in the history
…multi]polygon, multipoint
  • Loading branch information
rouault committed Oct 7, 2024
1 parent 8cbe405 commit 076e31b
Showing 1 changed file with 42 additions and 13 deletions.
55 changes: 42 additions & 13 deletions ogr/ogrsf_frmts/arrow_common/ograrrowwriterlayer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<arrow::Field>(
"vertices", getFixedSizeListOfPoint()));
};

const auto getListOfRings = [&getListOfVertices]()
{
return arrow::list(
std::make_shared<arrow::Field>("rings", getListOfVertices()));
};

const auto getListOfVerticesStruct = [&pointStructType]()
{
return arrow::list(
std::make_shared<arrow::Field>("vertices", pointStructType));
};

const auto getListOfRingsStruct = [&getListOfVerticesStruct]()
{
return arrow::list(std::make_shared<arrow::Field>(
"rings", getListOfVerticesStruct()));
};

std::shared_ptr<arrow::DataType> dt;
switch (m_aeGeomEncoding[i])
{
Expand All @@ -340,48 +364,53 @@ 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<arrow::Field>(
"points", getFixedSizeListOfPoint()));
break;

case OGRArrowGeomEncoding::GEOARROW_FSL_MULTILINESTRING:
dt = arrow::list(arrow::list(getFixedSizeListOfPoint()));
dt = arrow::list(std::make_shared<arrow::Field>(
"linestrings", getListOfVertices()));
break;

case OGRArrowGeomEncoding::GEOARROW_FSL_MULTIPOLYGON:
dt = arrow::list(
arrow::list(arrow::list(getFixedSizeListOfPoint())));
dt = arrow::list(std::make_shared<arrow::Field>(
"polygons", getListOfRings()));
break;

case OGRArrowGeomEncoding::GEOARROW_STRUCT_POINT:
dt = pointStructType;
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<arrow::Field>("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<arrow::Field>(
"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<arrow::Field>(
"polygons", getListOfRingsStruct()));
break;
}

Expand Down

0 comments on commit 076e31b

Please sign in to comment.