find features within distance

602
2
Jump to solution
02-11-2020 02:43 PM
MauricioRamirez1
New Contributor

I have a map service hosted locally on my ArcGIS server with the location of all the fire hydrants in my city.  I want to know if there's a way to find the nearest hydrant to the location I click on the map.  Or to search for a hydrant within 50 meters.

0 Kudos
1 Solution

Accepted Solutions
dotMorten_esri
Esri Notable Contributor

You could use GeometryEngine to create a 50m buffer around your point, then query the table with the hydrants (ie the Url to you mapservice + "/" + the layer id). Something along the lines of:

var searchPolygon = GeometryEngine.BufferGeodetic(clickPoint, 50, LinearUnits.Meters);
var table = new ServiceFeatureTable(new Uri("https://PathToFireHydrantSubLayer"));
var hydrants = await table.QueryFeaturesAsync(new QueryParameters() { Geometry = searchPolygon });

View solution in original post

0 Kudos
2 Replies
dotMorten_esri
Esri Notable Contributor

You could use GeometryEngine to create a 50m buffer around your point, then query the table with the hydrants (ie the Url to you mapservice + "/" + the layer id). Something along the lines of:

var searchPolygon = GeometryEngine.BufferGeodetic(clickPoint, 50, LinearUnits.Meters);
var table = new ServiceFeatureTable(new Uri("https://PathToFireHydrantSubLayer"));
var hydrants = await table.QueryFeaturesAsync(new QueryParameters() { Geometry = searchPolygon });

0 Kudos
MichaelBranscomb
Esri Frequent Contributor

...And if you would like to know actual travel distance/time then I suggest taking a look at the following samples:

Find closest facility to an incident (interactive) | ArcGIS for Developers 

Find service area | ArcGIS for Developers 

Cheers

Mike

0 Kudos