%% Plot Road Topology Data from Driving Route
% Load a sequence of latitude and longitude coordinates from a driving route.

data = load('geoSequence.mat')

% Create a HERE HD Live Map (HERE HDLM) reader from the specified coordinates. If you have not previously set up HERE HDLM credentials, a dialog box prompts you to enter them. The reader contains layered map data for the tile that the driving route is on.

reader = hereHDLMReader(data.latitude,data.longitude);

%
% Read road topology data from the TopologyGeometry layer. Plot the data.

roadTopology = read(reader,'TopologyGeometry');
plot(roadTopology)
legend('Location','northeastoutside')

%
% Overlay the driving route coordinates on the plot.

hold on
geoplot(data.latitude,data.longitude,'bo-','DisplayName','Route')
hold off

%
% Zoom in on the route.

latcenter = median(data.latitude);
loncenter = median(data.longitude);

offset = 0.005;
latlim = [latcenter-offset,latcenter+offset];
lonlim = [loncenter-offset,loncenter+offset];

geolimits(latlim,lonlim)

% Copyright 2018 The MathWorks, Inc.