Hi,I created a simple python script that creates a buffer. I have also created a result map service. However, no result image shows up. I am not sure if it is due to my python script or silverlight code.Here is my python code:
import arcpy, sys, os, string
workspaceName = r"C:\...\databaseconn.sde"
arcpy.env.workspace = workspaceName
arcpy.gp.overwriteOutput=1
result=arcpy.Buffer_analysis("polygon", "polygon_buffer", "5 MILES", "", "", "", "")
featset = result.getOutput(0)
arcpy.SetParameter(0,featset)
(The polygon feature class has over 10000 polygons).I add this python script to a toolbox and run the script once and then add the python script to the mxd document (drag and drop). I save the mxd document and from ArcCatalog I publish the service. In the ArcCatalog I can see two services are created. 1. A geoprocessing service and 2. A Map service.From my silverlight code I call the rest url and execute the task. The task executes successfully:
private void button1_Click(object sender, RoutedEventArgs e)
{
string url = "http://mymachine/ArcGIS/rest/services/GPResultService/GPServer/Buffer";
Geoprocessor geoprocessorTask = new Geoprocessor(url);
geoprocessorTask.UpdateDelay = 1000;
geoprocessorTask.JobCompleted += GeoprocessorTask_JobCompleted;
geoprocessorTask.Failed += geoprocessorTask_Failed;
List<GPParameter> parameters = new List<GPParameter>();
geoprocessorTask.SubmitJobAsync(parameters);
}
private void GeoprocessorTask_JobCompleted(object sender, JobInfoEventArgs e)
{
Geoprocessor geoprocessorTask = sender as Geoprocessor;
geoprocessorTask.GetResultDataCompleted += (s1, ev1) =>
{
if (ev1.Parameter is GPFeatureRecordSetLayer)
{
GPFeatureRecordSetLayer gpLayer = ev1.Parameter as GPFeatureRecordSetLayer;
if (gpLayer.FeatureSet.Features.Count == 0)
{
geoprocessorTask.GetResultImageLayerCompleted += (s2, ev2) =>
{
GPResultImageLayer gpImageLayer = ev2.GPResultImageLayer;
gpImageLayer.ID = "BufferLayer";
gpImageLayer.Opacity = 0.7;
myMap.Layers.Add(gpImageLayer);
};
geoprocessorTask.GetResultImageLayerAsync(e.JobInfo.JobId,"featset");
return;
}
}
};
geoprocessorTask.GetResultDataAsync(e.JobInfo.JobId, "featset");
}
geoprocessorTask.GetResultImageLayerCompleted event is raised and the gpImageLayer is added to the map. However there is nothing in the layer I mean I cannot see any image on the map .Can anyone let me know what is wrongThanks