Select to view content in your preferred language

How to get the polygons from the viewshed geoprocessing

1378
3
12-12-2011 06:36 AM
CHRISTOSCHARMATZIS
Deactivated User
Hello, I want to develope an application which uses the polygons from the point viewshed.
I trying to use the viewshed geoprocessing code and I am trying to get the viewshed Polygons from the graphic layer.
Like this example http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#ViewShed


So we have the above code....
private void GeoprocessorTask_ExecuteCompleted(object sender, ESRI.ArcGIS.Client.Tasks.GPExecuteCompleteEventArgs args)
{
MyMap.Cursor = System.Windows.Input.Cursors.Hand;
GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;

foreach (GPParameter gpParameter in args.Results.OutParameters)
{
if (gpParameter is GPFeatureRecordSetLayer)
{
GPFeatureRecordSetLayer layer = gpParameter as GPFeatureRecordSetLayer;
foreach (Graphic graphic in layer.FeatureSet.Features)
{
graphic.Symbol = LayoutRoot.Resources["DefaultFillSymbol"] as Symbol;
graphicsLayer.Graphics.Add(graphic);
}
}
}

I have tried to change the code in
foreach (Graphic graphic in layer.FeatureSet.Features)
{
//Polygon polygon = new Polygon();
//graphic.Geometry = polygon;
graphic.Symbol = LayoutRoot.Resources["DefaultFillSymbol"] as Symbol;
graphicsLayer.Graphics.Add(graphic);
}

but it doesn't work..

Could someone please help me ...?
(I am quite new in c#).
0 Kudos
3 Replies
JenniferNery
Esri Regular Contributor
I'm not sure what you are trying to accomplish. You want to get the polygon geometry? If yes, I added the highlighted code from this SDK sample: http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#ViewShed


 private void GeoprocessorTask_ExecuteCompleted(object sender, ESRI.ArcGIS.Client.Tasks.GPExecuteCompleteEventArgs args)
        {
            MyMap.Cursor = System.Windows.Input.Cursors.Hand;
            GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;

            foreach (GPParameter gpParameter in args.Results.OutParameters)
            {
                if (gpParameter is GPFeatureRecordSetLayer)
                {
                    GPFeatureRecordSetLayer layer = gpParameter as GPFeatureRecordSetLayer;
                    foreach (Graphic graphic in layer.FeatureSet.Features)
                    {
                        var polygon = graphic.Geometry as Polygon;
                        graphic.Symbol = LayoutRoot.Resources["DefaultFillSymbol"] as Symbol;
                        graphicsLayer.Graphics.Add(graphic);
                    }
                }
            }
     }
0 Kudos
CHRISTOSCHARMATZIS
Deactivated User
OK, I FOUND MY MISTAKE!!!!

THANK YOU VERY MUCH!!!!
0 Kudos
dotMorten_esri
Esri Notable Contributor
Just an FYI that like all the services on the sampleservers that service is a is not to be used in a production  environment. There is no guarantee this service will stay up and might change in the future.
0 Kudos