I'm migrating from calling native MiTAB operations for exporting features to a MapInfo TAB file to using GDAL and the MapInfo driver. I'm using C# and MaxRev.Gdal.Core package (and MaxRev.Gdal.WindowsRuntime.Minimal)
But when I try to export features that has geometry collections with mixed geometry types, GDAL creates multiple features in the TAB file.
If I try a feature with a collection of polygons, all is good too.. 1 feature with 2 polygons.
My old code calling MiTAB directly works fine.
Simple code showing the issue
{
// Register the OGR library
Ogr.RegisterAll();
// Create a new MapInfo Tab file
DataSource ds = Ogr.GetDriverByName("MapInfo File").CreateDataSource(@"c:\temp\playground.tab", null);
// Create a layer
Layer layer = ds.CreateLayer("layer", null, wkbGeometryType.wkbUnknown, null);
// Create a feature
Feature feature = new Feature(layer.GetLayerDefn());
// Create a MultiGeometry
Geometry multiGeometry = new Geometry(wkbGeometryType.wkbGeometryCollection);
// Add polygons and polylines to the MultiGeometry
Geometry polygonGeometry = Geometry.CreateFromWkt("POLYGON ((0 0, 0 1, 1 1, 1 0, 0 0))");
Geometry polylineGeometry = Geometry.CreateFromWkt("LINESTRING (2 0, 3 0, 3 1, 2 1)");
multiGeometry.AddGeometry(polygonGeometry);
multiGeometry.AddGeometry(polylineGeometry);
// Set the MultiGeometry as the feature's geometry
feature.SetGeometryDirectly(multiGeometry);
// Create the feature in the layer
layer.CreateFeature(feature);
// Cleanup
feature.Dispose();
ds.Dispose();
}
GEOMETRYCOLLECTION ( LINESTRING ( 2 0, 3 0, 3 1, 2 1 ), POLYGON (( 0 0, 0 1, 1 1, 1 0, 0 0 )))
once you have added the components with your code?