From 5ec3111e8ba92e07b4ed1b588a479e185cacd3c9 Mon Sep 17 00:00:00 2001 From: Josh Baker Date: Mon, 14 Nov 2016 10:27:18 -0700 Subject: [PATCH 1/2] faster congruent modulo for points, fixes #83 --- index/norm.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/index/norm.go b/index/norm.go index adbdeb81..0a68e364 100644 --- a/index/norm.go +++ b/index/norm.go @@ -1,13 +1,16 @@ package index +import "math" + // normPoint takes the latitude and longitude of one point and return the x,y position on a world map. // The map bounds are minimum -180,-90 and maximum 180,90. These values are x,y; not lat,lon. -func normPoint(lat, lon float64) (x float64, y float64, normd bool) { - // Check if the rect is completely in bounds. This is likely to be the vast majority of cases. +func normPoint(lat, lon float64) (x, y float64, normd bool) { + // Check if the rect is completely in bounds. + // This is likely to be the vast majority of cases. if lon >= -180 && lon <= 180 && lat >= -90 && lat <= 90 { return lon, lat, false } - // TODO: replace loops with math/mod. + lat = math.Mod(lat, 360) for lat < -90 || lat > 90 { if lat < -90 { lat = -90 - (90 + lat) @@ -18,6 +21,7 @@ func normPoint(lat, lon float64) (x float64, y float64, normd bool) { lon = 180 + lon } } + lon = math.Mod(lon, 360) for lon < -180 { lon += 360 } From d61b194e49653d59e65b051131a1984a66045753 Mon Sep 17 00:00:00 2001 From: Josh Baker Date: Mon, 14 Nov 2016 11:05:28 -0700 Subject: [PATCH 2/2] allow for precise search for strings, fixes #82 --- controller/search.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/controller/search.go b/controller/search.go index 0a775210..b339b897 100644 --- a/controller/search.go +++ b/controller/search.go @@ -383,6 +383,9 @@ func (c *Controller) cmdSearch(msg *server.Message) (res string, err error) { }, ) } else { + // must disable globSingle for string value type matching because + // globSingle is only for ID matches, not values. + sw.globSingle = false s.cursor = sw.col.SearchValuesRange( s.cursor, g.Limits[0], g.Limits[1], s.desc, func(id string, o geojson.Object, fields []float64) bool {