Skip to content

Commit

Permalink
OpenFileGDB: add support for CREATE_MULTIPATCH=YES layer creation opt…
Browse files Browse the repository at this point in the history
…ion for compatibility with FileGDB driver
  • Loading branch information
rouault committed Jan 15, 2025
1 parent 45279ab commit 5c3f351
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
3 changes: 3 additions & 0 deletions ogr/ogrsf_frmts/openfilegdb/ogropenfilegdbdrivercore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,9 @@ void OGROpenFileGDBDriverSetCommonMetadata(GDALDriver *poDriver)
"coordinate precision grid'/>"
" <Option name='MSCALE' type='float' description='M scale of the "
"coordinate precision grid'/>"
" <Option name='CREATE_MULTIPATCH' type='boolean' "
"description='Whether to write geometries of layers of type "
"MultiPolygon as MultiPatch' default='NO' />"
" <Option name='COLUMN_TYPES' type='string' description='A list of "
"strings of format field_name=fgdb_field_type (separated by comma) to "
"force the FileGDB column type of fields to be created'/>"
Expand Down
26 changes: 21 additions & 5 deletions ogr/ogrsf_frmts/openfilegdb/ogropenfilegdblayer_write.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,12 @@ bool OGROpenFileGDBLayer::Create(const OGRGeomFieldDefn *poSrcGeomFieldDefn)
const auto eFlattenType = wkbFlatten(OGR_GT_GetLinear(m_eGeomType));
if (eFlattenType == wkbNone)
eTableGeomType = FGTGT_NONE;
else if (CPLTestBool(m_aosCreationOptions.FetchNameValueDef(
"CREATE_MULTIPATCH", "FALSE")))
{
// For compatibility with FileGDB driver
eTableGeomType = FGTGT_MULTIPATCH;
}
else if (eFlattenType == wkbPoint)
eTableGeomType = FGTGT_POINT;
else if (eFlattenType == wkbMultiPoint)
Expand Down Expand Up @@ -2159,11 +2165,21 @@ bool OGROpenFileGDBLayer::PrepareFileGDBFeature(OGRFeature *poFeature,
eFlattenType != wkbPolyhedralSurface &&
eFlattenType != wkbGeometryCollection)
{
CPLError(CE_Failure, CPLE_NotSupported,
"Can only insert a "
"TIN/PolyhedralSurface/GeometryCollection in a "
"esriGeometryMultiPatch layer");
return false;
if (CPLTestBool(m_aosCreationOptions.FetchNameValueDef(
"CREATE_MULTIPATCH", "FALSE")) &&
eFlattenType == wkbMultiPolygon)
{
// ok
}
else
{
CPLError(
CE_Failure, CPLE_NotSupported,
"Can only insert a "
"TIN/PolyhedralSurface/GeometryCollection in a "
"esriGeometryMultiPatch layer");
return false;
}
}
break;
}
Expand Down

0 comments on commit 5c3f351

Please sign in to comment.