Hi folks,I'm doing some debugging for a GDAL ticket ( http://trac.osgeo.org/gdal/ticket/4832 ), and I have come across some odd behaviour, and have some questions relating to null & empty geometries.My test code is here: https://gist.github.com/3813984 and everything has been run under Linux/64bit against the v1.2 API.Null geometries:What is the correct way to define them?Option 1:
row.SetNull(L"SHAPE"); // where SHAPE is the geometry field in the feature class
// then check for null via
row.IsNull(L"SHAPE");
This seems to work, and a table with only null geometries has a table extent of Nan,Nan,Nan,Nan. But what is geometryNull/shapeNull for then?Option 2: Don't call row.setGeometry(). Rows get added to the FGDB with geometries as random types (sometimes geometryNull, sometimes geometryMultiPatch, sometimes the previous geometry type created), and with coordinates NaN/random/from the previous geometry created.Option 3:
PointShapeBuffer geom;
row.SetGeometry(geom); // Errors with: Invalid pointer function parameter. (-2147467261)
Option 4:
PointShapeBuffer geom;
geom.Setup(FileGDBAPI::shapeNull); // Errors with: 522
row.SetGeometry(geom); // If you ignore the above, errors with: Invalid pointer function parameter. (-2147467261)
Option 5: Something else? 🙂Empty Geometries:(I'm using POINT EMPTY as an example, but the same logic presumably applies to GEOMETRYCOLLECTION EMPTY, POLYGON EMPTY, etc)
PointShapeBuffer geom;
geom.Setup(FileGDBAPI::shapePoint);
geom.SetEmpty();
row.SetGeometry(geom);
If you do this as the first features in an table, you get a random shapeType (eg. 64, 65), and geometryNull for the geometryType. geom.IsEmpty() returns false.If you do this after you've added other points, you get the same shapeType, geometryType, and coordinates as the last non-empty point. geom.IsEmpty() returns false - ie. the geometry of the last non-empty feature is copied to the empty feature.If a table has any rows with empty geometries, the bounds of the row extend to 0 - eg. add (100,100) and (POINT EMPTY) to a Table, and table.GetExtent() will return (xMin=0, xMax=100, yMin=0, yMax=100). If a table only has empty geometries, the extent will be (0, 0, 0, 0)Is there a better way to set/read empty geometries?Cheers,Rob 🙂