Creating multi buffer

589
2
Jump to solution
12-27-2012 07:47 AM
EnriqueIbarra
New Contributor III
I'm using GeometryService to create buffers, I did a query over a Feature Layer in a map service and obtained a collection of features, now a need to draw buffers over these points, but apper that GeometryService don't support make more than once at time, have somebody did it? or ther's another way to make it possible?

The QueryTask

void queryTask_ExecuteCompleted(object sender, QueryEventArgs e)
        {
            foreach (Graphic item in e.FeatureSet.Features)
            {
                Graphic queryGraphic = new Graphic();
                ESRI.ArcGIS.Client.Geometry.MapPoint mapPnt = new MapPoint(item.Geometry.Extent.XMax, item.Geometry.Extent.YMax);
                queryGraphic.Geometry = ESRI.ArcGIS.Client.Bing.Transform.GeographicToWebMercator(mapPnt);
               
                queryGraphic.Geometry.SpatialReference = sReference;

                BufferParameters bufferParams = new BufferParameters()
                {
                    BufferSpatialReference = new SpatialReference(102100),
                    OutSpatialReference = MapaGM.SpatialReference,
                    Unit = LinearUnit.Meter,
                };

                bufferParams.Distances.Add(1000);
                bufferParams.Features.Add(queryGraphic);
                geometryService.BufferAsync(bufferParams);
            }         
        }


And the GeometryService

void geometryService_BufferCompleted(object sender, GraphicsEventArgs e)
        {
            Graphic bufferGraphic = new Graphic();
            bufferGraphic.Geometry = e.Results[0].Geometry;
            bufferGraphic.Symbol = LayoutRoot.Resources["BufferSymbol"] as Symbol;
            bufferGraphic.SetZIndex(1);
            pointAndBufferGraphicsLayer.Graphics.Add(bufferGraphic);
        }
0 Kudos
1 Solution

Accepted Solutions
EnriqueIbarra
New Contributor III
You should be able to pass all the features returned from the QueryTask to the Buffer.  The code below works for me


Thanks Terry
well, I used this refference and it works!
http://resources.esri.com/help/9.3/arcgisserver/apis/silverlight/help/Geometry_task.htm

View solution in original post

0 Kudos
2 Replies
TerryGiles
Occasional Contributor III
You should be able to pass all the features returned from the QueryTask to the Buffer.  The code below works for me

void QueryTask_ExecuteCompleted(object sender, QueryEventArgs e)
        {

            FeatureSet fs = e.FeatureSet;
            if (fs.Count() == 0)
            {
                MessageBox.Show("Sorry, no data matches your query.  Please try again", "Query Error", MessageBoxButton.OK);
            }
            else
            {
                BufferParameters buffParam = new BufferParameters() {
                    Unit = LinearUnit.Meter,
                    BufferSpatialReference = _Map.SpatialReference,
                    OutSpatialReference = _Map.SpatialReference
                };
                buffParam.Distances.Add(500);
                buffParam.Features.AddRange(fs.Features);

                GeometryService geoService = new GeometryService("http://<servername>/ArcGIS/rest/services/Geometry/GeometryServer");
                geoService.BufferCompleted += (send,args) =>
                {
                    GraphicsLayer gl = (GraphicsLayer)_Map.Layers[_GraphicsLayer];
                    gl.ClearGraphics();
                    gl.Renderer = LayoutRoot.Resources["SelectRendererPoly"] as IRenderer;  //polygon renderer defined in XAML
                    foreach (var g in args.Results)
                    {
                        gl.Graphics.Add(g);

                    }
                    gl.Refresh();
                };
                geoService.BufferAsync(buffParam);
         }
}
0 Kudos
EnriqueIbarra
New Contributor III
You should be able to pass all the features returned from the QueryTask to the Buffer.  The code below works for me


Thanks Terry
well, I used this refference and it works!
http://resources.esri.com/help/9.3/arcgisserver/apis/silverlight/help/Geometry_task.htm
0 Kudos