我已经成功打开了一个 DBF 表:
String dbfDirectoryPath = "Z:/ESRI/data/washingtonCountyDataFiles/tlg_roads";
IWorkspaceFactory workspaceFactory = new ShapefileWorkspaceFactory();
IWorkspace workspace = workspaceFactory.OpenFromFile(dbfDirectoryPath, 0);
IFeatureWorkspace featureWorkspace = workspace as IFeatureWorkspace;
String dbfTable = "tlg_roads_l.dbf";
ITable table = featureWorkspace.OpenTable(dbfTable);
现在我想映射它,我认为这需要调用 mapControl.AddLayer(layer)。所以我需要以某种方式将此对象从 featureWorkspace 转换为 ILayer。
看起来我可以只 CreateFeatureClass 然后转换为 ILayer,但是 CreateFeatureClass 有 6 个参数,包括 CLSID,所以我觉得我错过了一些概念点。感谢您的任何建议:)
//IFeatureClass featureclass = tableWorkspace.CreateFeatureClass //req six args, incl. CLSID
ILayer layer = featureclass as ILayer;
mapControl.AddLayer(layer);