Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

up vote 0 down vote accepted

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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