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.