Restrict network dataset segments on certain days

270
0
10-20-2022 04:03 AM
SOTIRIOSTRIANTOS
New Contributor III

ArcMap 10.7.1 network analyst extension

I want to restrict network dataset segments on certain days, i.e every Tuesday a road is closed due to a reason.

The approach that i made was as follows:

Added 3 new fields in my network feature class (RestrictedDay, RestrictedFrom, RestrictedTo)

restricteddaysAttributetable fields.PNG

Then i created a descriptor called  RestrictedDayDESC (unknown units Integer Data Type)

Type Field

Value expression

import time
def X (RestrictedDay):
    if RestrictedDay is None:
        retVal= -1
    else:
        retVal = time.strptime(RestrictedDay, "%A").tm_wday
    return retVal

 

Then i added a restriction called RestrictedDays  (unknown units Boolean Data Type)

and a parameter called RestrictedDayDESC 

restricteddaysParameters.PNG

Finally i created a function evaluator

restricteddays.PNG

If i create a network analyst layer through arcmap the logic works. an i can change parameter value through Attribute Parameters tab

layer properties.PNG

So far so good but we work with python and i cannot find a way to pass the current day parameter to 

MakeRouteLayer method

The travelmode is as follows

{
	"name": "Car Oneways",
	"type": "AUTOMOBILE",
	"description": "Models the movement of motorbikes and other similar small automobiles and finds solutions that optimize travel distance. Travel obeys one-way roads and follows other rules that are specific to cars.",
	"impedanceAttributeName": "Minutes_Traffic",
	"timeAttributeName": "Minutes_Traffic",
	"distanceAttributeName": "Length",
	"restrictionAttributeNames": ["Barriers", "Cycleway", "Footway", "Oneway", "Path", "RestrictedDays", "Steps", "Tolls"],
	"attributeParameterValues": [{
		"attributeName": "Oneway",
		"parameterName": "Restriction Usage",
		"value": -1
	}, {
		"attributeName": "Barriers",
		"parameterName": "Restriction Usage",
		"value": -1
	}, {
		"attributeName": "Cycleway",
		"parameterName": "Restriction Usage",
		"value": -1
	}, {
		"attributeName": "Footway",
		"parameterName": "Restriction Usage",
		"value": -1
	}, {
		"attributeName": "OnewayHighways",
		"parameterName": "Restriction Usage",
		"value": -1
	}, {
		"attributeName": "OnewaySelective",
		"parameterName": "Restriction Usage",
		"value": -1
	}, {
		"attributeName": "Path",
		"parameterName": "Restriction Usage",
		"value": -1
	}, {
		"attributeName": "Steps",
		"parameterName": "Restriction Usage",
		"value": -1
	}, {
		"attributeName": "Tolls",
		"parameterName": "Restriction Usage",
		"value": -1
	}, {
		"attributeName": "RestrictedDays",
		"parameterName": "Restriction Usage",
		"value": -1
	}, {
		"attributeName": "RestrictedDays",
		"parameterName": "RestrictedDaysDESC",
		"value": 3
	}],
	"useHierarchy": true,
	"uturnAtJunctions": "esriNFSBAtDeadEndsOnly",
	"simplificationTolerance": null,
	"simplificationToleranceUnits": "esriUnknownUnits"
}

To summarize

how can i change (u'RestrictedDays', u'RestrictedDaysDESC'): 3,  to current day number?

Tags (1)
0 Kudos
0 Replies