Select to view content in your preferred language

Problem with Vehicle Routing Problem task in js and python

1665
0
03-23-2017 06:47 AM
AlbertoLópez
Occasional Contributor

Hello;

 

I'm trying to create a Python geprocessing script for the network analyst Vehicle Routing Problem task.

 

Here is a part of the Python script:

#

inOrders = arcpy.GetParameterAsText(0)

inDepot = arcpy.GetParameterAsText(1)

inRoute = arcpy.GetParameterAsText(2)

timeUnits = arcpy.GetParameterAsText(3)

distanceUnits = arcpy.GetParameterAsText(4)

pointsBarriers=arcpy.GetParameterAsText(5)

lineBarriers=arcpy.GetParameterAsText(6)

polygonsBarriers=arcpy.GetParameterAsText(7)

restrictions=arcpy.GetParameterAsText(8)

def SolveVehicleRoutingProblem():

   try:

 

       pathND = r"\\XXXXX\YYYYY\GNEXT_Road_Network_1.gdb\ND_UTM_33\Tripoli_UTM_33_ND"

       outResult =arcpy.na.SolveVehicleRoutingProblem(inOrders, inDepot, inRoute, "", timeUnits, distanceUnits, pathND, ,"",""," ","","","","","","","","","", pointsBarriers,lineBarriers,polygonsBarriers,"","","",restrictions)

       #arcpy.SetParameter(9, outResult)

#

pointsBarriers, lineBarriers, polygonsBarriers, and restrictions are optional parameters

 

When I run the Python script from ArcMap I think it works fine, although no gdb file is generated in the scratch local folder.

 After running the script I public the script as a geoprocessing  service, but when I consuming it with javascript I get the following error:

  • esriJobMessageTypeInformative: Input field [OID] was not mapped to a field in the network analysis class "Orders". Input field [OID] was not mapped to a field in the network analysis class "Depots". Input field [OID] was not mapped to a field in the network analysis class "Routes". Depots (Name = "Location 1") is unlocated. Routes (Name = "Item1") does not have a StartDepotName value nor an EndDepotName value. Orders (Name = "Location 1") is unlocated. WARNING 030088: Solve returned an error, but errors were converted to warnings. WARNING 030092: VRP Solver failed due to invalid input.


I do not know why the word “Location 1” appears in the error, because it does not appear in either the js code or the python code.

The javascript code is as follows:

#

 

  var params = {

                //"Breaks": "",

                //"pathND": pathND,

                "timeUnits": "Minutes",

                "distanceUnits": "Meters",

                "inDepot": '{"features":[{"geometry":{"x":' + xDepotPoint + ',"y":' + yDepotPoint + '},"attributes":{"Name": "inDepot"}}]}',

                "inOrders": '{"features":[{"geometry":{"x":' + xOrdersPoint + ',"y":' + yOrdersPoint + '},"attributes":{"Name": "inOrders"}}]}',

                "inRoute": '{"features":[{"attributes":{"Name":"outputRouteVRP","StartDepotName": "inDepot","EndDepotName":"inDepot"}}]}',

            };

 

           

           this.gp = new Geoprocessor(THE URL);

           this.gp.setProcessSpatialReference(this.map.spatialReference);

           this.gp.setOutSpatialReference(this.map.spatialReference);

           this.gp.submitJob(params, lang.hitch(this, this.processingComplete),     this.gpJobStatus, this.gpJobFailed);

    

},

        processingComplete: function (jobinfo) {

 

            this.gp.getResultData(jobinfo.jobId, "outResult", this.showRoutes);

 

            if (jobinfo.jobStatus == 'esriJobSucceeded') {

               

 

            }

            else if (jobinfo.jobStatus == "esriJobFailed") {

                dom.byId('statusGPOP').innerHTML = jobinfo.jobStatus;

                var errors = array.filter(jobinfo.messages, function (item) {

                    return item.type === "esriJobMessageTypeError";

                });

                for (var e = 0; e < errors.length; e++) {

                    //Poner el texto en el div de resultados

                    var span = $('<p/>').addClass('errorGP').html(errors.description);

                    span.appendTo($("#divCCStatus"));

                }

            }

        },

 

showRoutes: function(results) {

            var features = results.value.features;

            var symbol = new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([243, 156, 18]), 4);

}

#

In "\arcgisserver\directories\arcgisjobs\solvevehicleroutingproblem_gpserver\jea6d11970a3c467bad8a104ca8aae98e\scratch"  a gdb file is generated but it is empty.

 

Any suggestions? Are the input parameters correct?

 

Thank you very much.

0 Kudos
0 Replies