Help on opening an SDC Network Dataset in Java ?

601
1
03-28-2011 07:41 AM
Highlighted
New Contributor
Hello ,

Help! Does anybody know how to open a SDC network dataset in java. I am trying to use the provided  Street SDC Network Dataset from ESRI.


Thanks,
Rodel
Tags (2)
Reply
0 Kudos
1 Reply
Highlighted
New Contributor
I fount it!


String sdcPath ="C:/ARCGIS/MAp and Data/streetmap_na/data";
IWorkspace theSDCWorkspace = openSdcWorkspace(sdcPath);

String networkDatasetName="streets.sdc";

INetworkDataset nwDataset = openSDCNetworkDataset(theSDCWorkspace,networkDatasetName);

public INetworkDataset openSDCNetworkDataset(IWorkspace networkDatasetWorkspace,
      String networkDatasetName)throws AutomationException,
      IOException{
      // Shapefile and SDC network datasets will not have a feature dataset,
      // so pass in the featureDatasetName as an empty string for those types.
      if (networkDatasetWorkspace == null || networkDatasetName == "")
          return null;
      // Get the IDatasetContainer based on the workspace type.
      IDatasetContainer3 datasetContainer3 = null;
         // Example: FileSystemWorkspaces include SDC and shapefile.
            IWorkspaceExtensionManager workspaceExtensionManager = (IWorkspaceExtensionManager)networkDatasetWorkspace;
            UID networkID = new UID();
            networkID.setValue("esriGeoDatabase.NetworkDatasetWorkspaceExtension");
            IWorkspaceExtension workspaceExtension =  workspaceExtensionManager.findExtension(networkID);
            datasetContainer3 = new IDatasetContainer3Proxy(workspaceExtension);
            // Example: LocalDatabaseWorkspaces can be personal geodatabases and file geodatabases.
            // An example RemoteDatabaseWorkspace is an ArcSDE geodatabase.
            // Both LocalDatabaseWorkspace and RemoteDatabaseWorkspace network datasets are
            // opened the same way.

            if (datasetContainer3 == null)
          return null;
      // Use the container to open the network dataset.
      IDataset dataset = datasetContainer3.getDatasetByName(esriDatasetType.esriDTNetworkDataset, networkDatasetName);
      INetworkDataset networkDataset = new INetworkDatasetProxy(dataset);
      // Some Network Analyst methods, such as INASolver.Bind, require an IDENetworkDataset.
      // You can access the DataElement from the network dataset via the IDatasetComponent interface
      IDatasetComponent datasetComponent = new IDatasetComponentProxy(networkDataset);
      IDENetworkDataset deNetworkDataset = (IDENetworkDataset) datasetComponent.getDataElement();
      return networkDataset;
}
Reply
0 Kudos