Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unpaved rendering for turning circles #4770

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 12 additions & 2 deletions project.mml
Expand Up @@ -611,8 +611,14 @@ Layer:
<<: *osm2pgsql
table: &turning-circle_sql |-
(SELECT DISTINCT ON (p.way)
p.way AS way,
-- Valid line geometry requires at least two points that are NOT identical, therefore moving them slightly.
ST_MakeLine(ST_Translate(p.way, -0.0001, -0.0001), ST_Translate(p.way, 0.0001, 0.0001)) AS way,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't like generating fake lines. Why can't we use a point and crop out an appropriately sized circle from the unpaved pattern?

Copy link
Collaborator

Choose a reason for hiding this comment

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

That would mean cutting about 30 different circular SVGs from the patterns. And you would still get a discontinuity of the pattern rendering at the transit from the turning circle to the linear road.

The other alternative would be using ST_Buffer() + polygon pattern, but that would require the road width progression to be available in SQL. On the other hand, that would allow merging the turning circle and highway area layers and this way could reduce size of roads.mss quite a bit...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

As @imago explained, using a point geometry

would mean cutting about 30 different circular SVGs from the patterns

Therefore, I think what is proposed in this PR is easier in code and maintenance.

p.highway AS type,
CASE WHEN l.surface IN ('unpaved', 'compacted', 'dirt', 'earth', 'fine_gravel', 'grass', 'grass_paver', 'gravel', 'ground',
'mud', 'pebblestone', 'salt', 'sand', 'woodchips', 'clay', 'ice', 'snow') THEN 'unpaved'
WHEN l.surface IN ('paved', 'asphalt', 'cobblestone', 'cobblestone:flattened', 'sett', 'concrete', 'concrete:lanes',
'concrete:plates', 'paving_stones', 'metal', 'wood', 'unhewn_cobblestone') THEN 'paved'
END AS int_surface,
l.highway AS int_tc_type,
CASE WHEN l.service IN ('parking_aisle', 'drive-through', 'driveway')
THEN 'INT-minor'::text
Expand All @@ -638,7 +644,11 @@ Layer:
'mini_roundabout')
AND l.way && !bbox!
AND p.way && !bbox! -- Both conditions are necessary for good index usage, even with the DWithin above
ORDER BY p.way, v.prio
ORDER BY
p.way,
v.prio,
CASE WHEN surface IN ('unpaved', 'compacted', 'dirt', 'earth', 'fine_gravel', 'grass', 'grass_paver', 'gravel', 'ground',
'mud', 'pebblestone', 'salt', 'sand', 'woodchips', 'clay', 'ice', 'snow') THEN 0 ELSE 1 END DESC
) AS turning_circle_sql
properties:
minzoom: 15
Expand Down
150 changes: 142 additions & 8 deletions style/roads.mss
Expand Up @@ -2946,7 +2946,7 @@ tertiary is rendered from z10 and is not included in osm_planet_roads. */
}

#turning-circle-fill {
[int_tc_type = 'primary'][zoom >= 15] {
[int_tc_type = 'primary'][zoom >= 15][int_surface != 'unpaved'] {
marker-fill: @primary-fill;
marker-width: @primary-width-z15 * 1.6;
marker-height: @primary-width-z15 * 1.6;
Expand All @@ -2966,8 +2966,25 @@ tertiary is rendered from z10 and is not included in osm_planet_roads. */
marker-ignore-placement: true;
marker-line-width: 0;
}
[int_tc_type = 'primary'][zoom >= 15][int_surface = 'unpaved'] {
line-pattern-type: repeat;
line-pattern-alignment: global;
line-pattern-width: @primary-width-z15 * 1.6;
line-pattern-file: url("symbols/unpaved/unpaved_primary-fill.svg");
[zoom >= 17] {
line-pattern-width: @primary-width-z17 * 1.6;
}
[zoom >= 18] {
line-pattern-width: @primary-width-z18 * 1.6;
}
[zoom >= 19] {
line-pattern-width: @primary-width-z19 * 1.6;
}
line-pattern-cap: round;
line-pattern-join: round;
}

[int_tc_type = 'secondary'][zoom >= 15] {
[int_tc_type = 'secondary'][zoom >= 15][int_surface != 'unpaved'] {
marker-fill: @secondary-fill;
marker-width: @secondary-width-z15 * 1.6;
marker-height: @secondary-width-z15 * 1.6;
Expand All @@ -2991,8 +3008,28 @@ tertiary is rendered from z10 and is not included in osm_planet_roads. */
marker-ignore-placement: true;
marker-line-width: 0;
}
[int_tc_type = 'secondary'][zoom >= 15][int_surface = 'unpaved'] {
line-pattern-type: repeat;
line-pattern-alignment: global;
line-pattern-width: @secondary-width-z15 * 1.6;
line-pattern-file: url("symbols/unpaved/unpaved_secondary-fill.svg");
[zoom >= 16] {
line-pattern-width: @secondary-width-z16 * 1.6;
}
[zoom >= 17] {
line-pattern-width: @secondary-width-z17 * 1.6;
}
[zoom >= 18] {
line-pattern-width: @secondary-width-z18 * 1.6;
}
[zoom >= 19] {
line-pattern-width: @secondary-width-z19 * 1.6;
}
line-pattern-cap: round;
line-pattern-join: round;
}

[int_tc_type = 'tertiary'][zoom >= 15] {
[int_tc_type = 'tertiary'][zoom >= 15][int_surface != 'unpaved'] {
marker-fill: @tertiary-fill;
marker-width: @tertiary-width-z15 * 1.6;
marker-height: @tertiary-width-z15 * 1.6;
Expand All @@ -3016,9 +3053,29 @@ tertiary is rendered from z10 and is not included in osm_planet_roads. */
marker-ignore-placement: true;
marker-line-width: 0;
}
[int_tc_type = 'tertiary'][zoom >= 15][int_surface = 'unpaved'] {
line-pattern-type: repeat;
line-pattern-alignment: global;
line-pattern-width: @tertiary-width-z15 * 1.6;
line-pattern-file: url("symbols/unpaved/unpaved_residential-fill.svg");
[zoom >= 16] {
line-pattern-width: @tertiary-width-z16 * 1.6;
}
[zoom >= 17] {
line-pattern-width: @tertiary-width-z17 * 1.6;
}
[zoom >= 18] {
line-pattern-width: @tertiary-width-z18 * 1.6;
}
[zoom >= 19] {
line-pattern-width: @tertiary-width-z19 * 1.6;
}
line-pattern-cap: round;
line-pattern-join: round;
}

[int_tc_type = 'residential'],
[int_tc_type = 'unclassified'] {
[int_tc_type = 'residential'][int_surface != 'unpaved'],
[int_tc_type = 'unclassified'][int_surface != 'unpaved'] {
[zoom >= 15] {
marker-fill: @residential-fill;
marker-width: @residential-width-z15 * 1.6;
Expand All @@ -3044,8 +3101,31 @@ tertiary is rendered from z10 and is not included in osm_planet_roads. */
marker-line-width: 0;
}
}
[int_tc_type = 'residential'][int_surface = 'unpaved'],
[int_tc_type = 'unclassified'][int_surface = 'unpaved'] {
[zoom >= 15] {
line-pattern-type: repeat;
line-pattern-alignment: global;
line-pattern-width: @residential-width-z15 * 1.6;
line-pattern-file: url("symbols/unpaved/unpaved_residential-fill.svg");
[zoom >= 16] {
line-pattern-width: @residential-width-z16 * 1.6;
}
[zoom >= 17] {
line-pattern-width: @residential-width-z17 * 1.6;
}
[zoom >= 18] {
line-pattern-width: @residential-width-z18 * 1.6;
}
[zoom >= 19] {
line-pattern-width: @residential-width-z19 * 1.6;
}
line-pattern-cap: round;
line-pattern-join: round;
}
}

[int_tc_type = 'living_street'][zoom >= 15] {
[int_tc_type = 'living_street'][zoom >= 15][int_surface != 'unpaved'] {
marker-fill: @living-street-fill;
marker-width: @living-street-width-z15 * 1.6;
marker-height: @living-street-width-z15 * 1.6;
Expand All @@ -3069,8 +3149,28 @@ tertiary is rendered from z10 and is not included in osm_planet_roads. */
marker-ignore-placement: true;
marker-line-width: 0;
}
[int_tc_type = 'living_street'][zoom >= 15][int_surface = 'unpaved'] {
line-pattern-type: repeat;
line-pattern-alignment: global;
line-pattern-width: @living-street-width-z15 * 1.6;
line-pattern-file: url("symbols/unpaved/unpaved_living-street-fill.svg");
[zoom >= 16] {
line-pattern-width: @living-street-width-z16 * 1.6;
}
[zoom >= 17] {
line-pattern-width: @living-street-width-z17 * 1.6;
}
[zoom >= 18] {
line-pattern-width: @living-street-width-z18 * 1.6;
}
[zoom >= 19] {
line-pattern-width: @living-street-width-z19 * 1.6;
}
line-pattern-cap: round;
line-pattern-join: round;
}

[int_tc_type = 'service'][int_tc_service = 'INT-normal'][zoom >= 16] {
[int_tc_type = 'service'][int_tc_service = 'INT-normal'][zoom >= 16][int_surface != 'unpaved'] {
marker-fill: @service-fill;
marker-width: @service-width-z16 * 1.6;
marker-height: @service-width-z16 * 1.6;
Expand All @@ -3094,8 +3194,28 @@ tertiary is rendered from z10 and is not included in osm_planet_roads. */
marker-ignore-placement: true;
marker-line-width: 0;
}
[int_tc_type = 'service'][int_tc_service = 'INT-normal'][zoom >= 16][int_surface = 'unpaved'] {
line-pattern-type: repeat;
line-pattern-alignment: global;
line-pattern-width: @service-width-z16 * 1.6;
line-pattern-file: url("symbols/unpaved/unpaved_residential-fill.svg");
[zoom >= 17] {
line-pattern-width: @service-width-z17 * 1.6;
}
[zoom >= 18] {
line-pattern-width: @service-width-z18 * 1.6;
}
[zoom >= 19] {
line-pattern-width: @service-width-z19 * 1.6;
}
[zoom >= 20] {
line-pattern-width: @service-width-z20 * 1.6;
}
line-pattern-cap: round;
line-pattern-join: round;
}

[int_tc_type = 'service'][int_tc_service = 'INT-minor'][zoom >= 18] {
[int_tc_type = 'service'][int_tc_service = 'INT-minor'][zoom >= 18][int_surface != 'unpaved'] {
marker-fill: @service-fill;
marker-width: @minor-service-width-z18 * 1.6;
marker-height: @minor-service-width-z18 * 1.6;
Expand All @@ -3111,6 +3231,20 @@ tertiary is rendered from z10 and is not included in osm_planet_roads. */
marker-ignore-placement: true;
marker-line-width: 0;
}
[int_tc_type = 'service'][int_tc_service = 'INT-minor'][zoom >= 18][int_surface = 'unpaved'] {
line-pattern-type: repeat;
line-pattern-alignment: global;
line-pattern-width: @minor-service-width-z18 * 1.6;
line-pattern-file: url("symbols/unpaved/unpaved_residential-fill.svg");
[zoom >= 19] {
line-pattern-width: @minor-service-width-z19 * 1.6;
}
[zoom >= 20] {
line-pattern-width: @minor-service-width-z20 * 1.6;
}
line-pattern-cap: round;
line-pattern-join: round;
}

[int_tc_type = 'track'][zoom >= 15] {
marker-fill: @track-fill;
Expand Down