Hello,I am having a problem with using the IdentifyTask in conjunction with a QueryTask and the MaxAllowableOffset option.I am first using the IdentifyTask to find features in a dynamic map service layer that intersect a given graphics layer feature.Then if any of the features have more than a certain number of vertices I am running a QueryTask and setting MaxAllowableOffset to generalise the feature, but only for those features.This works fine the first time it is run, but after the first run the IdentifyTask appears to be using the MaxAllowableOffset value that was set by the QueryTask, so all the features are generalised by the IdentifyTask!I have tried setting MaxAllowableOffset for the IdentifyTask to zero (via IdentifyParameters.MaxAllowableOffset) and this didn't fix the problem.However, when I set IdentifyParameters.MaxAllowableOffset to a small value (0.001 metres) it fixed the problem.This doesn't seem like a nice workaround, so I'm hoping someone can explain why this is happening, or whether this is a bug?Cheers,AndrewHere's a summary of the code:
IdentifyParameters sitesQueryIdentifyParams = new IdentifyParameters();
sitesQueryIdentifyParams.Geometry = selectedUnionedGeometry;
sitesQueryIdentifyParams.MapExtent = _map.Extent;
sitesQueryIdentifyParams.Width = (int)_map.ActualWidth;
sitesQueryIdentifyParams.Height = (int)_map.ActualHeight;
// Set sites query identify tolerance to 0 pixels
sitesQueryIdentifyParams.Tolerance = 0;
sitesQueryIdentifyParams.LayerOption = LayerOption.all;
// Perform identify on Sites layer
sitesQueryIdentifyParams.LayerIds.Add(Convert.ToInt16(_sitesLayerId));
sitesQueryIdentifyParams.SpatialReference = _map.SpatialReference;
// TEST - Explicitly set MaxAllowableOffset - this only works when set to a small value
sitesQueryIdentifyParams.MaxAllowableOffset = 0.001;
// Perform Sites Query Identify operation (asynchronously)
IdentifyTask sitesQueryIdentifyTask = new IdentifyTask(_ahelpPilotMapUrl);
// Disable caching identify results
sitesQueryIdentifyTask.DisableClientCaching = true;
sitesQueryIdentifyTask.ExecuteCompleted += SitesQueryIdentifyTask_ExecuteCompleted;
sitesQueryIdentifyTask.Failed += SitesQueryIdentifyTask_Failed;
sitesQueryIdentifyTask.ExecuteAsync(sitesQueryIdentifyParams, graphicsLayerLabel);
...
private void SitesQueryIdentifyTask_ExecuteCompleted(object sender, IdentifyEventArgs args)
{
_identifyGraphics = new List<Graphic>();
foreach (IdentifyResult result in args.IdentifyResults)
{
_identifyGraphics.Add(result.Feature);
}
// Loop through graphics, for each graphic count number of vertices (polygons/lines only) and if greater than a threshold generalise
_identifyGraphicsToGeneralise = new List<Graphic>();
_identifyGeneraliseCompleteCount = 0;
foreach (Graphic identifyGraphic in _identifyGraphics)
{
int identifyVerticeCount = 0;
if (identifyGraphic.Geometry is ESRI.ArcGIS.Client.Geometry.Polygon)
{
ESRI.ArcGIS.Client.Geometry.Polygon identifyPolygon = (ESRI.ArcGIS.Client.Geometry.Polygon)identifyGraphic.Geometry;
ObservableCollection<ESRI.ArcGIS.Client.Geometry.PointCollection> identifyPolyRings = identifyPolygon.Rings;
foreach (ESRI.ArcGIS.Client.Geometry.PointCollection identifyRing in identifyPolyRings)
{
identifyVerticeCount += identifyRing.Count;
}
}
else if (identifyGraphic.Geometry is ESRI.ArcGIS.Client.Geometry.Polyline)
{
ESRI.ArcGIS.Client.Geometry.Polyline identifyPolyline = (ESRI.ArcGIS.Client.Geometry.Polyline)identifyGraphic.Geometry;
foreach (ESRI.ArcGIS.Client.Geometry.PointCollection identifyPath in identifyPolyline.Paths)
{
identifyVerticeCount += identifyPath.Count;
}
}
if (identifyVerticeCount > _MAX_VERTICES)
{
// Add to list of graphics to generalise
_identifyGraphicsToGeneralise.Add(identifyGraphic);
}
}
foreach (Graphic identifyGeneraliseGraphic in _identifyGraphicsToGeneralise)
{
// Use QueryTask to run query for this graphic, set MaxAllowableOffset to reduce vertices
QueryTask identifyQueryGeneralizeTask = new QueryTask(_ahelpPilotMapUrl + "/" + _sitesLayerId);
// Disable caching query results
identifyQueryGeneralizeTask.DisableClientCaching = true;
identifyQueryGeneralizeTask.ExecuteCompleted += IdentifyQueryTaskGeneralize_ExecuteCompleted;
identifyQueryGeneralizeTask.Failed += IdentifyQueryTaskGeneralize_Failed;
ESRI.ArcGIS.Client.Tasks.Query identifyQueryGeneralize = new ESRI.ArcGIS.Client.Tasks.Query();
// Set up query for given feature
identifyQueryGeneralize.Where = _OBJECTID_FIELD_NAME + "=" + identifyGeneraliseGraphic.Attributes[_OBJECTID_FIELD_NAME].ToString();
// Specify same projection as first layer of map, as this will determine overall spatial projection
identifyQueryGeneralize.OutSpatialReference = _map.SpatialReference;
identifyQueryGeneralize.ReturnGeometry = true;
// Set max allowable offset for sites with a lot of vertices, to reduce size of geometry returned
identifyQueryGeneralize.MaxAllowableOffset = _MAX_ALLOWABLE_OFFSET;
// Add all fields to query so they are all returned with geometry
identifyQueryGeneralize.OutFields.Add("*");
identifyQueryGeneralizeTask.ExecuteAsync(identifyQueryGeneralize, identifyGeneraliseGraphic);
}
...