1

I am new to geoprocessing services and tried to publish my first. I created a simple model with one parameter, a featureset, and I am intersecting it with another layer which is specified in the model and uploaded to the server.

If I pass the required parameter,as below, it never executes. If I pass an empty parameter object, var params = {}, it runs.

    var app = {};
    app.qtCounties = new QueryTask("http://myserver/arcgis/rest/services/PA_Counties/MapServer/0");
    app.qCounties = new Query();
    app.qCounties.returnGeometry = true;
    app.qCounties.outFields = ["*"];

    paCounties.on("click", getData);function getData(evt) {
            console.log("In GetData The Event graphic is " + evt.Graphic + "Point is ", evt.mapPoint.x, evt.mapPoint.y)
            var county, promises, qGeom, point, pxWidth, padding;

            point = evt.mapPoint;
            pxWidth = map.extent.getWidth() / map.width;
            padding = 2 * pxWidth;
            qGeom = new Extent({
                "xmin": point.x - padding,
                "ymin": point.y - padding,
                "xmax": point.x + padding,
                "ymax": point.y + padding,
                "spatialReference": point.spatialReference
            });

            app.qCounties.geometry = qGeom;

            county = app.qtCounties.execute(app.qCounties);
            console.log("deferreds: ", county);
            promises = new all([county]);
            promises.then(handleQueryResults);
            console.log("created d list");


            function handleQueryResults(results) {
                console.log("queries finished: ", results);

                gp = new Geoprocessor("http://myserver/arcgis/rest/services/TestIntersectModel/GPServer/TestIntersectModel");
                gp.setOutSpatialReference({ wkid: 4326 });


                var params = { "Input_Polygon": results[0].features };
                gp.execute(params, completed);
                function completed(res) {
                    console.log("Completed GeoProcssing", res)
                }


                console.log("Params ", params)}

When the query runs I get a valid object in results which is set as the lone parameter. Apparently I am not passing the parameter as a featureset but not sure how else to pass it? Any help would be appreciated.

I published my service using this example. Though, I did not publish it as a map service, the last step, and I am trying to access it via javascript api instead of the server web page method. The model works fine when run in desktop and providing the parameter manually.

1 Answer 1

0

There were two issues with the above that took me so long to resolve.

  1. I was running this through visual studio so when I tried the correct result it looked like it just stopped running. I received no error messages in the console. I then copied the file and ran off of my test web server and it was showing errors and actually trying to run the job on the gis server.

  2. What seemed to resolve the issue was to set the params variable to results[0] dropping the features.

    var params = { "Input_Polygon": results[0] };

Now it passes the featureset on to the server and I get a valid result back. If anybody has a more correct solution please post.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.