[gdal-dev] Using GDAL (MaxRev.GDAL) to write TAB files with mixed geometry

Michael Tjener Pallesen (MTP) MTP at NIRAS.DK
Thu Jan 18 05:42:57 PST 2024


Hi

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)
https://github.com/MaxRev-Dev/gdal.netcore

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();
}

I have asked this question on gis.stackexchange too which lead to this mail. Here a user tried the same simple test without using MaxRev's version and came to the same result.

https://gis.stackexchange.com/questions/474496/using-gdal-maxrev-gdal-to-write-tab-files-with-mixed-geometry


Med venlig hilsen

Michael Tjener Pallesen
Softwareudvikler

[cid:image001.png at 01DA4A1C.9FB4D8E0]

Ceres Allé 3
8000 Aarhus C
Denmark
www.niras.dk<https://www.niras.dk/?utm_campaign=e-mail-signatur&utm_source=internal&utm_medium=e-mail&utm_content=e-mail-signatur-dk>

M: +45 3085 0906
L: +45 8732 5808
T: +45 8732 3232
E: mtp at niras.dk<mailto:mtp at niras.dk>

Følg os på:
[cid:image002.jpg at 01DA4A1C.9FB4D8E0]<https://www.linkedin.com/company/niras/mycompany/verification/>  [cid:image003.jpg at 01DA4A1C.9FB4D8E0] <https://www.facebook.com/NIRASGroup>

[cid:image004.png at 01DA4A1C.9FB4D8E0]

Denne e-mail kan indeholde fortrolige oplysninger. Hvis du fejlagtigt har
modtaget denne, kontakt venligst afsenderen øjeblikkeligt og slet mailen
samt eventuelle bilag. Kopier ikke denne mail, og undlad at dele dens
indhold med tredje part. Tak. NIRAS' håndtering af personlig information
står beskrevet i vores privatlivspolitik.<https://www.niras.dk/privacy-policy/>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20240118/2bde494a/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 4432 bytes
Desc: image001.png
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20240118/2bde494a/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image002.jpg
Type: image/jpeg
Size: 940 bytes
Desc: image002.jpg
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20240118/2bde494a/attachment-0002.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image003.jpg
Type: image/jpeg
Size: 887 bytes
Desc: image003.jpg
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20240118/2bde494a/attachment-0003.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image004.png
Type: image/png
Size: 3798 bytes
Desc: image004.png
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20240118/2bde494a/attachment-0003.png>


More information about the gdal-dev mailing list