/** * Solves a route based on specified network dataset and stops fc * @param workspacePath * @param inputStopsFC * @param shapeInputNameField * @param networkDatasetName * @param outLayerPath */ public void solveRoute( String workspacePath ,String inputStopsFeatureDataset, String inputStopsFC ,String shapeInputNameField ,String networkDatasetFeatureDataset, String networkDatasetName ,String outLayerPath ){ // Open the feature workspace, input feature class, and network dataset try { //open file geodatabase IWorkspaceFactory workspaceFactory = new FileGDBWorkspaceFactory(); IFeatureWorkspace featureWorkspace = new IFeatureWorkspaceProxy(workspaceFactory.openFromFile(workspacePath, 0)); //open input feature class IFeatureDataset featureDataset = featureWorkspace.openFeatureDataset(inputStopsFeatureDataset); IFeatureClassContainer inputStopsFeatureCC = new IFeatureClassContainerProxy(featureDataset); IFeatureClass inputStopsFClass = inputStopsFeatureCC.getClassByName(inputStopsFC); //open network dataset featureDataset = featureWorkspace.openFeatureDataset(networkDatasetFeatureDataset); IFeatureDatasetExtensionContainer fdsExtCont = new IFeatureDatasetExtensionContainerProxy(featureDataset); IFeatureDatasetExtension fdsExt = fdsExtCont.findExtension(esriDatasetType.esriDTNetworkDataset); IDatasetContainer2 dsCont = new IDatasetContainer2Proxy(fdsExt); IDataset dataset = dsCont.getDatasetByName(esriDatasetType.esriDTNetworkDataset, networkDatasetName); NetworkDataset networkDataset = new NetworkDataset(dataset); // Create the Route NALayer INALayer naLayer = createRouteAnalysisLayer("Route", networkDataset); INAContext naContext = naLayer.getContext(); INAClass stopsNAClass = (INAClass) naContext.getNAClasses().getItemByName("Stops"); // Load the Stops INAClassFieldMap naClassFieldMap = new NAClassFieldMap(); naClassFieldMap.setMappedField("Name", shapeInputNameField); INAClassLoader naLoader = new NAClassLoader(); naLoader.setLocatorByRef(naContext.getLocator()); naLoader.setNAClassByRef(stopsNAClass); naLoader.setFieldMapByRef(naClassFieldMap); int[] rowsInCursor = { 0 }; int[] rowsLocated = { 0 }; ITrackCancel cancelTracker = new CancelTracker(); FeatureCursor cursor = new FeatureCursor(inputStopsFClass.search(new QueryFilter(), false)); naLoader.load(cursor, cancelTracker, rowsInCursor, rowsLocated); // Solve INASolver naSolver = naContext.getSolver(); naSolver.solve(naContext, new GPMessages(), cancelTracker); // Save the layer to disk saveLayerToDisk(naLayer, outLayerPath); } catch (Exception e) { e.printStackTrace(); } }
Sorry for detracting from the actual problem and creating noise on the thread--I'm just trying to learn from how the senior members, like yourself, analyze problems so that I can be a better problem solver.
Plus.. in Java: String.valueOf(null); will debug with the line of error using the JDK.which is: Exception in thread "main" java.lang.NullPointerException at java.lang.String.<init>(String.java:177) at java.lang.String.valueOf(String.java:2840) at AimsConnectDemo.main(AimsConnectDemo.java:20) If you check the Java Source code for the String class, you will find that line 177 tries to the get length of null. But this is probably not related to Pavan's issue - I hope.Unknown source seems like an appropriate error message since it could be that Pavan's network dataset might not have been created properly? I can only point people in certain directions, they have to figure out the rest.
Exception in thread "main" java.lang.NullPointerException at java.lang.String.<init>(String.java:177) at java.lang.String.valueOf(String.java:2840) at AimsConnectDemo.main(AimsConnectDemo.java:20)
Oh. I thought that was because of missing debug symbols:
Pavan's original post:
The following is the Exception I am getting.AutomationException: 0x80004001 - Not implementedat com.esri.arcgis.interop.Dispatch.vtblInvoke(Unknown Source)at com.esri.arcgis.geodatabase.INetworkDatasetProxy.getState(Unknown Source).
Pavan,Can you show us how you are creating your NAContext? Are you setting the LocatorByRef to a INALocator? And you have added a LocatorAgent? How did you bind the NetWorkDataset to your INALocatorAgent? correction: it goes all the way back to how you instantiated your NetworkDataset. Did you use NetworkDatasetFDExtension and IDatasetContainer ?This is probably where it starts since your error indicates an unknown source.
Hi Leo Donahue,I am using the FileGDB.The following is the code which is failing for me with the case in getting the state of the NetworkDataset as such which gives the information of it.Like whether it is built(or)unbuilt(or)unknown.INetworkDataset nds = naContext.getNALocator.getNetworkDataset();int state = nds.getState();However I will try with code post like instead of getting the state of the NetworkDataset through naLocator reference I will make like to get the state of it from directly getting the NetworkDataset through the naContext.Thanks in Advance
Přihlášení členové mohou přispívat, sledovat aktualizace a další. Jste tu noví? Zaregistrujte si bezplatný účet.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.