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

Add different linestyles depending on way type #16

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
16 changes: 15 additions & 1 deletion src/defaults/defaults.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,12 @@ function set_edge_defaults(osmplot)
osm.highways)) # save labels to enable hide_elabels functionality
edge_color = color_streets(osmplot.index_to_way[])
edge_width = width_streets(osmplot.index_to_way[])
edge_attr = (; linestyle = style_streets(osmplot.index_to_way[]))
elabels = show_elabels(osmplot.hide_elabels[], osmplot.osm_elabels[])
elabels_textsize = 11
arrow_size = arrows_streets(osmplot.index_to_way[])

return (; edge_color, edge_width, elabels, elabels_textsize, arrow_size)
return (; edge_color, edge_width, edge_attr, elabels, elabels_textsize, arrow_size)
end

function color_streets(i2w)
Expand Down Expand Up @@ -79,6 +80,19 @@ function width_streets(i2w)
return widths
end

function style_streets(i2w)
styles = fill(:solid, length(i2w))

for (index, way) in pairs(i2w)
waytype = get(way.tags, "highway", :solid)
if waytype !== :solid && haskey(WAYTYPESTYLES, waytype)
styles[index] = WAYTYPESTYLES[waytype]
end
end

return styles
end

function label_streets(sorted_edges, n2i, ways)
labels = fill("", length(sorted_edges))

Expand Down