Skip to content

Commit e435177

Browse files
author
Sreekanth Sivasankaran
authored
Merge pull request #4 from blevesearch/jsoniter_version
Reverting to a stable jsoniter version
2 parents 1e74e8d + c8c7ced commit e435177

File tree

4 files changed

+22
-30
lines changed

4 files changed

+22
-30
lines changed

geojson/geojson_s2_util.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ func s2PolygonFromCoordinates(coordinates [][][]float64) *s2.Polygon {
192192
func s2PolygonFromS2Rectangle(s2rect *s2.Rect) *s2.Polygon {
193193
loops := make([]*s2.Loop, 0, 1)
194194
var points []s2.Point
195-
for j := 0; j <= 4; j++ {
195+
for j := 0; j < 4; j++ {
196196
points = append(points, s2.PointFromLatLng(s2rect.Vertex(j%4)))
197197
}
198198

geojson/geojson_shapes_impl.go

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1756,28 +1756,18 @@ func checkEnvelopeContainsShape(s2rect *s2.Rect, shapeIn,
17561756

17571757
// check if the other shape is a polygon.
17581758
if p2, ok := other.(*Polygon); ok {
1759-
1760-
for i := 0; i < p2.s2pgn.NumEdges(); i++ {
1761-
edge := p2.s2pgn.Edge(i)
1762-
if !s2rect.ContainsPoint(edge.V0) ||
1763-
!s2rect.ContainsPoint(edge.V1) {
1764-
return false, nil
1765-
}
1766-
}
1767-
1768-
return true, nil
1759+
s2pgnRect := s2PolygonFromS2Rectangle(s2rect)
1760+
return s2pgnRect.Contains(p2.s2pgn), nil
17691761
}
17701762

17711763
// check if the other shape is a multipolygon.
17721764
if p2, ok := other.(*MultiPolygon); ok {
1773-
// check the intersection for any polygon in the collection.
1765+
s2pgnRect := s2PolygonFromS2Rectangle(s2rect)
1766+
1767+
// check the containment for every polygon in the collection.
17741768
for _, s2pgn := range p2.s2pgns {
1775-
for i := 0; i < s2pgn.NumEdges(); i++ {
1776-
edge := s2pgn.Edge(i)
1777-
if !s2rect.ContainsPoint(edge.V0) ||
1778-
!s2rect.ContainsPoint(edge.V1) {
1779-
return false, nil
1780-
}
1769+
if !s2pgnRect.Contains(s2pgn) {
1770+
return false, nil
17811771
}
17821772
}
17831773

go.mod

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,7 @@ go 1.12
55
require (
66
github.com/blevesearch/bleve_index_api v1.0.1
77
github.com/golang/geo v0.0.0-20210211234256-740aa86cb551
8-
github.com/json-iterator/go v1.1.12
8+
github.com/google/gofuzz v1.2.0 // indirect
9+
github.com/json-iterator/go v0.0.0-20171115153421-f7279a603ede
10+
github.com/stretchr/testify v1.7.1 // indirect
911
)

go.sum

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
github.com/blevesearch/bleve_index_api v1.0.1 h1:nx9++0hnyiGOHJwQQYfsUGzpRdEVE5LsylmmngQvaFk=
22
github.com/blevesearch/bleve_index_api v1.0.1/go.mod h1:fiwKS0xLEm+gBRgv5mumf0dhgFr2mDgZah1pqv1c1M4=
3+
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
34
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
4-
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
5-
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
65
github.com/golang/geo v0.0.0-20210211234256-740aa86cb551 h1:gtexQ/VGyN+VVFRXSFiguSNcXmS6rkKT+X7FdIrTtfo=
76
github.com/golang/geo v0.0.0-20210211234256-740aa86cb551/go.mod h1:QZ0nwyI2jOfgRAoBvP+ab5aRr7c9x7lhGEJrKvBwjWI=
8-
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
9-
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
10-
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
11-
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc=
12-
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
13-
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
14-
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
7+
github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0=
8+
github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
9+
github.com/json-iterator/go v0.0.0-20171115153421-f7279a603ede h1:YrgBGwxMRK0Vq0WSCWFaZUnTsrA/PZE/xs1QZh+/edg=
10+
github.com/json-iterator/go v0.0.0-20171115153421-f7279a603ede/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
1511
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
1612
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
1713
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
18-
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
19-
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
14+
github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY=
15+
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
16+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
17+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
18+
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
19+
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

0 commit comments

Comments
 (0)