Skip to content
This repository has been archived by the owner on Aug 8, 2024. It is now read-only.

Commit

Permalink
Todos: Introduce RoadTodos
Browse files Browse the repository at this point in the history
  • Loading branch information
tordans committed May 16, 2024
1 parent ae24295 commit 9609c4d
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
43 changes: 43 additions & 0 deletions processing/topics/roads_bikelanes/roads/RoadTodos.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package.path = package.path .. ";/processing/topics/helper/?.lua"
require('RemoveNilValues')
RoadTodo = {}
RoadTodo.__index = RoadTodo

-- @param args table
-- @param args.key string
-- @param args.desc string
-- @param args.conditions function
function RoadTodo.new(args)
local self = setmetatable({}, RoadTodo)
self.key = args.key
self.desc = args.desc
self.conditions = args.conditions
return self
end

function RoadTodo:checkCondition(objectTags, resultTags)
if self.conditions(objectTags, resultTags) then
return self.key
else
return nil
end
end

-- === Fahrradstraßen ===
local check_cycleway_shared = RoadTodo.new({
key = "check_cycleway_shared",
desc = "Tagging `cycleway=shared` is very old tagging and should be checked an maybe removed.",
conditions = function(tagsObject, _)
return tagsObject.cycleway == "shared"
end
})


-- Public funtion
function RoadTodos(tagsObject, resultTags)
local todos = {}

todos[#todos + 1] = check_cycleway_shared:checkCondition(tagsObject, resultTags)

return RemoveNilValues(todos)
end
2 changes: 2 additions & 0 deletions processing/topics/roads_bikelanes/roads_bikelanes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ require("ExtractPublicTags")
require("Round")
require("DefaultId")
require("PathsGeneralization")
require("RoadTodos")

local roadsTable = osm2pgsql.define_table({
name = 'roads',
Expand Down Expand Up @@ -134,6 +135,7 @@ function osm2pgsql.process_way(object)
MergeTable(results, Maxspeed(object))
end
MergeTable(results, BikelanesPresence(object, cycleways))
results.todos = ToMarkdownList(RoadTodos(tags, results))

-- We need sidewalk for Biklanes(), but not for `roads`
if not IsSidepath(tags) then
Expand Down

0 comments on commit 9609c4d

Please sign in to comment.