Polygon intersection selects unselected graphics on user drawn polygon.

4698
14
Jump to solution
04-26-2012 06:03 AM
by Anonymous User
Not applicable
Original User: e_saurabh

Hi
   I have a small problem. i have some graphics on my base map. Now I do a Intersect for the graphics using polygon.Extent.Intersects(graphic.Geometry.Extent). This selects the different shapes on the map on which the polygon is drawn. But this also selects the graphics nearby with that comes around that selected graphic features which is not selected. I need to avoid this. Can anybody provide some light on it. I am using

VS 2010.
Silverlight 4.

I am using the code

GraphicsLayer graphicLayer = edmsMap.Layers[selectedProgramTypeName] as GraphicsLayer;
GraphicCollection graphicCollection = new GraphicCollection();
graphicCollection = graphicLayer.Graphics;
foreach (Graphic graphic in graphicCollection)
  { 
     if (polygon.Extent.Intersects(graphic.Geometry.Extent))
    {
         ESRI.ArcGIS.Client.Symbols.SimpleFillSymbol FillSymbol;
        FillSymbol = (ESRI.ArcGIS.Client.Symbols.SimpleFillSymbol)(LayoutRoot.Resources        ["PolygonSelectSymbol"]);
     graphic.Symbol = (ESRI.ArcGIS.Client.Symbols.SimpleFillSymbol)FillSymbol;
}
}
My xaml code is

<esriSymbols:SimpleFillSymbol x:Key="PolygonSelectSymbol" Fill="#66BB0000" BorderBrush="#88CC0000" BorderThickness="2"  />

Any code snippet will be good
Please find the attached screen shot along with.

Regards,
Saurabh.
0 Kudos
14 Replies
by Anonymous User
Not applicable
Original User: e_saurabh

Still waiting for any suitable approach for this.

~Saurabh.
0 Kudos
by Anonymous User
Not applicable
Original User: jenniferdnery

Oh I see. If your GraphicsLayer contain features from a service, you can do a spatial query by setting Query.Geometry: http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#SpatialQuery. If your GraphicsLayer contain features that only reside in the client, you can use FindGraphicsInHostCoordinates() but this only accepts either Point or Rect. You can also tweak this SDK sample: http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#Intersect. You can skip the QueryTask section where it adds the results to the GraphicsLayer, since your features are drawn and not retrieved from service.
0 Kudos
SaurabhDasgupta
New Contributor II
Hi Jennifer,
               Thanks a lot for your reply and applogise for the dealy. I got my problem resolved using the FindGraphicsInHostCoordinates() method. Now I am able to select the required graphics on the map layer and no more false positives are returned. Just for an query, is there any way out to do this process using the polygon selection which should return only the true positives. Thanks again.

~Saurabh.
0 Kudos
by Anonymous User
Not applicable
Original User: SharpGIS

You can do the findgraphicsinhostcoordinates to get a good set of candidates, then use the geometry service to perform a full analysis on the remaining features.
0 Kudos
SaurabhDasgupta
New Contributor II
Thanks Mortein. I will try the option.

~Saurabh.
0 Kudos