Identify layers with large tolerance

1025
2
Jump to solution
08-17-2017 06:12 AM
MarcWouters
New Contributor III

I would like to execute a 'find' command searching for features around the mouse click with a search radius of 200 pixels.

Using identifyLayers and setting tolerance to 200, I get no results. Apparently the maximum tolerance is only 100.

Any ideas how I can increase the search area ?

Thanks for any idea.

Marc

0 Kudos
1 Solution

Accepted Solutions
LukeSmallwood
Esri Contributor

Hi Marc,

If you are searching for features you may be able to use the queryFeatures method FeatureTable Class | ArcGIS for Developers for each of the layers.

This method accepts a QueryParameters Class | ArcGIS for Developers  which allows you to set a geometry to query. So, your workflow would be something like:

1 - get the position at which the user clicked

2 - use the buffer method of GeometryEngine Class | ArcGIS for Developers to define your search area

3 - pass the Polygon returned by the buffer operation to a QueryParameters

4 - pass the QueryParameters to start a queryFeatures task for each layer you are interested in

One issue with that approach is that the buffer will be constructed using an absolute distance rather than a number of pixels. If that's an issue you would need to find some way of mapping 200 pixels to a distance for the current map scale etc. You could do something like:

1 - take the users point in screen-space

2 - shift it by 200 along the x-axis

3 - get the map location of that point

4 - then use distance method on GeometryEngine Class | ArcGIS for Developers to work out the distance between the 2 points (this is what the buffer radius should be). 

I hope that helps - please let me know how you get on.

Thanks,

Luke

View solution in original post

2 Replies
LukeSmallwood
Esri Contributor

Hi Marc,

If you are searching for features you may be able to use the queryFeatures method FeatureTable Class | ArcGIS for Developers for each of the layers.

This method accepts a QueryParameters Class | ArcGIS for Developers  which allows you to set a geometry to query. So, your workflow would be something like:

1 - get the position at which the user clicked

2 - use the buffer method of GeometryEngine Class | ArcGIS for Developers to define your search area

3 - pass the Polygon returned by the buffer operation to a QueryParameters

4 - pass the QueryParameters to start a queryFeatures task for each layer you are interested in

One issue with that approach is that the buffer will be constructed using an absolute distance rather than a number of pixels. If that's an issue you would need to find some way of mapping 200 pixels to a distance for the current map scale etc. You could do something like:

1 - take the users point in screen-space

2 - shift it by 200 along the x-axis

3 - get the map location of that point

4 - then use distance method on GeometryEngine Class | ArcGIS for Developers to work out the distance between the 2 points (this is what the buffer radius should be). 

I hope that helps - please let me know how you get on.

Thanks,

Luke

MarcWouters
New Contributor III

Hi Luke,

Thanks for the suggestion !

I wasn't yet aware that you could also use a geometry in the queryFeatures method.

Using the absolute distance instead of pixels is not a real problem, the only problem we have is using the correct SpatialReference: we create a default map before loading our feature tables, therefor the spatial references don't always match.   

We already convert the position of the mouseclick using GeometryEngine::project(), but now I get more results than I expect. The search area is much wider than the buffer (which I showed on the map for confirmation).

Some extra digging into Spatial references is needed, I guess.

0 Kudos