ODCostMatrix Solver Sample snippet using Java

536
3
01-09-2013 08:34 PM
pavan_kumarmuttigi
New Contributor
Hi,

Can anyone please provide me info on some sample java code snippet for the ODCostMatrix Solver using Java.


Thanks in Advance
0 Kudos
3 Replies
MarkBaird
Esri Regular Contributor
ODCostMatrix is a geoprocessing (GP) tool available in ArcGIS Desktop.

In order to use this tool in a different client you would go through a workflow similar to:

- Using Model Builder or a python script create a model which uses your GP tool. e.g. ODCostMatrix
- Publish the tool either to ArcGIS Server or to a geo-processing package
- Write an application to consume the published tool.

If you are using the Runtime API for Java SE (this should not be confised with arcObjects based solutions like ArcGIS Engine) when you might write some code like this:

    // create a geoprocessor
    Geoprocessor geoprocessor = new Geoprocessor(url of endpoint with your tool);

    // provide input arguments
    List<GPParameter> gpInputParams = new ArrayList<GPParameter>();
    gpInputParams.add(<appropriate instance of GPParameter>);
    // repeat for each input parameter
   
    // run geoprocessing task and process result
    // one of the options to run the geoprocessing task
    geoprocessor.executeAsync(...);

You will note that I've suggested using executeAsync where you need to wire up an event handler for when the process completes.  This allows your application to remain responsive whilst the GP tool is running.

If you look in the sample application which comes with the SDK we have several examples showing you how to execute local and server based GP tools.
0 Kudos
pavan_kumarmuttigi
New Contributor
Hi Mark,

Can you provide me some info on ODCostMatrix Solver like by opening the geodatabase file using workspacefactory,getting the networkdataset from that opened geodatabase file,then creating the naLayer and nacontext needed for the solver.

Thanks in Advance.
0 Kudos
MarkBaird
Esri Regular Contributor
This post has been moved from the ArcGIS Runtime forum... can anyone help with this?
0 Kudos