Skip to content

Commit c6b3511

Browse files
author
ltokareva
committed
[WIP] adding custom tags to ways
1 parent c30254c commit c6b3511

File tree

1 file changed

+138
-0
lines changed

1 file changed

+138
-0
lines changed

src/testing_graph.jl

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
using JSON3, LightOSM
2+
custom_tags = Dict(
3+
"DTP_REG_NAME" => "GREATER METRO",
4+
"LGA_ABB_NAME" => "CASEY",
5+
"MEL30_ART" => "N",
6+
)
7+
8+
vmt_tags = Dict(
9+
"ufi" => "59472156",
10+
"div_rd" => "U",
11+
"road_name" => "ORMISTON",
12+
"road_seal" => "1"
13+
)
14+
# f = open("/Users/ltokareva/Desktop/small_osm.json", "r");
15+
# data = JSON3.read(f, Dict);
16+
17+
# for element in data["elements"]
18+
# element["id"] = string(element["id"])
19+
# if element["type"] == "way"
20+
# element["nodes"] = [string(i) for i in element["nodes"]]
21+
# end
22+
# end
23+
24+
# empty_vsls = JSON3.write(data);
25+
# open("/Users/ltokareva/Desktop/osm_sample_string_id.json","w") do f
26+
# write(f, empty_vsls)
27+
# end
28+
29+
# Original file
30+
# data_file = "/Users/ltokareva/Desktop/small_osm.json"
31+
# Edited file
32+
# data_file = "/Users/ltokareva/Desktop/graph_benchmarking/osm_sample_string_id.json"
33+
data_file = "/Users/ltokareva/Desktop/graph_benchmarking/small_osm.json"
34+
data_file = "/Users/ltokareva/Desktop/graph_benchmarking/osm_vicmap_tags.json"
35+
# osm_string_id_graph = graph_from_file(data_file, weight_type=:distance, precompute_dijkstra_states=true)
36+
osm_int_id_graph = graph_from_file(data_file, weight_type=:distance, precompute_dijkstra_states=true)
37+
38+
# Adding Vicmap tags
39+
f = open("/Users/ltokareva/Desktop/graph_benchmarking/osm_sample_string_id.json", "r");
40+
data = JSON3.read(f, Dict);
41+
42+
i = 0
43+
for element in data["elements"]
44+
if element["type"] == "way"
45+
element["vmt_tags"]= Dict(
46+
"ufi" => i,
47+
"div_rd" => "U",
48+
"road_name" => string("Road_name", i),
49+
"road_seal" => i
50+
)
51+
52+
element["custom_tags"]= Dict(
53+
"DTP_REG_NAME" => "GREATER METRO",
54+
"LGA_ABB_NAME" => "CASEY",
55+
"MEL30_ART" => "N",
56+
)
57+
i += 1
58+
end
59+
end
60+
empty_vsls = JSON3.write(data);
61+
open("/Users/ltokareva/Desktop/graph_benchmarking/osm_vicmap_tags.json","w") do f
62+
write(f, empty_vsls)
63+
end
64+
65+
struct Foo
66+
bar
67+
baz::Int
68+
qux::Float64
69+
end
70+
71+
using JSON3, LightOSM
72+
U = String
73+
T = String
74+
W = Float64
75+
foo = OSMGraph{U,T,W}()
76+
77+
78+
struct Huei{T<:DEFAULT_OSM_ID_TYPE}
79+
id::T
80+
nodes::Vector{T}
81+
tags::Dict{String,Any}
82+
end
83+
84+
Huei(id::T, nodes, tags::Dict{String, Any}) where T <: DEFAULT_OSM_ID_TYPE = Huei(id, convert(Vector{T}, nodes), tags)
85+
86+
h1_dict = Dict("lisa" => "lll", "kirill" => 1)
87+
h2 = Huei("12", ["1", "2"], h1_dict)
88+
89+
hueis = Dict{Union{Int, String}}()
90+
91+
# Test it
92+
Huei_int = Huei(10)
93+
Huei_string = Huei("Hello")
94+
95+
println(Huei_int)
96+
println(Huei_string)
97+
98+
99+
mutable struct HGraphs{T <: DEFAULT_OSM_ID_TYPE}
100+
hueis::Dict{T,Way{T}}
101+
end
102+
103+
struct Way{T <: DEFAULT_OSM_ID_TYPE}
104+
id::T
105+
nodes::Vector{T}
106+
tags::Dict{String,Any}
107+
end
108+
Way(id::T, nodes, tags::Dict{String, Any}) where T <: DEFAULT_OSM_ID_TYPE = Way(id, convert(Vector{T}, nodes), tags)
109+
110+
new_way = Way(1, [1,2,3], Dict("lisa" => "sucks", "kirill" => 12, "javed" => "love"))
111+
112+
new_way = Way("1", ["1","2","3"], Dict("lisa" => "sucks", "kirill" => 12, "javed" => "love"))
113+
114+
115+
function print_type_info(T::Type)
116+
println("The type passed is: ", T)
117+
end
118+
119+
# Calling the function with different types
120+
print_type_info(Int)
121+
print_type_info(Float64)
122+
print_type_info(String)
123+
124+
125+
LightOSM.shortest_path(osm_string_id_graph, "293816403", "9105320427")
126+
LightOSM.shortest_path(osm_int_id_graph, 293816403, 9105320427)
127+
128+
osm_string_id_graph.nodes
129+
osm_string_id_graph.ways
130+
131+
osm_int_id_graph.nodes
132+
osm_int_id_graph.ways
133+
134+
point_a = GeoLocation(-37.89919244521005, 145.12319581573013)
135+
136+
nearest_point_on_way(osm_string_id_graph, point_a, "577174270")
137+
138+
nearest_node(osm_string_id_graph, "293816403")

0 commit comments

Comments
 (0)