Ignore inaccessible roads, certain service roads, and areas (fixes #116)
This commit is contained in:
parent
73c1a62f80
commit
9d97489ac9
108
roads_import.lua
108
roads_import.lua
|
@ -56,6 +56,12 @@ local ADMIN_LEVEL_MAX = 8
|
||||||
local ONEWAY_YES = {"yes", "true", "1"}
|
local ONEWAY_YES = {"yes", "true", "1"}
|
||||||
local ONEWAY_REVERSE = {"reverse", "-1"}
|
local ONEWAY_REVERSE = {"reverse", "-1"}
|
||||||
|
|
||||||
|
-- https://wiki.openstreetmap.org/wiki/Tag:highway=service
|
||||||
|
local IGNORED_SERVICE_TYPES = {"parking_aisle", "driveway", "emergency_access", "drive-through"}
|
||||||
|
|
||||||
|
-- https://taginfo.openstreetmap.org/keys/access#values
|
||||||
|
local IGNORED_ACCESS_TYPES = {"no", "private", "permit", "official", "service", "emergency"}
|
||||||
|
|
||||||
local roads = osm2pgsql.define_way_table('road', {
|
local roads = osm2pgsql.define_way_table('road', {
|
||||||
{ column = 'zone', type = 'text', sql_type="zone_type" },
|
{ column = 'zone', type = 'text', sql_type="zone_type" },
|
||||||
{ column = 'directionality', type = 'int' },
|
{ column = 'directionality', type = 'int' },
|
||||||
|
@ -73,55 +79,67 @@ local regions = osm2pgsql.define_relation_table('region', {
|
||||||
|
|
||||||
|
|
||||||
function osm2pgsql.process_way(object)
|
function osm2pgsql.process_way(object)
|
||||||
if object.tags.highway and contains(HIGHWAY_TYPES, object.tags.highway) then
|
local tags = object.tags
|
||||||
local tags = object.tags
|
|
||||||
local zone = nil
|
|
||||||
|
|
||||||
if tags["zone:traffic"] then
|
-- only import certain highway ways, i.e. roads and pathways
|
||||||
zone = tags["zone:traffic"]
|
if not tags.highway then return end
|
||||||
|
if not contains(HIGHWAY_TYPES, tags.highway) then return end
|
||||||
|
|
||||||
if zone == "DE:urban" then
|
-- do not import areas (plazas etc.)
|
||||||
zone = "urban"
|
if tags.area == "yes" then return end
|
||||||
elseif zone == "DE:rural" then
|
|
||||||
zone = "rural"
|
-- ignore certain service roads
|
||||||
elseif zone == "DE:motorway" then
|
if contains(IGNORED_SERVICE_TYPES, tags.service) then return end
|
||||||
zone = "motorway"
|
|
||||||
elseif string.match(zone, "rural") then
|
-- ignore disallowed roads (often tram tracks and similar)
|
||||||
zone = "rural"
|
if contains(IGNORED_ACCESS_TYPES, tags.access) then return end
|
||||||
elseif string.match(zone, "urban") then
|
|
||||||
zone = "urban"
|
local zone = nil
|
||||||
elseif string.match(zone, "motorway") then
|
|
||||||
zone = "motorway"
|
if tags["zone:traffic"] then
|
||||||
elseif contains(URBAN_TYPES, tags.highway) then
|
zone = tags["zone:traffic"]
|
||||||
zone = "urban"
|
|
||||||
elseif contains(MOTORWAY_TYPES, tags.highway) then
|
if zone == "DE:urban" then
|
||||||
zone = "motorway"
|
zone = "urban"
|
||||||
else
|
elseif zone == "DE:rural" then
|
||||||
-- we can't figure it out
|
zone = "rural"
|
||||||
zone = nil
|
elseif zone == "DE:motorway" then
|
||||||
end
|
zone = "motorway"
|
||||||
|
elseif string.match(zone, "rural") then
|
||||||
|
zone = "rural"
|
||||||
|
elseif string.match(zone, "urban") then
|
||||||
|
zone = "urban"
|
||||||
|
elseif string.match(zone, "motorway") then
|
||||||
|
zone = "motorway"
|
||||||
|
elseif contains(URBAN_TYPES, tags.highway) then
|
||||||
|
zone = "urban"
|
||||||
|
elseif contains(MOTORWAY_TYPES, tags.highway) then
|
||||||
|
zone = "motorway"
|
||||||
|
else
|
||||||
|
-- we can't figure it out
|
||||||
|
zone = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
local directionality = 0
|
|
||||||
local oneway = tags.oneway
|
|
||||||
|
|
||||||
-- See https://wiki.openstreetmap.org/wiki/Key:oneway section "Implied oneway restriction"
|
|
||||||
if contains(ONEWAY_YES, tags.oneway) or tags.junction == "roundabout" or zone == "motorway" then
|
|
||||||
directionality = 1
|
|
||||||
oneway = true
|
|
||||||
elseif contains(ONEWAY_REVERSE, tags.oneway) then
|
|
||||||
directionality = -1
|
|
||||||
oneway = true
|
|
||||||
end
|
|
||||||
|
|
||||||
roads:add_row({
|
|
||||||
geom = { create = 'linear' },
|
|
||||||
name = tags.name,
|
|
||||||
zone = zone,
|
|
||||||
directionality = directionality,
|
|
||||||
oneway = oneway,
|
|
||||||
})
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local directionality = 0
|
||||||
|
local oneway = tags.oneway
|
||||||
|
|
||||||
|
-- See https://wiki.openstreetmap.org/wiki/Key:oneway section "Implied oneway restriction"
|
||||||
|
if contains(ONEWAY_YES, tags.oneway) or tags.junction == "roundabout" or zone == "motorway" then
|
||||||
|
directionality = 1
|
||||||
|
oneway = true
|
||||||
|
elseif contains(ONEWAY_REVERSE, tags.oneway) then
|
||||||
|
directionality = -1
|
||||||
|
oneway = true
|
||||||
|
end
|
||||||
|
|
||||||
|
roads:add_row({
|
||||||
|
geom = { create = 'linear' },
|
||||||
|
name = tags.name,
|
||||||
|
zone = zone,
|
||||||
|
directionality = directionality,
|
||||||
|
oneway = oneway,
|
||||||
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
function osm2pgsql.process_relation(object)
|
function osm2pgsql.process_relation(object)
|
||||||
|
|
Loading…
Reference in a new issue