OpenStreetMapXPlot.jl icon indicating copy to clipboard operation
OpenStreetMapXPlot.jl copied to clipboard

Labeling streets

Open michael-prange opened this issue 3 years ago • 2 comments

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

michael-prange avatar Feb 09 '22 23:02 michael-prange

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.

pszufe avatar Feb 11 '22 16:02 pszufe

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.

michael-prange avatar Feb 11 '22 17:02 michael-prange