Fixed issue with some features not working with WITHIN

This bug was fixed in the geojson dependency.

https://github.com/tidwall/geojson/pull/15

Closed #539
This commit is contained in:
tidwall 2020-03-21 17:38:14 -07:00
parent 81e449afef
commit 957233c298
5 changed files with 11 additions and 4 deletions

2
go.mod
View File

@ -28,7 +28,7 @@ require (
github.com/tidwall/buntdb v1.1.0
github.com/tidwall/cities v0.0.0-20190730194520-dbe1ae0b862c // indirect
github.com/tidwall/geoindex v1.1.0
github.com/tidwall/geojson v1.1.10
github.com/tidwall/geojson v1.1.12
github.com/tidwall/gjson v1.3.2
github.com/tidwall/grect v0.0.0-20161006141115-ba9a043346eb // indirect
github.com/tidwall/lotsa v0.0.0-20180225195211-a03631ac7f1c // indirect

2
go.sum
View File

@ -63,6 +63,8 @@ github.com/tidwall/geojson v1.1.8 h1:n/WT/PG0OEHrxUJQoeqkupWDt3pwbHMynl6OF9xKIM0
github.com/tidwall/geojson v1.1.8/go.mod h1:tBjfxeALRFLc25LLpjtWzy2nIrNmW1ze1EAhLtd8+QQ=
github.com/tidwall/geojson v1.1.10 h1:ALzsrTn62pq65DudSQpYDjjCUaq6dP1XQm51GVYgJyo=
github.com/tidwall/geojson v1.1.10/go.mod h1:tBjfxeALRFLc25LLpjtWzy2nIrNmW1ze1EAhLtd8+QQ=
github.com/tidwall/geojson v1.1.12 h1:Ol83kqH2zeYJHP16xteZtr8VRukIXeF/TqVvJodM41M=
github.com/tidwall/geojson v1.1.12/go.mod h1:tBjfxeALRFLc25LLpjtWzy2nIrNmW1ze1EAhLtd8+QQ=
github.com/tidwall/gjson v1.3.2 h1:+7p3qQFaH3fOMXAJSrdZwGKcOO/lYdGS0HqGhPqDdTI=
github.com/tidwall/gjson v1.3.2/go.mod h1:P256ACg0Mn+j1RXIDXoss50DeIABTYK1PULOJHhxOls=
github.com/tidwall/grect v0.0.0-20161006141115-ba9a043346eb h1:5NSYaAdrnblKByzd7XByQEJVT8+9v0W/tIY0Oo4OwrE=

View File

@ -110,7 +110,7 @@ func (g *Feature) Within(obj Object) bool {
// Contains ...
func (g *Feature) Contains(obj Object) bool {
return g.base.Within(obj)
return g.base.Contains(obj)
}
// WithinRect ...
@ -180,7 +180,8 @@ func parseJSONFeature(keys *parseKeys, opts *ParseOptions) (Object, error) {
if point, ok := g.base.(*Point); ok {
if g.extra != nil {
members := g.extra.members
if gjson.Get(members, "properties.type").String() == "Circle" {
if !opts.DisableCircleType &&
gjson.Get(members, "properties.type").String() == "Circle" {
// Circle
radius := gjson.Get(members, "properties.radius").Float()
units := gjson.Get(members, "properties.radius_units").String()

View File

@ -95,6 +95,9 @@ type ParseOptions struct {
// type when a geojson point only consists of an 2D x/y coord and no extra
// json members.
AllowSimplePoints bool
// DisableCircleType disables the special Circle syntax that is unique to
// only Tile38.
DisableCircleType bool
}
// DefaultParseOptions ...
@ -104,6 +107,7 @@ var DefaultParseOptions = &ParseOptions{
IndexGeometryKind: geometry.QuadTree,
RequireValid: false,
AllowSimplePoints: false,
DisableCircleType: false,
}
// Parse a GeoJSON object

2
vendor/modules.txt vendored
View File

@ -81,7 +81,7 @@ github.com/tidwall/buntdb
# github.com/tidwall/geoindex v1.1.0
github.com/tidwall/geoindex
github.com/tidwall/geoindex/child
# github.com/tidwall/geojson v1.1.10
# github.com/tidwall/geojson v1.1.12
github.com/tidwall/geojson
github.com/tidwall/geojson/geo
github.com/tidwall/geojson/geometry