@@ -68,6 +68,14 @@ parking_class = Set{
6868 ' emergency_access'
6969}
7070
71+ local function to_number_uint (s )
72+ local n = tonumber (s )
73+ if n ~= nil and n > 0 and n % 1 == 0 then
74+ return n
75+ end
76+ return nil
77+ end
78+
7179function Guidance .set_classification (highway , result , input_way )
7280 if motorway_types [highway ] then
7381 result .road_classification .motorway_class = true
@@ -107,22 +115,22 @@ function Guidance.set_classification (highway, result, input_way)
107115
108116 local lane_count = input_way :get_value_by_key (" lanes" )
109117 if lane_count then
110- local lc = tonumber (lane_count )
118+ local lc = to_number_uint (lane_count )
111119 if lc ~= nil then
112120 result .road_classification .num_lanes = lc
113121 end
114122 else
115123 local total_count = 0
116124 local forward_count = input_way :get_value_by_key (" lanes:forward" )
117125 if forward_count then
118- local fc = tonumber (forward_count )
126+ local fc = to_number_uint (forward_count )
119127 if fc ~= nil then
120128 total_count = fc
121129 end
122130 end
123131 local backward_count = input_way :get_value_by_key (" lanes:backward" )
124132 if backward_count then
125- local bc = tonumber (backward_count )
133+ local bc = to_number_uint (backward_count )
126134 if bc ~= nil then
127135 total_count = total_count + bc
128136 end
@@ -137,10 +145,10 @@ end
137145local function get_psv_counts (way ,data )
138146 local psv_forward , psv_backward = Tags .get_forward_backward_by_key (way ,data ,' lanes:psv' )
139147 if psv_forward then
140- psv_forward = tonumber (psv_forward )
148+ psv_forward = to_number_uint (psv_forward )
141149 end
142150 if psv_backward then
143- psv_backward = tonumber (psv_backward )
151+ psv_backward = to_number_uint (psv_backward )
144152 end
145153 return psv_forward or 0 ,
146154 psv_backward or 0
0 commit comments