pszufe / OpenStreetMapXPlot.jl

Plotting functionality for the OpenStreetMapX.jl (Supports Plots.jl with GR or PythonPlot backend)
MIT License
35 stars 5 forks source link

Labeling streets #15

Open michael-prange opened 2 years ago

michael-prange commented 2 years ago

Is there an easy way to extend the code to allow streets to be labeled?

pszufe commented 2 years ago

Yes! This can be easily added.

Object MapData has a field roadways that has a Vector with road descriptions.

For an example consider the sample map:

mx = get_map_data(joinpath(dirname(pathof(OpenStreetMapX)),"..","test/data/reno_east3.osm"),use_cache=false)

The first roadway has the following nodes:

julia> mx.roadways[1].nodes
4-element Vector{Int64}:
 2441017888
 2441017878
 2441017870
 2975020216

The name of the roadway (here Pyramid Way) can be found in the tags field:

julia> mx.roadways[1].tags
Dict{String, String} with 11 entries:
  "oneway"     => "yes"
  "lanes"      => "1"
  "surface"    => "asphalt"
  "name"       => "Pyramid Way"
  "horse"      => "no"
  "lit"        => "yes"
  "highway"    => "secondary"
  "turn:lanes" => "left"
  "source"     => "Bing"
  "foot"       => "no"
  "bicycle"    => "no"

Hence all you need to do is to iterate along roadways, take the first node, get it location and than do the plotting.

michael-prange commented 2 years ago

Thanks. I will work on a function that adds road names to a map.

Sent from my iPad

On Feb 11, 2022, at 11:54, Przemysław Szufel @.***> wrote:

 Yes! This can be easily added.

Object MapData has a field roadways that has a Vector with road descriptions.

For an example consider the sample map:

mx = get_map_data(joinpath(dirname(pathof(OpenStreetMapX)),"..","test/data/reno_east3.osm"),use_cache=false) The first roadway has the following nodes:

julia> mx.roadways[1].nodes 4-element Vector{Int64}: 2441017888 2441017878 2441017870 2975020216 The name of the roadway (here Pyramid Way) can be found in the tags field:

julia> mx.roadways[1].tags Dict{String, String} with 11 entries: "oneway" => "yes" "lanes" => "1" "surface" => "asphalt" "name" => "Pyramid Way" "horse" => "no" "lit" => "yes" "highway" => "secondary" "turn:lanes" => "left" "source" => "Bing" "foot" => "no" "bicycle" => "no" Hence all you need to do is to iterate along roadways, take the first node, get it location and than do the plotting.

— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you authored the thread.