Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions images/tiler-imposm/config/imposm3.template.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,6 @@
"odbl:note",
"history",

"roof:*",
"building:levels",
"building:part",
"building:material",
"building:colour",
"generator:*",
"tactile_paving",
"crossing:markings",
Expand Down
69 changes: 69 additions & 0 deletions images/tiler-imposm/config/layers/buildings.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,66 @@
"name": "height",
"key": "height"
},
{
"type": "string",
"name": "min_height",
"key": "min_height"
},
{
"type": "string",
"name": "building_height",
"key": "building:height"
},
{
"type": "string",
"name": "building_min_level",
"key": "building:min_level"
},
{
"type": "string",
"name": "building_use",
"key": "building:use"
},
{
"type": "string",
"name": "building_material",
"key": "building:material"
},
{
"type": "string",
"name": "building_levels",
"key": "building:levels"
},
{
"type": "string",
"name": "building_colour",
"key": "building:colour"
},
{
"type": "string",
"name": "building_part",
"key": "building:part"
},
Comment thread
Rub21 marked this conversation as resolved.
{
"type": "string",
"name": "roof_material",
"key": "roof:material"
},
{
"type": "string",
"name": "roof_colour",
"key": "roof:colour"
},
{
"type": "string",
"name": "roof_shape",
"key": "roof:shape"
},
{
"type": "string",
"name": "roof_height",
"key": "roof:height"
},
{
"type": "string",
"name": "start_date",
Expand Down Expand Up @@ -96,7 +156,16 @@
"mapping": {
"building": [
"__any__"
],
"building:part": [
"__any__"
]
},
"filters": {
"reject": {
"building": ["no", "none", "No"],
"building:part": ["no", "none", "No"]
}
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions images/tiler-imposm/config/layers/buildings_points.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@
"name": "class",
"key": null
},
{
"type": "string",
"name": "building_use",
"key": "building:use"
},
{
"type": "string",
"name": "start_date",
Expand Down
72 changes: 72 additions & 0 deletions images/tiler-imposm/config/layers/buildings_relation_members.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{
"tags": {
"load_all": true,
"exclude": [
"created_by",
"source",
"source:datetime"
]
},
"generalized_tables": {},
"tables": {
"buildings_relation_members": {
"type": "relation_member",
"fields": [
{
"type": "id",
"name": "osm_id",
"key": null
},
{
"type": "mapping_value",
"name": "type",
"key": null
},
{
"type": "mapping_key",
"name": "class",
"key": null
},
{
"type": "hstore_tags",
"name": "tags",
"key": null
},
{
"name": "geometry",
"type": "geometry"
},
{
"name": "member",
"type": "member_id"
},
{
"name": "role",
"type": "member_role"
},
{
"name": "me_building",
"type": "string",
"key": "building",
"from_member": true
},
{
"name": "me_building_part",
"type": "string",
"key": "building:part",
"from_member": true
},
{
"type": "hstore_tags",
"name": "me_tags",
"from_member": true
}
],
"mapping": {
"type": [
"building"
]
}
}
}
}
89 changes: 89 additions & 0 deletions images/tiler-imposm/config/layers/water_multilines.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
{
"tags": {
"load_all": true,
"exclude": [
"created_by",
"source",
"source:datetime"
]
},
"generalized_tables": {},
"tables": {
"water_multilines": {
"type": "relation_member",
"fields": [
{
"type": "id",
"name": "osm_id",
"key": null
},
{
"type": "geometry",
"name": "geometry",
"key": null
},
{
"type": "string",
"name": "name",
"key": "name"
},
{
"type": "mapping_value",
"name": "type",
"key": null
},
{
"type": "mapping_key",
"name": "class",
"key": null
},
{
"type": "string",
"name": "bridge",
"key": "bridge"
},
{
"type": "string",
"name": "start_date",
"key": "start_date"
},
{
"type": "string",
"name": "end_date",
"key": "end_date"
},
{
"type": "hstore_tags",
"name": "tags",
"key": null
},
{
"type": "member_id",
"name": "member"
},
{
"type": "hstore_tags",
"name": "me_tags",
"from_member": true
},
{
"type": "string",
"name": "me_name",
"key": "name",
"from_member": true
},
{
"type": "string",
"name": "me_waterway",
"key": "waterway",
"from_member": true
}
],
"mapping": {
"type": [
"waterway"
]
}
}
}
}
84 changes: 56 additions & 28 deletions images/tiler-imposm/queries/ohm_mviews/buildings.sql
Original file line number Diff line number Diff line change
@@ -1,61 +1,89 @@
-- ============================================================================
-- Partial index on building relation outline members.
-- Speeds up the EXISTS subquery that derives hide_3d in mv_buildings_areas_z16_20.
-- Mirrors the OpenMapTiles pattern for the building layer.
-- ============================================================================
CREATE INDEX IF NOT EXISTS osm_buildings_relation_members_outline_idx
ON osm_buildings_relation_members (member)
WHERE role = 'outline';

-- ============================================================================
-- Prepare points materialized view for higher zoom levels (12+)
-- Add height and height_fixed columns
-- All building/roof attributes (height, building:height, building:material, etc.)
-- are now extracted as native columns by imposm in osm_buildings_points
-- ============================================================================
-- 3D / rendering attributes (height, materials, colours, levels, parts, roof
-- shape) are only meaningful on polygon footprints. Points (building=*
-- nodes) keep just identity/classification fields (name, type, building_use,
-- addresses). Inject NULLs of matching types so the UNION with polygon
-- centroids in mv_buildings_points_centroids_* aligns by name and type.
SELECT create_points_mview(
'osm_buildings_points',
'mv_buildings_points',
'id, source, osm_id',
ARRAY['NULL as height'],
ARRAY[
'NULL::double precision AS height',
'NULL::double precision AS min_height',
'NULL::double precision AS roof_height',
'NULL::numeric AS building_min_level',
'NULL::text AS building_material',
'NULL::numeric AS building_levels',
'NULL::text AS building_colour',
'NULL::text AS building_part',
'FALSE::boolean AS is_building_part',
'FALSE::boolean AS hide_3d',
'NULL::text AS roof_material',
'NULL::text AS roof_colour',
'NULL::text AS roof_shape'
],
NULL
);



-- ============================================================================
-- Zoom 14-15:
-- Very low simplification (5m)
-- Very small areas (>5K m² = 0.005 km²)
-- Add height_fixed column
-- Zoom 16-20: BASE
-- No simplification, all areas. Height columns are parsed to numeric here.
-- `height` falls back to deprecated `building:height` and `building_height`
-- is dropped from the output. All derived zoom levels inherit this.
-- ============================================================================
SELECT create_areas_mview(
'osm_buildings',
'mv_buildings_areas_z14_15',
5,
5000,
'mv_buildings_areas_z16_20',
0,
0,
'id, osm_id, type',
NULL,
NULL,
NULL
'(class = ''building:part'') AS is_building_part, EXISTS (SELECT 1 FROM osm_buildings_relation_members obrm WHERE obrm.member = ABS(osm_buildings.osm_id) AND obrm.role = ''outline'') AS hide_3d',
'{"height": "COALESCE(parse_to_meters(height), parse_to_meters(building_height))", "min_height": "parse_to_meters(min_height)", "roof_height": "parse_to_meters(roof_height)", "building_levels": "clean_numeric(building_levels)", "building_min_level": "clean_numeric(building_min_level)"}'::jsonb,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By the way, most OSM tilesets seem to omit building:levels=* and building:min_level=*, instead using these tags as a fallback in case height=* and min_height=* are missing, respectively. They generally assume that a level is 3 meters tall. Some tilesets randomize the heights slightly so that adjacent buildings with the same number of levels look distinct on the map. A stylesheet can’t do that because it evaluates each building individually without context about surrounding buildings.

We can ticket out this fallback as tail work, since we’d have to think through the implications for roof:levels=* too.

ARRAY['building_height']
);

SELECT create_points_centroids_mview(
'mv_buildings_areas_z14_15',
'mv_buildings_points_centroids_z14_15',
'mv_buildings_points'
);
-- ============================================================================
-- Zoom 16-20:
-- No simplification
-- All areas
-- Add height_fixed column
-- Zoom 14-15: derived from z16_20
-- Low simplification (5m), filters out small buildings (<5,000 m²)
-- ============================================================================

SELECT create_areas_mview(
'osm_buildings',
SELECT create_area_mview_from_mview(
'mv_buildings_areas_z16_20',
0,
0,
'id, osm_id, type',
NULL,
NULL,
'mv_buildings_areas_z14_15',
5,
5000,
NULL
);

-- ============================================================================
-- Centroids per zoom level (UNION with point-tagged buildings)
-- ============================================================================
SELECT create_points_centroids_mview(
'mv_buildings_areas_z16_20',
'mv_buildings_points_centroids_z16_20',
'mv_buildings_points'
);
SELECT create_points_centroids_mview(
'mv_buildings_areas_z14_15',
'mv_buildings_points_centroids_z14_15',
'mv_buildings_points'
);

-- Refresh areas views
-- REFRESH MATERIALIZED VIEW CONCURRENTLY mv_buildings_areas_z14_15;
Expand Down
Loading