From 32329bcce43df2680ea9bc5bbed2ba5f0b24e7cc Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Mon, 29 Jun 2015 13:31:04 +0900 Subject: [PATCH] Fixing distance calc --- static/scripts/grapher.js | 3 ++- types.go | 2 +- util.go | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/static/scripts/grapher.js b/static/scripts/grapher.js index 8425389..72951c3 100644 --- a/static/scripts/grapher.js +++ b/static/scripts/grapher.js @@ -454,7 +454,8 @@ } function modeClick(event, x, y) { - alert('mode clicked'); + var mode = _data.mode === 'prod' ? 'dist' : 'prod'; + updateState(_data.value, mode); } this.update = function(data, scale) { diff --git a/types.go b/types.go index af5b677..f4f4237 100644 --- a/types.go +++ b/types.go @@ -50,7 +50,7 @@ type jsonQueryRequest struct { Geo *jsonGeoData `json:"geo"` MaxResults int `json:"maxResults"` MinScore float64 `json:"minScore"` - Modes map[string]string `json:"modeMap"` + Modes map[string]string `json:"modes"` Profile featureMap `json:"profile"` Resolution int `json:"resolution"` SortAsc bool `json:"sortAsc"` diff --git a/util.go b/util.go index e89205f..f849053 100644 --- a/util.go +++ b/util.go @@ -82,7 +82,7 @@ func compare(features1 featureMap, features2 featureMap, modes modeMap) float64 switch mode, _ := modes[key]; mode { case ModeTypeDist: - result += 1 - math.Abs(value1-value2)/2 + result += 1 - math.Abs(value1-value2) default: result += value1 * value2 }