     END IF;
 END;
 $$ LANGUAGE plpgsql IMMUTABLE;
-
-CREATE OR REPLACE FUNCTION classify_structure(is_tunnel BOOLEAN, is_bridge BOOLEAN, is_ford BOOLEAN) RETURNS VARCHAR
-AS $$
-BEGIN
-    IF is_tunnel THEN
-        RETURN 'tunnel';
-    ELSIF is_bridge THEN
-        RETURN 'bridge';
-    ELSIF is_ford THEN
-        RETURN 'ford';
-    ELSE
-        RETURN 'none';
-    END IF;
-END;
-$$ LANGUAGE plpgsql IMMUTABLE;

CREATE OR REPLACE VIEW road_z5toz6 AS
    SELECT osm_id, geometry, type, construction, tracktype, service, access, oneway, 'none' AS structure, z_order, timestamp
    FROM osm_road_geometry

      AND type IN ('motorway', 'trunk', 'primary', 'motorway_link', 'primary_link', 'trunk_link', 'secondary', 'secondary_link', 'tertiary', 'teriary_link');

CREATE OR REPLACE VIEW road_z13 AS
    SELECT osm_id, geometry, type, construction, tracktype, service, access, oneway, road_structure(is_tunnel, is_bridge, is_ford) AS structure, z_order, timestamp
    FROM osm_road_geometry
    WHERE classify_road(type) IN ('minor_rail', 'street_limited', 'service')
      AND type IN ('motorway', 'trunk', 'primary', 'motorway_link', 'primary_link', 'trunk_link', 'secondary', 'secondary_link', 'tertiary', 'teriary_link');

CREATE OR REPLACE VIEW road_z14 AS
    SELECT osm_id, geometry, type, construction, tracktype, service, access, oneway, road_structure(is_tunnel, is_bridge, is_ford) AS structure, z_order, timestamp
    FROM osm_road_geometry;

CREATE OR REPLACE VIEW road_layer AS (
