@@ -103,6 +103,7 @@ function get_direction_from_superrel(rel, relations)
103103 function set_result (direction , current_rel )
104104 if (result ~= nil ) and (direction ~= nil ) then
105105 print (' WARNING: relation ' .. rel :id () .. ' is a part of more then one supperrelations ' .. result_id .. ' and ' .. current_rel :id ())
106+ result = nil
106107 else
107108 result = direction
108109 result_id = current_rel :id ()
@@ -147,41 +148,54 @@ function Relations.parse_route_relation(rel, way, relations)
147148 end
148149
149150 if t == ' route' then
151+ local role_direction = nil
150152 local route = rel :get_value_by_key (" route" )
151153 if route == ' road' then
152154 -- process case, where directions set as role
153155 if is_direction (role ) then
154- result [' route_direction' ] = role
155- add_extra_data (m )
156+ role_direction = role
156157 end
157158 end
158159
160+ local tag_direction = nil
159161 local direction = rel :get_value_by_key (' direction' )
160162 if direction then
161163 direction = string.lower (direction )
162164 if is_direction (direction ) then
163- if role == ' forward' then
164- result [' route_direction' ] = direction
165- add_extra_data (m )
166- end
165+ tag_direction = direction
167166 end
168167 end
169- end
170168
171- -- process superrelations
172- local super_dir = get_direction_from_superrel (rel , relations )
169+ -- determine direction
170+ local result_direction = role_direction
171+ if result_direction == nil and tag_direction ~= ' ' then
172+ result_direction = tag_direction
173+ end
173174
174- -- check if there are data error
175- local dir = result [' route_direction' ]
176- if (dir ~= nil ) and (super_dir ~= nil ) and (dir ~= super_dir ) then
177- print (' ERROR: conflicting relation directions found for way ' .. way :id () ..
178- ' relation direction is ' .. dir .. ' superrelation direction is ' .. super_dir )
179- end
175+ if role_direction ~= nil and tag_direction ~= nil and role_direction ~= tag_direction then
176+ result_direction = nil
177+ print (' WARNING: conflict direction in role of way ' .. way :id () .. ' and direction tag in relation ' .. rel :id ())
178+ end
180179
181- if (dir == nil ) and (super_dir ~= nil ) then
182- result [' route_direction' ] = super_dir
180+
181+ -- process superrelations
182+ local super_dir = get_direction_from_superrel (rel , relations )
183+
184+ -- check if there are data error
185+
186+ if (result_direction ~= nil ) and (super_dir ~= nil ) and (result_direction ~= super_dir ) then
187+ print (' ERROR: conflicting relation directions found for way ' .. way :id () ..
188+ ' relation direction is ' .. result_direction .. ' superrelation direction is ' .. super_dir )
189+ result_direction = nil
190+ elseif result_direction == nil then
191+ result_direction = super_dir
192+ end
193+
194+ result [' route_direction' ] = result_direction
195+ add_extra_data (m )
183196 end
184197
198+
185199 return result
186200end
187201
0 commit comments