In my application a plug-in datasource has been implemented to read specifically formatted files containing a mix of data types, including geometry in the form of polygons, lines, and points. Using the "Add Data" button in ArcScene/ArcMap, the file in question can be selected to reveal the different datasets (polygons or lines, usually) contained within the file, after which they can be added individually into the scene or map.
A functionality I'm looking to add involves automation of the add data process, so I need a way to specify which (one, some or all) dataset(s) within the file get added to the scene/map. However, what I have currently always adds the polygons (which are the default) and not line or point data.
Currently I'm creating feature layers as follows:
// open workspace
IWorkspace workspace = workspaceFactory.OpenFromFile(System.IO.Path.GetDirectoryName(filename), 0);
// cast as feature workspace
IFeatureWorkspace featureWorkspace = workspace as IFeatureWorkspace;
// get a featureclass from the workspace
IFeatureClass featureClass = featureWorkspace.OpenFeatureClass(System.IO.Path.GetFileName(filename));
// create a new feature layer
IFeatureLayer featureLayer = new FeatureLayerClass
{
Name = featureClass.AliasName,
FeatureClass = featureClass
};
The issue arises when getting a featureclass from the workspace, which is done by a string containing the name. It only works properly if I include the file extension in the argument to OpenFeatureClass(string), for example "3d_data.ext" instead of simply "3d_data". I find this confusing-- shouldn't the extension only be required when opening the workspace from the file?
When browsing the file via "Add data", the polygon data is called "3d_data", and lines is "3d_data-lines". Creation of the feature class fails if "3d_data-lines" is provided to OpenFeatureClass, just as it does if just "3d_data" is used. Do I have to Open a FeatureDataset from the file first, and then create individual featureclasses from the FeatureDataset?
