Passing Query Response FeatureSet to geoprocessor input FeatureSet

486
0
09-18-2013 09:11 AM
DanRicketts
New Contributor
I am new to geoprocessing services and tried to publish my first.  I created a simple model with one parameter, a featureset for input polygons, 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 the featureset can't be passed direclty as a featureset to a query?  Any help would be appreciated.  I have tried several different things with results ranging from never running to error response 400 to an empty object returned. 

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.
0 Kudos
0 Replies