-
Notifications
You must be signed in to change notification settings - Fork 0
/
branchRoute.m
97 lines (91 loc) · 1.88 KB
/
branchRoute.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
close all;
%% Base Case
%this is case30 with positions added for graphing
% base = loadcase('case118mod.mat');
base = loadcase('case30_updated.mat');
%
% X = base.Xpos;
% Y = base.Ypos;
% figure;
%
% I = imread('layout_30bus.png');
% hi = imagesc(I);
% mCase = base; mCase.Xpos = X; mCase.Ypos = Y;
% hold on; gridPlot(mCase); hold off;
%
%
% x = mean(X);
% y = mean(Y);
%
%
% nBranches = length( base.branch(:,1));
% connections = base.branch(:,1:2);
%
% % branchPoints = cell(1, nBranches);
%
% for i = 25,
%
% busses = connections(i,:);
%
% X(busses);
% Y(busses);
% hold on
% plot(X(busses), Y(busses), 'r');
% scatter(X(busses(1)), Y(busses(1)), 'g');
% Xlims = xlim;
% Ylims = ylim;
%
%
% line = [X(busses(1)) Y(busses(1))]
%
% endPoint = [X(busses(2)), Y(busses(2))];
% [x,y] = ginput(1)
%
%
% while sum(x<Xlims) == 1 && sum(y<Ylims) == 1,
%
% endDistance = sqrt(sum(([x,y] - endPoint).^2))
% nPoints = size(line,1);
%
% if endDistance >5,
% line = [line; [x,y]];
%
% plot( line(nPoints:nPoints+1,1), line(nPoints:nPoints+1,2), 'r');
% scatter(line(end,1),line(end,2), 'g'); %plot new point
%
% [x,y] = ginput(1);
% else
% line = [line; endPoint];
%
% plot( line(nPoints:nPoints+1,1), line(nPoints:nPoints+1,2), 'r');
% scatter(line(end,1),line(end,2), 'g'); %plot new point
% break;
% end
%
%
% end
%
% branchPoints{i} = line;
%
% fprintf('finished %d of %d\n\n', i, nBranches);
% close all;
%
% hi = imagesc(I);
% mCase = base; mCase.Xpos = X; mCase.Ypos = Y;
% hold on; gridPlot(mCase); hold off;
%
% base.line{i} = line;
% pause(0.5)
%
%
% end
%
% hold off
figure; hold on
for i = 1:length(base.branch_geo),
branch_geo = base.branch_geo{i}
for j = 1:length(branch_geo)-1,
plot(branch_geo(j:j+1, 1), branch_geo(j:j+1,2));
end
scatter(branch_geo([1,end], 1), branch_geo([1,end],2));
end