diff --git a/api/migrations/versions/ddde1cdc767b_add_road_column_has_cars.py b/api/migrations/versions/ddde1cdc767b_add_road_column_has_cars.py new file mode 100644 index 0000000..fb6234a --- /dev/null +++ b/api/migrations/versions/ddde1cdc767b_add_road_column_has_cars.py @@ -0,0 +1,24 @@ +"""add road column has_cars + +Revision ID: ddde1cdc767b +Revises: a049e5eb24dd +Create Date: 2022-04-03 20:13:22.874195 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = "ddde1cdc767b" +down_revision = "a049e5eb24dd" +branch_labels = None +depends_on = None + + +def upgrade(): + op.add_column("road", sa.Column("has_cars", sa.Boolean)) + + +def downgrade(): + op.drop_column("road", "has_cars") diff --git a/roads_import.lua b/roads_import.lua index 1744525..3770212 100644 --- a/roads_import.lua +++ b/roads_import.lua @@ -35,6 +35,11 @@ local HIGHWAY_TYPES = { "track", "road", } +local UNMOTORIZED_TRAFFIC_HIGHWAY_TYPES = { + "cycleway", + "footway", + "path", +} local ZONE_TYPES = { "urban", "rural", @@ -68,6 +73,7 @@ local roads = osm2pgsql.define_way_table('road', { { column = 'name', type = 'text' }, { column = 'geometry', type = 'linestring' }, { column = 'oneway', type = 'bool' }, + { column = 'has_cars', type = 'bool' }, }) local regions = osm2pgsql.define_relation_table('region', { @@ -83,7 +89,9 @@ function osm2pgsql.process_way(object) -- only import certain highway ways, i.e. roads and pathways if not tags.highway then return end - if not contains(HIGHWAY_TYPES, tags.highway) then return end + + local unmotorized_traffic = contains(UNMOTORIZED_TRAFFIC_HIGHWAY_TYPES, tags.highway) + if not contains(HIGHWAY_TYPES, tags.highway) and not unmotorized_traffic then return end -- do not import areas (plazas etc.) if tags.area == "yes" then return end @@ -139,6 +147,7 @@ function osm2pgsql.process_way(object) zone = zone, directionality = directionality, oneway = oneway, + has_cars = not unmotorized_traffic }) end