Fixed invalid BOUNDS result

This commit ensures that BOUNDS always returns Polygon.
This commit is contained in:
tidwall 2022-11-21 04:47:56 -07:00
parent ee2237d195
commit 6b8211c468
4 changed files with 6 additions and 6 deletions

2
go.mod
View File

@ -20,7 +20,7 @@ require (
github.com/tidwall/btree v1.5.0
github.com/tidwall/buntdb v1.2.9
github.com/tidwall/expr v0.8.3
github.com/tidwall/geojson v1.4.2
github.com/tidwall/geojson v1.4.3
github.com/tidwall/gjson v1.14.3
github.com/tidwall/hashmap v1.6.1
github.com/tidwall/limiter v0.4.0

4
go.sum
View File

@ -361,8 +361,8 @@ github.com/tidwall/expr v0.8.3/go.mod h1:GnVpaS2R9wWV9Ft2u5TPDypJ+iQNxhAt9ISTUaU
github.com/tidwall/geoindex v1.4.4/go.mod h1:rvVVNEFfkJVWGUdEfU8QaoOg/9zFX0h9ofWzA60mz1I=
github.com/tidwall/geoindex v1.7.0 h1:jtk41sfgwIt8MEDyC3xyKSj75iXXf6rjReJGDNPtR5o=
github.com/tidwall/geoindex v1.7.0/go.mod h1:rvVVNEFfkJVWGUdEfU8QaoOg/9zFX0h9ofWzA60mz1I=
github.com/tidwall/geojson v1.4.2 h1:foR+7MWweUPLcFI8oWMTHp22Qkc7XHRJo15e9rCnv64=
github.com/tidwall/geojson v1.4.2/go.mod h1:1cn3UWfSYCJOq53NZoQ9rirdw89+DM0vw+ZOAVvuReg=
github.com/tidwall/geojson v1.4.3 h1:yae/k/DhJdc9psaTJQ3pNOdbol70eH+nCijy6O7TxBw=
github.com/tidwall/geojson v1.4.3/go.mod h1:1cn3UWfSYCJOq53NZoQ9rirdw89+DM0vw+ZOAVvuReg=
github.com/tidwall/gjson v1.12.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
github.com/tidwall/gjson v1.14.3 h1:9jvXn7olKEHU1S9vwoMGliaT8jq1vJ7IH/n9zD9Dnlw=
github.com/tidwall/gjson v1.14.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=

View File

@ -47,7 +47,7 @@ func Simple(g geojson.Object, meters float64) (geojson.Object, error) {
}
return geojson.NewFeature(bg, g.Members()), nil
case *geojson.Circle:
return Simple(g.Primative(), meters)
return Simple(g.Polygon(), meters)
case nil:
return nil, errors.New("cannot buffer nil object")
default:

View File

@ -43,7 +43,7 @@ func keys_BOUNDS_test(mc *mockServer) error {
Do("BOUNDS", "mykey").JSON().Err("key not found"),
Do("SET", "mykey", "myid1", "POINT", 33, -115).OK(),
Do("BOUNDS", "mykey").Str("[[-115 33] [-115 33]]"),
Do("BOUNDS", "mykey").JSON().Str(`{"ok":true,"bounds":{"type":"Point","coordinates":[-115,33]}}`),
Do("BOUNDS", "mykey").JSON().Str(`{"ok":true,"bounds":{"type":"Polygon","coordinates":[[[-115,33],[-115,33],[-115,33],[-115,33],[-115,33]]]}}`),
Do("SET", "mykey", "myid2", "POINT", 34, -112).OK(),
Do("BOUNDS", "mykey").Str("[[-115 33] [-112 34]]"),
Do("DEL", "mykey", "myid2").Str("1"),
@ -293,7 +293,7 @@ func keys_SET_test(mc *mockServer) error {
Do("SET", "mykey", "myid", "BOUNDS", 33, -115, 33, -115).OK(),
Do("GET", "mykey", "myid", "POINT").Str("[33 -115]"),
Do("GET", "mykey", "myid", "BOUNDS").Str("[[33 -115] [33 -115]]"),
Do("GET", "mykey", "myid", "OBJECT").Str(`{"type":"Point","coordinates":[-115,33]}`),
Do("GET", "mykey", "myid", "OBJECT").Str(`{"type":"Polygon","coordinates":[[[-115,33],[-115,33],[-115,33],[-115,33],[-115,33]]]}`),
Do("GET", "mykey", "myid", "HASH", 7).Str("9my5xp7"),
Do("DEL", "mykey", "myid").Str("1"),
Do("GET", "mykey", "myid").Str("<nil>"),