% TracksInShapefile % Separated those OSM tracks which use the SRN, i.e. are long trips in % cars. % Author: George Hilton Email: g.hilton@soton.ac.uk % Date 20/01/2017 (Trump Inauguration!) % Load shapefile of road network load('C:\Local\Traffic Data\Highways Shape File\HighwaysLatLon.mat') Tracks = dir('C:\Local\Traffic Data\Matlab OSM tracks'); % Remove current and parent directory markers to prevent infinite loop yg = ismember({Tracks.name},{'.','..'}); Tracks(yg) = []; itr = 0 Number = 1 % Iterate through all tracks for i1 = 1 : length(Tracks) ThisTrack = Tracks(i1).name; load(ThisTrack) flag = 0; TrackBox = [min(data.Latitude(1),data.Latitude(length(data))) , min(data.Longitude(1),data.Longitude(length(data))) , max(data.Latitude(1),data.Latitude(length(data))) , max(data.Longitude(1),data.Longitude(length(data)))]; % Iterate through all highway polygons for i2 = 1 : length(Highways) % Check Latitudes if TrackBox(1) < Highways(i2).BoundingBox(1) && TrackBox(3) > Highways(i2).BoundingBox(2) % Check Longitudes if TrackBox(2) < Highways(i2).BoundingBox(3) && TrackBox(4) > Highways(i2).BoundingBox(4) Number = Number + 1 % Save track in subfolder str = sprintf('SuccessTrack_%d',Number); save(str,'data') break end end end clear data clear TrackBox itr = itr + 1 end