Select to view content in your preferred language

GPResultImageLayer - No Image

5289
10
02-02-2011 07:20 AM
IgressT
Emerging Contributor
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 wrong

Thanks
0 Kudos
10 Replies
IgressT
Emerging Contributor
Go to your gp service under manager and edit it.

First go to the Parameters tab and bump up your - Maximum Number of Records Returned by Server:
GO CRAZY and set it to something like 50000

Then Go to the pooling tab. and GO CRAZY on
The maximum time a client can use a service:    
The maximum time a client will wait to get a service: 
The maximum time an idle instance can be kept running: 

Give them like a
60000 seconds
6000 seconds
80000 seconds

Don't tell ESRI I said this because I think it might affect performance :rolleyes: when running this GP Service but for now just see if works.


Hi,
Thanks for the info. However, it doesn't seem to work for me as no image is being returned (checked in fiddler also).
0 Kudos