find nearest facility

602
3
Jump to solution
09-17-2020 06:51 PM
MauricioRamirez1
New Contributor


When we receive an incident request, we need to find the nearest facility to that address.  By the time we go to search, we have already converted the address to a set of coordinates.  I have a layer with my facilities.  What's the best way to find the nearest facility using the runtime SDK for QT. 

0 Kudos
1 Solution

Accepted Solutions
LucasDanzinger
Esri Frequent Contributor

You can use ClosestFacilityTask.

Here is a sample in QML - arcgis-runtime-samples-qt/ArcGISRuntimeSDKQt_QMLSamples/Routing/ClosestFacility at master · Esri/arc... 

And here is the C++ version - arcgis-runtime-samples-qt/ArcGISRuntimeSDKQt_CppSamples/Routing/ClosestFacility at master · Esri/arc... 

In our samples, we use mouse click to get the coordinates, but in your case, you can just create a Point object from the coordinates you have instead.

View solution in original post

3 Replies
LucasDanzinger
Esri Frequent Contributor

You can use ClosestFacilityTask.

Here is a sample in QML - arcgis-runtime-samples-qt/ArcGISRuntimeSDKQt_QMLSamples/Routing/ClosestFacility at master · Esri/arc... 

And here is the C++ version - arcgis-runtime-samples-qt/ArcGISRuntimeSDKQt_CppSamples/Routing/ClosestFacility at master · Esri/arc... 

In our samples, we use mouse click to get the coordinates, but in your case, you can just create a Point object from the coordinates you have instead.

MauricioRamirez1
New Contributor

I notice you create points manually.  In my case the points are in a layer on the ArcGIS server.  Is there a way to iterate through that?

0 Kudos