Add walking distance parameter
This commit is contained in:
parent
0881ecddfc
commit
8162813362
@ -41,6 +41,10 @@
|
||||
<label for="searchKeyword">Keyword <span class="label label-warning" id="customized" style="display: none;">Cutomized</span></label>
|
||||
<select id="searchKeyword" class="form-control"></select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="walkingDist">Walking distance (km)</label>
|
||||
<input class="form-control" type="number" step="any" value="1.0" id="walkingDist">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="minScore">Minimum score</label>
|
||||
<input class="form-control" type="number" step="any" value="0.25" id="minScore">
|
||||
|
@ -66,7 +66,7 @@
|
||||
|
||||
onSearch();
|
||||
|
||||
$('#searchKeyword,#minScore,#hintSteps,#maxResults').change(onSearch);
|
||||
$('#searchKeyword,#minScore,#hintSteps,#walkingDist,#maxResults').change(onSearch);
|
||||
$('#historyIndex').on('slideStop', onSelectSnapshot);
|
||||
$('#learn').click(onLearn);
|
||||
$('#forget').click(onForget);
|
||||
@ -129,11 +129,12 @@
|
||||
var keyword = $('#searchKeyword').val();
|
||||
|
||||
_ctx.query = {
|
||||
features: _.clone(_ctx.parameters.keywords[keyword]),
|
||||
range: { min: -1.0, max: 1.0 },
|
||||
minScore: parseFloat($('#minScore').val()),
|
||||
hintSteps: parseInt($('#hintSteps').val()),
|
||||
maxResults: parseInt($('#maxResults').val())
|
||||
features: _.clone(_ctx.parameters.keywords[keyword]),
|
||||
range: { min: -1.0, max: 1.0 },
|
||||
walkingDist: parseFloat($('#walkingDist').val()),
|
||||
minScore: parseFloat($('#minScore').val()),
|
||||
hintSteps: parseInt($('#hintSteps').val()),
|
||||
maxResults: parseInt($('#maxResults').val())
|
||||
};
|
||||
|
||||
if (_ctx.geo) {
|
||||
|
@ -194,7 +194,7 @@ function getKeywords(callback) {
|
||||
});
|
||||
}
|
||||
|
||||
function getRecords(geo, callback) {
|
||||
function getRecords(geo, walkingDist, callback) {
|
||||
pool.query('SELECT * FROM reviews', function(err, rows) {
|
||||
if (err) {
|
||||
throw err;
|
||||
@ -220,7 +220,7 @@ function getRecords(geo, callback) {
|
||||
};
|
||||
});
|
||||
|
||||
computeRecordGeo(records, geo, 1000.0);
|
||||
computeRecordGeo(records, geo, walkingDist * 1000.0);
|
||||
callback(records);
|
||||
});
|
||||
}
|
||||
@ -250,9 +250,9 @@ function computeRecordGeo(records, geo, accessDist) {
|
||||
});
|
||||
}
|
||||
|
||||
function getData(geo, callback) {
|
||||
function getData(geo, walkingDist, callback) {
|
||||
getKeywords(function(keywords) {
|
||||
getRecords(geo, function(records) {
|
||||
getRecords(geo, walkingDist, function(records) {
|
||||
callback({
|
||||
keywords: keywords,
|
||||
records: records
|
||||
@ -268,7 +268,7 @@ function getParameters(callback) {
|
||||
}
|
||||
|
||||
function execQuery(query, callback) {
|
||||
getData(query.geo, function(data) {
|
||||
getData(query.geo, query.walkingDist, function(data) {
|
||||
var searchResults = findRecords(
|
||||
data,
|
||||
query.features,
|
||||
|
Loading…
Reference in New Issue
Block a user