-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathTDrive_trajectory_reading.m
47 lines (38 loc) · 1.17 KB
/
TDrive_trajectory_reading.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
function [latLong,numberOfEffectiveRecord,visitingTime] = TDrive_trajectory_reading(param)
latLong=[];
visitingTime = {};
numberOfEffectiveRecord = 0;
maindir = param.inputFile;
subdir = dir(maindir);
if length( subdir ) == 0
error('Error, Please check your file path!');
return;
end
tline = 1;
for i = 1 : length( subdir )
if( length(subdir(i).name) <= 4 || ~isequal( subdir(i).name(end-3:end), '.txt' )) % if file is a directory then pass
continue;
end
fileName = fullfile(maindir, subdir(i).name);
fileID = fopen(fileName);
C = textscan(fileID,'%f %D %f %f','delimiter',',');
fclose(fileID);
index = C{1};
time = C{2};
long = C{3};
lat = C{4};
if length(index) < 1
continue;
end
% time = cellfun(@datetime,strtime,'UniformOutput',false);
visitingTime = [visitingTime; time];
latLong = [latLong;[index,lat,long]];
if(tline >= param.readingNumOfTraj)
break;
end
tline = tline + 1;
end
if tline == 1
error('Error, No trajectory has been loaded. Please check your file path!');
end
numberOfEffectiveRecord = min(param.readingNumOfTraj,length(subdir));