Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
GPS-Tracking-of-On-Campus-Walking-Project/MATLAB_Functions/HuskyTrack/SenDes_HuskyTrack/GraphData.m
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
82 lines (72 sloc)
2.46 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% | |
% Function: GraphData | |
% Author: Michael T. Ballard (michael.ballard@uconn.edu) | |
% Date: Spring 2019 | |
% | |
% Description: The GraphData function takes a matrix of data pulled from | |
% the HuskyTrack Database and translated by this package's | |
% parsing function and then creates a visualization of this | |
% data overlaid onto a map of the University of Connecticut. | |
% If a first and last index are provided, only the subset | |
% denoted by the indices will be graphed. Any provided | |
% indices that are beyond the range of the set are ignored. | |
% | |
% Parameters: dataMat - A matrix of HuskyTrack Data as parsed by the | |
% Parser function. This parameter is required. | |
% first - The index of the first user to be graphed. | |
% This parameter is optional. | |
% last - The index of the last user to be graphed. | |
% This parameter is optional. | |
% | |
% | |
% Return: >0 - The Number of Users Graphed | |
% Else - Failure | |
% | |
function [success] = GraphData(varargin) | |
dataMat = varargin{1}; | |
[r,c] = size(dataMat); | |
try | |
parsed_osm = evalin('base', 'parsed_osm'); | |
catch | |
try | |
load('parsed_osm.mat', 'parsed_osm'); | |
catch | |
disp('Parsed File not found, Parsing...') | |
parsed_osm = ParseMap(); | |
end | |
end | |
fig = figure; | |
ax = axes('Parent', fig); | |
hold(ax, 'on'); | |
plot_way(ax, parsed_osm); | |
hold(ax, 'on'); | |
success = 0; | |
if(nargin == 1) | |
for i = 1:r | |
plot([dataMat(i).locations.longitude], [dataMat(i).locations.latitude]); | |
hold(ax, 'on'); | |
success = success+1; | |
end | |
hold(ax, 'off'); | |
elseif(nargin == 3) | |
first = varargin{2}; | |
last = varargin{3}; | |
for i = 1:r | |
if(i >= first & i <= last) | |
plot([dataMat(i).locations.longitude], [dataMat(i).locations.latitude]); | |
hold(ax, 'on'); | |
success = success + 1; | |
end | |
end | |
hold(ax, 'off'); | |
else | |
error('GraphData may take only 1 or 3 inputs (dataMat) or (dataMat, first, last)') | |
end | |
end | |
% Parse the map if a parsed version does not exist | |
function [parsed_osm, osm_xml] = ParseMap() | |
openOSM = 'map.osm'; | |
[parsed_osm, osm_xml] = parse_openstreetmap(openOSM); | |
save('parsed_osm.mat', 'parsed_osm'); | |
assignin('base','parsed_osm',parsed_osm); | |
end | |