-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgetManyAAC.m
83 lines (69 loc) · 3.57 KB
/
getManyAAC.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
function [manyAAC, manyTimes] = getManyAAC(amenityTags, places, gridSizes, sigmas)
% Returns the correlation between Amenity/person of different granularities of gridSizes and sigmas for many places and amenities
%
% INPUT:
% amenityTags(m) (String) - Name of the amenities to consider
% places(n) (String) - Names of polygon areas in OpenSteetMap
% gridSizes(i) (Integer Array) - Array of Grid granularity in metres
% sigmas(j) (Integer Array) - Standard deviation to use for gaussian blurring
% OUTPUT:
% manyGridSizesSigmasAAC{m,n}(i,j) (Double)
% Correlation between amenity map of amenityTags{m} of given
% places{n} in grid format for various gridSizes(i) and sigmas(j)
% manyTimes{m,n}(i,j) (Double) - Time taken to process manyGridSizesSigmasAAC{m,n}(i,j)
% EXAMPLE:
% [manyGridSizesSigmasAAC, manyTimes] = getManyGridSizesSigmasAACs({'hospital','bar'},{'Bristol','Manchester'},[100:100:4000],[0.2:0.2:8])
g = length(gridSizes);
s = length(sigmas);
a = length(amenityTags);
p = length(places);
manyAAC = cell(p,a,a);
manyTimes = cell(p,a,a);
%%
for m = 1:length(places)
place = places{m};
for n = 1:length(amenityTags)
for o = (n+1):length(amenityTags)
amenityTag1 = amenityTags{n};
amenityTag2 = amenityTags{o};
fCorr = ['./results/AAC/manyGridSizesSigmasAmenityAmenityCorrelation-' place '-' amenityTag1 '-' amenityTag2];
fCorrR = ['./results/AAC/manyGridSizesSigmasAmenityAmenityCorrelation-' place '-' amenityTag2 '-' amenityTag1];
fTime = ['./results/AAC/time-manyGridSizesSigmasAmenityAmenityCorrelation-' place '-' amenityTag1 '-' amenityTag2];
fTimeR = ['./results/AAC/time-manyGridSizesSigmasAmenityAmenityCorrelation-' place '-' amenityTag2 '-' amenityTag1];
if exist(fCorr,'file') && exist(fTime,'file')
correlation = csvread(fCorr);
time = csvread(fTime);
elseif exist(fCorrR,'file') && exist(fTimeR,'file')
correlation = csvread(fCorrR);
time = csvread(fTimeR);
else
correlation = zeros(g,s);
time = zeros(g,s);
step = ['Processing ' place ':' amenityTag1 ':' amenityTag2 '...'];
disp(step);
h = waitbar(0,step);
for i=1:g
gridSize = gridSizes(i);
for j=1:s
tic;
completed = (i-1 + j/s)/g;
waitbar(completed,h,[step num2str(completed*100) '%']);
sigma = sigmas(j);
disp(['Processing gridSize:sigma (' num2str(gridSize) ':' num2str(sigma) ')...']);
correlation(i,j) = getAAC({amenityTag1 amenityTag2}, place, gridSize, sigma);
time(i,j) = toc;
end
end
close(h);
disp(['Saving results to file ' fCorr '...']);
csvwrite(fCorr,correlation);
disp(['Saving times to file ' fTime '...']);
csvwrite(fTime,time);
end
manyAAC{m,n,o} = correlation;
manyAAC{m,o,n} = correlation;
manyTimes{m,n,o} = time;
manyTimes{m,o,n} = time;
end
end
end