-
Notifications
You must be signed in to change notification settings - Fork 46
/
plot_road_network.m
53 lines (45 loc) · 1.4 KB
/
plot_road_network.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
function [] = plot_road_network(ax, connectivity_matrix, parsed_osm)
% plot the nodes and edges connecting them
%
% usage
% PLOT_ROAD_NETWORK(ax, connectivity_matrix, parsed_osm)
%
% input
% ax = axes object handle.
% connectivity_matrix = matrix representing the road network
% connectivity, as returned by the function
% extract_connectivity.
% parsed_osm = MATLAB structure containing the OpenStreetMap XML data
% after parsing, as returned by function
% parse_openstreetmap.
%
%
%
% 2012.04.24 (c) Ioannis Filippidis, [email protected]
%
% See also EXTRACT_CONNECTIVITY, PARSE_OPENSTREETMAP, ROUTE_PLANNER.
nodes = parsed_osm.node;
node_ids = nodes.id;
node_xys = nodes.xy;
n = size(connectivity_matrix, 2);
held = takehold(ax);
nodelist = [];
for curnode=1:n
curxy = node_xys(:, curnode);
% find neighbors
curadj = connectivity_matrix(curnode, :);
neighbors = find(curadj == 1);
neighbor_xy = node_xys(:, neighbors);
% plot edges to each neighbor
for j=1:size(neighbor_xy, 2)
otherxy = neighbor_xy(:, j);
xy = [curxy, otherxy];
plotmd(ax, xy)
end
% is node connected ?
if ~isempty(neighbor_xy)
nodelist = [nodelist, curnode];
end
end
%plot_nodes(ax, parsed_osm, nodelist)
givehold(ax, held)