Skip to content

Commit

Permalink
Rework the tunnel and bridge layers for better performance
Browse files Browse the repository at this point in the history
Compiling the project to a Mapnik XML file was taking a lot of time,
mainly due to the tunnel and bridge layers. Here are some fixes to
improve compilation time.

* Use attachments for tunnels and bridges instead of selecting all the
data three times from the database and filtering on it.
* Rework the filtering in `roads.mss` file to avoid having too many
levels of imbrication, responsible for a lot of overhead at compilation.
* Remove the upper zoom limit as there is no reason to stop displaying
the roads above zoom 20.

Before this PR, compilation time obtained through

```
\time carto cyclosm-cartocss-style/project.mml > /dev/null
```

was of about 5 minutes.

It is now of 24 seconds.

Fixes #60.
  • Loading branch information
Phyks committed Feb 20, 2019
1 parent 7f0c928 commit 6b46e47
Show file tree
Hide file tree
Showing 2 changed files with 238 additions and 167 deletions.
16 changes: 4 additions & 12 deletions project.mml
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ Layer:
<<: *osm2pgsql
table: |-
(
SELECT way, COALESCE(highway, railway) AS type, 0 AS bridge, access, render, layer, 1 as tunnel,
SELECT way, COALESCE(highway, railway) AS type, 0 AS bridge, access, layer, 1 as tunnel,
CASE
WHEN highway IN ('motorway', 'trunk') THEN 'motorway'
WHEN highway IN ('primary', 'secondary') THEN 'mainroad'
Expand All @@ -257,17 +257,9 @@ Layer:
tags->'ramp:stroller' AS ramp_stroller,
tags->'ramp:bicycle' AS ramp_cycle,
tags->'ramp:wheelchair' AS ramp_wheelchair
FROM (
SELECT *, '1_outline' AS render FROM planet_osm_line
WHERE tunnel NOT IN ('', '0', 'no')
UNION ALL
SELECT *, '2_line' AS render FROM planet_osm_line
WHERE tunnel NOT IN ('', '0', 'no')
UNION ALL
SELECT *, '3_inline' AS render FROM planet_osm_line
WHERE tunnel NOT IN ('', '0', 'no')
) AS tunnels
ORDER BY layer ASC, render ASC
FROM planet_osm_line
WHERE tunnel NOT IN ('', '0', 'no')
ORDER BY layer ASC
) AS data
geometry: linestring
properties:
Expand Down
Loading

0 comments on commit 6b46e47

Please sign in to comment.