NAServer - Closest Facility

2204
5
11-18-2009 07:23 AM
Joachim_EckboJuell
New Contributor III
Hi,

Good thing that more of the NA-functionallity is available through the REST-endpoints. But after testing the Solve Closest Facility function, I'm a little disappointed (hopefully it's just something I don't understand).

In the REST API, there are a bunch of parameters you can set. I tried adding a single incident, and in the facilities parameter referencing my Facility-layer in the network layer (Facilities). But this didn't work. I was only able to either add features, or reference a feature class in the map service.

The only way to make this function respond quickly enough, is to add the facilities to the network layer, and the then publish this MXD as a service. And then use these facilities in the Solve. I have around 3000 facilities. So the approaches available through the REST API right now just won't do it for me.

Am I missing something? Or will this be possible in the final release? If not, could you please add it 🙂

-JJ
0 Kudos
5 Replies
RaviNarayanan
Esri Contributor
In the services directory page for Solve Closest Facility, there are two buttons in the bottom of the page that can be used to execute the request -- "Solve Closest Facility (GET)" and "Solve Closest Facility (POST)".

If the input parameters are lengthy, then the request should use POST since there are limitations (in browsers) to the length of urls that can be handled. Please let us know if it works when using "Solve Closest Facility (POST)".

Also here is sample JSON for a couple of facilities and an incident that can be used in the services directory page. Please give this a try after replacing the geometry with appropriate values to test. Also make sure the value of default cutoff is appropriate and return routes or directions is selection. otherwise there may be no results returned.

Facilities:
{"features": [    {      "attributes": {"Name":"Ghirardelli Square"},      "geometry" :{"x" : -122.4219243,"y" : 37.8056528}   },   { "attributes": {"Name": "San Francisco Museum of Modern Art"},     "geometry": {       "x": -122.401134465,       "y": 37.7857056500001     } } ]}

Incidents:
{"features": [   {     "attributes":{"Name":"Arguello Blvd"},     "geometry": {"x": -122.458689675511,"y": 37.7805250632726}   } ]}

Thanks
Ravi
0 Kudos
RaviNarayanan
Esri Contributor
Thank you for this posting. Currently NA Closest Facility operation in REST API requires an input for incidents and facilities as json features or layer. The option of using facilities from an existing closest facility network layer is not implemented. We'll investigate the feasibility of adding this functionality.

Thanks again for this feedback.
0 Kudos
DmitryKudinov
Occasional Contributor
Thank you for your input.

For now (beta-1) you can use datalayer (a point feature class in the same map document) as a workaround. It will significantly speed up the loading process and overall server response time, if before publishing the doc you populate location fields on the point feature class.

Another benefit of using datalayer is its spatial filter: if your 3000 facilities are all over a large network and you are doing hierarchical solve, it will cause solver to do backward search from every of the 3000 facilities to the highest level of hierarchy. So, if you are looking for facilities within some specific cutoff value, it might be significantly faster to use datalayer with spatial filter around your incident.

If you do not want to use spatial filter when loading facilities, try using exact solve (useHierarchy = false) with some cutoff value.

Please try these described approaches - performance may significantly vary depending on your network and clustering of locations.
0 Kudos
Joachim_EckboJuell
New Contributor III
Hi,

Has this been "fixed" in beta 2? I haven't had the chance to look at it yet. But in the REST API help, describing the facilities parameter on Solve Closest Facilities, it says:

"If facilities are not specified, preloaded facilities from the map document are used in the analysis."

Does this mean I can use the facilities already added to the network layer in the published service?
0 Kudos
RaviNarayanan
Esri Contributor
Thanks to your feedback about using pre-loaded facilities. At beta 2 we have added support for using pre loaded stop, facilities or barriers in NA Solve Route/ServiceArea/ClosestFacility operations.
0 Kudos