Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Merge pull request #3 from mtb14006/mtb14006-patch-2
Add files via upload
- Loading branch information
Showing
24 changed files
with
122,652 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
% | ||
% 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 | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
% | ||
% Function: PullData | ||
% Author: Michael T. Ballard (michael.ballard@uconn.edu) | ||
% Date: Spring 2019 | ||
% | ||
% Description: The PullData function opens a TCP connection to the | ||
% specified host and places a query to the database designed for the | ||
% HuskyTrack System. The response to this query is then collected and | ||
% stored for further manipulations and analysis. Note that | ||
% time is always considered to be 12:00 AM Midnight, thus the | ||
% end date is exclusive. | ||
% | ||
% Parameters: url - A URL to access the host database's API from | ||
% ie. 'http://sdp40.cse.uconn.edu/api/' | ||
% startTime - A time stamp to indicate the earliest desired | ||
% data. In the form 'YYYYMMDD', ie. 20190503 | ||
% (May 3, 2019) | ||
% endTime - A time stamp to indicate the latest desired | ||
% data. In the form 'YYYYMMDD', ie. 20190503 | ||
% (May 3, 2019) | ||
% | ||
% Return: dataMat - A struct containing all users and their | ||
% location data retrieved from the host | ||
% | ||
|
||
function [dataMat] = PullData(url, startTime, endTime) | ||
|
||
api = [url 'locationdata?start=' startTime 'T000000&end=' endTime 'T000000']; | ||
options = weboptions('ContentType', 'json'); | ||
data = webread(api); | ||
dataMat = jsondecode(data); | ||
|
||
end | ||
|
2 changes: 2 additions & 0 deletions
2
MATLAB_Functions/HuskyTrack/SenDes_HuskyTrack/SenDes_HuskyTrack.prj
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<MATLABProject xmlns="http://www.mathworks.com/MATLABProjectFile" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0"/> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
% | ||
% Function: SortData | ||
% Author: Michael T. Ballard (michael.ballard@uconn.edu) | ||
% Date: Spring 2019 | ||
% | ||
% Description: The SortData function sorts a HuskyTrack retrieved data | ||
% struct by the timestamp of each location point. Should not | ||
% be necessary for data taken directly from th database. | ||
% | ||
% Parameters: dataMat - A matrix of HuskyTrack Data to be sorted | ||
% | ||
% | ||
% Return: 0 - Successful Termination | ||
% | ||
function [success] = SortData(dataMat) | ||
|
||
[r,c] = size(dataMat); | ||
|
||
for i = 1:r | ||
[tmp ind] = sort({dataMat(i).locations.timestamp}); | ||
dataMat(i) = dataMat(i).locations(ind); | ||
end | ||
|
||
end | ||
|
Oops, something went wrong.