How to programmatically access a plug-in data source


Summary
ArcGIS deals with several read-only data sources, such as StreetMap, computer-aided design (CAD), and Smart Data Compression (SDC) formats used by RouteMAP IMS. A plug-in data source integrates a new data format completely into ArcGIS, in a read-only manner. The data source can be programmed with using normal geodatabase interfaces such as IWorkspace and IFeatureClass.

Accessing a plug-in data source programmatically


One of the advantages of plug-in data sources is that once implemented, they can be accessed by client developers using the normal geodatabase ArcObjects application programming interface (API). Only the interfaces with names starting with IPlugIn must be used when implementing the data source.
The code snippet below shows how to access a plug-in data source programmatically to add the custom data as a read-only layer to the map. Notice the workspace factory is created by using the method EngineContext.createObject(). The object reference of the PlugInWorkspaceFactoryHelper class is passed in as the method argument for the createObject() method.
[Java]
//Declare class variable

addPluginDsLayer(MapBean mapBean, String folderName, String featureClassName){
    //Add snippet to add PlugIn DS as a feature layer to the map
    IWorkspaceFactory workspaceFactory = (IWorkspaceFactory)
        EngineContext.createObject(SimplePointWorkspaceFactoryHelper.class);
    IFeatureWorkspace featureWorkspace = (IFeatureWorkspace)
        workspaceFactory.openFromFile(folderName, 0);
    IFeatureClass featureClass = featureWorkspace.openFeatureClass(featureClassName);
    //create a new feature layer and add it to the map
    IFeatureLayer featureLayer = new FeatureLayer();
    featureLayer.setName(featureClass.getAliasName());
    featureLayer.setFeatureClassByRef(featureClass);
    mapBean.addLayer((ILayer)featureLayer, 0);
    mapBean.refresh(esriViewDrawPhase.esriViewGeography, null, null);
}
You can also open the workspace with IWorkspaceFactory.open. In this case, supply a property set with a single property of DATABASE and the appropriate workspace string.






Development licensingDeployment licensing
Engine Developer KitEngine
ArcGIS for Desktop BasicArcGIS for Desktop Basic
ArcGIS for Desktop StandardArcGIS for Desktop Standard
ArcGIS for Desktop AdvancedArcGIS for Desktop Advanced