Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance Improvements for Routing and Routing Immediately on Page Load #14

Merged
merged 8 commits into from Jun 20, 2014
Merged

Performance Improvements for Routing and Routing Immediately on Page Load #14

merged 8 commits into from Jun 20, 2014

Conversation

japorito
Copy link
Contributor

Route on page load:

Specifying an endpoint in the initialization call to wayfinding causes the plugin to show the route to there immediately when the page loads. For consistency with startpoint, this supports being passed as either a string with the ID of the destination, or a function which returns the ID.

Performance enhancements in routeTo:

Prior to this commit, when routeTo was called, it generated the shortest path to every place in all the maps (but from only one start point) and then discarded that information and started over with the next routeTo. This commit saves that data, unless a) the startpoint is changed or b) the accessibility option is toggled. Both of those conditions invalidate the dataStore path metadata, so it needs to be regenerated.

The performance increase with this is dramatic. After the paths are generated, routing to anywhere is near instantaneous, even on our large maps. Before it would take a few seconds to complete. You only have to pay this penalty on the first routeTo. Alternatively, if the client supplies a dataStore cache which already has path metadata for the specific startpoint they initialize it with, they can set option.wayFound to true in the initialization, and avoid that initial several seconds of cost altogether.

QUESTION: I could make it initialize the dataStore cache with the path metadata on the initial page load. For large maps (such as ours) this adds a significant (~4.5 s) delay to the initial page load time, but then all routing operations are instantaneous. Is it better to have that delay then, or on the first routing operation, from a UX perspective? Should I make it client configurable?

…o everywhere. Previously, this information was discarded and re-generated with each routeTo. This commit only deletes it when the start point changes or accessibleRoute is toggled (which invalidates the path data stored in dataStore.
@jraller
Copy link
Member

jraller commented Apr 10, 2014

I'll look this over and get back to you soon.

@japorito
Copy link
Contributor Author

I've added some commits since the pull request. Since they get automatically added into the pull request, I'll summarize them.

Code cleanup:
Factored out reusable code into separate functions.

getRoutes action:
Added an action 'getRoutes' to wayfinding that can be given either an id for the endpoint or an array of ids. The function will then return an object containing the start- and end-point ids, the route and the length of the route for each endpoint id it receives.
Possible use cases: client wants to route to the nearest restroom, so it calls 'getRoutes' with an array of restroom ids. Checks for the min-length restroom id and call routeTo to that restroom. Could feasibly be used by the client to make a rough estimate of how long it will take to get somewhere, as well.

…u get the shortest route to either a single destination, or an array of destinations.
…reachable paths. Colorize unreachable rooms and paths for visual diagnostic.
…wayfinding is initialized with 'mapEvents': true. This is to ease writing extra ui elements (such as a floor switcher).
…bugs with routing on (or soon after) page load.
jraller added a commit that referenced this pull request Jun 20, 2014
Performance Improvements for Routing and Routing Immediately on Page Load
@jraller jraller merged commit 0a8426d into ucdavis:master Jun 20, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants