Select to view content in your preferred language

Time cost for Closest Facility not visible anymore

548
2
Jump to solution
2 weeks ago
no33mis
Occasional Contributor

Dear all,

We have a web application that uses the closest facility analysis tool. We have recently upgraded our Portal to 11.3 and our code to the latest ArcGIS JS version (4.33). This is the function within the application that runs the analysis and retrieves the attributes:

function findClosestFacility(startFeature: Graphic, featuresetFacilities: FeatureSet) {

const params = new ClosestFacilityParameters({
facilities: featuresetFacilities,
incidents: new FeatureSet({ features: [startFeature] }),
returnRoutes: true,
returnFacilities: true,
defaultTargetFacilityCount: 1,
        });

closestFacility.solve(closestFacilityUrl, params).then(
            (results) => {
console.log(results)
showRoutes(results.routes.features);
setDistanceToFacility(results.routes.features[0].attributes.Total_Length)
setTimeToFacility(results.routes.features[0].attributes.Total_WALKTIME) // this one is now undefined

if (currentDestination !== params.facilities.features[0].geometry.x || searchAddress || searchClear) {
view.current.goTo({ target: results.routes.features[0] });
                }

setCurrentDestination(params.facilities.features[0].geometry.x)
setSearchClear(false)

            },
            (error) => {
console.log(error);
            }
        );
    }
Since the updates the Total_WALKTIME attribute doesn't exist anymore, only TOTAL_Length. Hence we are not able to provide the time information to the end-users. I have checked the network layer in ArcGIS Pro and can confirm that there is still a WALKTIME cost.
 
 
walktime1.pngwalktime2.png
 
Thanks in advance for any inputs.
0 Kudos
1 Solution

Accepted Solutions
no33mis
Occasional Contributor

In case anyone wonders, we were able to solve the issue. Since the update, it was necessary to define the method "impedanceAttribute" to be able to retrieve the WALKTIME. 

const params = new ClosestFacilityParameters({
facilities: featuresetFacilities,
incidents: new FeatureSet({ features: [startFeature] }),
returnRoutes: true,
returnFacilities: true,
impedanceAttribute: "WALKTIME",
defaultTargetFacilityCount: 1,
        });

View solution in original post

0 Kudos
2 Replies
Noah-Sager
Esri Regular Contributor

Hi @no33mis, thanks for posting your question here. I'm not 100% sure what's occurring, but I have some hunches.

When you upgraded the Portal version, did this update the default travel mode? Or did you have some other customizations that might have reverted back to default values during the upgrade?

Additionally, you can use the fetchServiceDescription() method to return the travel mode of the service.
https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-networkService.html#fetchSer...

const { supportedTravelModes } = await networkService.fetchServiceDescription(
   config.routeServiceUrl,
   apiKey,
);
const driveTravelMode = supportedTravelModes.find(({ name }) => name === "Driving Distance");

0 Kudos
no33mis
Occasional Contributor

In case anyone wonders, we were able to solve the issue. Since the update, it was necessary to define the method "impedanceAttribute" to be able to retrieve the WALKTIME. 

const params = new ClosestFacilityParameters({
facilities: featuresetFacilities,
incidents: new FeatureSet({ features: [startFeature] }),
returnRoutes: true,
returnFacilities: true,
impedanceAttribute: "WALKTIME",
defaultTargetFacilityCount: 1,
        });
0 Kudos