This blog post is in continuation of my previous post on “Read FDO Features using Map 3D Geospatial Platform API “. If FDO data has an attribute like “AREA” as shown in the screenshot below, we can access the same using –
String ftrArea = ftrRdr.GetString("AREA");
However, if there is no such attribute or data field in the FDO data, in that case we can use the following approach to access the FDO Geometry and then read it’s Area property as shown in the code snippet below :
//this is just an example; change this according to your FDO data field
Int32 ftrID = ftrRdr.GetInt32("Autogenerated_SDF_ID");
String geomName = mapLayer.GetFeatureGeometryName();
MgByteReader reader = ftrRdr.GetGeometry(geomName);
// Convert the AGF binary data to MgGeometry.
MgAgfReaderWriter agfReaderWriter = new MgAgfReaderWriter();
MgGeometry ftrGeometry = agfReaderWriter.Read(reader);
ed.WriteMessage("\n Feature ID :" + ftrID.ToString() + " " + "Area : " + ftrGeometry.Area.ToString());
Hope this is useful to you!