Select to view content in your preferred language

Turn By Turn Directions sequence is incorrect

106
2
Monday
Alok_Shah
New Contributor

Hi,

We are using ArcPy.NAX for route-solving solutions and to get the turn-by-turn directions. Recently we have observed that it's solving routes as expected and also returning turn-by-turn directions, but the sequence of turn-by-turn directions is not correct. Attaching a couple of screenshots for reference. This is a random behavior.  Sometimes it returns correctly and sometimes it gives incorrect results. 

Link of ArcPy.Nax - Route—ArcGIS Pro | Documentation

Screenshot of directions:

Alok_Shah_0-1719257232578.png

 

We also tried to sort the directions feature class based on the object id but still it's giving the same result. Snapshot of python code.

Alok_Shah_1-1719257659913.png

 

@RodneyConger - We have raised a ticket with ESRI support but tagging you. It would be great if you can guide us or provide some pointers.

0 Kudos
2 Replies
RodneyConger
Esri Contributor

Hi Alok, I understand your observation of this behavior is it's random. Do you think you could create hardcoded script that i could point to my local version of SMP that can reproduce this if i run it a few times? by hardcoded, i mean you set all the parameters needed to create the route. 

Alternatively, you could export one of these solves to a layer package via the result object
https://pro.arcgis.com/en/pro-app/latest/arcpy/network-analyst/routeresult.htm

I am also curious what you are doing with the directions after you generate them to display them in the UI above.

 

0 Kudos
Alok_Shah
New Contributor

Hi @RodneyConger ,

Please find the requested layer file as an attachment. For this route, it's happening every time and another observation is that if we remove the barrier then it's working fine. 

 

 

We are not doing anything with the directions. We are only setting directions in the output parameters after generating it. Here is the screenshot from the tool.

Alok_Shah_0-1719446893350.png

 

Another observation is that this is happening when we are loading the line restrictions but if we don’t load it then it’s giving directions as expected. Below is the code which we have used to load the line restrictions.

Note: We tried 5-10 times and it’s giving directions as expected.

    def LoadLineRestriction(self,route,is_use_line_restriction,line_restriction_lyr,whereClause,copyedFeturesArray):
        logger = self.logger
        DEBUG = self.DEBUG
        if is_use_line_restriction :
            result = arcpy.SelectLayerByAttribute_management(in_layer_or_view=line_restriction_lyr, selection_type="NEW_SELECTION", where_clause= whereClause)
            sectedCount = int(result.getOutput (1))
            if(sectedCount > 0):
                selectionlyr= result.getOutput (0)
                copyFields =("LOCATIONS",)
                line_restriction_obj = cUtil.InputFeatureClass(selectionlyr)
                line_restriction_obj.copyFeatures(self.out_gdb_workspace,'LineRestriction',copyFields)
                copyedFeturesArray.append(line_restriction_obj)
                line_restriction = line_restriction_obj.catalogPath
                field_mappings_line_restriction = self.GetLineRestrictionFieldMappings(route)
                route.load(arcpy.nax.RouteInputDataType.LineBarriers, line_restriction,field_mappings_line_restriction,False)
        return
    

    def GetLineRestrictionFieldMappings(self,route):
        field_mappings_line_restriction= route.fieldMappings(arcpy.nax.RouteInputDataType.LineBarriers, True)
        field_mappings_line_restriction["Name"].mappedFieldName = "ORIG_FID"
        field_mappings_line_restriction["Locations"].mappedFieldName = g_ESRI_variable_2
        return field_mappings_line_restriction;

 

0 Kudos