From d3bfe49629be4f3b867deffc4ce6e71ebc3e1df3 Mon Sep 17 00:00:00 2001 From: Lucas Verney Date: Sat, 4 Mar 2023 19:40:02 +0100 Subject: [PATCH] Optimize Z9 rendering (#645) Z9 was quite anomaly in terms of rendering time. It was taking much longer than Z8 and Z10 during pre-computation. Dominant layer was landuse_gen0. It was using subpixel rendering for landuse, which is useful at very low zoom but seems to be safely discardable at Z9. Also add checks between way geometries and bbox to ensure correct usage of geospatial indexes in db. See as well https://github.com/gravitystorm/openstreetmap-carto/pull/2874 and https://github.com/gravitystorm/openstreetmap-carto/pull/3458#issuecomment-430873795. See https://github.com/cyclosm/cyclosm-cartocss-style/issues/644. --- base.mss | 4 ++-- project.mml | 12 +++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/base.mss b/base.mss index 123469f..36cc883 100644 --- a/base.mss +++ b/base.mss @@ -17,8 +17,8 @@ polygon-gamma: 0.75; } -#landuse_gen0[zoom>1][zoom<=9], -#landuse_gen1[zoom>9][zoom<=12], +#landuse_gen0[zoom>1][zoom<=8], +#landuse_gen1[zoom>8][zoom<=12], #landuse[zoom>=13] { [type='amenity_grave_yard'], [type='landuse_cemetery'] { diff --git a/project.mml b/project.mml index 0db4306..3d10fb1 100644 --- a/project.mml +++ b/project.mml @@ -84,7 +84,7 @@ Layer: CASE WHEN "natural" IS NOT NULL THEN ('natural_' || "natural") ELSE NULL END, CASE WHEN leisure IS NOT NULL THEN ('leisure_' || leisure) ELSE NULL END, CASE WHEN amenity IS NOT NULL THEN ('amenity_' || amenity) ELSE NULL END, - CASE WHEN highway IN ('pedestrian') THEN ('highway_' || highway) ELSE NULL END + CASE WHEN highway IS NOT NULL THEN ('highway_' || highway) ELSE NULL END ) AS type, sport FROM planet_osm_polygon @@ -102,7 +102,7 @@ Layer: geometry: polygon properties: minzoom: 2 - maxzoom: 9 + maxzoom: 8 - id: landuse_gen1 <<: *extents Datasource: @@ -129,12 +129,13 @@ Layer: OR highway IN ('pedestrian') ) AND way_area > 1*!pixel_width!::real*!pixel_height!::real + AND way && !bbox! ORDER BY way_area DESC ) AS data geometry: polygon properties: cache-features: true - minzoom: 10 + minzoom: 9 maxzoom: 12 - id: landuse <<: *extents @@ -182,6 +183,7 @@ Layer: ("natural" = 'wood' OR landuse = 'forest') AND building IS NULL AND way_area > 1*!pixel_width!::real*!pixel_height!::real + AND way && !bbox! ORDER BY way_area DESC ) AS data geometry: polygon @@ -336,6 +338,7 @@ Layer: OR landuse in ('basin', 'reservoir') ) AND way_area > 0.1*!pixel_width!::real*!pixel_height!::real + AND way && !bbox! AND (tunnel IS NULL OR tunnel NOT IN ('yes', 'culvert')) ) AS data geometry: polygon @@ -363,6 +366,7 @@ Layer: OR landuse in ('basin', 'reservoir') ) AND way_area > 1*!pixel_width!::real*!pixel_height!::real + AND way && !bbox! AND (tunnel IS NULL OR tunnel NOT IN ('yes', 'culvert')) ) AS data geometry: polygon @@ -924,6 +928,7 @@ Layer: OR (boundary = 'protected_area' AND tags->'protect_class' IN ('1','1a','1b','2','3','4','5','6','7','24','97','98','99'))) AND building IS NULL AND way_area > 1*!pixel_width!::real*!pixel_height!::real + AND way && !bbox! ) AS protected_areas properties: cache-features: true @@ -1920,6 +1925,7 @@ Layer: (landuse = 'military' OR military = 'danger_area') AND building IS NULL AND way_area > 1*!pixel_width!::real*!pixel_height!::real + AND way && !bbox! ORDER BY way_area DESC ) AS data geometry: polygon