Compute accessibility, cleanup ui
This commit is contained in:
parent
01e7489bd3
commit
3eacfa63bc
@ -85,10 +85,10 @@
|
|||||||
var _densitySize = 10;
|
var _densitySize = 10;
|
||||||
var _desatOffset = -0.3;
|
var _desatOffset = -0.3;
|
||||||
var _height = 500;
|
var _height = 500;
|
||||||
var _padding = 10;
|
var _padding = 5;
|
||||||
var _panelSize = 20;
|
var _panelSize = 20;
|
||||||
var _tickSize = 5;
|
var _tickSize = 5;
|
||||||
var _width = 110;
|
var _width = 100;
|
||||||
var _easeTime = 400;
|
var _easeTime = 400;
|
||||||
|
|
||||||
var _animation = null;
|
var _animation = null;
|
||||||
|
@ -67,7 +67,7 @@ function findRecords(data, features, minScore) {
|
|||||||
name: record.name,
|
name: record.name,
|
||||||
url: 'http://www.tripadvisor.com' + record.relativeUrl,
|
url: 'http://www.tripadvisor.com' + record.relativeUrl,
|
||||||
score: score,
|
score: score,
|
||||||
distance: record.distance,
|
distance: record.distanceToUser / 1000.0,
|
||||||
id: record.id
|
id: record.id
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -219,29 +219,33 @@ function getRecords(geo, callback) {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
computeRecordGeo(records, geo);
|
computeRecordGeo(records, geo, 1000.0);
|
||||||
callback(records);
|
callback(records);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function computeRecordGeo(records, geo) {
|
function computeRecordGeo(records, geo, accessDist) {
|
||||||
var distMin = Number.MAX_VALUE;
|
var distUserMin = Number.MAX_VALUE;
|
||||||
var distMax = Number.MIN_VALUE;
|
var distUserMax = Number.MIN_VALUE;
|
||||||
|
|
||||||
_.each(records, function(record) {
|
_.each(records, function(record) {
|
||||||
record.distance = 0.0;
|
record.distanceToUser = 0.0;
|
||||||
if (geo) {
|
if (geo) {
|
||||||
record.distance = geolib.getDistance(record.geo, geo) / 1000.0;
|
record.distanceToUser = geolib.getDistance(record.geo, geo);
|
||||||
}
|
}
|
||||||
|
|
||||||
distMin = Math.min(distMin, record.distance);
|
distUserMin = Math.min(distUserMin, record.distanceToUser);
|
||||||
distMax = Math.max(distMax, record.distance);
|
distUserMax = Math.max(distUserMax, record.distanceToUser);
|
||||||
});
|
});
|
||||||
|
|
||||||
var distRange = distMax - distMin;
|
var distUserRange = distUserMax - distUserMin;
|
||||||
|
|
||||||
_.each(records, function(record) {
|
_.each(records, function(record) {
|
||||||
record.features.proximity = -((record.distance - distMin) / distRange - 0.5) * 2.0;
|
record.features.nearby = -((record.distanceToUser - distUserMin) / distUserRange - 0.5) * 2.0;
|
||||||
|
|
||||||
|
record.features.accessible = 1.0 - (record.distanceToStation / accessDist);
|
||||||
|
record.features.accessible = Math.min(record.features.accessible, 1.0);
|
||||||
|
record.features.accessible = Math.max(record.features.accessible, -1.0);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user