Fixes JS exception when there are no coordinates present.

This commit is contained in:
James Phillips 2016-08-08 17:38:22 -07:00
parent 1bf15d4355
commit f23786cd5a
No known key found for this signature in database
GPG Key ID: 77183E682AC5FC11
2 changed files with 20 additions and 13 deletions

File diff suppressed because one or more lines are too long

View File

@ -311,12 +311,19 @@ App.NodesShowRoute = App.BaseRoute.extend({
var n = distances.length; var n = distances.length;
var halfN = Math.floor(n / 2); var halfN = Math.floor(n / 2);
var median; var median;
if (n > 0) {
if (n % 2) { if (n % 2) {
// odd // odd
median = distances[halfN].distance; median = distances[halfN].distance;
} else { } else {
median = (distances[halfN - 1].distance + distances[halfN].distance) / 2; median = (distances[halfN - 1].distance + distances[halfN].distance) / 2;
} }
} else {
median = 0;
min = 0;
max = 0;
}
// Return a promise hash of the node and nodes // Return a promise hash of the node and nodes
return Ember.RSVP.hash({ return Ember.RSVP.hash({