From 8162813362745c47723b07c57f36b28338990121 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Mon, 5 Jan 2015 16:26:47 +0900 Subject: [PATCH] Add walking distance parameter --- client/html/index.html | 4 ++++ client/scripts/application.js | 13 +++++++------ server/search.js | 10 +++++----- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/client/html/index.html b/client/html/index.html index f522110..014a579 100644 --- a/client/html/index.html +++ b/client/html/index.html @@ -41,6 +41,10 @@ +
+ + +
diff --git a/client/scripts/application.js b/client/scripts/application.js index fb214b0..4607930 100644 --- a/client/scripts/application.js +++ b/client/scripts/application.js @@ -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) { diff --git a/server/search.js b/server/search.js index 28c2910..987b90c 100644 --- a/server/search.js +++ b/server/search.js @@ -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,