﻿<?xml version="1.0" encoding="utf-8"?>
<networkConfiguration>
    <edge>
        <name>roads</name>
        <connect_policy>AnyVertex</connect_policy>
        <osm_fields>
            <osm_field>access</osm_field>
            <osm_field>avspeed</osm_field>
            <osm_field>construct</osm_field>
            <osm_field>proposed</osm_field>
            <osm_field>maxheight</osm_field>
            <osm_field>maxspeed</osm_field>
            <osm_field>maxweight</osm_field>
            <osm_field>oneway</osm_field>
            <osm_field>slowdown</osm_field>
            <osm_field>name</osm_field>
        </osm_fields>
        <query>(highway IS NOT NULL) AND (LOWER(highway) in ('motorway','motorway_link','trunk','trunk_link','primary','primary_link','secondary','secondary_link','tertiary','tertiary_link','living_street','residential','unclassified','road'))</query>
        <street_name_fields>
            <direction_prefix></direction_prefix>
            <type_prefix></type_prefix>
            <street_name>osm_name</street_name>
            <direction_suffix></direction_suffix>
            <type_suffix></type_suffix>
        </street_name_fields>
    </edge>

    <junction>
        <name>barriers</name>
        <connect_policy>Override</connect_policy>
        <osm_fields>
            <osm_field>access</osm_field>
            <osm_field>slowdown</osm_field>
        </osm_fields>
        <query>(barrier IS NOT NULL) AND (LOWER(barrier) in ('block','bollard','chain','debris','jersey_barrier','lift_gate','log','spikes','swing_gate'))</query>
    </junction>

    <turn>
        <name>osm_turns</name>
    </turn>

    <connectivity>
        <group>
            <source>roads</source>
            <source>barriers</source>
        </group>
    </connectivity>

    <directions>
        <length_attr>Length</length_attr>
        <length_units>Miles</length_units>
        <time_attr>DriveTime</time_attr>
    </directions>

    <network>
        <network_attribute>
            <name>Access</name>
            <default_value>false</default_value>
            <restriction useAsDefault="true">
                <evaluator_attributes>
                    <source>roads</source>
                    <direction>From-To</direction>
                    <Field script_type="VBScript">
                        <expression>restricted</expression>
                        <pre_logic>
                            <![CDATA[
                            restricted = False
                            Select Case [osm_access]
                                Case "no", "destination", "delivery", "agricultural", "forestry", "private"
                                    restricted = True
                            End Select
                            ]]>
                        </pre_logic>
                    </Field>
                </evaluator_attributes>
                <evaluator_attributes>
                    <source>roads</source>
                    <direction>To-From</direction>
                    <Field script_type="VBScript">
                        <expression>restricted</expression>
                        <pre_logic>
                            <![CDATA[
                            restricted = False
                            Select Case [osm_access]
                                Case "no", "destination", "delivery", "agricultural", "forestry", "private"
                                    restricted = True
                            End Select
                            ]]>
                        </pre_logic>
                    </Field>
                </evaluator_attributes>
            </restriction>
        </network_attribute>

        <network_attribute>
            <name>AvSpeed</name>
            <default_value>0</default_value>
            <descriptor>
                <datatype>double</datatype>
                <evaluator_attributes>
                    <source>roads</source>
                    <direction>From-To</direction>
                    <Field script_type="VBScript">
                        <expression>dbl</expression>
                        <pre_logic>
                            <![CDATA[
                            dbl = 0.0
                            If IsNumeric( [osm_avspeed] ) Then
                                dbl = CDbl( [osm_avspeed] )
                            End If
                            ]]>
                        </pre_logic>
                    </Field>
                </evaluator_attributes>
                <evaluator_attributes>
                    <source>roads</source>
                    <direction>To-From</direction>
                    <Field script_type="VBScript">
                        <expression>dbl</expression>
                        <pre_logic>
                            <![CDATA[
                            dbl = 0.0
                            If IsNumeric( [osm_avspeed] ) Then
                                dbl = CDbl( [osm_avspeed] )
                            End If
                            ]]>
                        </pre_logic>
                    </Field>
                </evaluator_attributes>
            </descriptor>
        </network_attribute>

        <network_attribute>
            <name>Barrier</name>
            <default_value>false</default_value>
            <restriction useAsDefault="true">
                <evaluator_attributes>
                    <source>barriers</source>
                    <direction>From-To</direction>
                    <Field script_type="VBScript">
                        <expression>restricted</expression>
                        <pre_logic>
                            <![CDATA[
                            restricted = True
                            Select Case [osm_access]
                            Case "yes", "designated", "official", "permissive"
                                restricted = False
                            End Select
                            ]]>
                        </pre_logic>
                    </Field>
                </evaluator_attributes>
            </restriction>
        </network_attribute>

        <network_attribute>
            <name>Closed</name>
            <default_value>false</default_value>
            <restriction useAsDefault="true">
                <evaluator_attributes>
                    <source>roads</source>
                    <direction>From-To</direction>
                    <Field script_type="VBScript">
                        <expression>restricted</expression>
                        <pre_logic>
                            <![CDATA[
                            restricted = False
                            If [osm_construct] = "yes" OR [osm_proposed] = "yes" Then
                                restricted = True
                            End If
                            ]]>
                        </pre_logic>
                    </Field>
                </evaluator_attributes>
                <evaluator_attributes>
                    <source>roads</source>
                    <direction>To-From</direction>
                    <Field script_type="VBScript">
                        <expression>restricted</expression>
                        <pre_logic>
                            <![CDATA[
                            restricted = False
                            If [osm_construct] = "yes" OR [osm_proposed] = "yes" Then
                                restricted = True
                            End If
                            ]]>
                        </pre_logic>
                    </Field>
                </evaluator_attributes>
            </restriction>
        </network_attribute>

        <network_attribute>
            <name>DriveTime</name>
            <default_value>0</default_value>
            <cost useAsDefault="true">
                <units>Minutes</units>
                <datatype>double</datatype>
                <evaluator_attributes>
                    <source>roads</source>
                    <direction>From-To</direction>
                    <Script script_type="VBScript">
                        <expression>driveTime</expression>
                        <pre_logic>
                            <![CDATA[
                            'Speed must not be 0 (division by 0).
                            speed = Edge.AttributeValueByName("AvSpeed")
                            If speed = 0 Then
                                speed = 0.001
                            End If

                            slowDownFactor = 1
                            If Edge.AttributeValueByName("SlowDown") = True Then
                                slowDownFactor = 1.25
                            End If

                            driveTime = slowDownFactor * (Edge.AttributeValueByName("Length") * 60) / (speed * 1000)
                            ]]>
                        </pre_logic>
                    </Script>
                </evaluator_attributes>
                <evaluator_attributes>
                    <source>roads</source>
                    <direction>To-From</direction>
                    <Script script_type="VBScript">
                        <expression>driveTime</expression>
                        <pre_logic>
                            <![CDATA[
                            'Speed must not be 0 (division by 0).
                            speed = Edge.AttributeValueByName("AvSpeed")
                            If speed = 0 Then
                                speed = 0.001
                            End If

                            slowDownFactor = 1
                            If Edge.AttributeValueByName("SlowDown") = True Then
                                slowDownFactor = 1.25
                            End If

                            driveTime = slowDownFactor * (Edge.AttributeValueByName("Length") * 60) / (speed * 1000)
                            ]]>
                        </pre_logic>
                    </Script>
                </evaluator_attributes>
                <evaluator_attributes>
                    <source>barriers</source>
                    <direction>To-From</direction>
                    <Script script_type="VBScript">
                        <expression>driveTime</expression>
                        <pre_logic>
                            <![CDATA[
                            driveTime = 0
                            If Junction.AttributeValueByName("SlowDown") = True Then
                                driveTime = 0.1
                            End If
                            ]]>
                        </pre_logic>
                    </Script>
                </evaluator_attributes>
            </cost>
        </network_attribute>

        <network_attribute>
            <name>HeightRestriction</name>
            <default_value>0</default_value>
            <restriction useAsDefault="true">
                <parameter>
                    <name>Height</name>
                    <datatype>double</datatype>
                    <default_value>0</default_value>
                </parameter>
                <evaluator_attributes>
                    <source>roads</source>
                    <direction>From-To</direction>
                    <Script script_type="VBScript">
                        <expression>restricted</expression>
                        <pre_logic>
                            <![CDATA[
                            restricted = False
                            If ParameterValueByName("Height") > Edge.AttributeValueByName("MaxHeight") Then
                                restricted = True
                            End If
                            ]]>
                        </pre_logic>
                    </Script>
                </evaluator_attributes>
                <evaluator_attributes>
                    <source>roads</source>
                    <direction>To-From</direction>
                    <Script script_type="VBScript">
                        <expression>restricted</expression>
                        <pre_logic>
                            <![CDATA[
                            restricted = False
                            If ParameterValueByName("Height") > Edge.AttributeValueByName("MaxHeight") Then
                                restricted = True
                            End If
                            ]]>
                        </pre_logic>
                    </Script>
                </evaluator_attributes>
            </restriction>
        </network_attribute>

        <network_attribute>
            <name>Length</name>
            <default_value>0</default_value>
            <cost useAsDefault="true">
                <units>Meters</units>
                <datatype>double</datatype>
                <evaluator_attributes>
                    <source>roads</source>
                    <direction>From-To</direction>
                    <Field script_type="VBScript">
                        <expression>[SHAPE]</expression>
                    </Field>
                </evaluator_attributes>
                <evaluator_attributes>
                    <source>roads</source>
                    <direction>To-From</direction>
                    <Field script_type="VBScript">
                        <expression>[SHAPE]</expression>
                    </Field>
                </evaluator_attributes>
            </cost>
        </network_attribute>

        <network_attribute>
            <name>MaxHeight</name>
            <default_value>0</default_value>
            <descriptor>
                <datatype>double</datatype>
                <evaluator_attributes>
                    <source>roads</source>
                    <direction>From-To</direction>
                    <Field script_type="VBScript">
                        <expression>maxHeight</expression>
                        <pre_logic>
                            <![CDATA[
                            maxHeight = 0.0
                            If IsNumeric( [osm_maxheight] ) Then
                                maxHeight = CDbl( [osm_maxheight] )
                            End If
                            ]]>
                        </pre_logic>
                    </Field>
                </evaluator_attributes>
                <evaluator_attributes>
                    <source>roads</source>
                    <direction>To-From</direction>
                    <Field script_type="VBScript">
                        <expression>maxHeight</expression>
                        <pre_logic>
                            <![CDATA[
                            maxHeight = 0.0
                            If IsNumeric( [osm_maxheight] ) Then
                                maxHeight = CDbl( [osm_maxheight] )
                            End If
                            ]]>
                        </pre_logic>
                    </Field>
                </evaluator_attributes>
            </descriptor>
        </network_attribute>

        <network_attribute>
            <name>MaxSpeed</name>
            <default_value>0</default_value>
            <descriptor>
                <datatype>double</datatype>
                <evaluator_attributes>
                    <source>roads</source>
                    <direction>From-To</direction>
                    <Field script_type="VBScript">
                        <expression>maxSpeed</expression>
                        <pre_logic>
                            <![CDATA[
                            maxSpeed = 0.0
                            If IsNumeric([osm_maxspeed]) Then
                                maxSpeed = CDbl( [osm_maxspeed] )
                            End If
                            ]]>
                        </pre_logic>
                    </Field>
                </evaluator_attributes>
                <evaluator_attributes>
                    <source>roads</source>
                    <direction>To-From</direction>
                    <Field script_type="VBScript">
                        <expression>maxSpeed</expression>
                        <pre_logic>
                            <![CDATA[
                            maxSpeed = 0.0
                            If IsNumeric([osm_maxspeed]) Then
                                maxSpeed = CDbl( [osm_maxspeed] )
                            End If
                            ]]>
                        </pre_logic>
                    </Field>
                </evaluator_attributes>
            </descriptor>
        </network_attribute>

        <network_attribute>
            <name>MaxWeight</name>
            <default_value>0</default_value>
            <descriptor>
                <datatype>double</datatype>
                <evaluator_attributes>
                    <source>roads</source>
                    <direction>From-To</direction>
                    <Field script_type="VBScript">
                        <expression>maxWeight</expression>
                        <pre_logic>
                            <![CDATA[
                            maxWeight = 0.0
                            If IsNumeric( [osm_maxweight] ) Then
                                maxWeight = CDbl( [osm_maxweight] )
                            End If
                            ]]>
                        </pre_logic>
                    </Field>
                </evaluator_attributes>
                <evaluator_attributes>
                    <source>roads</source>
                    <direction>To-From</direction>
                    <Field script_type="VBScript">
                        <expression>maxWeight</expression>
                        <pre_logic>
                            <![CDATA[
                            maxWeight = 0.0
                            If IsNumeric( [osm_maxweight] ) Then
                                maxWeight = CDbl( [osm_maxweight] )
                            End If
                            ]]>
                        </pre_logic>
                    </Field>
                </evaluator_attributes>
            </descriptor>
        </network_attribute>

        <network_attribute>
            <name>Oneway</name>
            <default_value>false</default_value>
            <restriction useAsDefault="true">
                <evaluator_attributes>
                    <source>roads</source>
                    <direction>From-To</direction>
                    <Field script_type="VBScript">
                        <expression>restricted</expression>
                        <pre_logic>
                            <![CDATA[
                            restricted = False
                            If [osm_oneway] = "yes" Then
                                restricted = True
                            End If
                            ]]>
                        </pre_logic>
                    </Field>
                </evaluator_attributes>
                <evaluator_attributes>
                    <source>roads</source>
                    <direction>To-From</direction>
                    <Field script_type="VBScript">
                        <expression>restricted</expression>
                        <pre_logic>
                            <![CDATA[
                            restricted = False
                            If [osm_oneway] = "-1" Then
                                restricted = True
                            End If
                            ]]>
                        </pre_logic>
                    </Field>
                </evaluator_attributes>
            </restriction>
        </network_attribute>

        <network_attribute>
            <name>SlowDown</name>
            <default_value>false</default_value>
            <descriptor>
                <datatype>boolean</datatype>
                <evaluator_attributes>
                    <source>roads</source>
                    <direction>From-To</direction>
                    <Field script_type="VBScript">
                        <expression>slowDown</expression>
                        <pre_logic>
                            <![CDATA[
                            slowDown = False
                            If [osm_slowDown] <> "no" Then
                                slowDown = True
                            End If
                            ]]>
                        </pre_logic>
                    </Field>
                </evaluator_attributes>
                <evaluator_attributes>
                    <source>roads</source>
                    <direction>To-From</direction>
                    <Field script_type="VBScript">
                        <expression>slowDown</expression>
                        <pre_logic>
                            <![CDATA[
                            slowDown = False
                            If [osm_slowDown] <> "no" Then
                                slowDown = True
                            End If
                            ]]>
                        </pre_logic>
                    </Field>
                </evaluator_attributes>
                <evaluator_attributes>
                    <source>barriers</source>
                    <direction>From-To</direction>
                    <Field script_type="VBScript">
                        <expression>slowDown</expression>
                        <pre_logic>
                            <![CDATA[
                            slowDown = False
                            If [osm_slowDown] <> "no" Then
                                slowDown = True
                            End If
                            ]]>
                        </pre_logic>
                    </Field>
                </evaluator_attributes>
            </descriptor>
        </network_attribute>
    <network_attribute>
      <name>Hierachy</name>
      <default_value>0</default_value>
      <hierachy useAsDefault="true">
        <evaluator_attributes>
          <source>roads</source>
          <direction>From-To</direction>
          <Field script_type="VBScript">
            <expression>h_level</expression>
            <pre_logic>
	  <![CDATA[
              h_level = 4
              Select Case LCase([highway])
              Case "motorway", "motorway_link"
              h_level = 1
              Case "trunk", "trunk_link"
              h_level = 2
              Case "primary", "primary_link"
              h_level = 3
              Case "secondary", "secondary_link"
              h_level = 4
              Case "tertiary", "tertiary_link", "living_street", "residential"
              h_level = 5
              End Select
	  ]]>
            </pre_logic>
          </Field>
        </evaluator_attributes>
        <evaluator_attributes>
          <source>roads</source>
          <direction>To-From</direction>
          <Field script_type="VBScript">
            <expression>h_level</expression>
            <pre_logic>
	  <![CDATA[
              h_level = 4
              Select Case LCase([highway])
              Case "motorway", "motorway_link"
              h_level = 1
              Case "trunk", "trunk_link"
              h_level = 2
              Case "primary", "primary_link"
              h_level = 3
              Case "secondary", "secondary_link"
              h_level = 4
              Case "tertiary", "tertiary_link", "living_street", "residential"
              h_level = 5
              End Select
	  ]]>
            </pre_logic>
          </Field>
        </evaluator_attributes>
      </hierachy>
    </network_attribute>
    </network>
</networkConfiguration>
