ehallander

How to create Geometric Network within a Geodatabase

Discussion created by ehallander on Sep 1, 2011
I am working with 10.0 and a 9.3 created File Geodatabase that contains a FeatureDataset with a FeatureClass of of simpleEdges and a built Network Dataset.

The goal is to create a Geometric Network using the ILoaderNetwork2 interface in Java

So, I

1) Created a new File Geodatabase and Feature Dataset.

2) I imported the FeatureClass that contains the geometries, and the Juntions table that appears to be a result of building the Network Dataset. I think at this point it is fair to say that my newly created File Geodatabase is in the 10.0 format.

3) I then followed the instructions in http://help.arcgis.com/en/sdk/10.0/java_ao_adf/conceptualhelp/engine/index.html#/How_to_create_geometric_networks_within_a_geodatabase/00010000044q000000/ to see if I could do this programatically.

The link above is to the 10.0 Manual, yet when I attempt to execute the line

networkLoader2.setFeatureDatasetName(featuredatasetName);

I find that this method does not exist and I seem to need the setFeatureDatasetNameByRef call for which I built an IDatasetName object as a FeatureDatasetName object with the WorkspaceName reference being set correctly.

Other than that I followed the example as written, preserving enabled values, ignoring the source info, and not adding any weights.

Let's say I want the new Geometric Network to have the name 'Network'.

I run this and I get the following:

SEVERE: com.vfsd.fcs.pps.vgp.tools.esri.common.EsriGeoNetwork.buildGeoNetwork:Automation Exception: Code 2147746833, Source: ESRI GeoDatabase, Description: The table was not found. [Network_Junctions]
AutomationException: 0x80040411 - The table was not found. [_Junctions] in 'ESRI GeoDatabase'
at com.esri.arcgis.networkanalysis.NetworkLoader.loadNetwork(Unknown Source)
at com.vfsd.fcs.pps.vgp.tools.esri.common.EsriGeoNetwork.buildGeoNetwork(EsriGeoNetwork.java:525)

Which complains about the table Network_Junctions being not found. Pretty sure this is supposed to get created.

If I use ArcCatalog and select the NetworkFeature Dataset and New->Geometric network and follow the same basic steps, and execute, it succeeds (with some edge errors), thus creating the 'Network' Geometric Network, and a 'Network_Junctions' FeatureClass with all the junctions.

So I am guessing that the networkLoader.loadNetwork() method should be responsible for getting this all created.

What simple concept (Realizing that there are of course no simple concepts in this package) am I missing here? I am having trouble finding a reference to this error allowing me to see where others have failed.

Thanks
Eric

PS. The basic code structure is

   private void buildGeoNetwork(FeatureDataset fDataset, IDatasetName idn, String networkName) {
    try {
  INetworkLoader2 networkLoader2 = new NetworkLoader();
  networkLoader2.setNetworkName(networkName);
  networkLoader2.setNetworkType(esriNetworkType.esriNTUtilityNetwork);
  networkLoader2.setFeatureDatasetNameByRef(idn);
  networkLoader2.setPreserveEnabledValues(true);
  networkLoader2.setSnapTolerance(networkLoader2.getMinSnapTolerance());
 
  IFeatureClass[] fclasses = extractFeatureClasses(fDataset);
  for (int i=0; i<fclasses.length; i++)
  {
   int fccVal = networkLoader2.canUseFeatureClass(fclasses[i].getAliasName());
   if ( fccVal == esriNetworkLoaderFeatureClassCheck.esriNLFCCValid)
   {
    logger.debug("Adding Feature Class " + fclasses[i].getAliasName());
       networkLoader2.addFeatureClass(fclasses[i].getAliasName(), fclasses[i].getFeatureType(), null,
           false);
   }
   else
   {
    logger.warn("Unable to use Feature Class " + fclasses[i].getAliasName() + "[" + EsriNLFCHelper.decode(fccVal) + "]");
   }
  }
 
  networkLoader2.loadNetwork();
                .
                .


I build up my DatasetName as

IWorkspaceName wsn = new WorkspaceName();
wsn.setWorkspaceFactoryProgID(FileGDBWorkspaceFactory.getClsid());
wsn.setPathName(ws.getPathName()); // Where ws is my current open workspace
wsn.setBrowseName(ws.getBrowseName()); // Just filling it all out
IDatasetName fsn = new FeatureDatasetName();
fsn.setWorkspaceByRef(wsn);
fsn.setName(fDataset.getName()); // where fDataset is my Feature Data Set.

buildGeoNetwork(fDataset, fsn, NetworkName);

Outcomes